Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp287798rdf; Thu, 2 Nov 2023 23:58:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0puukIik45gaZHShm9jzjHAlrXBedE2WdN6VBY3I9O7B9HT8v8xblHQ/6GfKUlzMi2nkp X-Received: by 2002:a17:90b:1e09:b0:280:2438:11e with SMTP id pg9-20020a17090b1e0900b002802438011emr15479767pjb.39.1698994688294; Thu, 02 Nov 2023 23:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698994688; cv=none; d=google.com; s=arc-20160816; b=tPY2Tv7vPdhRb0azFJpwBkKVILyRvzoRC9WSSMjlSWrF8wvihqg2IO6zYVgUz7DzLR PzfWlgcQNoEyX8B0P4Nv7sLuh6tYdJycVIyFDnH3p9O5KC+pk/sm5C06NfQupFycrpWX sOKe3JDWoQB6+vR7XOQGPNlfr3qKS4mLbB691oL3fvX4mfklRz5gTxSXuifh0LHTl61m C3e8suMkH+4fCaeoWgcno/w271iiGaTfOYUPYSylroblTZmyU55Mtv/LanLNUxPfErKS A3KZF2Q5Zuw6H/voO2obuWdMNmTpeh6+k/66Qnt8Ofljs3tQzjB70UYU2dIzvtJY6WjH iAgw== 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=KHQNCqh7IPPPjiiqQLJqEnjPvunncTy30QJs9Er1TLQ=; fh=FsznnDxpmef1vC1z7PHIgrdOV6pY0Temw/oyToZsikg=; b=DPCy226zq2S2JjZtg31+cjXBH8L1BBATGVaPHUD+16ebIgza5SKqflU3Gmzn1q1Nkn T2q4TkXiPRvdyv8bP6h8LUovDpBJV4T1MhbcoQbq3CWEL3cJUbfaDWlCVeZgNgowGUOF GPFRMsGkQUNqSAZJZUcIXlHQcE35riisZTJ7bopBuDNf+DT83UImKf6z25Q3NcWjDurM 7tlIo+79iiIE2jM9AYIjhSJI6U0YpxzLbIXCxpCnIyH7q5I18zCzcKrd/AVEWUEaZClz 4rl3y52G2/tIICPnX5x/E7N5jtDIjdy34G7iAt+dZlX+yRCNpz3wVbjdWK6cTEsM4ZXn m4ZQ== 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 ob16-20020a17090b391000b00276bdabe471si1198512pjb.163.2023.11.02.23.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 23:58:08 -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 4C82A82B1C4B; Thu, 2 Nov 2023 23:58:07 -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 S232633AbjKCG6H (ORCPT + 99 others); Fri, 3 Nov 2023 02:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232634AbjKCG6F (ORCPT ); Fri, 3 Nov 2023 02:58:05 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B12CC131 for ; Thu, 2 Nov 2023 23:58:02 -0700 (PDT) Received: from kwepemm000013.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMBM41zV8zrTrk; Fri, 3 Nov 2023 14:54:56 +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:00 +0800 From: Zhihao Cheng To: , CC: , , Subject: [PATCH 1/5] jbd2: Add errseq to detect client fs's bdev writeback error Date: Fri, 3 Nov 2023 22:52:46 +0800 Message-ID: <20231103145250.2995746-2-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:07 -0700 (PDT) Add errseq in journal, so that JBD2 can detect whether metadata is successfully fallen on fs bdev. This patch adds detection in recovery process to replace original solution(using local variable wb_err). Signed-off-by: Zhihao Cheng Suggested-by: Jan Kara --- fs/jbd2/journal.c | 1 + fs/jbd2/recovery.c | 7 +------ include/linux/jbd2.h | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 30dec2bd2ecc..a655d9a88f79 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1535,6 +1535,7 @@ static journal_t *journal_init_common(struct block_device *bdev, journal->j_fs_dev = fs_dev; journal->j_blk_offset = start; journal->j_total_len = len; + jbd2_init_fs_dev_write_error(journal); err = journal_load_superblock(journal); if (err) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 01f744cb97a4..1f7664984d6e 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -289,8 +289,6 @@ int jbd2_journal_recover(journal_t *journal) journal_superblock_t * sb; struct recovery_info info; - errseq_t wb_err; - struct address_space *mapping; memset(&info, 0, sizeof(info)); sb = journal->j_superblock; @@ -308,9 +306,6 @@ int jbd2_journal_recover(journal_t *journal) return 0; } - wb_err = 0; - mapping = journal->j_fs_dev->bd_inode->i_mapping; - errseq_check_and_advance(&mapping->wb_err, &wb_err); err = do_one_pass(journal, &info, PASS_SCAN); if (!err) err = do_one_pass(journal, &info, PASS_REVOKE); @@ -334,7 +329,7 @@ int jbd2_journal_recover(journal_t *journal) err2 = sync_blockdev(journal->j_fs_dev); if (!err) err = err2; - err2 = errseq_check_and_advance(&mapping->wb_err, &wb_err); + err2 = jbd2_check_fs_dev_write_error(journal); if (!err) err = err2; /* Make sure all replayed data is on permanent storage */ diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 52772c826c86..15798f88ade4 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -998,6 +998,13 @@ struct journal_s */ struct block_device *j_fs_dev; + /** + * @j_fs_dev_wb_err: + * + * Records the errseq of the client fs's backing block device. + */ + errseq_t j_fs_dev_wb_err; + /** * @j_total_len: Total maximum capacity of the journal region on disk. */ @@ -1695,6 +1702,25 @@ static inline void jbd2_journal_abort_handle(handle_t *handle) handle->h_aborted = 1; } +static inline void jbd2_init_fs_dev_write_error(journal_t *journal) +{ + struct address_space *mapping = journal->j_fs_dev->bd_inode->i_mapping; + + /* + * Save the original wb_err value of client fs's bdev mapping which + * could be used to detect the client fs's metadata async write error. + */ + errseq_check_and_advance(&mapping->wb_err, &journal->j_fs_dev_wb_err); +} + +static inline int jbd2_check_fs_dev_write_error(journal_t *journal) +{ + struct address_space *mapping = journal->j_fs_dev->bd_inode->i_mapping; + + return errseq_check(&mapping->wb_err, + READ_ONCE(journal->j_fs_dev_wb_err)); +} + #endif /* __KERNEL__ */ /* Comparison functions for transaction IDs: perform comparisons using -- 2.39.2