diff mbox series

[3/3] block: Cleanup block device zone helpers

Message ID 20240621031506.759397-4-dlemoal@kernel.org (mailing list archive)
State New, archived
Headers show
Series Cleanup blkdev zone helpers | expand

Commit Message

Damien Le Moal June 21, 2024, 3:15 a.m. UTC
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 <dlemoal@kernel.org>
---
 include/linux/blkdev.h | 44 ++++++++++++------------------------------
 1 file changed, 12 insertions(+), 32 deletions(-)

Comments

Christoph Hellwig June 21, 2024, 5:15 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Johannes Thumshirn June 21, 2024, 10:44 a.m. UTC | #2
On 21.06.24 05:15, Damien Le Moal wrote:
> 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  
	value ~^

Otherwise,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Zhu Yanjun June 21, 2024, 10:57 a.m. UTC | #3
在 2024/6/21 13:14, Christoph Hellwig 写道:
> 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

s/valu/value ?

Zhu Yanjun

> 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 <dlemoal@kernel.org>
> ---
>   include/linux/blkdev.h | 44 ++++++++++++------------------------------
>   1 file changed, 12 insertions(+), 32 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 1078a7d51295..e89003360c17 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -673,11 +673,21 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>   }
>   
>   #ifdef CONFIG_BLK_DEV_ZONED
> -
>   static inline unsigned int disk_nr_zones(struct gendisk *disk)
>   {
> -	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
> +	return disk->nr_zones;
> +}
> +bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
> +#else /* CONFIG_BLK_DEV_ZONED */
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
> +{
> +	return 0;
> +}
> +static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
> +{
> +	return false;
>   }
> +#endif /* CONFIG_BLK_DEV_ZONED */
>   
>   static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>   {
> @@ -701,36 +711,6 @@ static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>   	return bdev->bd_disk->queue->limits.max_active_zones;
>   }
>   
> -bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
> -#else /* CONFIG_BLK_DEV_ZONED */
> -static inline unsigned int bdev_nr_zones(struct block_device *bdev)
> -{
> -	return 0;
> -}
> -
> -static inline unsigned int disk_nr_zones(struct gendisk *disk)
> -{
> -	return 0;
> -}
> -static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
> -{
> -	return 0;
> -}
> -static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
> -{
> -	return 0;
> -}
> -
> -static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
> -{
> -	return 0;
> -}
> -static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
> -{
> -	return false;
> -}
> -#endif /* CONFIG_BLK_DEV_ZONED */
> -
>   static inline unsigned int blk_queue_depth(struct request_queue *q)
>   {
>   	if (q->queue_depth)
diff mbox series

Patch

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1078a7d51295..e89003360c17 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -673,11 +673,21 @@  static inline bool blk_queue_is_zoned(struct request_queue *q)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
-
 static inline unsigned int disk_nr_zones(struct gendisk *disk)
 {
-	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
+	return disk->nr_zones;
+}
+bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
+#else /* CONFIG_BLK_DEV_ZONED */
+static inline unsigned int disk_nr_zones(struct gendisk *disk)
+{
+	return 0;
+}
+static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
+{
+	return false;
 }
+#endif /* CONFIG_BLK_DEV_ZONED */
 
 static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
@@ -701,36 +711,6 @@  static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 	return bdev->bd_disk->queue->limits.max_active_zones;
 }
 
-bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
-#else /* CONFIG_BLK_DEV_ZONED */
-static inline unsigned int bdev_nr_zones(struct block_device *bdev)
-{
-	return 0;
-}
-
-static inline unsigned int disk_nr_zones(struct gendisk *disk)
-{
-	return 0;
-}
-static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
-{
-	return 0;
-}
-static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
-{
-	return 0;
-}
-
-static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
-{
-	return 0;
-}
-static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
-{
-	return false;
-}
-#endif /* CONFIG_BLK_DEV_ZONED */
-
 static inline unsigned int blk_queue_depth(struct request_queue *q)
 {
 	if (q->queue_depth)