[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <214e0c82-ce20-ba0f-77bd-21f3b83fd1f1@samsung.com>
Date: Tue, 24 May 2022 09:10:53 +0200
From: Pankaj Raghav <p.raghav@...sung.com>
To: Hannes Reinecke <hare@...e.de>, <axboe@...nel.dk>, <hch@....de>,
<snitzer@...hat.com>, <damien.lemoal@...nsource.wdc.com>,
<Johannes.Thumshirn@....com>
CC: <linux-nvme@...ts.infradead.org>, <dm-devel@...hat.com>,
<dsterba@...e.com>, <jiangbo.365@...edance.com>,
<linux-kernel@...r.kernel.org>, <gost.dev@...sung.com>,
<linux-block@...r.kernel.org>, <jaegeuk@...nel.org>,
Luis Chamberlain <mcgrof@...nel.org>
Subject: Re: [PATCH v5 2/7] block: allow blk-zoned devices to have
non-power-of-2 zone size
On 5/24/22 07:19, Hannes Reinecke wrote:
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index c4e4c7071b7b..f5c7a41032ba 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -676,6 +676,21 @@ static inline unsigned int
>> blk_queue_zone_no(struct request_queue *q,
>> return div64_u64(sector, zone_sectors);
>> }
>> +static inline bool blk_queue_is_zone_start(struct request_queue *q,
>> sector_t sec)
>> +{
>> + sector_t zone_sectors = blk_queue_zone_sectors(q);
>> + u64 remainder = 0;
>> +
>> + if (!blk_queue_is_zoned(q))
>> + return false;
>> +
>
> Not sure if we need this here; surely blk_queue_zone_sectors() will
> already barf, and none of the callers did this check.
>
I totally agree with you but all the other blk_queue_* functions had
this defensive check and I didn't want to break that pattern:
static inline unsigned int blk_queue_zone_no(struct request_queue *q,
sector_t sector)
{
....
if (!blk_queue_is_zoned(q))
return 0;
....
}
>> + if (is_power_of_2(zone_sectors))
>> + return IS_ALIGNED(sec, zone_sectors);
>> +
And, if the chunk sectors is 0, then we will do the npo2 calculation
resulting in a divide by zero even though chances of that happening is
very very low as you pointed out.
>> + div64_u64_rem(sec, zone_sectors, &remainder);
>> + return remainder == 0;
>> +}
>> +
>> static inline bool blk_queue_zone_is_seq(struct request_queue *q,
>> sector_t sector)
>> {
>> @@ -722,6 +737,12 @@ static inline unsigned int
>> blk_queue_zone_no(struct request_queue *q,
>> {
>> return 0;
>> }
>> +
>> +static inline bool blk_queue_is_zone_start(struct request_queue *q,
>> sector_t sec)
>> +{
>> + return false;
>> +}
>> +
>> static inline unsigned int queue_max_open_zones(const struct
>> request_queue *q)
>> {
>> return 0;
> Otherwise looks good.
>
Thanks!
> Cheers,
>
> Hannes
Powered by blists - more mailing lists