linux-imx/drivers/md
Joe Thornber 8f5e58d2d9 dm btree: fix serious bug in btree_split_beneath()
commit bc68d0a435 upstream.

When inserting a new key/value pair into a btree we walk down the spine of
btree nodes performing the following 2 operations:

  i) space for a new entry
  ii) adjusting the first key entry if the new key is lower than any in the node.

If the _root_ node is full, the function btree_split_beneath() allocates 2 new
nodes, and redistibutes the root nodes entries between them.  The root node is
left with 2 entries corresponding to the 2 new nodes.

btree_split_beneath() then adjusts the spine to point to one of the two new
children.  This means the first key is never adjusted if the new key was lower,
ie. operation (ii) gets missed out.  This can result in the new key being
'lost' for a period; until another low valued key is inserted that will uncover
it.

This is a serious bug, and quite hard to make trigger in normal use.  A
reproducing test case ("thin create devices-in-reverse-order") is
available as part of the thin-provision-tools project:
  https://github.com/jthornber/thin-provisioning-tools/blob/master/functional-tests/device-mapper/dm-tests.scm#L593

Fix the issue by changing btree_split_beneath() so it no longer adjusts
the spine.  Instead it unlocks both the new nodes, and lets the main
loop in btree_insert_raw() relock the appropriate one and make any
neccessary adjustments.

Reported-by: Monty Pavel <monty_pavel@sina.com>
Signed-off-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2018-03-03 15:51:00 +00:00
..
persistent-data dm btree: fix serious bug in btree_split_beneath() 2018-03-03 15:51:00 +00:00
bitmap.c md/bitmap: prevent bitmap_daemon_work running while initialising bitmap 2012-04-22 15:30:58 -07:00
bitmap.h md: remove typedefs: mddev_t -> struct mddev 2011-10-11 16:47:53 +11:00
dm-bio-record.h
dm-bufio.c dm bufio: fix integer overflow when limiting maximum cache size 2018-02-13 18:32:17 +00:00
dm-bufio.h dm: add bufio 2011-10-31 20:19:09 +00:00
dm-builtin.c dm sysfs: fix a module unload race 2014-04-02 00:58:43 +01:00
dm-crypt.c dm crypt: mark key as invalid until properly loaded 2017-03-16 02:18:27 +00:00
dm-delay.c dm delay: fix a possible deadlock due to shared workqueue 2014-01-03 04:33:22 +00:00
dm-exception-store.c dm exception store: fix init error path 2012-04-02 09:53:05 -07:00
dm-exception-store.h dm snapshot: fix hung bios when copy error occurs 2016-02-13 10:34:07 +00:00
dm-flakey.c dm flakey: error READ bios during the down_interval 2016-11-20 01:01:30 +00:00
dm-io.c dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME 2015-05-09 23:16:25 +01:00
dm-ioctl.c dm: fix truncated status strings 2013-03-20 15:03:20 +00:00
dm-kcopyd.c dm kcopyd: add dm_kcopyd_zero to zero an area 2011-10-31 20:18:58 +00:00
dm-linear.c dm: fix truncated status strings 2013-03-20 15:03:20 +00:00
dm-log-userspace-base.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
dm-log-userspace-transfer.c dm log userspace: fix memory leak in dm_ulog_tfr_init failure path 2014-12-14 16:23:46 +00:00
dm-log-userspace-transfer.h dm log: userspace add luid to distinguish between concurrent log instances 2009-09-04 20:40:34 +01:00
dm-log.c dm: use vzalloc 2011-08-02 12:32:02 +01:00
dm-mpath.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:50:43 +00:00
dm-mpath.h
dm-path-selector.c md: Add module.h to all files using it implicitly 2011-10-31 19:31:18 -04:00
dm-path-selector.h dm mpath: add start_io and nr_bytes to path selectors 2009-06-22 10:12:27 +01:00
dm-queue-length.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
dm-raid.c dm raid: ensure superblock's size matches device's logical block size 2014-12-14 16:23:49 +00:00
dm-raid1.c dm mirror: do not degrade the mirror on discard error 2015-05-09 23:16:17 +01:00
dm-region-hash.c dm raid1: fix crash with mirror recovery and discard 2012-07-25 04:11:31 +01:00
dm-round-robin.c md: Add module.h to all files using it implicitly 2011-10-31 19:31:18 -04:00
dm-service-time.c md: Add module.h to all files using it implicitly 2011-10-31 19:31:18 -04:00
dm-snap-persistent.c dm snapshot: fix hung bios when copy error occurs 2016-02-13 10:34:07 +00:00
dm-snap-transient.c dm snapshot: fix hung bios when copy error occurs 2016-02-13 10:34:07 +00:00
dm-snap.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:50:43 +00:00
dm-stripe.c dm: fix truncated status strings 2013-03-20 15:03:20 +00:00
dm-sysfs.c dm sysfs: fix a module unload race 2014-04-02 00:58:43 +01:00
dm-table.c dm: discard support requires all targets in a table support discards 2018-02-13 18:32:17 +00:00
dm-target.c dm: error return error for discards 2010-08-12 04:14:14 +01:00
dm-thin-metadata.c dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 2018-03-03 15:51:00 +00:00
dm-thin-metadata.h dm: add thin provisioning target 2011-10-31 20:21:18 +00:00
dm-thin.c dm thin: allocate the cell_sort_array dynamically 2015-08-12 16:33:20 +02:00
dm-uevent.c md: Add in export.h for files using EXPORT_SYMBOL 2011-10-31 19:31:19 -04:00
dm-uevent.h
dm-zero.c dm: zero silently drop discards 2010-08-12 04:14:12 +01:00
dm.c dm: fix race between dm_get_from_kobject() and __dm_destroy() 2018-02-13 18:32:15 +00:00
dm.h dm sysfs: fix a module unload race 2014-04-02 00:58:43 +01:00
faulty.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
Kconfig dm sysfs: fix a module unload race 2014-04-02 00:58:43 +01:00
linear.c md linear: fix a race between linear_add() and linear_congested() 2017-06-05 21:13:48 +01:00
linear.h md linear: fix a race between linear_add() and linear_congested() 2017-06-05 21:13:48 +01:00
Makefile dm sysfs: fix a module unload race 2014-04-02 00:58:43 +01:00
md.c md: ensure md devices are freed before module is unloaded. 2017-06-05 21:13:48 +01:00
md.h Merge branch 'for-3.2/core' of git://git.kernel.dk/linux-block 2011-11-04 17:06:58 -07:00
multipath.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
multipath.h md/multipath: typedef removal: multipath_conf_t -> struct mpconf 2011-10-11 16:48:57 +11:00
raid1.c md: don't use flush_signals in userspace processes 2017-10-12 15:27:10 +01:00
raid1.h md/raid1: ensure device failure recorded before write request returns. 2015-11-17 15:54:45 +00:00
raid5.c md: don't use flush_signals in userspace processes 2017-10-12 15:27:10 +01:00
raid5.h md/raid5: typedef removal: raid5_conf_t -> struct r5conf 2011-10-11 16:49:52 +11:00
raid10.c raid10: include bio_end_io_list in nr_queued to prevent freeze_array hang 2016-05-01 00:05:19 +02:00
raid10.h md/raid10: ensure device failure recorded before write request returns. 2015-11-17 15:54:45 +00:00
raid0.c md/raid0: apply base queue limits *before* disk_stack_limits 2015-11-17 15:54:41 +00:00
raid0.h md/raid0: typedef removal: raid0_conf_t -> struct r0conf 2011-10-11 16:48:59 +11:00