Received: by 10.213.65.68 with SMTP id h4csp2121055imn; Sun, 8 Apr 2018 20:13:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx49H8UsikNrGZZXWiuCfgnRhbe0/89S1DBcSroSki024ZkeHinEKNFUPoUjTpJINbq2WKZl3 X-Received: by 2002:a17:902:a60d:: with SMTP id u13-v6mr36915432plq.305.1523243290059; Sun, 08 Apr 2018 20:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243290; cv=none; d=google.com; s=arc-20160816; b=jjoHNK10usZT0suZ9pWjPgCADle2B22qBJd4cwrySiKp5V9FDwqroOwmio0PlVGVp2 oybB8TUqjiod/JSqSz7yCeFDpMjqlXQB2ZJSuiWpOvXEB94Abw+H8hvj6f+kXZFgz2ut 0f8NmbNuihQ2fGYZii7Fn/LCHBfaad7IFPjAb13gsdVZLkNljHzfTAPcYxJABrCn/Xc9 cnyP5QnpjqfkhXpGlH+1O/hGx9pVbCOBIY4gY8o8Apd+8FhgZCj7Hj3isy07W+CGp0TP 6B6rXRl3s0Jn5LQwwhgQAKno9/I3ZqIcD29uAEIlr891ZOjhZvnTAi0M2sBYlUUhHfvA zkRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+QrfYRfBzAk5NbNqDgH8DOUDel6OmjU1b18Q5Kf6Gy4=; b=wOm1rVnQmaG3ZjswEZIGRODbGG5DVbCNwY/yJk+m6a48nrTslBZQ8O3V1KTasC92bL z3aCfuxldWnnyj5KOp7EOaQ9Nzvgfv8gIayuuaDb5Dpdnfe5LT4T/C/aH+dRZ2+yQeQ3 yW3iGbTBrJPMSxr8S1rh4yJ77hOI5FflRGP5BkmZP6mv64k3kUEOUvyO9+wgs7n6YpZ0 MeeZ24lu7qqwpzpKGk4hajPWXl87p3xSQOn0+DQ56OD12i19hqc5IsoU8+VWwTAwsDwD GY8ezavu4L+EuOdOzW9vYjksXwOaEWtp2AQI0YLWFkLA4qOty7+tPX6dZnTpzfzt8s0H Kqmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=TJiF8lJn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9si11987933pfl.268.2018.04.08.20.07.33; Sun, 08 Apr 2018 20:08:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=TJiF8lJn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757437AbeDIBtp (ORCPT + 99 others); Sun, 8 Apr 2018 21:49:45 -0400 Received: from mail-by2nam01on0130.outbound.protection.outlook.com ([104.47.34.130]:18358 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932373AbeDIAd4 (ORCPT ); Sun, 8 Apr 2018 20:33:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+QrfYRfBzAk5NbNqDgH8DOUDel6OmjU1b18Q5Kf6Gy4=; b=TJiF8lJnC8+EA1byr39GIXq102GLs+8gEBqnY1vqP2HUxxWHZz5NnfeYQfBEWSla06g++E3WbM/LudwMF9XNcGTGlaNVHxGDqMJD1BKRkffWHL9e6PAkPuY/H14uTemQ1JFihyJt+toCxHIqP+PTPHdhHzQvQ/PhuU9Tfm6BeJk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:33:51 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:33:51 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: piaojun , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 256/293] ocfs2: return error when we attempt to access a dirty bh in jbd2 Thread-Topic: [PATCH AUTOSEL for 4.9 256/293] ocfs2: return error when we attempt to access a dirty bh in jbd2 Thread-Index: AQHTz5ldqVEByGvTXUqZ/V62Xq5NkQ== Date: Mon, 9 Apr 2018 00:26:12 +0000 Message-ID: <20180409002239.163177-256-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0806;7:Q/mVP38Mg++tizypQw9k6oqNbiCp5x0v2N9brbY0TSQRlj78VANxbTP46PlLi7MGXevi02f4rwXyfPZI6hfQK1NmlURfq0zRoPUdrw8XoTfCSBn3daX25rZa1zUpI+/Se9e12HlBBG7l0ZxKXLAosxTi8DSfHFi8VmUtPwxCLvR4sOh/NaVNv/3w8W4rJo1oPq3RY96LjTKxjbFfXkryT8TykRbVXvY4hmlJgIRy3VTh3A2/5Aj5JNcP9dMKsIEr;20:mWEZ/4Kn9LpMb/UUYe4JydhAujlUKfCkviYWbtkCo6BH7xDmXnwR8Is5tx95gRf5iBCYqSQBV9W8S66IlKvZ4YwBCc3Gc4o+yzhZji3lcZaa+vjnzzvVSfp31hVWv00ZLJs2NoLAE53V4MbYxiZMjrTa05nZi29VhG4893MjeQI= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4b29cb16-1b40-4420-a2de-08d59db1915d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(50582790962513)(85827821059158)(42068640409301)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(43544003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(551934003)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(39060400002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(6306002)(86362001)(966005)(14454004)(72206003)(8936002)(106356001)(22906009)(14143004)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ztCOtQEbHZMJjBukmt+Vpdy0tJpxSOwdoTJ+5PNW1Kw+oAegB+P30acdzTenYmSNW92QABBFLfTf2yYRme+/GIfEEKVSXnDrtdhhtx62Wt5KpnbXt/IvmwyTDnPQ0TXXkZKFYWUwptEdEBrFD5GA9/6dzlK8EMTlBf0wLMYvFXskhPROaJZmBLTgOTtiSQ8vKWV/ertGEhFBb0m6pZntkok1ib+AP3WqC5g1lCCBZOWG2K2tmu5sZB1IBtTjVeztF8gxYv+efRyzUiZB16Bl5NDVmGRfP5cScrn6NKgarmFZBGsbO6D8Lcg1eo3grXVu/nSiblG02naVaH/K5xqgVxgYiK2CniSK5cPei1OOYCBUe8A9Xc+Qjt/PjY+n0lqfaICQ4nySMLAxg+pXeZaCfJr5/wnptRZRmU0h1/LReyg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b29cb16-1b40-4420-a2de-08d59db1915d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:12.9881 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: piaojun [ Upstream commit d984187e3a1ad7d12447a7ab2c43ce3717a2b5b3 ] We should not reuse the dirty bh in jbd2 directly due to the following situation: 1. When removing extent rec, we will dirty the bhs of extent rec and truncate log at the same time, and hand them over to jbd2. 2. The bhs are submitted to jbd2 area successfully. 3. The write-back thread of device help flush the bhs to disk but encounter write error due to abnormal storage link. 4. After a while the storage link become normal. Truncate log flush worker triggered by the next space reclaiming found the dirty bh of truncate log and clear its 'BH_Write_EIO' and then set it uptodate in __ocfs2_journal_access(): ocfs2_truncate_log_worker ocfs2_flush_truncate_log __ocfs2_flush_truncate_log ocfs2_replay_truncate_records ocfs2_journal_access_di __ocfs2_journal_access // here we clear io_error and set 'tl_b= h' uptodata. 5. Then jbd2 will flush the bh of truncate log to disk, but the bh of extent rec is still in error state, and unfortunately nobody will take care of it. 6. At last the space of extent rec was not reduced, but truncate log flush worker have given it back to globalalloc. That will cause duplicate cluster problem which could be identified by fsck.ocfs2. Sadly we can hardly revert this but set fs read-only in case of ruining atomicity and consistency of space reclaim. Link: http://lkml.kernel.org/r/5A6E8092.8090701@huawei.com Fixes: acf8fdbe6afb ("ocfs2: do not BUG if buffer not uptodate in __ocfs2_j= ournal_access") Signed-off-by: Jun Piao Reviewed-by: Yiwen Jiang Reviewed-by: Changwei Ge Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/journal.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index a244f14c6b87..fa947d36ae1d 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -666,23 +666,24 @@ static int __ocfs2_journal_access(handle_t *handle, /* we can safely remove this assertion after testing. */ if (!buffer_uptodate(bh)) { mlog(ML_ERROR, "giving me a buffer that's not uptodate!\n"); - mlog(ML_ERROR, "b_blocknr=3D%llu\n", - (unsigned long long)bh->b_blocknr); + mlog(ML_ERROR, "b_blocknr=3D%llu, b_state=3D0x%lx\n", + (unsigned long long)bh->b_blocknr, bh->b_state); =20 lock_buffer(bh); /* - * A previous attempt to write this buffer head failed. - * Nothing we can do but to retry the write and hope for - * the best. + * A previous transaction with a couple of buffer heads fail + * to checkpoint, so all the bhs are marked as BH_Write_EIO. + * For current transaction, the bh is just among those error + * bhs which previous transaction handle. We can't just clear + * its BH_Write_EIO and reuse directly, since other bhs are + * not written to disk yet and that will cause metadata + * inconsistency. So we should set fs read-only to avoid + * further damage. */ if (buffer_write_io_error(bh) && !buffer_uptodate(bh)) { - clear_buffer_write_io_error(bh); - set_buffer_uptodate(bh); - } - - if (!buffer_uptodate(bh)) { unlock_buffer(bh); - return -EIO; + return ocfs2_error(osb->sb, "A previous attempt to " + "write this buffer head failed\n"); } unlock_buffer(bh); } --=20 2.15.1