Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp287811rdf; Thu, 2 Nov 2023 23:58:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOpGTYGc0pVvcPGFZjh0RQ8yEIeOuBpxuyCkhSMAxaefz+bbDsiH1adHxHy7k9r0qh89s9 X-Received: by 2002:a05:6a20:da8e:b0:153:78c1:c40f with SMTP id iy14-20020a056a20da8e00b0015378c1c40fmr23206827pzb.15.1698994691581; Thu, 02 Nov 2023 23:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698994691; cv=none; d=google.com; s=arc-20160816; b=HOkYhV/QNAPYYIu8ApIucTIAfQOrSXe2ruC4/nEMT9TVBWxA4PLyqO9cra50irR93d oB0P6xbnldI2fTK370gQM3otWEAVGXwcWHPy0gLGlC5TM4mjqRjRlyUS4vURF9FRRWNt 0YzfWIpksv4CrYlCQ80OjHwjPor1uWa6B/oX4RE9+dxzEvTBEYeSaZ8uHOI1F1Oali+C X+os5fP3bJhL4QtaIlqbH6N/KAhWN3yUComa7tBq6S7OI9jCNgF8LZ5HtHNIplm8Bpju QN3SdMPpMXs5iN797AphDmISi3Pv82wnF9k0GHs2q5e5vNBOJnOROJjbnkvQPEsZ7qnr EFAQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5CRvMj6oInNXn8WSPwS0n+XFzy0v0Qa7rzdrHBojgGA=; fh=FsznnDxpmef1vC1z7PHIgrdOV6pY0Temw/oyToZsikg=; b=Qw8EpRxyf5nEQywUzgEghfEoIOZi3t13v3noYT2hrUPcPQzqovUtJTXg9Oreoq2RcL nnk8R3DsW2putDtNZf38rRSjcmPAFOP8o37FOVubMWXQh6GUXB/wYtvMqlXwwRtmyKHY G/VMAWAhduqT/PwRbpdVsXUOZxp9Mfjsj/H83bYWkoo69D6wWrzNxRcBmDoPdqcRKCTi FdSwv6diP+IbMbhHsoeNH0noTZLl/3I5fDZDkdMO6o/cmEgATqY2+l0DCcSnb8fXSVa8 s0uM0g6E5M0xdrb4qpVmLe5ttRqGBuekp5I1RbdfWi9R/+iiXuxV1FR0yaR3EDIvDJ5H Fr0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t2-20020a17090ae50200b002790fa91d77si1187547pjy.145.2023.11.02.23.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 23:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7B6FD80AB1D6; Thu, 2 Nov 2023 23:58:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232819AbjKCG6K (ORCPT + 99 others); Fri, 3 Nov 2023 02:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbjKCG6I (ORCPT ); Fri, 3 Nov 2023 02:58:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1378EDC for ; Thu, 2 Nov 2023 23:58:06 -0700 (PDT) Received: from kwepemm000013.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMBM563cqzrTwL; Fri, 3 Nov 2023 14:54:57 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm000013.china.huawei.com (7.193.23.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 14:58:01 +0800 From: Zhihao Cheng To: , CC: , , Subject: [PATCH 4/5] jbd2: Abort journal when detecting metadata writeback error of fs dev Date: Fri, 3 Nov 2023 22:52:49 +0800 Message-ID: <20231103145250.2995746-5-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103145250.2995746-1-chengzhihao1@huawei.com> References: <20231103145250.2995746-1-chengzhihao1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.67] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000013.china.huawei.com (7.193.23.81) X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 23:58:10 -0700 (PDT) This is a replacement solution of commit bc71726c725767 ("ext4: abort the filesystem if failed to async write metadata buffer"), JBD2 can detects metadata writeback error of fs dev by 'j_fs_dev_wb_err'. Signed-off-by: Zhihao Cheng --- fs/jbd2/transaction.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 5f08b5fd105a..cb0b8d6fc0c6 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1231,11 +1231,25 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) { struct journal_head *jh; + journal_t *journal; int rc; if (is_handle_aborted(handle)) return -EROFS; + journal = handle->h_transaction->t_journal; + if (jbd2_check_fs_dev_write_error(journal)) { + /* + * If the fs dev has writeback errors, it may have failed + * to async write out metadata buffers in the background. + * In this case, we could read old data from disk and write + * it out again, which may lead to on-disk filesystem + * inconsistency. Aborting journal can avoid it happen. + */ + jbd2_journal_abort(journal, -EIO); + return -EIO; + } + if (jbd2_write_access_granted(handle, bh, false)) return 0; -- 2.39.2