Skip to content

Commit 742b06b

Browse files
Jiufei Xuetytso
authored andcommitted
jbd2: check superblock mapped prior to committing
We hit a BUG at fs/buffer.c:3057 if we detached the nbd device before unmounting ext4 filesystem. The typical chain of events leading to the BUG: jbd2_write_superblock submit_bh submit_bh_wbc BUG_ON(!buffer_mapped(bh)); The block device is removed and all the pages are invalidated. JBD2 was trying to write journal superblock to the block device which is no longer present. Fix this by checking the journal superblock's buffer head prior to submitting. Reported-by: Eric Ren <[email protected]> Signed-off-by: Jiufei Xue <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Reviewed-by: Jan Kara <[email protected]> Cc: [email protected]
1 parent fe53cbc commit 742b06b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/jbd2/journal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,10 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
13501350
journal_superblock_t *sb = journal->j_superblock;
13511351
int ret;
13521352

1353+
/* Buffer got discarded which means block device got invalidated */
1354+
if (!buffer_mapped(bh))
1355+
return -EIO;
1356+
13531357
trace_jbd2_write_superblock(journal, write_flags);
13541358
if (!(journal->j_flags & JBD2_BARRIER))
13551359
write_flags &= ~(REQ_FUA | REQ_PREFLUSH);

0 commit comments

Comments
 (0)