android_kernel_samsung_msm8976/drivers/md/persistent-data
Joe Thornber ff3296214c dm transaction manager: fix corruption due to non-atomic transaction commit
commit a9d45396f5956d0b615c7ae3b936afd888351a47 upstream.

The persistent-data library used by dm-thin, dm-cache, etc is
transactional.  If anything goes wrong, such as an io error when writing
new metadata or a power failure, then we roll back to the last
transaction.

Atomicity when committing a transaction is achieved by:

a) Never overwriting data from the previous transaction.
b) Writing the superblock last, after all other metadata has hit the
   disk.

This commit and the following commit ("dm: take care to copy the space
map roots before locking the superblock") fix a bug associated with (b).
When committing it was possible for the superblock to still be written
in spite of an io error occurring during the preceeding metadata flush.
With these commits we're careful not to take the write lock out on the
superblock until after the metadata flush has completed.

Change the transaction manager's semantics for dm_tm_commit() to assume
all data has been flushed _before_ the single superblock that is passed
in.

As a prerequisite, split the block manager's block unlocking and
flushing by simplifying dm_bm_flush_and_unlock() to dm_bm_flush().  Now
the unlocking must be done separately.

This issue was discovered by forcing io errors at the crucial time
using dm-flakey.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-13 13:59:45 +02:00
..
Kconfig dm persistent data: remove CONFIG_EXPERIMENTAL 2013-03-01 22:45:46 +00:00
Makefile dm persistent data: add bitset 2013-03-01 22:45:51 +00:00
dm-array.c dm array: fix a reference counting bug in shadow_ablock 2013-12-20 07:45:11 -08:00
dm-array.h dm persistent data: add transactional array 2013-03-01 22:45:51 +00:00
dm-bitset.c dm persistent data: add bitset 2013-03-01 22:45:51 +00:00
dm-bitset.h dm persistent data: add bitset 2013-03-01 22:45:51 +00:00
dm-block-manager.c dm transaction manager: fix corruption due to non-atomic transaction commit 2014-05-13 13:59:45 +02:00
dm-block-manager.h dm transaction manager: fix corruption due to non-atomic transaction commit 2014-05-13 13:59:45 +02:00
dm-btree-internal.h dm persistent data: add btree_walk 2013-03-01 22:45:50 +00:00
dm-btree-remove.c dm thin: fix discard corruption 2013-03-20 17:21:24 +00:00
dm-btree-spine.c dm persistent data: add btree_walk 2013-03-01 22:45:50 +00:00
dm-btree.c dm persistent data: add btree_walk 2013-03-01 22:45:50 +00:00
dm-btree.h dm persistent data: add btree_walk 2013-03-01 22:45:50 +00:00
dm-persistent-data-internal.h
dm-space-map-common.c dm space map common: make sure new space is used during extend 2014-02-13 13:48:01 -08:00
dm-space-map-common.h
dm-space-map-disk.c dm persistent data: add threshold callback to space map 2013-05-10 14:37:20 +01:00
dm-space-map-disk.h
dm-space-map-metadata.c dm space map metadata: fix bug in resizing of thin metadata 2014-02-13 13:48:01 -08:00
dm-space-map-metadata.h
dm-space-map.h dm persistent data: add threshold callback to space map 2013-05-10 14:37:20 +01:00
dm-transaction-manager.c dm transaction manager: fix corruption due to non-atomic transaction commit 2014-05-13 13:59:45 +02:00
dm-transaction-manager.h dm transaction manager: fix corruption due to non-atomic transaction commit 2014-05-13 13:59:45 +02:00