dm thin metadata: fix bug in dm_thin_remove_range()
dm_btree_remove_leaves() only unmaps a contiguous region so we need a
loop, in __remove_range(), to handle ranges that contain multiple
regions.
A new btree function, dm_btree_lookup_next(), is introduced which is
more efficiently able to skip over regions of the thin device which
aren't mapped. __remove_range() uses dm_btree_lookup_next() for each
iteration of __remove_range()'s loop.
Also, improve description of dm_btree_remove_leaves().
Fixes: 6550f075
("dm thin metadata: add dm_thin_remove_range()")
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # 4.1+
This commit is contained in:

committed by
Mike Snitzer

parent
30ce6e1cc5
commit
993ceab919
@@ -109,6 +109,13 @@ int dm_btree_del(struct dm_btree_info *info, dm_block_t root);
|
||||
int dm_btree_lookup(struct dm_btree_info *info, dm_block_t root,
|
||||
uint64_t *keys, void *value_le);
|
||||
|
||||
/*
|
||||
* Tries to find the first key where the bottom level key is >= to that
|
||||
* given. Useful for skipping empty sections of the btree.
|
||||
*/
|
||||
int dm_btree_lookup_next(struct dm_btree_info *info, dm_block_t root,
|
||||
uint64_t *keys, uint64_t *rkey, void *value_le);
|
||||
|
||||
/*
|
||||
* Insertion (or overwrite an existing value). O(ln(n))
|
||||
*/
|
||||
@@ -135,9 +142,10 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
|
||||
uint64_t *keys, dm_block_t *new_root);
|
||||
|
||||
/*
|
||||
* Removes values between 'keys' and keys2, where keys2 is keys with the
|
||||
* final key replaced with 'end_key'. 'end_key' is the one-past-the-end
|
||||
* value. 'keys' may be altered.
|
||||
* Removes a _contiguous_ run of values starting from 'keys' and not
|
||||
* reaching keys2 (where keys2 is keys with the final key replaced with
|
||||
* 'end_key'). 'end_key' is the one-past-the-end value. 'keys' may be
|
||||
* altered.
|
||||
*/
|
||||
int dm_btree_remove_leaves(struct dm_btree_info *info, dm_block_t root,
|
||||
uint64_t *keys, uint64_t end_key,
|
||||
|
Reference in New Issue
Block a user