Skip to content

Commit a662f3c

Browse files
jankaratytso
authored andcommitted
jbd2: do not try to recover wiped journal
If a journal is wiped, we will set journal->j_tail to 0. However if 'write' argument is not set (as it happens for read-only device or for ocfs2), the on-disk superblock is not updated accordingly and thus jbd2_journal_recover() cat try to recover the wiped journal. Fix the check in jbd2_journal_recover() to use journal->j_tail for checking empty journal instead. Signed-off-by: Jan Kara <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent e6eff39 commit a662f3c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/jbd2/recovery.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,19 +282,20 @@ static int fc_do_one_pass(journal_t *journal,
282282
int jbd2_journal_recover(journal_t *journal)
283283
{
284284
int err, err2;
285-
journal_superblock_t * sb;
286-
287285
struct recovery_info info;
288286

289287
memset(&info, 0, sizeof(info));
290-
sb = journal->j_superblock;
291288

292289
/*
293290
* The journal superblock's s_start field (the current log head)
294291
* is always zero if, and only if, the journal was cleanly
295-
* unmounted.
292+
* unmounted. We use its in-memory version j_tail here because
293+
* jbd2_journal_wipe() could have updated it without updating journal
294+
* superblock.
296295
*/
297-
if (!sb->s_start) {
296+
if (!journal->j_tail) {
297+
journal_superblock_t *sb = journal->j_superblock;
298+
298299
jbd2_debug(1, "No recovery required, last transaction %d, head block %u\n",
299300
be32_to_cpu(sb->s_sequence), be32_to_cpu(sb->s_head));
300301
journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1;

0 commit comments

Comments
 (0)