lkml.org 
[lkml]   [2022]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] block: simplify blksize_bits() implementation
From
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.

Thanks,

Bart.

\
 
 \ /
  Last update: 2022-10-30 04:01    [W:0.042 / U:1.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site