Skip to content

Commit

Permalink
dm cache metadata: fix metadata2 format's blocks_are_clean_separate_d…
Browse files Browse the repository at this point in the history
…irty

The dm_bitset_cursor_begin() call was using the incorrect nr_entries.
Also, the last dm_bitset_cursor_next() must be avoided if we're at the
end of the cursor.

Fixes: 7f1b215 ("dm cache metadata: use cursor api in blocks_are_clean_separate_dirty()")
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
jthornber authored and snitm committed Mar 20, 2017
1 parent f1a880a commit 0d963b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/md/dm-cache-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ static int blocks_are_clean_separate_dirty(struct dm_cache_metadata *cmd,
*result = true;

r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root,
from_cblock(begin), &cmd->dirty_cursor);
from_cblock(cmd->cache_blocks), &cmd->dirty_cursor);
if (r) {
DMERR("%s: dm_bitset_cursor_begin for dirty failed", __func__);
return r;
Expand All @@ -959,14 +959,16 @@ static int blocks_are_clean_separate_dirty(struct dm_cache_metadata *cmd,
return 0;
}

begin = to_cblock(from_cblock(begin) + 1);
if (begin == end)
break;

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);
Expand Down

0 comments on commit 0d963b6

Please sign in to comment.