[dm-devel] [PATCH v3] dm zoned: Silence a static checker warning
Damien Le Moal
Damien.LeMoal at wdc.com
Wed Apr 10 08:14:32 UTC 2019
On 2019/04/10 17:13, Dan Carpenter wrote:
> My static checker complains about this line from dmz_get_zoned_device()
>
> aligned_capacity = dev->capacity & ~(blk_queue_zone_sectors(q) - 1);
>
> The problem is that "aligned_capacity" and "dev->capacity" are sector_t
> type (which is a u64 under most configs) but blk_queue_zone_sectors(q)
> returns a u32 so the higher 32 bits in aligned_capacity are cleared to
> zero. This patch adds a cast to address the issue.
>
> Fixes: 114e025968b5 ("dm zoned: ignore last smaller runt zone")
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> ---
> v2: The v1 patch declared blk_queue_zone_sectors() as sector_t but the
> v2 cast added a cast to u64.
> v3: Cast it to sector_t instead
>
> drivers/md/dm-zoned-target.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index 8865c1709e16..51d029bbb740 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -643,7 +643,8 @@ static int dmz_get_zoned_device(struct dm_target *ti, char *path)
>
> q = bdev_get_queue(dev->bdev);
> dev->capacity = i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT;
> - aligned_capacity = dev->capacity & ~(blk_queue_zone_sectors(q) - 1);
> + aligned_capacity = dev->capacity &
> + ~((sector_t)blk_queue_zone_sectors(q) - 1);
> if (ti->begin ||
> ((ti->len != dev->capacity) && (ti->len != aligned_capacity))) {
> ti->error = "Partial mapping not supported";
>
Thanks for fixing this !
Reviewed-by: Damien Le Moal <damien.lemoal at wdc.com>
--
Damien Le Moal
Western Digital Research
More information about the dm-devel
mailing list