Skip to content

Commit caaf710

Browse files
damien-lemoalaxboe
authored andcommitted
block: Cleanup block device zone helpers
There is no need to conditionally define on CONFIG_BLK_DEV_ZONED the inline helper functions bdev_nr_zones(), bdev_max_open_zones(), bdev_max_active_zones() and disk_zone_no() as these function will return the correct valu in all cases (zoned device or not, including when CONFIG_BLK_DEV_ZONED is not set). Furthermore, disk_nr_zones() definition can be simplified as disk->nr_zones is always 0 for regular block devices. 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 b6cfe22 commit caaf710

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

include/linux/blkdev.h

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,21 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
673673
}
674674

675675
#ifdef CONFIG_BLK_DEV_ZONED
676-
677676
static inline unsigned int disk_nr_zones(struct gendisk *disk)
678677
{
679-
return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
678+
return disk->nr_zones;
679+
}
680+
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
681+
#else /* CONFIG_BLK_DEV_ZONED */
682+
static inline unsigned int disk_nr_zones(struct gendisk *disk)
683+
{
684+
return 0;
685+
}
686+
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
687+
{
688+
return false;
680689
}
690+
#endif /* CONFIG_BLK_DEV_ZONED */
681691

682692
static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
683693
{
@@ -701,36 +711,6 @@ static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
701711
return bdev->bd_disk->queue->limits.max_active_zones;
702712
}
703713

704-
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
705-
#else /* CONFIG_BLK_DEV_ZONED */
706-
static inline unsigned int bdev_nr_zones(struct block_device *bdev)
707-
{
708-
return 0;
709-
}
710-
711-
static inline unsigned int disk_nr_zones(struct gendisk *disk)
712-
{
713-
return 0;
714-
}
715-
static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
716-
{
717-
return 0;
718-
}
719-
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
720-
{
721-
return 0;
722-
}
723-
724-
static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
725-
{
726-
return 0;
727-
}
728-
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
729-
{
730-
return false;
731-
}
732-
#endif /* CONFIG_BLK_DEV_ZONED */
733-
734714
static inline unsigned int blk_queue_depth(struct request_queue *q)
735715
{
736716
if (q->queue_depth)

0 commit comments

Comments
 (0)