Skip to content

Commit c288d29

Browse files
committed
ext2: Fix BUG_ON in evict() on inode deletion
Commit 8e3dffc 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 <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent af591ad commit c288d29

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

fs/ext2/ialloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ void ext2_free_inode (struct inode * inode)
118118
* as writing the quota to disk may need the lock as well.
119119
*/
120120
/* Quota is already initialized in iput() */
121-
ext2_xattr_delete_inode(inode);
122121
dquot_free_inode(inode);
123122
dquot_drop(inode);
124123

fs/ext2/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "ext2.h"
3535
#include "acl.h"
3636
#include "xip.h"
37+
#include "xattr.h"
3738

3839
static int __ext2_write_inode(struct inode *inode, int do_sync);
3940

@@ -88,6 +89,7 @@ void ext2_evict_inode(struct inode * inode)
8889
inode->i_size = 0;
8990
if (inode->i_blocks)
9091
ext2_truncate_blocks(inode, 0);
92+
ext2_xattr_delete_inode(inode);
9193
}
9294

9395
invalidate_inode_buffers(inode);

0 commit comments

Comments
 (0)