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]
Date: Thu, 30 Nov 2023 13:36:01 +0100
From: Jan Kara <jack@...e.cz>
To: Gou Hao <gouhao@...ontech.com>
Cc: tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz,
	alex@...sterfs.com, linux-ext4@...r.kernel.org,
	linux-kernel@...r.kernel.org, gouhaojake@....com
Subject: Re: [PATCH] ext4: improving calculation of 'fe_{len|start}' in
 mb_find_extent()

On Mon 13-11-23 16:26:17, Gou Hao wrote:
> After first execution of mb_find_order_for_block():
> 
> 'fe_start' is the value of 'block' passed in mb_find_extent().
> 
> 'fe_len' is the difference between the length of order-chunk and
> remainder of the block divided by order-chunk.
> 
> And 'next' does not require initialization after above modifications.
> 
> Signed-off-by: Gou Hao <gouhao@...ontech.com>

Ah, nice simplification! Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/ext4/mballoc.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 454d5612641e..d3f985f7cab8 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1958,8 +1958,7 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
>  static int mb_find_extent(struct ext4_buddy *e4b, int block,
>  				int needed, struct ext4_free_extent *ex)
>  {
> -	int next = block;
> -	int max, order;
> +	int max, order, next;
>  	void *buddy;
>  
>  	assert_spin_locked(ext4_group_lock_ptr(e4b->bd_sb, e4b->bd_group));
> @@ -1977,16 +1976,12 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
>  
>  	/* find actual order */
>  	order = mb_find_order_for_block(e4b, block);
> -	block = block >> order;
>  
> -	ex->fe_len = 1 << order;
> -	ex->fe_start = block << order;
> +	ex->fe_len = (1 << order) - (block & ((1 << order) - 1));
> +	ex->fe_start = block;
>  	ex->fe_group = e4b->bd_group;
>  
> -	/* calc difference from given start */
> -	next = next - ex->fe_start;
> -	ex->fe_len -= next;
> -	ex->fe_start += next;
> +	block = block >> order;
>  
>  	while (needed > ex->fe_len &&
>  	       mb_find_buddy(e4b, order, &max)) {
> -- 
> 2.20.1
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ