Skip to content

Commit b6cfe22

Browse files
damien-lemoalaxboe
authored andcommitted
block: Define bdev_nr_zones() as an inline function
There is no need for bdev_nr_zones() to be an exported function calculating the number of zones of a block device. Instead, given that all callers use this helper with a fully initialized block device that has a gendisk, we can redefine this function as an inline helper in blkdev.h. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4ac9056 commit b6cfe22

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

block/blk-zoned.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,6 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
115115
}
116116
EXPORT_SYMBOL_GPL(blk_zone_cond_str);
117117

118-
/**
119-
* bdev_nr_zones - Get number of zones
120-
* @bdev: Target device
121-
*
122-
* Return the total number of zones of a zoned block device. For a block
123-
* device without zone capabilities, the number of zones is always 0.
124-
*/
125-
unsigned int bdev_nr_zones(struct block_device *bdev)
126-
{
127-
sector_t zone_sectors = bdev_zone_sectors(bdev);
128-
129-
if (!bdev_is_zoned(bdev))
130-
return 0;
131-
return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
132-
ilog2(zone_sectors);
133-
}
134-
EXPORT_SYMBOL_GPL(bdev_nr_zones);
135-
136118
/**
137119
* blkdev_report_zones - Get zones information
138120
* @bdev: Target block device

include/linux/blkdev.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
673673
}
674674

675675
#ifdef CONFIG_BLK_DEV_ZONED
676-
unsigned int bdev_nr_zones(struct block_device *bdev);
677676

678677
static inline unsigned int disk_nr_zones(struct gendisk *disk)
679678
{
@@ -687,6 +686,11 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
687686
return sector >> ilog2(disk->queue->limits.chunk_sectors);
688687
}
689688

689+
static inline unsigned int bdev_nr_zones(struct block_device *bdev)
690+
{
691+
return disk_nr_zones(bdev->bd_disk);
692+
}
693+
690694
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
691695
{
692696
return bdev->bd_disk->queue->limits.max_open_zones;

0 commit comments

Comments
 (0)