Skip to content

Commit

Permalink
dm cache metadata: Fix loading discard bitset
Browse files Browse the repository at this point in the history
Add missing dm_bitset_cursor_next() to properly advance the bitset
cursor.

Otherwise, the discarded state of all blocks is set according to the
discarded state of the first block.

Fixes: ae4a46a ("dm cache metadata: use bitset cursor api to load discard bitset")
Cc: [email protected]
Signed-off-by: Nikos Tsironis <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
ntsiron authored and snitm committed Apr 18, 2019
1 parent 7aedf75 commit e28adc3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/md/dm-cache-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,11 +1167,18 @@ static int __load_discards(struct dm_cache_metadata *cmd,
if (r)
return r;

for (b = 0; b < from_dblock(cmd->discard_nr_blocks); b++) {
for (b = 0; ; b++) {
r = fn(context, cmd->discard_block_size, to_dblock(b),
dm_bitset_cursor_get_value(&c));
if (r)
break;

if (b >= (from_dblock(cmd->discard_nr_blocks) - 1))
break;

r = dm_bitset_cursor_next(&c);
if (r)
break;
}

dm_bitset_cursor_end(&c);
Expand Down

0 comments on commit e28adc3

Please sign in to comment.