[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <487c9368-36fe-25ec-7a76-f6aa50c4d3d5@opensource.wdc.com>
Date: Mon, 16 May 2022 15:54:10 +0200
From: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
To: Pankaj Raghav <p.raghav@...sung.com>, axboe@...nel.dk,
naohiro.aota@....com, Johannes.Thumshirn@....com,
snitzer@...nel.org, dsterba@...e.com, jaegeuk@...nel.org,
hch@....de
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
jonathan.derrick@...ux.dev, bvanassche@....org,
Keith Busch <kbusch@...nel.org>, gost.dev@...sung.com,
linux-nvme@...ts.infradead.org,
Johannes Thumshirn <jth@...nel.org>,
Josef Bacik <josef@...icpanda.com>,
linux-block@...r.kernel.org, Alasdair Kergon <agk@...hat.com>,
matias.bjorling@....com, Jens Axboe <axboe@...com>,
Sagi Grimberg <sagi@...mberg.me>, dm-devel@...hat.com,
jiangbo.365@...edance.com, Chaitanya Kulkarni <kch@...dia.com>,
linux-fsdevel@...r.kernel.org, Chris Mason <clm@...com>,
Luis Chamberlain <mcgrof@...nel.org>,
Hannes Reinecke <hare@...e.de>
Subject: Re: [PATCH v4 01/13] block: make blkdev_nr_zones and
blk_queue_zone_no generic for npo2 zsze
On 2022/05/16 15:39, Pankaj Raghav wrote:
> Adapt blkdev_nr_zones and blk_queue_zone_no function so that it can
> also work for non-power-of-2 zone sizes.
>
> As the existing deployments of zoned devices had power-of-2
> assumption, power-of-2 optimized calculation is kept for those devices.
>
> There are no direct hot paths modified and the changes just
> introduce one new branch per call.
>
> Reviewed-by: Luis Chamberlain <mcgrof@...nel.org>
> Reviewed by: Adam Manzanares <a.manzanares@...sung.com>
> Reviewed-by: Hannes Reinecke <hare@...e.de>
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
> ---
> block/blk-zoned.c | 13 ++++++++++---
> include/linux/blkdev.h | 8 +++++++-
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 38cd840d8..140230134 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -111,16 +111,23 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
> * blkdev_nr_zones - Get number of zones
> * @disk: Target gendisk
> *
> - * Return the total number of zones of a zoned block device. For a block
> - * device without zone capabilities, the number of zones is always 0.
> + * Return the total number of zones of a zoned block device, including the
> + * eventual small last zone if present. For a block device without zone
> + * capabilities, the number of zones is always 0.
> */
> unsigned int blkdev_nr_zones(struct gendisk *disk)
> {
> sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
> + sector_t capacity = get_capacity(disk);
>
> if (!blk_queue_is_zoned(disk->queue))
> return 0;
> - return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
> +
> + if (is_power_of_2(zone_sectors))
> + return (capacity + zone_sectors - 1) >>
> + ilog2(zone_sectors);
Why the line break here ? This fits on one line, no ?
> +
> + return div64_u64(capacity + zone_sectors - 1, zone_sectors);
> }
> EXPORT_SYMBOL_GPL(blkdev_nr_zones);
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 1b24c1fb3..22fe512ee 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -675,9 +675,15 @@ static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
> static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> sector_t sector)
> {
> + sector_t zone_sectors = blk_queue_zone_sectors(q);
> +
> if (!blk_queue_is_zoned(q))
> return 0;
> - return sector >> ilog2(q->limits.chunk_sectors);
> +
> + if (is_power_of_2(zone_sectors))
> + return sector >> ilog2(zone_sectors);
> +
> + return div64_u64(sector, zone_sectors);
> }
>
> static inline bool blk_queue_zone_is_seq(struct request_queue *q,
--
Damien Le Moal
Western Digital Research
Powered by blists - more mailing lists