aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2015-12-09 11:23:24 -0500
committerMike Snitzer <snitzer@redhat.com>2015-12-09 13:18:12 -0500
commit49e99fc717f624aa75ca755d6e7bc029efd3f0e9 (patch)
treed4bf6148e45a044eaf8cba9c5e827efff06a7f1b
parent993ceab91986e2e737ce9a3e23bebc8cce649240 (diff)
dm thin metadata: fix bug when taking a metadata snapshot
When you take a metadata snapshot the btree roots for the mapping and details tree need to have their reference counts incremented so they persist for the lifetime of the metadata snap. The roots being incremented were those currently written in the superblock, which could possibly be out of date if concurrent IO is triggering new mappings, breaking of sharing, etc. Fix this by performing a commit with the metadata lock held while taking a metadata snapshot. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Cc: stable@vger.kernel.org
-rw-r--r--drivers/md/dm-thin-metadata.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 67871e74c82b..c219a053c7f6 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -1207,6 +1207,12 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
1207 dm_block_t held_root; 1207 dm_block_t held_root;
1208 1208
1209 /* 1209 /*
1210 * We commit to ensure the btree roots which we increment in a
1211 * moment are up to date.
1212 */
1213 __commit_transaction(pmd);
1214
1215 /*
1210 * Copy the superblock. 1216 * Copy the superblock.
1211 */ 1217 */
1212 dm_sm_inc_block(pmd->metadata_sm, THIN_SUPERBLOCK_LOCATION); 1218 dm_sm_inc_block(pmd->metadata_sm, THIN_SUPERBLOCK_LOCATION);