linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails
@ 2011-06-22  2:33 Jiaying Zhang
  2011-06-22  9:08 ` Lukas Czerner
  2011-07-11  0:10 ` Ted Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Jiaying Zhang @ 2011-06-22  2:33 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4

We have hit the same BUG_ON as described in
https://bugzilla.kernel.org/show_bug.cgi?id=31222
on some of our servers that have disk failures or corrupted inodes. After
looking at the code, I think the problem is that we are not freeing inode's
preallocation list when check_eofblocks_fl fails in ext4_ext_map_blocks(),
which leaves the inode's preallocation list in an inconsistent state.

Below is a proposed patch to fix the bug. I have tested it by manually
inserting a random failure in check_eofblocks_fl() and run a test that
creates and uses an inode's preallocated blocks. Without the fix, the kernel
crashes after a few runs. With the fix, no crash is observed.
    
ext4: free allocated and pre-allocated blocks when check_eofblocks_fl fails

Upon corrupted inode or disk failures, we may fail after we already allocate
some blocks from the inode or take some blocks from the inode's preallocation
list, but before we successfully insert the corresponding extent to the extent
tree. In this case, we should free any allocated blocks and discard the inode's
preallocated blocks because the entries in the inode's preallocation list may
be in an inconsistent state.

Signed-off-by: Jiaying Zhang <jiayingz@google.com>
---
 fs/ext4/extents.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5199bac..8cf6ec9 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3596,10 +3596,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
        }

        err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
-       if (err)
-               goto out2;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails
  2011-06-22  2:33 [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails Jiaying Zhang
@ 2011-06-22  9:08 ` Lukas Czerner
  2011-07-11  0:10 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Czerner @ 2011-06-22  9:08 UTC (permalink / raw)
  To: Jiaying Zhang; +Cc: tytso, linux-ext4

On Tue, 21 Jun 2011, Jiaying Zhang wrote:

> We have hit the same BUG_ON as described in
> https://bugzilla.kernel.org/show_bug.cgi?id=31222
> on some of our servers that have disk failures or corrupted inodes. After
> looking at the code, I think the problem is that we are not freeing inode's
> preallocation list when check_eofblocks_fl fails in ext4_ext_map_blocks(),
> which leaves the inode's preallocation list in an inconsistent state.
> 
> Below is a proposed patch to fix the bug. I have tested it by manually
> inserting a random failure in check_eofblocks_fl() and run a test that
> creates and uses an inode's preallocated blocks. Without the fix, the kernel
> crashes after a few runs. With the fix, no crash is observed.
>     

Hi, have you even read my previous reply ?

> ext4: free allocated and pre-allocated blocks when check_eofblocks_fl fails

Why not to use this ^^^^^^^ line for a subject ? It is immediately
clear what filesystem is it for. Also, why do you have this line in the
commit description anyway ?

It seems that you intended to have the first two paragraphs just as
comments, but you do not really want it to be in commit description, is
that right ? So either add it into commit description or put it after
the "--- " line.

Thanks!
-Lukas

> 
> Upon corrupted inode or disk failures, we may fail after we already allocate
> some blocks from the inode or take some blocks from the inode's preallocation
> list, but before we successfully insert the corresponding extent to the extent
> tree. In this case, we should free any allocated blocks and discard the inode's
> preallocated blocks because the entries in the inode's preallocation list may
> be in an inconsistent state.
> 
> Signed-off-by: Jiaying Zhang <jiayingz@google.com>
> ---
>  fs/ext4/extents.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 5199bac..8cf6ec9 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3596,10 +3596,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
>         }
> 
>         err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
> -       if (err)
> -               goto out2;
> -
> -       err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
> +       if (!err)
> +               err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
>         if (err) {
>                 /* free data blocks we just allocated */
>                 /* not a good idea to call discard here directly,
> 

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails
  2011-06-22  2:33 [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails Jiaying Zhang
  2011-06-22  9:08 ` Lukas Czerner
@ 2011-07-11  0:10 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Ted Ts'o @ 2011-07-11  0:10 UTC (permalink / raw)
  To: Jiaying Zhang; +Cc: linux-ext4

On Tue, Jun 21, 2011 at 07:33:50PM -0700, Jiaying Zhang wrote:
> ext4: free allocated and pre-allocated blocks when check_eofblocks_fl fails
> 
> Upon corrupted inode or disk failures, we may fail after we already allocate
> some blocks from the inode or take some blocks from the inode's preallocation
> list, but before we successfully insert the corresponding extent to the extent
> tree. In this case, we should free any allocated blocks and discard the inode's
> preallocated blocks because the entries in the inode's preallocation list may
> be in an inconsistent state.
> 
> Signed-off-by: Jiaying Zhang <jiayingz@google.com>

Thanks, added to the ext4 tree.  I reformatted the commit description
because its fill width was a bit too large.

	    	    	     	       	 - Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-11  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-22  2:33 [PATCH RESEND] Free allocated and pre-allocated blocks when check_eofblocks_fl fails Jiaying Zhang
2011-06-22  9:08 ` Lukas Czerner
2011-07-11  0:10 ` Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).