Skip to content

Commit

Permalink
dm thin metadata: fix bug when taking a metadata snapshot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Joe Thornber authored and Mike Snitzer committed Dec 9, 2015
1 parent 993ceab commit 49e99fc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/md/dm-thin-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 49e99fc

Please sign in to comment.