All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: Frank Mayhar <fmayhar@google.com>
Cc: Surbhi Palande <surbhi.palande@canonical.com>,
	linux-ext4@vger.kernel.org
Subject: Re: [PATCH] replaced BUG() with return -EIO from	ext4_ext_get_blocks
Date: Fri, 11 Dec 2009 14:02:58 -0600	[thread overview]
Message-ID: <4B22A572.5010201@redhat.com> (raw)
In-Reply-To: <1260554859.21896.8.camel@bobble.smo.corp.google.com>

Frank Mayhar wrote:
> On Fri, 2009-12-11 at 16:06 +0200, Surbhi Palande wrote:
>> This patch fixes the upstream bug# 14286. When the address of an extent
>> corresponding to a given block is NULL and the tree is being traversed for
>> fetching such an address, a -EIO should be reported instead of a BUG(). This
>> situation should normally not occur. However if it does, then the system
>> should be rendered usable.
>>
>> Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com>
>> ---
>>  fs/ext4/extents.c |    7 ++++++-
>>  1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
>> index 3a7928f..51f87f3 100644
>> --- a/fs/ext4/extents.c
>> +++ b/fs/ext4/extents.c
>> @@ -3190,7 +3190,12 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
>>  	 * this situation is possible, though, _during_ tree modification;
>>  	 * this is why assert can't be put in ext4_ext_find_extent()
>>  	 */
>> -	BUG_ON(path[depth].p_ext == NULL && depth != 0);
>> +	if (path[depth].p_ext == NULL && depth != 0) {
>> +		err = -EIO;
>> +		printk(KERN_ERR "\n ext4 fs error in %s,%s,%s while reading a block ", \
>> +					__FILE__, __func__, __LINE__);
>> +		goto out2;
>> +	}
>>  	eh = path[depth].p_hdr;
>>  
>>  	ex = path[depth].p_ext;
> 
> As it happens, I fixed this locally but, as I considered it a band-aid
> fix at the time, I never pushed it to you guys.  My version of the fix
> is below; it dumps more information before returning the EIO.  I don't
> have a strong preference between the two versions but I would like to
> see the commentary included and the extra information is often useful
> during debugging.

My first thought was that this was a bandaid too, but I guess it can
come about due to on-disk corruption for any reason, so it should
be handled gracefully, and I suppose this approach seems fine.

I think the original plan was that a BUG() should be primarily for things
that would arise from a programming error, though EIO & graceful shutdown
even for that class of errors would probably be best.

Since this is catching on-disk corruption, though, it'd be better to call
ext4_error() and let the mount-time error-handling policy decide what to do.

I like having more info but below seems awfully wordy ;)  Maybe the first
printk would suffice, and switching it to an ext4_error() would be best,
I think.

-Eric


> Signed-off-by:  Frank Mayhar <fmayhar@google.com>
> 
>  fs/ext4/extents.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index f7bdd55..7aa0bf6 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -2859,8 +2859,24 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
>  	 * consistent leaf must not be empty;
>  	 * this situation is possible, though, _during_ tree modification;
>  	 * this is why assert can't be put in ext4_ext_find_extent()
> +	 *
> +	 * We don't want to panic in this case, as it can lead to a crash
> +	 * loop; instead we want to catch the error and abort.
>  	 */
> -	BUG_ON(path[depth].p_ext == NULL && depth != 0);
> +	if (path[depth].p_ext == NULL && depth != 0) {
> +		printk(KERN_ERR
> +		       "EXT4-fs (%s): corrupt extent node ino %lu iblock %d"
> +		       " depth %d pblock %lld\n",
> +		       inode->i_sb->s_id, inode->i_ino, iblock, depth,
> +		       path[depth].p_block);
> +		if (!path[depth].p_hdr)
> +			path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
> +		printk(KERN_ERR "EXT4-fs (%s): eh_entries %d eh_max %d\n",
> +		       inode->i_sb->s_id, path[depth].p_hdr->eh_entries,
> +		       path[depth].p_hdr->eh_max);
> +		err = -EIO;
> +		goto out2;
> +	}
>  	eh = path[depth].p_hdr;
>  
>  	ex = path[depth].p_ext;


  reply	other threads:[~2009-12-11 20:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-11 14:06 [PATCH] replaced BUG() with return -EIO from ext4_ext_get_blocks Surbhi Palande
2009-12-11 18:07 ` Frank Mayhar
2009-12-11 20:02   ` Eric Sandeen [this message]
2009-12-11 20:22     ` Frank Mayhar
2009-12-11 20:31       ` Eric Sandeen
2009-12-11 21:11         ` Frank Mayhar
2009-12-11 22:11       ` Surbhi Palande
2009-12-11 22:16         ` Frank Mayhar
2009-12-12 21:00     ` [PATCH v2] " Surbhi Palande
2009-12-14 15:04       ` tytso

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=4B22A572.5010201@redhat.com \
    --to=sandeen@redhat.com \
    --cc=fmayhar@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=surbhi.palande@canonical.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.