Skip to content

Commit

Permalink
ext4: flush journal when switching from data=journal mode
Browse files Browse the repository at this point in the history
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 <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Yongqiang Yang authored and Theodore Ts'o committed Dec 28, 2011
1 parent 2aff57b commit 5872dda
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4660,7 +4660,6 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
}

jbd2_journal_lock_updates(journal);
jbd2_journal_flush(journal);

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

if (val)
ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
else
else {
jbd2_journal_flush(journal);
ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
}
ext4_set_aops(inode);

jbd2_journal_unlock_updates(journal);
Expand Down

0 comments on commit 5872dda

Please sign in to comment.