]> git.ipfire.org Git - people/ms/linux.git/commitdiff
dm thin metadata: fix bug when taking a metadata snapshot
authorJoe Thornber <ejt@redhat.com>
Wed, 9 Dec 2015 16:23:24 +0000 (16:23 +0000)
committerMike Snitzer <snitzer@redhat.com>
Wed, 9 Dec 2015 18:18:12 +0000 (13:18 -0500)
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
drivers/md/dm-thin-metadata.c

index 67871e74c82bc9fc0ce831dad66c920fc368efbc..c219a053c7f66d1ebae80a19b005af38914dbe8c 100644 (file)
@@ -1206,6 +1206,12 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
        struct dm_block *copy, *sblock;
        dm_block_t held_root;
 
+       /*
+        * We commit to ensure the btree roots which we increment in a
+        * moment are up to date.
+        */
+       __commit_transaction(pmd);
+
        /*
         * Copy the superblock.
         */