public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>,
	David Dindorp <ddi@dubex.dk>
Subject: Re: [PATCH] fix header check in ext4_ext_search_right() for deep extent trees.
Date: Mon, 9 Mar 2009 10:29:53 +0530	[thread overview]
Message-ID: <20090309045953.GA26853@skywalker> (raw)
In-Reply-To: <49B18CAB.5020605@redhat.com>

On Fri, Mar 06, 2009 at 02:50:51PM -0600, Eric Sandeen wrote:
> This should resolve kernel.org bugzilla 12821
> 
> I've not actually crafted a workload to exercise this code; 
> this is from inspection...
> 
> The ext4_ext_search_right() function is confusing; it uses a
> "depth" variable which is 0 at the root and maximum at the leaves, 
> but the on-disk metadata uses a "depth" (actually eh_depth) which
> is opposite: maximum at the root, and 0 at the leaves.
> 
> The ext4_ext_check_header() function is given a depth and checks
> the header agaisnt that depth; it expects the on-disk semantics,
> but we are giving it the opposite in the while loop in this 
> function.  We should be giving it the on-disk notion of "depth"
> which we can get from (p_depth - depth) - and if you look, the last
> (more commonly hit) call to ext4_ext_check_header() does just this.

Correct. Few lines below we are passing the right depth when verifying
the leaf blocks. So I guess it was a coding error.


> 
> Sending in the wrong depth results in (incorrect) messages
> about corruption:
> 
> EXT4-fs error (device sdb1): ext4_ext_search_right: bad header
> in inode #2621457: unexpected eh_depth - magic f30a, entries 340,
> max 340(0), depth 1(2)
> 
> Reported-by: David Dindorp <ddi@dubex.dk>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>


Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>


> --
> 
> Index: linux-2.6/fs/ext4/extents.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/extents.c
> +++ linux-2.6/fs/ext4/extents.c
> @@ -1122,7 +1122,8 @@ ext4_ext_search_right(struct inode *inod
>  	struct ext4_extent_idx *ix;
>  	struct ext4_extent *ex;
>  	ext4_fsblk_t block;
> -	int depth, ee_len;
> +	int depth;	/* Note, NOT eh_depth; depth from top of tree */
> +	int ee_len;
> 
>  	BUG_ON(path == NULL);
>  	depth = path->p_depth;
> @@ -1179,7 +1180,8 @@ got_index:
>  		if (bh == NULL)
>  			return -EIO;
>  		eh = ext_block_hdr(bh);
> -		if (ext4_ext_check_header(inode, eh, depth)) {
> +		/* subtract from p_depth to get proper eh_depth */
> +		if (ext4_ext_check_header(inode, eh, path->p_depth - depth)) {
>  			put_bh(bh);
>  			return -EIO;
>  		}
> 

-aneesh

  reply	other threads:[~2009-03-09  5:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-06 20:50 [PATCH] fix header check in ext4_ext_search_right() for deep extent trees Eric Sandeen
2009-03-09  4:59 ` Aneesh Kumar K.V [this message]
2009-03-09 11:36 ` Theodore Tso
2009-03-09 15:53   ` Eric Sandeen
2009-03-09 16:01   ` Aneesh Kumar K.V
2009-03-09 16:13     ` Eric Sandeen
2009-03-09 17:34       ` Theodore Tso
2009-03-09 17:51         ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090309045953.GA26853@skywalker \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=ddi@dubex.dk \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox