Skip to content

Commit b4e73e6

Browse files
Zhihao Chengtytso
authored andcommitted
jbd2: abort journal when detecting metadata writeback error of fs dev
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]>
1 parent 8a4fd33 commit b4e73e6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/jbd2/transaction.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,25 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh,
12311231
int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
12321232
{
12331233
struct journal_head *jh;
1234+
journal_t *journal;
12341235
int rc;
12351236

12361237
if (is_handle_aborted(handle))
12371238
return -EROFS;
12381239

1240+
journal = handle->h_transaction->t_journal;
1241+
if (jbd2_check_fs_dev_write_error(journal)) {
1242+
/*
1243+
* If the fs dev has writeback errors, it may have failed
1244+
* to async write out metadata buffers in the background.
1245+
* In this case, we could read old data from disk and write
1246+
* it out again, which may lead to on-disk filesystem
1247+
* inconsistency. Aborting journal can avoid it happen.
1248+
*/
1249+
jbd2_journal_abort(journal, -EIO);
1250+
return -EIO;
1251+
}
1252+
12391253
if (jbd2_write_access_granted(handle, bh, false))
12401254
return 0;
12411255

0 commit comments

Comments
 (0)