Skip to content

Commit

Permalink
jbd2: abort journal when detecting metadata writeback error of fs dev
Browse files Browse the repository at this point in the history
This is a replacement solution of commit bc71726 ("ext4: abort
the filesystem if failed to async write metadata buffer"), JBD2 can
detect metadata writeback error of fs dev by 'j_fs_dev_wb_err'.

Signed-off-by: Zhihao Cheng <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
Zhihao Cheng authored and tytso committed Jan 5, 2024
1 parent 8a4fd33 commit b4e73e6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,11 +1231,25 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh,
int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
{
struct journal_head *jh;
journal_t *journal;
int rc;

if (is_handle_aborted(handle))
return -EROFS;

journal = handle->h_transaction->t_journal;
if (jbd2_check_fs_dev_write_error(journal)) {
/*
* If the fs dev has writeback errors, it may have failed
* to async write out metadata buffers in the background.
* In this case, we could read old data from disk and write
* it out again, which may lead to on-disk filesystem
* inconsistency. Aborting journal can avoid it happen.
*/
jbd2_journal_abort(journal, -EIO);
return -EIO;
}

if (jbd2_write_access_granted(handle, bh, false))
return 0;

Expand Down

0 comments on commit b4e73e6

Please sign in to comment.