public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <Naohiro.Aota@wdc.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH 1/2] block: introduce zone capacity helper
Date: Wed, 12 Mar 2025 02:07:00 +0000	[thread overview]
Message-ID: <D8DX5DG9RPSR.349R1ZG7XDGRW@wdc.com> (raw)
In-Reply-To: <da0d31a0-f2af-4aa8-ba9b-ce73bc010325@kernel.org>

On Wed Mar 12, 2025 at 10:39 AM JST, Damien Le Moal wrote:
> On 3/12/25 10:31, Naohiro Aota wrote:
>> {bdev,disk}_zone_capacity() takes block_device or gendisk and sector position
>> and returns the zone capacity of the corresponding zone.
>> 
>> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
>> ---
>>  include/linux/blkdev.h | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>> 
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index d37751789bf5..3c860a0cf339 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -826,6 +826,27 @@ static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
>>  		(sb->s_blocksize_bits - SECTOR_SHIFT);
>>  }
>>  
>> +#ifdef CONFIG_BLK_DEV_ZONED
>
> There is already an "#ifdef CONFIG_BLK_DEV_ZONED" in blkdev.h, see
> disk_nr_zones(). Please add this new helper under that ifdef to avoid adding a
> new one.

Sure. But, since this patch uses get_capacity(), we need to move the
existing ones here instead.

>
>> +static inline unsigned int disk_zone_capacity(struct gendisk *disk, sector_t pos)
>> +{
>> +	sector_t zone_sectors = disk->queue->limits.chunk_sectors;
>> +
>> +	if (pos + zone_sectors >= get_capacity(disk))
>> +		return disk->last_zone_capacity;
>> +	return disk->zone_capacity;
>> +}
>> +#else /* CONFIG_BLK_DEV_ZONED */
>> +static inline unsigned int disk_zone_capacity(struct gendisk *disk, sector_t pos)
>
> Is this ever called for a non zoned drive ? It should not be... So do we really
> need this stub ?

I added that just let it compile without CONFIG_BLK_DEV_ZONED. Well, the code
querying the capacity should be under CONFIG_BLK_DEV_ZONED, so maybe it
is not necessary. I'll drop that.

>
>> +{
>> +	return 0;
>> +}
>> +#endif /* CONFIG_BLK_DEV_ZONED */
>> +
>> +static inline unsigned int bdev_zone_capacity(struct block_device *bdev, sector_t pos)
>> +{
>> +	return disk_zone_capacity(bdev->bd_disk, pos);
>> +}
>> +
>>  int bdev_disk_changed(struct gendisk *disk, bool invalidate);
>>  
>>  void put_disk(struct gendisk *disk);

  reply	other threads:[~2025-03-12  2:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12  1:31 [PATCH 0/2] btrfs: zoned: skip reporting zone for new block group Naohiro Aota
2025-03-12  1:31 ` [PATCH 1/2] block: introduce zone capacity helper Naohiro Aota
2025-03-12  1:39   ` Damien Le Moal
2025-03-12  2:07     ` Naohiro Aota [this message]
2025-03-12  5:27   ` Christoph Hellwig
2025-03-12  6:55     ` Damien Le Moal
2025-03-12  7:00       ` Christoph Hellwig
2025-03-12  7:11         ` Damien Le Moal
2025-03-12  1:31 ` [PATCH 2/2] btrfs: zoned: skip reporting zone for new block group Naohiro Aota
2025-03-12  1:42   ` Damien Le Moal
2025-03-13  2:24     ` Shinichiro Kawasaki

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=D8DX5DG9RPSR.349R1ZG7XDGRW@wdc.com \
    --to=naohiro.aota@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /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