Skip to contentSkip to conversation

Ext2: do not mark_inode_dirty to avoid BUG_ON

PATCH In review fanchaoting 4 participants 5 messages Mar 12, 2013 – Mar 14, 2013 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Ext2: do not mark_inode_dirty to avoid BUG_ON

From: Wang Shilong <[email protected]>

commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into a regression that casue BUG_ON when unlinking inode.

---
 fs/ext2/balloc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/ext2/balloc.c +0 -1
index 9f9992b..06d82fc 100644
@@ -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

#1 lore raw
Quoted 11 lines · fanchaoting

Date: Tue, 12 Mar 2013 13:06:37 +0800
From: fanchaoting <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
[email protected]
Subject: [PATCH] Ext2: do not mark_inode_dirty to avoid BUG_ON

From: Wang Shilong <[email protected]>

commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into a regression that casue BUG_ON when unlinking inode.

Hi,

it seems to be that we do need to mark the inode dirty, because we're changing inode->i_blocks from within dquot_free_block_nodirty().

However looking at the code we usually call mark_inode_dirty(inode) after we call ext2_free_blocks() except when we're about to remove the inode so it seems that having that call within ext2_free_blocks() is not necessary.

However I am not sure about the error path in ext2_alloc_branch() which does not dirty the inode after calling ext2_free_blocks(). However presumably since we're just undoing the changes we might have done and not actually allocating, or freeing any space for real, dirtying the inode might not be necessary. Can you confirm that ?

Thanks!
-Lukas

Quoted 29 lines
---
 fs/ext2/balloc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/ext2/balloc.c +0 -3
index 9f9992b..06d82fc 100644
@@ -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 
 
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 16 lines · Lukáš Czerner
Quoted 11 lines · fanchaoting

Date: Tue, 12 Mar 2013 13:06:37 +0800
From: fanchaoting <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
[email protected]
Subject: [PATCH] Ext2: do not mark_inode_dirty to avoid BUG_ON

From: Wang Shilong <[email protected]>

commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into a regression that casue BUG_ON when unlinking inode.

Hi,

Quoted 8 lines

it seems to be that we do need to mark the inode dirty, because we're changing inode->i_blocks from within dquot_free_block_nodirty().

However looking at the code we usually call mark_inode_dirty(inode) after we call ext2_free_blocks() except when we're about to remove the inode so it seems that having that call within ext2_free_blocks() is not necessary.

Yeah. Actually the problem is specifically with ext2_xattr_delete_inode()
marking inode dirty because that is called after clear_inode(). Everything before clear_inode() call is free to dirty the inode because clear_inode() clears the dirty flag. I wonder if we shouldn't move that call into ext2_evict_inode() before clear_inode() and be done with it. Because the fact that ext2_free_blocks() cannot dirty the inode looks more surprising than the fact that ext2_free_inode() doesn't automatically free extended attributes.

Quoted 6 lines

However I am not sure about the error path in ext2_alloc_branch() which does not dirty the inode after calling ext2_free_blocks(). However presumably since we're just undoing the changes we might have done and not actually allocating, or freeing any space for real, dirtying the inode might not be necessary. Can you confirm that ?

I think that needs to dirty the inode. It may be written out in some
intermediate state...

Honza

Quoted 28 lines
Quoted 28 lines
---
 fs/ext2/balloc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/ext2/balloc.c +0 -3
index 9f9992b..06d82fc 100644
@@ -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 
 
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 6 lines
Jan Kara <[email protected]>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to fanchaoting
Quoted 7 lines · fanchaoting

From: Wang Shilong <[email protected]>

commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into a regression that casue BUG_ON when unlinking inode.

I ended up fixing the problem by the attached patch. It looks cleaner to
me that way... Thanks for your fix anyway.

Honza

Quoted 21 lines
---
 fs/ext2/balloc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/ext2/balloc.c +0 -2
index 9f9992b..06d82fc 100644
@@ -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 
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Quoted 1 line

From c288d2969627be7ffc90904ac8c6aae0295fbf9f Mon Sep 17 00:00:00 2001

From: Jan Kara <[email protected]>
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.

---
 fs/ext2/ialloc.c |    1 -
 fs/ext2/inode.c  |    2 ++
 2 files changed, 2 insertions(+), 1 deletions(-)
fs/ext2/ialloc.c +0 -1
index 8f370e0..7cadd82 100644
@@ -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);
 
fs/ext2/inode.c +2 -0
index c3881e5..fe60cc1 100644
@@ -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);
Signature · 1 line
1.7.1
#4 lore raw
Quoted 10 lines · 在 2013-3-14,上午7:09,Jan Kara <[email protected]> 写道:
Quoted 7 lines · fanchaoting

From: Wang Shilong <[email protected]>

commit 8e3dffc651cb668e1ff4d8b89cc1c3dde7540d3b leads into a regression that casue BUG_ON when unlinking inode.

I ended up fixing the problem by the attached patch. It looks cleaner to
me that way... Thanks for your fix anyway.

Sorry for delay reply, I am busy with my graduation project these two days. However, your patch looks more reasonable than mine.

Thanks very much to fanchaoting sending my patch out anyway.

Thanks,
Wang

Quoted 18 lines

Honza

Quoted 16 lines

---
fs/ext2/balloc.c | 1 -

1 files changed, 0 insertions(+), 1 deletions(-)
fs/ext2/balloc.c +0 -1
index 9f9992b..06d82fc 100644
@@ -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);
 	}
 }
 
Quoted 9 lines
Quoted 5 lines

-- 1.7.7.6

Signature · 3 lines
Jan Kara <[email protected]>
SUSE Labs, CR
<0001-ext2-Fix-BUG_ON-in-evict-on-inode-deletion.patch>

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html