Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1358636

[PATCH 3.4 067/107] dm btree: add ref counting ops for the leaves of top level btrees

From lizf@kernel.org
Newsgroups linux.kernel
Subject [PATCH 3.4 067/107] dm btree: add ref counting ops for the leaves of top level btrees
Date 2016-03-16 09:20 +0100
Message-ID <rdeQq-6eY-23@gated-at.bofh.it> (permalink)
References <rdeGK-6bc-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Joe Thornber <ejt@redhat.com>

3.4.111-rc1 review patch.  If anyone has any objections, please let me know.

------------------


commit b0dc3c8bc157c60b1d470163882be8c13e1950af upstream.

When using nested btrees, the top leaves of the top levels contain
block addresses for the root of the next tree down.  If we shadow a
shared leaf node the leaf values (sub tree roots) should be incremented
accordingly.

This is only an issue if there is metadata sharing in the top levels.
Which only occurs if metadata snapshots are being used (as is possible
with dm-thinp).  And could result in a block from the thinp metadata
snap being reused early, thus corrupting the thinp metadata snap.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[lizf: Backported to 3.4:
 - drop const
 - drop changes to remove_one()]
Signed-off-by: Zefan Li <lizefan@huawei.com>
---
 drivers/md/persistent-data/dm-btree-internal.h |  6 +++++
 drivers/md/persistent-data/dm-btree-remove.c   | 12 +++------
 drivers/md/persistent-data/dm-btree-spine.c    | 37 ++++++++++++++++++++++++++
 drivers/md/persistent-data/dm-btree.c          |  7 +----
 4 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/drivers/md/persistent-data/dm-btree-internal.h b/drivers/md/persistent-data/dm-btree-internal.h
index accbb05..c246578 100644
--- a/drivers/md/persistent-data/dm-btree-internal.h
+++ b/drivers/md/persistent-data/dm-btree-internal.h
@@ -131,4 +131,10 @@ int lower_bound(struct btree_node *n, uint64_t key);
 
 extern struct dm_block_validator btree_node_validator;
 
+/*
+ * Value type for upper levels of multi-level btrees.
+ */
+extern void init_le64_type(struct dm_transaction_manager *tm,
+			   struct dm_btree_value_type *vt);
+
 #endif	/* DM_BTREE_INTERNAL_H */
diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c
index a03178e..7c0d755 100644
--- a/drivers/md/persistent-data/dm-btree-remove.c
+++ b/drivers/md/persistent-data/dm-btree-remove.c
@@ -544,14 +544,6 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info,
 	return r;
 }
 
-static struct dm_btree_value_type le64_type = {
-	.context = NULL,
-	.size = sizeof(__le64),
-	.inc = NULL,
-	.dec = NULL,
-	.equal = NULL
-};
-
 int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
 		    uint64_t *keys, dm_block_t *new_root)
 {
@@ -559,12 +551,14 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
 	int index = 0, r = 0;
 	struct shadow_spine spine;
 	struct btree_node *n;
+	struct dm_btree_value_type le64_vt;
 
+	init_le64_type(info->tm, &le64_vt);
 	init_shadow_spine(&spine, info);
 	for (level = 0; level < info->levels; level++) {
 		r = remove_raw(&spine, info,
 			       (level == last_level ?
-				&info->value_type : &le64_type),
+				&info->value_type : &le64_vt),
 			       root, keys[level], (unsigned *)&index);
 		if (r < 0)
 			break;
diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c
index 2f0805c..f6cb762 100644
--- a/drivers/md/persistent-data/dm-btree-spine.c
+++ b/drivers/md/persistent-data/dm-btree-spine.c
@@ -242,3 +242,40 @@ int shadow_root(struct shadow_spine *s)
 {
 	return s->root;
 }
+
+static void le64_inc(void *context, void *value_le)
+{
+	struct dm_transaction_manager *tm = context;
+	__le64 v_le;
+
+	memcpy(&v_le, value_le, sizeof(v_le));
+	dm_tm_inc(tm, le64_to_cpu(v_le));
+}
+
+static void le64_dec(void *context, void *value_le)
+{
+	struct dm_transaction_manager *tm = context;
+	__le64 v_le;
+
+	memcpy(&v_le, value_le, sizeof(v_le));
+	dm_tm_dec(tm, le64_to_cpu(v_le));
+}
+
+static int le64_equal(void *context, void *value1_le, void *value2_le)
+{
+	__le64 v1_le, v2_le;
+
+	memcpy(&v1_le, value1_le, sizeof(v1_le));
+	memcpy(&v2_le, value2_le, sizeof(v2_le));
+	return v1_le == v2_le;
+}
+
+void init_le64_type(struct dm_transaction_manager *tm,
+		    struct dm_btree_value_type *vt)
+{
+	vt->context = tm;
+	vt->size = sizeof(__le64);
+	vt->inc = le64_inc;
+	vt->dec = le64_dec;
+	vt->equal = le64_equal;
+}
diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c
index d05cf15..dddd5a4 100644
--- a/drivers/md/persistent-data/dm-btree.c
+++ b/drivers/md/persistent-data/dm-btree.c
@@ -646,12 +646,7 @@ static int insert(struct dm_btree_info *info, dm_block_t root,
 	struct btree_node *n;
 	struct dm_btree_value_type le64_type;
 
-	le64_type.context = NULL;
-	le64_type.size = sizeof(__le64);
-	le64_type.inc = NULL;
-	le64_type.dec = NULL;
-	le64_type.equal = NULL;
-
+	init_le64_type(info->tm, &le64_type);
 	init_shadow_spine(&spine, info);
 
 	for (level = 0; level < (info->levels - 1); level++) {
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.4 000/107] 3.4.111-rc1 review lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 005/107] ext4: replace open coded nofail allocation in ext4_free_blocks() lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 012/107] dm thin: allocate the cell_sort_array dynamically lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 001/107] Btrfs: use kmem_cache_free when freeing entry in inode cache lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 026/107] libata: add ATA_HORKAGE_NOTRIM lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 017/107] drm: add a check for x/y in drm_mode_setcrtc lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 040/107] xhci: prevent bus_suspend if SS port resuming in phase 1 lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 020/107] net: call rcu_read_lock early in process_backlog lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 015/107] dm btree: silence lockdep lock inversion in dm_btree_del() lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 029/107] net: Clone skb before setting peeked flag lizf@kernel.org - 2016-03-16 09:10 +0100
  [PATCH 3.4 089/107] KVM: svm: unconditionally intercept #DB lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 082/107] isdn_ppp: Add checks for allocation failure in isdn_ppp_open() lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 098/107] kernel/watchdog.c: touch_nmi_watchdog should only touch local cpu not every one lizf@kernel.org - 2016-03-16 09:20 +0100
    Re: [PATCH 3.4 098/107] kernel/watchdog.c: touch_nmi_watchdog should  only touch local cpu not every one Don Zickus <dzickus@redhat.com> - 2016-03-16 15:20 +0100
      Re: [PATCH 3.4 098/107] kernel/watchdog.c: touch_nmi_watchdog should  only touch local cpu not every one Zefan Li <lizefan@huawei.com> - 2016-03-17 02:30 +0100
  [PATCH 3.4 102/107] ALSA: tlv: compute TLV_*_ITEM lengths automatically lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 053/107] drm/radeon/combios: add some validation of lvds values lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 073/107] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 055/107] x86/xen: Probe target addresses in set_aliased_prot() before the hypercall lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 095/107] atm: deal with setting entry before mkip was called lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 090/107] get rid of s_files and files_lock lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 105/107] usb: dwc3: Fix assignment of EP transfer resources lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 067/107] dm btree: add ref counting ops for the leaves of top level btrees lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 100/107] af_unix: Guard against other == sk in unix_dgram_sendmsg lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 093/107] ipv6: probe routes asynchronous in rt6_probe lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 054/107] target/iscsi: Fix double free of a TUR followed by a solicited NOPOUT lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 096/107] SUNRPC: never enqueue a ->rq_cong request on ->sending lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 066/107] localmodconfig: Use Kbuild files too lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 059/107] xhci: fix off by one error in TRB DMA address boundary check lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 097/107] ipv6: prevent fib6_run_gc() contention lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 088/107] KVM: x86: work around infinite loop in microcode when #AC is delivered lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 107/107] KVM: x86: move steal time initialization to vcpu entry time lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 099/107] net: fix warnings in 'make htmldocs' by moving macro definition out of field declaration lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 104/107] ALSA: usb-audio: Add a more accurate volume quirk for AudioQuest DragonFly lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 103/107] ALSA: tlv: add DECLARE_TLV_DB_RANGE() lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 106/107] dm btree remove: fix a bug when rebalancing nodes after removal lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 075/107] unix: avoid use-after-free in ep_remove_wait_queue lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 087/107] ipv6: addrconf: validate new MTU before applying it lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 094/107] netfilter: nf_conntrack: fix RCU race in nf_conntrack_find_get lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 048/107] iscsi-target: Fix use-after-free during TPG session shutdown lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 083/107] ppp, slip: Validate VJ compression slot parameters completely lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 091/107] Initialize msg/shm IPC objects before doing ipc_addid() lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 101/107] x86/LDT: Print the real LDT base address lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 086/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 092/107] net: avoid to hang up on sending due to sysctl configuration overflow. lizf@kernel.org - 2016-03-16 09:20 +0100
  [PATCH 3.4 060/107] rds: fix an integer overflow test in rds_info_getsockopt() lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 081/107] virtio-net: drop NETIF_F_FRAGLIST lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 078/107] RDS: verify the underlying transport exists before creating a connection lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 063/107] ocfs2: fix BUG in ocfs2_downconvert_thread_do_work() lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 077/107] net: add validation for the socket syscall protocol argument lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 072/107] net: Fix RCU splat in af_key lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 076/107] pptp: verify sockaddr_len in pptp_bind() and pptp_connect() lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 058/107] MIPS: Fix sched_getaffinity with MT FPAFF enabled lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 080/107] sg_start_req(): make sure that there's not too many elements in iovec lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 074/107] Revert "usb: dwc3: Reset the transfer resource index on SET_INTERFACE" lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 061/107] perf: Fix fasync handling on inherited events lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 056/107] x86/ldt: Make modify_ldt synchronous lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 064/107] x86/ldt: Correct LDT access in single stepping logic lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 085/107] KEYS: Fix race between key destruction and finding a keyring by name lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 062/107] MIPS: Make set_pte() SMP safe. lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 071/107] ipc,sem: fix use after free on IPC_RMID after a task using same semaphore set exits lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 065/107] x86/ldt: Correct FPU emulation access to LDT lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 070/107] EDAC, ppc4xx: Access mci->csrows array elements properly lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 084/107] USB: whiteheat: fix potential null-deref at probe lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 068/107] libiscsi: Fix host busy blocking during connection teardown lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 069/107] libfc: Fix fc_fcp_cleanup_each_cmd() lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 079/107] RDS: fix race condition when sending a message on unbound socket lizf@kernel.org - 2016-03-16 09:30 +0100
  [PATCH 3.4 036/107] usb: dwc3: Reset the transfer resource index on SET_INTERFACE lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 037/107] usb: xhci: Bugfix for NULL pointer deference in xhci_endpoint_init() function lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 049/107] niu: don't count tx error twice in case of headroom realloc fails lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 031/107] can: mcp251x: fix resume when device is down lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 051/107] USB: sierra: add 1199:68AB device ID lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 050/107] vhost: actually track log eventfd file lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 052/107] ALSA: usb-audio: add dB range mapping for some devices lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 034/107] md: make sure everything is freed when dm-raid stops an array. lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 046/107] netfilter: nf_conntrack: Support expectations in different zones lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 057/107] md/raid1: extend spinlock to protect raid1_end_read_request against inconsistencies lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 024/107] ata: pmp: add quirk for Marvell 4140 SATA PMP lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 028/107] libata: increase the timeout when setting transfer mode lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 043/107] Input: usbtouchscreen - avoid unresponsive TSC-30 touch screen lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 039/107] xhci: report U3 when link is in resume state lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 027/107] libata: force disable trim for SuperSSpeed S238 lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 033/107] inet: frags: fix defragmented packet's IP header for af_packet lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 032/107] mac80211: clear subdir_stations when removing debugfs lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 042/107] tile: use free_bootmem_late() for initrd lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 038/107] xhci: Calculate old endpoints correctly on device reset lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 025/107] libata: add ATA_HORKAGE_BROKEN_FPDMA_AA quirk for HP 250GB SATA disk VB0250EAVER lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 047/107] crypto: ixp4xx - Remove bogus BUG_ON on scattered dst buffer lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 045/107] mmc: block: Add missing mmc_blk_put() in power_ro_lock_show() lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 021/107] s390/process: fix sfpc inline assembly lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 041/107] usb-storage: ignore ZTE MF 823 card reader in mode 0x1225 lizf@kernel.org - 2016-03-16 09:40 +0100
  [PATCH 3.4 009/107] 9p: don't leave a half-initialized inode sitting around lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 007/107] hpfs: kstrdup() out of memory handling lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 011/107] dm btree remove: fix bug in redistribute3 lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 022/107] rds: rds_ib_device.refcount overflow lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 016/107] s390/sclp: clear upper register halves in _sclp_print_early lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 002/107] fs/buffer.c: support buffer cache allocations with gfp modifiers lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 010/107] ALSA: usb-audio: Add MIDI support for Steinberg MI2/MI4 lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 023/107] st: null pointer dereference panic caused by use after kref_put by st_open lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 004/107] ext4: avoid deadlocks in the writeback path by using sb_getblk_gfp lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 014/107] USB: cp210x: add ID for Aruba Networks controllers lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 013/107] USB: option: add 2020:4000 ID lizf@kernel.org - 2016-03-16 09:50 +0100
  [PATCH 3.4 018/107] rtnetlink: verify IFLA_VF_INFO attributes before passing them to driver lizf@kernel.org - 2016-03-16 09:50 +0100
  Re: [PATCH 3.4 000/107] 3.4.111-rc1 review Guenter Roeck <linux@roeck-us.net> - 2016-03-16 19:00 +0100
    Re: [PATCH 3.4 000/107] 3.4.111-rc1 review Zefan Li <lizefan@huawei.com> - 2016-03-17 02:30 +0100

csiph-web