Skip to content

Commit a0851ea

Browse files
zhangyi089brauner
authored andcommitted
jbd2: flush filesystem device before updating tail sequence
When committing transaction in jbd2_journal_commit_transaction(), the disk caches for the filesystem device should be flushed before updating the journal tail sequence. However, this step is missed if the journal is not located on the filesystem device. As a result, the filesystem may become inconsistent following a power failure or system crash. Fix it by ensuring that the filesystem device is flushed appropriately. Fixes: 3339578 ("jbd2: cleanup journal tail after transaction commit") Signed-off-by: Zhang Yi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent ac1e21b commit a0851ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/jbd2/commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ void jbd2_journal_commit_transaction(journal_t *journal)
772772
/*
773773
* If the journal is not located on the file system device,
774774
* then we must flush the file system device before we issue
775-
* the commit record
775+
* the commit record and update the journal tail sequence.
776776
*/
777-
if (commit_transaction->t_need_data_flush &&
777+
if ((commit_transaction->t_need_data_flush || update_tail) &&
778778
(journal->j_fs_dev != journal->j_dev) &&
779779
(journal->j_flags & JBD2_BARRIER))
780780
blkdev_issue_flush(journal->j_fs_dev);

0 commit comments

Comments
 (0)