Skip to content

Commit

Permalink
dm zoned: Silence a static checker warning
Browse files Browse the repository at this point in the history
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: 114e025 ("dm zoned: ignore last smaller runt zone")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
Dan Carpenter authored and snitm committed Apr 18, 2019
1 parent c13b548 commit a3839bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/md/dm-zoned-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit a3839bc

Please sign in to comment.