[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9f1385a3-b471-fcd9-2c0c-61f544fbc855@samsung.com>
Date: Mon, 9 May 2022 13:56:28 +0200
From: Pankaj Raghav <p.raghav@...sung.com>
To: Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
<jaegeuk@...nel.org>, <hare@...e.de>, <dsterba@...e.com>,
<axboe@...nel.dk>, <hch@....de>, <snitzer@...nel.org>
CC: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
<bvanassche@....org>, <linux-fsdevel@...r.kernel.org>,
<matias.bjorling@....com>, Jens Axboe <axboe@...com>,
<gost.dev@...sung.com>, <jonathan.derrick@...ux.dev>,
<jiangbo.365@...edance.com>, <linux-nvme@...ts.infradead.org>,
<dm-devel@...hat.com>, Naohiro Aota <naohiro.aota@....com>,
<linux-kernel@...r.kernel.org>,
Johannes Thumshirn <jth@...nel.org>,
Sagi Grimberg <sagi@...mberg.me>,
Alasdair Kergon <agk@...hat.com>,
<linux-block@...r.kernel.org>, Chaitanya Kulkarni <kch@...dia.com>,
Keith Busch <kbusch@...nel.org>, <linux-btrfs@...r.kernel.org>,
Luis Chamberlain <mcgrof@...nel.org>
Subject: Re: [PATCH v3 10/11] null_blk: allow non power of 2 zoned devices
On 2022-05-09 13:31, Damien Le Moal wrote:
>>>> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
>>>> index dae54dd1a..00c34e65e 100644
>>>> --- a/drivers/block/null_blk/zoned.c
>>>> +++ b/drivers/block/null_blk/zoned.c
>>>> @@ -13,7 +13,10 @@ static inline sector_t mb_to_sects(unsigned long mb)
>>>>
>>>> static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect)
>>>> {
>>>> - return sect >> ilog2(dev->zone_size_sects);
>>>> + if (is_power_of_2(dev->zone_size_sects))
>>>> + return sect >> ilog2(dev->zone_size_sects);
>>>
>>> As a separate patch, I think we should really have ilog2(dev->zone_size_sects)
>>> as a dev field to avoid doing this ilog2 for every call..
>>>
>> I don't think that is possible because `zone_size_sects` can also be non
>> po2.
>
> But when it is we can optimize that. All we need is add a "zone_size_sect_shift"
> field that is initialized when zone_size_sects is set when the device is
> created. Then, you can have code like:
>
> if (dev->zone_size_sect_shift))
> return sect >> dev->zone_size_sect_shift;
>
My only concern was confusing people who are reading the code where they
might implicitly assume that it can only be po2 as we have shift_sects.
Even though I am not sure if this optimization will directly add value
looking at my experiments with the current change, I can fold this in
with a comment on top of zone_size_sect_shifts variable stating that
size can be npo2 and this variable is only meaningful for the po2 size
scenario.
Powered by blists - more mailing lists