Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5037930rdb; Tue, 12 Dec 2023 17:51:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoe8m+gklOrrFCBwF4WKhhqdDgxmWVAFzapopCStQ30xnqmZmFZBlzoDRQCMm2oUTVyvpA X-Received: by 2002:a05:620a:1a22:b0:779:f985:76bf with SMTP id bk34-20020a05620a1a2200b00779f98576bfmr9397000qkb.37.1702432271991; Tue, 12 Dec 2023 17:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702432271; cv=none; d=google.com; s=arc-20160816; b=QFhbSeN2hexuaJb3TqgGDzI5fJx4b/ttikRnFXfSvw1HP4aVMaCWswy4AjkNMtqnTP NrOsIwZu9/a3i5fwHDYQTbLPAnEa0wpDYDf8bQ0qgvgFi/IJzLvmzUXFddJ2yl7UBZW9 2+ADM7qrx/VY5pqzo33+klBPDLSuLL48e2s1fD4RGi2sCGJpdxXwpQr4pe3DWWH14iGO nZkn1IL3uWMp3lf0/so4KqorQOa3q9HfFptGrCmsZuYJix/eCLO+JdGgURzMu1/+L767 kg6SWqFc/Ae9WRyaDcoxBGxWixp0mZkDIxqiqzfF9N37OrY0qCph1mevpoKeM3sLH0eX z0aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=sjBmNeQDmQ+vtrNLHzB0hB9V1BEPCHpwU4zY8pS5bt4=; fh=1ocxhdHf0Y/iI8w2wCrH9lkxpX+94NXA0fnSi498MuY=; b=TeQ8+FAQjCVU5djzLvbYByhiPPiP9rE0PZ3JxiWtzrdoVCZUup4uv+te6CJf8Cw8Ar xNUecH2X5/yL11jVjaTcHILxvj2wZ+Dz9SoMDtFPD1WIQWpM9JRmZaKXDrtj9/zI+p47 sSe/SkSv7L1kG9iZkyxVan59H7ptjUlSkSOGnoKCNSEfIn3BtaOcq8IlMJ+ctWixlZwx k8Acr2ERfX3SG4b6j0CKCkf+7qveEwrn+dVtPrrKvTi1tfhXe2VCAyweQbmr9RLE4v+a l5oxTYa/OkEKb4r2SDuuX2ZKvCt3D/Q/O9lc8LXn+hu7fivEtE+ERZ+BCUDemNsbmBDR bvoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y10-20020a05620a25ca00b0077422e5854fsi12415748qko.216.2023.12.12.17.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BBD591C20DE3 for ; Wed, 13 Dec 2023 01:51:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 134E210EA; Wed, 13 Dec 2023 01:51:06 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CB0AF for ; Tue, 12 Dec 2023 17:51:01 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4SqdK11h0Nz1L9lh; Wed, 13 Dec 2023 09:32:53 +0800 (CST) Received: from kwepemm000013.china.huawei.com (unknown [7.193.23.81]) by mail.maildlp.com (Postfix) with ESMTPS id 597E21800C9; Wed, 13 Dec 2023 09:33:58 +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.35; Wed, 13 Dec 2023 09:33:57 +0800 From: Zhihao Cheng To: , CC: , Subject: [PATCH v2 1/5] jbd2: Add errseq to detect client fs's bdev writeback error Date: Wed, 13 Dec 2023 09:32:20 +0800 Message-ID: <20231213013224.2100050-2-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231213013224.2100050-1-chengzhihao1@huawei.com> References: <20231213013224.2100050-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm000013.china.huawei.com (7.193.23.81) Add errseq in journal, so that JBD2 can detect whether metadata is successfully written to 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 Reviewed-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 206cb53ef2b0..559938a82379 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1534,6 +1534,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 beb30719ee16..cea1aa70ae36 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. */ @@ -1698,6 +1705,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