Commit 9704a322 authored by Zhang Xiaoxu's avatar Zhang Xiaoxu Committed by Theodore Ts'o

ext4: fix bdev write error check failed when mount fs with ro

Consider a situation when a filesystem was uncleanly shutdown and the
orphan list is not empty and a read-only mount is attempted. The orphan
list cleanup during mount will fail with:

ext4_check_bdev_write_error:193: comm mount: Error while async write back metadata

This happens because sbi->s_bdev_wb_err is not initialized when mounting
the filesystem in read only mode and so ext4_check_bdev_write_error()
falsely triggers.

Initialize sbi->s_bdev_wb_err unconditionally to avoid this problem.

Fixes: bc71726c ("ext4: abort the filesystem if failed to async write metadata buffer")
Cc: stable@kernel.org
Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20200928020556.710971-1-zhangxiaoxu5@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent dd0db94f
...@@ -4825,7 +4825,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4825,7 +4825,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
* used to detect the metadata async write error. * used to detect the metadata async write error.
*/ */
spin_lock_init(&sbi->s_bdev_wb_lock); spin_lock_init(&sbi->s_bdev_wb_lock);
if (!sb_rdonly(sb))
errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
&sbi->s_bdev_wb_err); &sbi->s_bdev_wb_err);
sb->s_bdev->bd_super = sb; sb->s_bdev->bd_super = sb;
...@@ -5719,14 +5718,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -5719,14 +5718,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
goto restore_opts; goto restore_opts;
} }
/*
* Update the original bdev mapping's wb_err value
* which could be used to detect the metadata async
* write error.
*/
errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
&sbi->s_bdev_wb_err);
/* /*
* Mounting a RDONLY partition read-write, so reread * Mounting a RDONLY partition read-write, so reread
* and store the current valid flag. (It may have * and store the current valid flag. (It may have
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment