Skip to content

Commit 5872dda

Browse files
xiaoqiangnktytso
authored andcommitted
ext4: flush journal when switching from data=journal mode
It's necessary to flush the journal when switching away from data=journal mode. This is because there are no revoke records when data blocks are journalled, but revoke records are required in the other journal modes. However, it is not necessary to flush the journal when switching into data=journal mode, and flushing the journal is expensive. So let's avoid it in that case. Signed-off-by: Yongqiang Yang <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]>
1 parent 2aff57b commit 5872dda

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ext4/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,7 +4660,6 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
46604660
}
46614661

46624662
jbd2_journal_lock_updates(journal);
4663-
jbd2_journal_flush(journal);
46644663

46654664
/*
46664665
* OK, there are no updates running now, and all cached data is
@@ -4672,8 +4671,10 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
46724671

46734672
if (val)
46744673
ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4675-
else
4674+
else {
4675+
jbd2_journal_flush(journal);
46764676
ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4677+
}
46774678
ext4_set_aops(inode);
46784679

46794680
jbd2_journal_unlock_updates(journal);

0 commit comments

Comments
 (0)