diff options
| author | Wengang Wang <wen.gang.wang@oracle.com> | 2025-10-31 14:05:01 -0700 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2025-11-26 17:05:39 -0500 |
| commit | 80d05f640a51f94b88640db7f1551f8e8fee44b9 (patch) | |
| tree | 9654e1f9cffa11782c281f9d814e2e3db363be09 /fs/jbd2/journal.c | |
| parent | 986835bf4d11032bba4ab8414d18fce038c61bb4 (diff) | |
| download | linux-next-80d05f640a51f94b88640db7f1551f8e8fee44b9.tar.gz linux-next-80d05f640a51f94b88640db7f1551f8e8fee44b9.zip | |
jbd2: store more accurate errno in superblock when possible
When jbd2_journal_abort() is called, the provided error code is stored
in the journal superblock. Some existing calls hard-code -EIO even when
the actual failure is not I/O related.
This patch updates those calls to pass more accurate error codes,
allowing the superblock to record the true cause of failure. This helps
improve diagnostics and debugging clarity when analyzing journal aborts.
Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Message-ID: <20251031210501.7337-1-wen.gang.wang@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/journal.c')
| -rw-r--r-- | fs/jbd2/journal.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index f43474002f50..2fe1786a8f1b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -937,8 +937,8 @@ int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr, printk(KERN_ALERT "%s: journal block not found " "at offset %lu on %s\n", __func__, blocknr, journal->j_devname); + jbd2_journal_abort(journal, ret ? ret : -EFSCORRUPTED); err = -EIO; - jbd2_journal_abort(journal, err); } else { *retp = block; } @@ -1859,8 +1859,9 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid, if (is_journal_aborted(journal)) return -EIO; - if (jbd2_check_fs_dev_write_error(journal)) { - jbd2_journal_abort(journal, -EIO); + ret = jbd2_check_fs_dev_write_error(journal); + if (ret) { + jbd2_journal_abort(journal, ret); return -EIO; } @@ -2157,9 +2158,11 @@ int jbd2_journal_destroy(journal_t *journal) * failed to write back to the original location, otherwise the * filesystem may become inconsistent. */ - if (!is_journal_aborted(journal) && - jbd2_check_fs_dev_write_error(journal)) - jbd2_journal_abort(journal, -EIO); + if (!is_journal_aborted(journal)) { + int ret = jbd2_check_fs_dev_write_error(journal); + if (ret) + jbd2_journal_abort(journal, ret); + } if (journal->j_sb_buffer) { if (!is_journal_aborted(journal)) { |
