public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: make blk_queue_zone_sectors() return sector_t type
@ 2019-04-10  6:10 Dan Carpenter
  2019-04-10  7:20 ` Damien Le Moal
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2019-04-10  6:10 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal
  Cc: Hannes Reinecke, Omar Sandoval, Martin K. Petersen,
	Bart Van Assche, Ming Lei, Greg Edwards, linux-block,
	kernel-janitors

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) but blk_queue_zone_sectors(q) returns a u32 so the
higher 32 bits in aligned_capacity are always cleared to zero.

Declaring blk_queue_zone_sectors() as a sector_t addresses this warning
and it feels intuitive based on the function name.  I updated
bdev_zone_sectors() as well just to be consistent.

Fixes: 114e025968b5 ("dm zoned: ignore last smaller runt zone")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Please review this one extra carefully.  I'm not positive it's correct.

 include/linux/blkdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4b85dc066264..1785a7f506be 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -670,7 +670,7 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
 	}
 }
 
-static inline unsigned int blk_queue_zone_sectors(struct request_queue *q)
+static inline sector_t blk_queue_zone_sectors(struct request_queue *q)
 {
 	return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
 }
@@ -1419,7 +1419,7 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
 	return false;
 }
 
-static inline unsigned int bdev_zone_sectors(struct block_device *bdev)
+static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-04-10  8:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-10  6:10 [PATCH] block: make blk_queue_zone_sectors() return sector_t type Dan Carpenter
2019-04-10  7:20 ` Damien Le Moal
2019-04-10  7:31   ` Dan Carpenter
2019-04-10  7:47   ` [PATCH v2] dm zoned: Silence a static checker warning Dan Carpenter
2019-04-10  7:56     ` Damien Le Moal
2019-04-10  8:03       ` Dan Carpenter
2019-04-10  8:06         ` [dm-devel] " Damien Le Moal
2019-04-10  8:12       ` [PATCH v3] " Dan Carpenter
2019-04-10  8:14         ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox