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] [day] [month] [year] [list]
Date:   Sun, 30 Oct 2022 11:52:39 +0800
From:   Dawei Li <set_pte_at@...look.com>
To:     Bart Van Assche <bvanassche@....org>
Cc:     axboe@...nel.dk, hch@....de, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] block: simplify blksize_bits() implementation

On Sat, Oct 29, 2022 at 08:33:22PM -0700, Bart Van Assche wrote:
> On 10/29/22 20:25, Dawei Li wrote:
> > On Sat, Oct 29, 2022 at 08:00:58PM -0700, Bart Van Assche wrote:
> > > On 10/29/22 19:17, Dawei Li wrote:
> > > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> > > > index 57ed49f20d2e..7b537afe8b38 100644
> > > > --- a/include/linux/blkdev.h
> > > > +++ b/include/linux/blkdev.h
> > > > @@ -1349,12 +1349,7 @@ static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
> > > >    /* assumes size > 256 */
> > > >    static inline unsigned int blksize_bits(unsigned int size)
> > > >    {
> > > > -	unsigned int bits = 8;
> > > > -	do {
> > > > -		bits++;
> > > > -		size >>= 1;
> > > > -	} while (size > 256);
> > > > -	return bits;
> > > > +	return order_base_2((size + SECTOR_SIZE - 1) >> SECTOR_SHIFT) + SECTOR_SHIFT;
> > > >    }
> > > 
> > > Why the rounding ("+ SECTOR_SIZE - 1")? The blksize_bits() argument should
> > > be an argument of two.
> > 
> > Yeah, that's what's supposed to be.
> > But I thought maybe a "just in case" is more robust?
> > Should we consider these corner cases(!is_power_of_2())?
> 
> I don't think that the Linux kernel supports block sizes that are not a
> power of two. Hence my request to leave out the rounding code. Keeping that
> code would be misleading because it would suggest that the blksize_bits()
> argument can be something else than a power of two.

Thanks for the review, bart.
Will resend the updated patch.
> 
> Thanks,
> 
> Bart.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ