public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Naohiro Aota <naohiro.aota@wdc.com>, linux-btrfs@vger.kernel.org
Cc: axboe@kernel.dk, linux-block@vger.kernel.org, hch@infradead.org
Subject: Re: [PATCH v2 1/2] block: introduce zone capacity helper
Date: Tue, 18 Mar 2025 14:14:29 +0900	[thread overview]
Message-ID: <2a641d02-1d59-4e0b-9dcc-defb64548d1b@kernel.org> (raw)
In-Reply-To: <e0fa06613d4f39f85a64c75e5b4413ccfd725c4b.1742259006.git.naohiro.aota@wdc.com>

On 3/18/25 9:59 AM, Naohiro Aota wrote:
> {bdev,disk}_zone_capacity() takes block_device or gendisk and sector position
> and returns the zone capacity of the corresponding zone.
> 
> With that, move disk_nr_zones() and blk_zone_plug_bio() to consolidate them in
> the same #ifdef block.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
>  include/linux/blkdev.h | 67 ++++++++++++++++++++++++++++--------------
>  1 file changed, 45 insertions(+), 22 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index d37751789bf5..6f1bdec27ac7 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -691,23 +691,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>  		(q->limits.features & BLK_FEAT_ZONED);
>  }
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -static inline unsigned int disk_nr_zones(struct gendisk *disk)
> -{
> -	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)
>  {
>  	if (!blk_queue_is_zoned(disk->queue))
> @@ -715,11 +698,6 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  	return sector >> ilog2(disk->queue->limits.chunk_sectors);
>  }
>  
> -static inline unsigned int bdev_nr_zones(struct block_device *bdev)
> -{
> -	return disk_nr_zones(bdev->bd_disk);
> -}
> -
>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return bdev->bd_disk->queue->limits.max_open_zones;
> @@ -826,6 +804,51 @@ static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
>  		(sb->s_blocksize_bits - SECTOR_SHIFT);
>  }
>  
> +#ifdef CONFIG_BLK_DEV_ZONED
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
> +{
> +	return disk->nr_zones;
> +}
> +bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
> +
> +/**
> + * disk_zone_capacity - returns the zone capacity of zone at @pos

@pos is not the start of the zone, so this should be:

 * disk_zone_capacity - returns the capacity of the zone containing @sect

And rename pos to sect.

With that, this looks good to me, so feel free to add:

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2025-03-18  5:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18  0:59 [PATCH v2 0/2] btrfs: zoned: skip reporting zone for new block group Naohiro Aota
2025-03-18  0:59 ` [PATCH v2 1/2] block: introduce zone capacity helper Naohiro Aota
2025-03-18  5:14   ` Damien Le Moal [this message]
2025-03-18  5:54     ` Christoph Hellwig
2025-03-18  7:57       ` Damien Le Moal
2025-03-18  8:04         ` Christoph Hellwig
2025-03-18  7:27   ` Johannes Thumshirn
2025-03-18  0:59 ` [PATCH v2 2/2] btrfs: zoned: skip reporting zone for new block group Naohiro Aota
2025-03-18  7:25   ` Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a641d02-1d59-4e0b-9dcc-defb64548d1b@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox