2020-09-24 01:12:37

by zhangxiaoxu (A)

[permalink] [raw]
Subject: [PATCH] ext4: Fix bdev write error check failed when mount fs with ro

If some errors has occurred on the device, and the orphan list not empty,
then mount the device with 'ro', the bdev write error check will failed:
ext4_check_bdev_write_error:193: comm mount: Error while async write back metadata

Since the sbi->s_bdev_wb_err wouldn't be initialized when mount file system
with 'ro', when clean up the orphan list and access the iloc buffer, bdev
write error check will failed.

So we should always initialize the sbi->s_bdev_wb_err even if mount the
file system with 'ro'.

Fixes: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
Signed-off-by: Zhang Xiaoxu <[email protected]>
---
fs/ext4/super.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ea425b49b345..086439889869 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4814,9 +4814,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
* used to detect the metadata async write error.
*/
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,
- &sbi->s_bdev_wb_err);
+ errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
+ &sbi->s_bdev_wb_err);
sb->s_bdev->bd_super = sb;
EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
ext4_orphan_cleanup(sb, es);
--
2.25.4


2020-09-24 14:02:21

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] ext4: Fix bdev write error check failed when mount fs with ro

On Wed 23-09-20 21:11:49, Zhang Xiaoxu wrote:
> If some errors has occurred on the device, and the orphan list not empty,
> then mount the device with 'ro', the bdev write error check will failed:
> ext4_check_bdev_write_error:193: comm mount: Error while async write back metadata
>
> Since the sbi->s_bdev_wb_err wouldn't be initialized when mount file system
> with 'ro', when clean up the orphan list and access the iloc buffer, bdev
> write error check will failed.
>
> So we should always initialize the sbi->s_bdev_wb_err even if mount the
> file system with 'ro'.
>
> Fixes: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
> Signed-off-by: Zhang Xiaoxu <[email protected]>

Thanks for the patch! Good catch! I just think you should now remove the
errseq_check_and_advance() call in ext4_remount() because it isn't needed
anymore.

Honza


> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index ea425b49b345..086439889869 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -4814,9 +4814,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
> * used to detect the metadata async write error.
> */
> 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,
> - &sbi->s_bdev_wb_err);
> + errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
> + &sbi->s_bdev_wb_err);
> sb->s_bdev->bd_super = sb;
> EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
> ext4_orphan_cleanup(sb, es);
> --
> 2.25.4
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2020-09-24 14:46:02

by zhangxiaoxu (A)

[permalink] [raw]
Subject: Re: [PATCH] ext4: Fix bdev write error check failed when mount fs with ro



?? 2020/9/24 16:06, Jan Kara ะด??:
> On Wed 23-09-20 21:11:49, Zhang Xiaoxu wrote:
>> If some errors has occurred on the device, and the orphan list not empty,
>> then mount the device with 'ro', the bdev write error check will failed:
>> ext4_check_bdev_write_error:193: comm mount: Error while async write back metadata
>>
>> Since the sbi->s_bdev_wb_err wouldn't be initialized when mount file system
>> with 'ro', when clean up the orphan list and access the iloc buffer, bdev
>> write error check will failed.
>>
>> So we should always initialize the sbi->s_bdev_wb_err even if mount the
>> file system with 'ro'.
>>
>> Fixes: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
>> Signed-off-by: Zhang Xiaoxu <[email protected]>
>
> Thanks for the patch! Good catch! I just think you should now remove the
> errseq_check_and_advance() call in ext4_remount() because it isn't needed
> anymore.

Thanks for your suggesstion.
I will send the v2 to remove the errseq_check_and_advance in ext4_remount.

Xiaoxu.
>
>
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index ea425b49b345..086439889869 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -4814,9 +4814,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>> * used to detect the metadata async write error.
>> */
>> 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,
>> - &sbi->s_bdev_wb_err);
>> + errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
>> + &sbi->s_bdev_wb_err);
>> sb->s_bdev->bd_super = sb;
>> EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
>> ext4_orphan_cleanup(sb, es);
>> --
>> 2.25.4
>>