Skip to content

Commit 51f57b0

Browse files
zhangyi089tytso
authored andcommitted
ext4, jbd2: ensure panic when aborting with zero errno
JBD2_REC_ERR flag used to indicate the errno has been updated when jbd2 aborted, and then __ext4_abort() and ext4_handle_error() can invoke panic if ERRORS_PANIC is specified. But if the journal has been aborted with zero errno, jbd2_journal_abort() didn't set this flag so we can no longer panic. Fix this by always record the proper errno in the journal superblock. Fixes: 4327ba5 ("ext4, jbd2: ensure entering into panic after recording an error in superblock") Signed-off-by: zhangyi (F) <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent d0a186e commit 51f57b0

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

fs/jbd2/checkpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)
164164
"journal space in %s\n", __func__,
165165
journal->j_devname);
166166
WARN_ON(1);
167-
jbd2_journal_abort(journal, 0);
167+
jbd2_journal_abort(journal, -EIO);
168168
}
169169
write_lock(&journal->j_state_lock);
170170
} else {

fs/jbd2/journal.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,12 +2156,10 @@ static void __journal_abort_soft (journal_t *journal, int errno)
21562156

21572157
__jbd2_journal_abort_hard(journal);
21582158

2159-
if (errno) {
2160-
jbd2_journal_update_sb_errno(journal);
2161-
write_lock(&journal->j_state_lock);
2162-
journal->j_flags |= JBD2_REC_ERR;
2163-
write_unlock(&journal->j_state_lock);
2164-
}
2159+
jbd2_journal_update_sb_errno(journal);
2160+
write_lock(&journal->j_state_lock);
2161+
journal->j_flags |= JBD2_REC_ERR;
2162+
write_unlock(&journal->j_state_lock);
21652163
}
21662164

21672165
/**
@@ -2203,11 +2201,6 @@ static void __journal_abort_soft (journal_t *journal, int errno)
22032201
* failure to disk. ext3_error, for example, now uses this
22042202
* functionality.
22052203
*
2206-
* Errors which originate from within the journaling layer will NOT
2207-
* supply an errno; a null errno implies that absolutely no further
2208-
* writes are done to the journal (unless there are any already in
2209-
* progress).
2210-
*
22112204
*/
22122205

22132206
void jbd2_journal_abort(journal_t *journal, int errno)

0 commit comments

Comments
 (0)