summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-thin-metadata.h
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2013-12-17 18:09:40 +0100
committerMike Snitzer <snitzer@redhat.com>2014-01-07 16:11:43 +0100
commit19fa1a6756ed9e92daa9537c03b47d6b55cc2316 (patch)
tree5e4957a39759e385227995fff9a6e1aa3c99550a /drivers/md/dm-thin-metadata.h
parentdm thin: initialize dm_thin_new_mapping returned by get_next_mapping (diff)
downloadlinux-19fa1a6756ed9e92daa9537c03b47d6b55cc2316.tar.xz
linux-19fa1a6756ed9e92daa9537c03b47d6b55cc2316.zip
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
Diffstat (limited to 'drivers/md/dm-thin-metadata.h')
-rw-r--r--drivers/md/dm-thin-metadata.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index 7bcc0e1d6238..2edf5dbac76a 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -181,6 +181,8 @@ int dm_pool_get_data_block_size(struct dm_pool_metadata *pmd, sector_t *result);
int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result);
+int dm_pool_block_is_used(struct dm_pool_metadata *pmd, dm_block_t b, bool *result);
+
/*
* Returns -ENOSPC if the new size is too small and already allocated
* blocks would be lost.