Further updates of Documentation/filesystem/ext4.txt
[ext4-patch-queue.git] / ext4-fix-hang-due-to-corrupted-jinode.patch
blob31a905c5fce7d1a52befb577bafc3dd3e9c4fe85
1 ext4: Fix file system hang due to corrupt jinode values.
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 While commiting the transaction we set the i_flags
6 of jbd2_inode to JI_COMMIT_RUNNING. This is needed to ensure
7 that when we are commiting the transaction we don't release
8 the inode via iput. In ext4_clear_inode we wait for the
9 flag to be cleared before we release the inode.
11 In ext4_new_inode we call iput for different failure cases
12 before initializing the jbd2_inode. This cause the failure
13 case to hang in iput as show below. Fix the same by initializing
14 jbd2_inode early.
16 [<c022d20e>] ? prepare_to_wait+0x49/0x4e
17 [<c02cf430>] jbd2_journal_release_jbd_inode+0x86/0xcc
18 [<c022d0e4>] ? wake_bit_function+0x0/0x43
19 [<c02b329b>] ext4_clear_inode+0x45/0x4a
20 [<c02748f7>] clear_inode+0x5f/0xae
21 [<c0274e8f>] generic_drop_inode+0x119/0x13a
22 [<c0274071>] iput+0x4b/0x4e
23 [<c02ab200>] ext4_new_inode+0xb29/0xb7a
24 [<c0272761>] ? dput+0x19/0xdc
25 [<c02cca5f>] ? jbd2_journal_start+0x8c/0xb9
26 [<c02b1cb4>] ext4_create+0x81/0xe7
27 [<c02b1c33>] ? ext4_create+0x0/0xe7
28 [<c026aa3c>] vfs_create+0x6c/0xdb
29 [<c026cfd6>] do_filp_open+0x1a6/0x6b5
30 [<c026284e>] do_sys_open+0x40/0xb6
31 [<c0262906>] sys_open+0x1e/0x26
32 [<c0202be6>] syscall_call+0x7/0xb
34 Reported-by: Holger Kiehl <Holger.Kiehl@dwd.de>
35 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
36 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
37 Acked-by: Jan Kara <jack@suse.cz>
38 ---
40 fs/ext4/ialloc.c | 1 -
41 fs/ext4/inode.c | 1 -
42 fs/ext4/mballoc.c | 2 --
43 fs/ext4/super.c | 1 +
44 4 files changed, 1 insertion(+), 4 deletions(-)
47 Index: linux-2.6.26-rc6/fs/ext4/ialloc.c
48 ===================================================================
49 --- linux-2.6.26-rc6.orig/fs/ext4/ialloc.c 2008-06-17 10:43:36.000000000 -0700
50 +++ linux-2.6.26-rc6/fs/ext4/ialloc.c 2008-06-17 10:43:36.000000000 -0700
51 @@ -820,7 +820,6 @@ got:
52 ei->i_state = EXT4_STATE_NEW;
54 ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
55 - jbd2_journal_init_jbd_inode(&ei->jinode, inode);
57 ret = inode;
58 if(DQUOT_ALLOC_INODE(inode)) {
59 Index: linux-2.6.26-rc6/fs/ext4/inode.c
60 ===================================================================
61 --- linux-2.6.26-rc6.orig/fs/ext4/inode.c 2008-06-17 10:43:36.000000000 -0700
62 +++ linux-2.6.26-rc6/fs/ext4/inode.c 2008-06-17 10:43:36.000000000 -0700
63 @@ -2704,7 +2704,6 @@ struct inode *ext4_iget(struct super_blo
64 ei->i_default_acl = EXT4_ACL_NOT_CACHED;
65 #endif
66 ei->i_block_alloc_info = NULL;
67 - jbd2_journal_init_jbd_inode(&ei->jinode, inode);
69 ret = __ext4_get_inode_loc(inode, &iloc, 0);
70 if (ret < 0)
71 Index: linux-2.6.26-rc6/fs/ext4/mballoc.c
72 ===================================================================
73 --- linux-2.6.26-rc6.orig/fs/ext4/mballoc.c 2008-06-17 10:43:36.000000000 -0700
74 +++ linux-2.6.26-rc6/fs/ext4/mballoc.c 2008-06-17 10:43:36.000000000 -0700
75 @@ -2255,8 +2255,6 @@ static int ext4_mb_init_backend(struct s
76 printk(KERN_ERR "EXT4-fs: can't get new inode\n");
77 goto err_freesgi;
79 - jbd2_journal_init_jbd_inode(&EXT4_I(sbi->s_buddy_cache)->jinode,
80 - sbi->s_buddy_cache);
81 EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
83 metalen = sizeof(*meta_group_info) << EXT4_DESC_PER_BLOCK_BITS(sb);
84 Index: linux-2.6.26-rc6/fs/ext4/super.c
85 ===================================================================
86 --- linux-2.6.26-rc6.orig/fs/ext4/super.c 2008-06-17 10:43:36.000000000 -0700
87 +++ linux-2.6.26-rc6/fs/ext4/super.c 2008-06-17 10:43:36.000000000 -0700
88 @@ -573,6 +573,7 @@ static struct inode *ext4_alloc_inode(st
89 memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
90 INIT_LIST_HEAD(&ei->i_prealloc_list);
91 spin_lock_init(&ei->i_prealloc_lock);
92 + jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode);
93 return &ei->vfs_inode;