mirror of https://github.com/torvalds/linux.git
block: introduce bdev_zone_start()
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> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e2b0ec7761
commit
25976c314f
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue