lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a55665f1-26ae-c19f-5e2e-cf733e8f7fef@samsung.com>
Date:   Wed, 4 May 2022 10:35:04 +0200
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     Bart Van Assche <bvanassche@....org>, <jaegeuk@...nel.org>,
        <axboe@...nel.dk>, <snitzer@...nel.org>, <hch@....de>,
        <mcgrof@...nel.org>, <naohiro.aota@....com>, <sagi@...mberg.me>,
        <damien.lemoal@...nsource.wdc.com>, <dsterba@...e.com>,
        <johannes.thumshirn@....com>
CC:     <linux-kernel@...r.kernel.org>, <linux-btrfs@...r.kernel.org>,
        <clm@...com>, <gost.dev@...sung.com>, <chao@...nel.org>,
        <linux-f2fs-devel@...ts.sourceforge.net>, <josef@...icpanda.com>,
        <jonathan.derrick@...ux.dev>, <agk@...hat.com>,
        <kbusch@...nel.org>, <kch@...dia.com>,
        <linux-nvme@...ts.infradead.org>, <dm-devel@...hat.com>,
        <jiangbo.365@...edance.com>, <linux-fsdevel@...r.kernel.org>,
        <matias.bjorling@....com>, <linux-block@...r.kernel.org>
Subject: Re: [PATCH 01/16] block: make blkdev_nr_zones and blk_queue_zone_no
 generic for npo2 zsze

On 2022-05-03 18:37, Bart Van Assche wrote:
>>       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);
>> +
>> +    return div64_u64(capacity + zone_sectors - 1, zone_sectors);
>>   }
>>   EXPORT_SYMBOL_GPL(blkdev_nr_zones);
> 
> Does anyone need support for more than 4 billion sectors per zone? If
> not, do_div() should be sufficient.
> 
You are absolutely right but blk_queue_zone_sectors explicitly changed
the return type to uint32_t to sector_t in this commit:
'113ab72  block: Fix potential overflow in blk_report_zones()'.

I initially did have a do_div but later changed to div64_u64 to avoid
any implicit down casting even though zone_sectors will be always
limited to an unsigned int.
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index 60d016138997..c4e4c7071b7b 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -665,9 +665,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);
>>   }
> 
> Same comment here.
> 
> Thanks,
> 
> Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ