From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>
Subject: [PATCH 2/2] block: introduce bdev_zone_start()
Date: Thu, 6 Nov 2025 16:06:27 +0900 [thread overview]
Message-ID: <20251106070627.96995-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20251106070627.96995-1-dlemoal@kernel.org>
Introduce the function bdev_zone_start() as a more explicit (and clear)
replacement for ALIGN_DOWN() to get the start sector of a zone
containing a particular sector of a zoned block device.
Use this new helper in blkdev_get_zone_info() and
blkdev_report_zones_cached().
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
block/blk-zoned.c | 4 ++--
include/linux/blkdev.h | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 2f4e45638601..e7e5542c538e 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -945,7 +945,7 @@ int blkdev_get_zone_info(struct block_device *bdev, sector_t sector,
return -EINVAL;
memset(zone, 0, sizeof(*zone));
- sector = ALIGN_DOWN(sector, zone_sectors);
+ sector = bdev_zone_start(bdev, sector);
if (!blkdev_has_cached_report_zones(bdev))
return blkdev_report_zone_fallback(bdev, sector, zone);
@@ -1063,7 +1063,7 @@ int blkdev_report_zones_cached(struct block_device *bdev, sector_t sector,
return blkdev_do_report_zones(bdev, sector, nr_zones, &args);
}
- for (sector = ALIGN_DOWN(sector, zone_sectors);
+ for (sector = bdev_zone_start(bdev, sector);
sector < capacity && idx < nr_zones;
sector += zone_sectors, idx++) {
ret = blkdev_get_zone_info(bdev, sector, &zone);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6a498aa7f7e7..2fff8a80dbd2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1522,6 +1522,12 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
return q->limits.chunk_sectors;
}
+static inline sector_t bdev_zone_start(struct block_device *bdev,
+ sector_t sector)
+{
+ return sector & ~(bdev_zone_sectors(bdev) - 1);
+}
+
static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
sector_t sector)
{
--
2.51.1
next prev parent reply other threads:[~2025-11-06 7:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 7:06 [PATCH 0/2] Zone related cleanups Damien Le Moal
2025-11-06 7:06 ` [PATCH 1/2] block: remove blk_zone_wp_offset() Damien Le Moal
2025-11-06 11:03 ` Christoph Hellwig
2025-11-06 7:06 ` Damien Le Moal [this message]
2025-11-06 11:03 ` [PATCH 2/2] block: introduce bdev_zone_start() Christoph Hellwig
2025-11-06 16:02 ` Bart Van Assche
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=20251106070627.96995-3-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@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;
as well as URLs for NNTP newsgroup(s).