aboutsummaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer2016-10-04 15:00:47 -0400
committerMike Snitzer2017-02-16 13:12:51 -0500
commit7f1b21591a632c6caefd9aa53b630808f4f477e1 (patch)
tree6a8358625f01366b4ef65be7d8f2fbffd6c58265 /drivers/md
parent9b696229aa7de356675a938c6c8a70b46085ed66 (diff)
dm cache metadata: use cursor api in blocks_are_clean_separate_dirty()
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-cache-metadata.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index 7e31a4b1c476..e4c2c1a1e993 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -931,27 +931,46 @@ static int blocks_are_clean_separate_dirty(struct dm_cache_metadata *cmd,
bool dirty_flag;
*result = true;
- // FIXME: use a cursor so we can benefit from preloading metadata.
+ r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root,
+ from_cblock(begin), &cmd->dirty_cursor);
+ if (r) {
+ DMERR("%s: dm_bitset_cursor_begin for dirty failed", __func__);
+ return r;
+ }
+
+ r = dm_bitset_cursor_skip(&cmd->dirty_cursor, from_cblock(begin));
+ if (r) {
+ DMERR("%s: dm_bitset_cursor_skip for dirty failed", __func__);
+ dm_bitset_cursor_end(&cmd->dirty_cursor);
+ return r;
+ }
+
while (begin != end) {
/*
* We assume that unmapped blocks have their dirty bit
* cleared.
*/
- r = dm_bitset_test_bit(&cmd->dirty_info, cmd->dirty_root,
- from_cblock(begin), &cmd->dirty_root, &dirty_flag);
- if (r)
- return r;
-
+ dirty_flag = dm_bitset_cursor_get_value(&cmd->dirty_cursor);
if (dirty_flag) {
- DMERR("cache block %llu is dirty",
+ DMERR("%s: cache block %llu is dirty", __func__,
(unsigned long long) from_cblock(begin));
+ dm_bitset_cursor_end(&cmd->dirty_cursor);
*result = false;
return 0;
}
+ r = dm_bitset_cursor_next(&cmd->dirty_cursor);
+ if (r) {
+ DMERR("%s: dm_bitset_cursor_next for dirty failed", __func__);
+ dm_bitset_cursor_end(&cmd->dirty_cursor);
+ return r;
+ }
+
begin = to_cblock(from_cblock(begin) + 1);
}
+ dm_bitset_cursor_end(&cmd->dirty_cursor);
+
return 0;
}