Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2702487pxk; Sun, 27 Sep 2020 19:06:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYl2SDv06wPjcGYqlMKWDiOmf9C3q20mIUkM2NMn2xT1emRuXej4ILfbyHvtxA3UWG2kJt X-Received: by 2002:aa7:c256:: with SMTP id y22mr13052376edo.16.1601258807928; Sun, 27 Sep 2020 19:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601258807; cv=none; d=google.com; s=arc-20160816; b=NoZbOHSHI6DtHIgrqyBHZ2oM6d8szVIDFpCCnWZ1pe4BEdGLpRDLU+1ohSpp2aOlaL uKKDg4svSqxIzbti60jjQ9ED3sygGnhysdDfTFqyRDt0IhTklFystPAUaRanCpnpuMPt nC/90b/gC89pkI5WeOFp4xsYyIgRNMPfzoAolAWLBbq3/o10k3A7/Zr2NqBkz5kmhaj6 9cAvpumWShtl6SwIC3UrB6NGWA8kPf9PjbOaaMjcYgvha7o0HsVqM70Q5pLhesNs2YS+ 1z/6qRJml0mpfIESDw6AZmjEFBagO/4XBVLrRy2N8F3rz7IEvR4C5TbG3TvVMRv0PYT3 y9Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7tpvavpsDXPJchpsvS9BQ2o7ENGwSUVT2s+WG6UCKaA=; b=ToevHEWkdQ5xgqpSQB3jEWYHE/1oC5H/EpBIUaCTxfG7qlTpu6LRWMWDi8453f5Psu Xo9udq4aTyOVx30V9bCyfffRjvd+ToZEBiJNOeIJmhHcIZQ2+ebSvrmmhO3H2x0agrr5 Of7C8/xf9/evmgwAPSJMu7Hof1YvFQKH5QXBD+hiUMjIlcDZgFrINASXDReo10d0uHqh S7XG5vFlfJvlwaFXNvoFhJMwDS+QkDlGgzVe9jGRnZupkBs+Gk+lman2hNZmGFu+N9n1 ucgUTvJXvNMIPzw3CFIBxB/FKltmwz+JjbOMEw9gQRttA7Kp7Fb39GoScNu5qIRKrJ/Z U4Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n25si6695523edt.464.2020.09.27.19.06.09; Sun, 27 Sep 2020 19:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726444AbgI1CGF (ORCPT + 99 others); Sun, 27 Sep 2020 22:06:05 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14251 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726412AbgI1CGF (ORCPT ); Sun, 27 Sep 2020 22:06:05 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C4426564A44FD1E0ABB3; Mon, 28 Sep 2020 10:06:03 +0800 (CST) Received: from localhost.localdomain (10.175.101.6) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Mon, 28 Sep 2020 10:05:56 +0800 From: Zhang Xiaoxu To: , , , CC: Subject: [PATCH v3] ext4: Fix bdev write error check failed when mount fs with ro Date: Sun, 27 Sep 2020 22:05:56 -0400 Message-ID: <20200928020556.710971-1-zhangxiaoxu5@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Reviewed-by: Jan Kara --- 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