]> git.baikalelectronics.ru Git - kernel.git/commit
dm space map metadata: fix bug in resizing of thin metadata
authorJoe Thornber <ejt@redhat.com>
Tue, 21 Jan 2014 11:07:32 +0000 (11:07 +0000)
committerMike Snitzer <snitzer@redhat.com>
Tue, 21 Jan 2014 17:15:01 +0000 (12:15 -0500)
commit0a3b08eaf3f1ce2f6771d4f1614e2846d3fe7590
tree6c2f127fba1646e127e9c15d31801a75bef609f4
parent5bf8361901b2702b80d3a9803b48d6af4b11b2eb
dm space map metadata: fix bug in resizing of thin metadata

This bug was introduced in commit dd4a5f24f2f332 ("dm space map metadata:
fix extending the space map").

When extending a dm-thin metadata volume we:

- Switch the space map into a simple bootstrap mode, which allocates
  all space linearly from the newly added space.
- Add new bitmap entries for the new space
- Increment the reference counts for those newly allocated bitmap
  entries
- Commit changes to disk
- Switch back out of bootstrap mode.

But, the disk commit may allocate space itself, if so this fact will be
lost when switching out of bootstrap mode.

The bug exhibited itself as an error when the bitmap_root, with an
erroneous ref count of 0, was subsequently decremented as part of a
later disk commit.  This would cause the disk commit to fail, and thinp
to enter read_only mode.  The metadata was not damaged (thin_check
passed).

The fix is to put the increments + commit into a loop, running until
the commit has not allocated extra space.  In practise this loop only
runs twice.

With this fix the following device mapper testsuite test passes:
 dmtest run --suite thin-provisioning -n thin_remove_works_after_resize

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # depends on commit dd4a5f24f2f332
drivers/md/persistent-data/dm-space-map-metadata.c