Skip to content

Commit a09decf

Browse files
Kai Litytso
authored andcommitted
jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal
If the journal is dirty when the filesystem is mounted, jbd2 will replay the journal but the journal superblock will not be updated by journal_reset() because JBD2_ABORT flag is still set (it was set in journal_init_common()). This is problematic because when a new transaction is then committed, it will be recorded in block 1 (journal->j_tail was set to 1 in journal_reset()). If unclean shutdown happens again before the journal superblock is updated, the new recorded transaction will not be replayed during the next mount (because of stale sb->s_start and sb->s_sequence values) which can lead to filesystem corruption. Fixes: 85e0c4e ("jbd2: if the journal is aborted then don't allow update of the log tail") Signed-off-by: Kai Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 71b565c commit a09decf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/jbd2/journal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,14 +1710,18 @@ int jbd2_journal_load(journal_t *journal)
17101710
journal->j_devname);
17111711
return -EFSCORRUPTED;
17121712
}
1713+
/*
1714+
* clear JBD2_ABORT flag initialized in journal_init_common
1715+
* here to update log tail information with the newest seq.
1716+
*/
1717+
journal->j_flags &= ~JBD2_ABORT;
17131718

17141719
/* OK, we've finished with the dynamic journal bits:
17151720
* reinitialise the dynamic contents of the superblock in memory
17161721
* and reset them on disk. */
17171722
if (journal_reset(journal))
17181723
goto recovery_error;
17191724

1720-
journal->j_flags &= ~JBD2_ABORT;
17211725
journal->j_flags |= JBD2_LOADED;
17221726
return 0;
17231727

0 commit comments

Comments
 (0)