linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: fanchaoting <fanchaoting@cn.fujitsu.com>
Cc: jack@suse.cz, tyhicks@canonical.com, linux-ext4@vger.kernel.org,
	wangshilong1991@gmail.com
Subject: Re: [PATCH] Ext2: do not mark_inode_dirty to avoid BUG_ON
Date: Thu, 14 Mar 2013 00:09:28 +0100	[thread overview]
Message-ID: <20130313230928.GA11068@quack.suse.cz> (raw)
In-Reply-To: <513EB7DD.3020103@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On Tue 12-03-13 13:06:37, fanchaoting wrote:
> From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
> 
> commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into
> a regression that casue BUG_ON when unlinking inode.
> 
> Reported-by: tyhicks@canonical.com
> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
  I ended up fixing the problem by the attached patch. It looks cleaner to
me that way... Thanks for your fix anyway.

							Honza
> ---
>  fs/ext2/balloc.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
> index 9f9992b..06d82fc 100644
> --- a/fs/ext2/balloc.c
> +++ b/fs/ext2/balloc.c
> @@ -562,7 +562,6 @@ error_return:
>  	if (freed) {
>  		percpu_counter_add(&sbi->s_freeblocks_counter, freed);
>  		dquot_free_block_nodirty(inode, freed);
> -		mark_inode_dirty(inode);
>  	}
>  }
>  
> -- 1.7.7.6 
> 
> 
> 
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

[-- Attachment #2: 0001-ext2-Fix-BUG_ON-in-evict-on-inode-deletion.patch --]
[-- Type: text/x-patch, Size: 1869 bytes --]

>From c288d2969627be7ffc90904ac8c6aae0295fbf9f Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Wed, 13 Mar 2013 12:57:08 +0100
Subject: [PATCH] ext2: Fix BUG_ON in evict() on inode deletion

Commit 8e3dffc6 introduced a regression where deleting inode with
large extended attributes leads to triggering
  BUG_ON(inode->i_state != (I_FREEING | I_CLEAR))
in fs/inode.c:evict(). That happens because freeing of xattr block
dirtied the inode and it happened after clear_inode() has been called.

Fix the issue by moving removal of xattr block into ext2_evict_inode()
before clear_inode() call close to a place where data blocks are
truncated. That is also more logical place and removes surprising
requirement that ext2_free_blocks() mustn't dirty the inode.

Reported-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext2/ialloc.c |    1 -
 fs/ext2/inode.c  |    2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 8f370e0..7cadd82 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -118,7 +118,6 @@ void ext2_free_inode (struct inode * inode)
 	 * as writing the quota to disk may need the lock as well.
 	 */
 	/* Quota is already initialized in iput() */
-	ext2_xattr_delete_inode(inode);
 	dquot_free_inode(inode);
 	dquot_drop(inode);
 
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index c3881e5..fe60cc1 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -34,6 +34,7 @@
 #include "ext2.h"
 #include "acl.h"
 #include "xip.h"
+#include "xattr.h"
 
 static int __ext2_write_inode(struct inode *inode, int do_sync);
 
@@ -88,6 +89,7 @@ void ext2_evict_inode(struct inode * inode)
 		inode->i_size = 0;
 		if (inode->i_blocks)
 			ext2_truncate_blocks(inode, 0);
+		ext2_xattr_delete_inode(inode);
 	}
 
 	invalidate_inode_buffers(inode);
-- 
1.7.1


  parent reply	other threads:[~2013-03-13 23:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12  5:06 [PATCH] Ext2: do not mark_inode_dirty to avoid BUG_ON fanchaoting
2013-03-12  8:14 ` Lukáš Czerner
2013-03-12 10:13   ` Jan Kara
2013-03-13 23:09 ` Jan Kara [this message]
2013-03-14  0:43   ` Wang Shilong

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=20130313230928.GA11068@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=fanchaoting@cn.fujitsu.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tyhicks@canonical.com \
    --cc=wangshilong1991@gmail.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;
as well as URLs for NNTP newsgroup(s).