Re: dm cache metadata: Fix loading discard bitset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 17 2019 at 10:19am -0400,
Nikos Tsironis <ntsironis@xxxxxxxxxxx> wrote:

> 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: ae4a46a1f6 ("dm cache metadata: use bitset cursor api to load discard bitset")
> Signed-off-by: Nikos Tsironis <ntsironis@xxxxxxxxxxx>

Nice catch, I'll obviously mark this for stable@ too.

One comment below.

> ---
>  drivers/md/dm-cache-metadata.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
> index 6fc93834da44..151aa95775be 100644
> --- a/drivers/md/dm-cache-metadata.c
> +++ b/drivers/md/dm-cache-metadata.c
> @@ -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;

Not understanding why you moved the conditional inside the loop, I'd
rather keep it in the for().  Or did you have some reason for this?

> +
> +			r = dm_bitset_cursor_next(&c);
> +			if (r)
> +				break;
>  		}
>  
>  		dm_bitset_cursor_end(&c);
> -- 
> 2.11.0
> 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux