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: <20240725104624.v73lgnkrojxaiuig@quack3>
Date: Thu, 25 Jul 2024 12:46:24 +0200
From: Jan Kara <jack@...e.cz>
To: libaokun@...weicloud.com
Cc: linux-ext4@...r.kernel.org, tytso@....edu, adilger.kernel@...ger.ca,
	jack@...e.cz, ritesh.list@...il.com, linux-kernel@...r.kernel.org,
	yi.zhang@...wei.com, yangerkun@...wei.com,
	Baokun Li <libaokun1@...wei.com>
Subject: Re: [PATCH 10/20] ext4: get rid of ppath in
 ext4_ext_create_new_leaf()

On Wed 10-07-24 12:06:44, libaokun@...weicloud.com wrote:
> From: Baokun Li <libaokun1@...wei.com>
> 
> The use of path and ppath is now very confusing, so to make the code more
> readable, pass path between functions uniformly, and get rid of ppath.
> 
> To get rid of the ppath in ext4_ext_create_new_leaf(), the following is
> done here:
> 
>  * Free the extents path when an error is encountered.
>  * Its caller needs to update ppath if it uses ppath.
> 
> No functional changes.
> 
> Signed-off-by: Baokun Li <libaokun1@...wei.com>

Just one nit below. Otherwise feel free to add:

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

> @@ -1424,28 +1423,24 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
>  		 * entry: create all needed subtree and add new leaf */
>  		err = ext4_ext_split(handle, inode, mb_flags, path, newext, i);
>  		if (err)
> -			goto out;
> +			goto errout;
>  
>  		/* refill path */
>  		path = ext4_find_extent(inode,
>  				    (ext4_lblk_t)le32_to_cpu(newext->ee_block),
>  				    path, gb_flags);
> -		if (IS_ERR(path))
> -			err = PTR_ERR(path);

So I'd rather have here:
		return path;

That way it's obvious we will not confuse some code below with error stored
in 'path' and we can also save one indentation level by removing 'else'
below (probably do reindenting in a separate patch).

								Honza

>  	} else {
>  		/* tree is full, time to grow in depth */
>  		err = ext4_ext_grow_indepth(handle, inode, mb_flags);
>  		if (err)
> -			goto out;
> +			goto errout;
>  
>  		/* refill path */
>  		path = ext4_find_extent(inode,
>  				   (ext4_lblk_t)le32_to_cpu(newext->ee_block),
>  				    path, gb_flags);
> -		if (IS_ERR(path)) {
> -			err = PTR_ERR(path);
> -			goto out;
> -		}
> +		if (IS_ERR(path))
> +			return path;
>  
>  		/*
>  		 * only first (depth 0 -> 1) produces free space;
> @@ -1457,9 +1452,11 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
>  			goto repeat;
>  		}
>  	}
> -out:
> -	*ppath = IS_ERR(path) ? NULL : path;
> -	return err;
> +	return path;
> +
> +errout:
> +	ext4_free_ext_path(path);
> +	return ERR_PTR(err);
>  }
>  
>  /*
> @@ -2112,10 +2109,14 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
>  	 */
>  	if (gb_flags & EXT4_GET_BLOCKS_METADATA_NOFAIL)
>  		mb_flags |= EXT4_MB_USE_RESERVED;
> -	err = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags,
> -				       ppath, newext);
> -	if (err)
> +	path = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags,
> +					path, newext);
> +	if (IS_ERR(path)) {
> +		*ppath = NULL;
> +		err = PTR_ERR(path);
>  		goto cleanup;
> +	}
> +	*ppath = path;
>  	depth = ext_depth(inode);
>  	eh = path[depth].p_hdr;
>  
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ