dm thin metadata: fix bug in dm_thin_remove_range()
authorJoe Thornber <ejt@redhat.com>
Wed, 2 Dec 2015 12:24:39 +0000 (12:24 +0000)
committerMike Snitzer <snitzer@redhat.com>
Wed, 2 Dec 2015 18:26:49 +0000 (13:26 -0500)
commit993ceab91986e2e737ce9a3e23bebc8cce649240
tree271d69ac484060b565f25614cf25a5595b036a6c
parent30ce6e1cc5a0f781d60227e9096c86e188d2c2bd
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+
drivers/md/dm-thin-metadata.c
drivers/md/persistent-data/dm-btree.c
drivers/md/persistent-data/dm-btree.h