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 v2 3/3] block: introduce bdev_zone_start()
Date: Fri, 7 Nov 2025 15:38:44 +0900 [thread overview]
Message-ID: <20251107063844.151103-4-dlemoal@kernel.org> (raw)
In-Reply-To: <20251107063844.151103-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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.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 b580d59ce210..3791755bc6ad 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -950,7 +950,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);
@@ -1068,7 +1068,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-07 6:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 6:38 [PATCH v2 0/3] Zone related cleanups Damien Le Moal
2025-11-07 6:38 ` [PATCH v2 1/3] block: improve blk_zone_wp_offset() Damien Le Moal
2025-11-07 8:34 ` Hannes Reinecke
2025-11-07 11:40 ` Christoph Hellwig
2025-11-07 16:06 ` Bart Van Assche
2025-11-07 6:38 ` [PATCH v2 2/3] block: refactor disk_zone_wplug_sync_wp_offset() Damien Le Moal
2025-11-07 8:35 ` Hannes Reinecke
2025-11-07 11:40 ` Christoph Hellwig
2025-11-07 16:06 ` Bart Van Assche
2025-11-07 6:38 ` Damien Le Moal [this message]
2025-11-07 8:36 ` [PATCH v2 3/3] block: introduce bdev_zone_start() Hannes Reinecke
2025-11-07 16:28 ` [PATCH v2 0/3] Zone related cleanups Jens Axboe
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=20251107063844.151103-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.