]> git.karo-electronics.de Git - karo-tx-linux.git/commit
dm thin: fix discard support to a previously shared block
authorJoe Thornber <ejt@redhat.com>
Tue, 17 Dec 2013 17:09:40 +0000 (12:09 -0500)
committerMike Snitzer <snitzer@redhat.com>
Tue, 17 Dec 2013 22:58:42 +0000 (17:58 -0500)
commit6d03f6ac888f2cfc9c840db0b965436d32f1816d
tree5e4957a39759e385227995fff9a6e1aa3c99550a
parentf5fad413284593aa0ff1eb4340f183785633ad41
dm thin: fix discard support to a previously shared block

If a snapshot is created and later deleted the origin dm_thin_device's
snapshotted_time will have been updated to reflect the snapshot's
creation time.  The 'shared' flag in the dm_thin_lookup_result struct
returned from dm_thin_find_block() is an approximation based on
snapshotted_time -- this is done to avoid 0(n), or worse, time
complexity.  In this case, the shared flag would be true.

But because the 'shared' flag reflects an approximation a block can be
incorrectly assumed to be shared (e.g. false positive for 'shared'
because the snapshot no longer exists).  This could result in discards
issued to a thin device not being passed down to the pool's underlying
data device.

To fix this we double check that a thin block is really still in-use
after a mapping is removed using dm_pool_block_is_used().  If the
reference count for a block is now zero the discard is allowed to be
passed down.

Also add a 'definitely_not_shared' member to the dm_thin_new_mapping
structure -- reflects that the 'shared' flag in the response from
dm_thin_find_block() can only be held as definitive if false is
returned.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1043527

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
drivers/md/dm-thin-metadata.h
drivers/md/dm-thin.c