History

block: introduce bdev_zone_no helper

Add a generic bdev_zone_no() helper to calculate zone number for a given sector in a block device. This helper internally uses disk_zone_no() to find the zone number. Use the helper bdev_zone_no() to calculate nr of zones. This lets us make modifications to the math if needed in one place.

Pankaj Raghav committed 3 years ago

Commit d67ea691 parent e29b2102 files · +6 −2Browse files

Showing the changes to include/linux/blkdev.h (1 of 2 files). Show all

Unified · Split

include/linux/blkdev.h+5−0
@@ -1288,6 +1288,11 @@ static inline bool bdev_is_zoned(struct block_device *bdev) · 1287 unmodified lines
12881288 return blk_queue_is_zoned(bdev_get_queue(bdev));
12891289 }
12901290
1291+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
1292+{
1293+ return disk_zone_no(bdev->bd_disk, sec);
1294+}
1295+
12911296 static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
12921297 blk_opf_t op)
12931298 {