• Joe Thornber's avatar
    dm space map metadata: fix bug in resizing of thin metadata · 88972eec
    Joe Thornber authored
    commit fca028438fb903852beaf7c3fe1cd326651af57d upstream.
    
    This bug was introduced in commit 7e664b3dec431e ("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: default avatarJoe Thornber <ejt@redhat.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    88972eec
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
dm-array.c Loading commit data...
dm-array.h Loading commit data...
dm-bitset.c Loading commit data...
dm-bitset.h Loading commit data...
dm-block-manager.c Loading commit data...
dm-block-manager.h Loading commit data...
dm-btree-internal.h Loading commit data...
dm-btree-remove.c Loading commit data...
dm-btree-spine.c Loading commit data...
dm-btree.c Loading commit data...
dm-btree.h Loading commit data...
dm-persistent-data-internal.h Loading commit data...
dm-space-map-common.c Loading commit data...
dm-space-map-common.h Loading commit data...
dm-space-map-disk.c Loading commit data...
dm-space-map-disk.h Loading commit data...
dm-space-map-metadata.c Loading commit data...
dm-space-map-metadata.h Loading commit data...
dm-space-map.h Loading commit data...
dm-transaction-manager.c Loading commit data...
dm-transaction-manager.h Loading commit data...