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]
Message-ID: <20080114103525.GA22676@skywalker>
Date:	Mon, 14 Jan 2008 16:05:25 +0530
From:	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
To:	Mingming Cao <cmm@...ibm.com>
Cc:	ext4 development <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] ext4: use ext4_ext_get_actual_len instead of directly
	using ext4_extent.ee_len

On Sat, Jan 12, 2008 at 11:44:00PM +0530, Aneesh Kumar K.V wrote:
>  fs/ext4/extents.c |   26 ++++++++++++++------------
>  1 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 81bce98..4269cc6 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -1029,7 +1029,7 @@ ext4_ext_search_left(struct inode *inode, struct ext4_ext_path *path,
>  {
>  	struct ext4_extent_idx *ix;
>  	struct ext4_extent *ex;
> -	int depth;
> +	int depth, ee_len;
> 
>  	BUG_ON(path == NULL);
>  	depth = path->p_depth;
> @@ -1043,6 +1043,7 @@ ext4_ext_search_left(struct inode *inode, struct ext4_ext_path *path,
>  	 * first one in the file */
> 
>  	ex = path[depth].p_ext;
> +	ee_len = ext4_ext_get_actual_len(ex);
>  	if (*logical < le32_to_cpu(ex->ee_block)) {
>  		BUG_ON(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex);
>  		while (--depth >= 0) {
> @@ -1052,10 +1053,10 @@ ext4_ext_search_left(struct inode *inode, struct ext4_ext_path *path,
>  		return 0;
>  	}
> 
> -	BUG_ON(*logical < le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len));
> +	BUG_ON(*logical < (le32_to_cpu(ex->ee_block) + ee_len));
> 
> -	*logical = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1;
> -	*phys = ext_pblock(ex) + le16_to_cpu(ex->ee_len) - 1;
> +	*logical = le32_to_cpu(ex->ee_block) + ee_len - 1;
> +	*phys = ext_pblock(ex) + ee_len - 1;
>  	return 0;
>  }
> 
> @@ -1075,7 +1076,7 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path,
>  	struct ext4_extent_idx *ix;
>  	struct ext4_extent *ex;
>  	ext4_fsblk_t block;
> -	int depth;
> +	int depth, ee_len;
> 
>  	BUG_ON(path == NULL);
>  	depth = path->p_depth;
> @@ -1089,6 +1090,7 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path,
>  	 * first one in the file */
> 
>  	ex = path[depth].p_ext;
> +	ee_len = ext4_ext_get_actual_len(ex);
>  	if (*logical < le32_to_cpu(ex->ee_block)) {
>  		BUG_ON(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex);
>  		while (--depth >= 0) {
> @@ -1100,7 +1102,7 @@ ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path,
>  		return 0;
>  	}
> 
> -	BUG_ON(*logical < le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len));
> +	BUG_ON(*logical < (le32_to_cpu(ex->ee_block) + ee_len));
> 
>  	if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) {
>  		/* next allocated block in this leaf */
> @@ -1315,7 +1317,7 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
>  	if (ext1_ee_len + ext2_ee_len > max_len)
>  		return 0;
>  #ifdef AGGRESSIVE_TEST
> -	if (le16_to_cpu(ex1->ee_len) >= 4)
> +	if (ext1_ee_len >= 4)
>  		return 0;
>  #endif
> 
> @@ -1555,7 +1557,7 @@ has_space:
>  	nearex = path[depth].p_ext;
>  	nearex->ee_block = newext->ee_block;
>  	ext4_ext_store_pblock(nearex, ext_pblock(newext));
> -	nearex->ee_len = newext->ee_len;
> +	nearex->ee_len = ext4_ext_get_actual_len(newext);
> 
>  merge:
>  	/* try to merge extents to the right */

This change is not needed.  ext4_ext_try_to_merge check whether the
extent is uninitialized or not and zero out the blocks if we are
merging.

> @@ -2310,7 +2312,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
>  				   - le32_to_cpu(newex.ee_block)
>  				   + ext_pblock(&newex);
>  			/* number of remaining blocks in the extent */

New patch is attached below.

-aneesh

View attachment "ext4_get_extent_length_fix.patch" of type "text/x-diff" (4778 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ