Skip to content

Commit c96e2b8

Browse files
Eric Sandeentytso
authored andcommitted
ext4: do not commit super on read-only bdev
Under some circumstances we may encounter a filesystem error on a read-only block device, and if we try to save the error info to the superblock and commit it, we'll wind up with a noisy error and backtrace, i.e.: [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode # ------------[ cut here ]------------ generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2) WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0 ... To avoid this, commit the error info in the superblock only if the block device is writable. Reported-by: Ritesh Harjani <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Andreas Dilger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent d05466b commit c96e2b8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ext4/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ static void save_error_info(struct super_block *sb, const char *func,
372372
unsigned int line)
373373
{
374374
__save_error_info(sb, func, line);
375-
ext4_commit_super(sb, 1);
375+
if (!bdev_read_only(sb->s_bdev))
376+
ext4_commit_super(sb, 1);
376377
}
377378

378379
/*

0 commit comments

Comments
 (0)