linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ext4: Fix bdev write error check failed when mount fs with ro
@ 2020-09-28  2:05 Zhang Xiaoxu
  2020-10-03  5:09 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Xiaoxu @ 2020-09-28  2:05 UTC (permalink / raw)
  To: yi.zhang, tytso, jack, linux-ext4; +Cc: adilger.kernel

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: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/super.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ea425b49b345..0303e6e17190 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);
@@ -5707,14 +5706,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 				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
 			 * and store the current valid flag.  (It may have
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] ext4: Fix bdev write error check failed when mount fs with ro
  2020-09-28  2:05 [PATCH v3] ext4: Fix bdev write error check failed when mount fs with ro Zhang Xiaoxu
@ 2020-10-03  5:09 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2020-10-03  5:09 UTC (permalink / raw)
  To: Zhang Xiaoxu; +Cc: yi.zhang, jack, linux-ext4, adilger.kernel

On Sun, Sep 27, 2020 at 10:05:56PM -0400, Zhang Xiaoxu wrote:
> 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: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>

Applied, thanks.

				- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-03  5:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28  2:05 [PATCH v3] ext4: Fix bdev write error check failed when mount fs with ro Zhang Xiaoxu
2020-10-03  5:09 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).