Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 4327ba52afd03 ("ext4, jbd2: ensure entering into panic after recording an error in superblock")
Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191204124614.45424-3-yi.zhang@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

zhangyi (F) and committed by
Theodore Ts'o
51f57b01 d0a186e0

+5 -12
+1 -1
fs/jbd2/checkpoint.c
··· 164 164 "journal space in %s\n", __func__, 165 165 journal->j_devname); 166 166 WARN_ON(1); 167 - jbd2_journal_abort(journal, 0); 167 + jbd2_journal_abort(journal, -EIO); 168 168 } 169 169 write_lock(&journal->j_state_lock); 170 170 } else {
+4 -11
fs/jbd2/journal.c
··· 2156 2156 2157 2157 __jbd2_journal_abort_hard(journal); 2158 2158 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); 2165 2163 } 2166 2164 2167 2165 /** ··· 2200 2202 * transaction without having to complete the transaction to record the 2201 2203 * failure to disk. ext3_error, for example, now uses this 2202 2204 * functionality. 2203 - * 2204 - * Errors which originate from within the journaling layer will NOT 2205 - * supply an errno; a null errno implies that absolutely no further 2206 - * writes are done to the journal (unless there are any already in 2207 - * progress). 2208 2205 * 2209 2206 */ 2210 2207