add patch migrate-into-vfs-crypto-engine
[ext4-patch-queue.git] / dont-call-ext4_should_journal_data-on-journal-inode
blob7e08f2ef3ee9a2c1ad47636f927b22e0463f7445
1 ext4: don't call ext4_should_journal_data() on the journal inode
3 From: Vegard Nossum <vegard.nossum@oracle.com>
5 If ext4_fill_super() fails early, it's possible for ext4_evict_inode()
6 to call ext4_should_journal_data() before superblock options and flags
7 are fully set up.  In that case, the iput() on the journal inode can
8 end up causing a BUG().
10 Work around this problem by reordering the tests so we only call
11 ext4_should_journal_data() after we know it's not the journal inode.
13 Fixes: 2d859db3e4 ("ext4: fix data corruption in inodes with journalled data")
14 Fixes: 2b405bfa84 ("ext4: fix data=journal fast mount/umount hang")
15 Cc: Jan Kara <jack@suse.cz>
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
18 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
19 Reviewed-by: Jan Kara <jack@suse.cz>
20 ---
21  fs/ext4/inode.c | 6 +++---
22  1 file changed, 3 insertions(+), 3 deletions(-)
24 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
25 index 321a31c..ea39d19 100644
26 --- a/fs/ext4/inode.c
27 +++ b/fs/ext4/inode.c
28 @@ -211,9 +211,9 @@ void ext4_evict_inode(struct inode *inode)
29                  * Note that directories do not have this problem because they
30                  * don't use page cache.
31                  */
32 -               if (ext4_should_journal_data(inode) &&
33 -                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) &&
34 -                   inode->i_ino != EXT4_JOURNAL_INO) {
35 +               if (inode->i_ino != EXT4_JOURNAL_INO &&
36 +                   ext4_should_journal_data(inode) &&
37 +                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) {
38                         journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
39                         tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;