From patchwork Wed Feb 1 11:46:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 51306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp219289wrn; Wed, 1 Feb 2023 03:28:41 -0800 (PST) X-Google-Smtp-Source: AK7set9vKNPIbH4eGUsPp46gMqjRHTTrJ1oLGZmSOrVeQDEhO+CKCGQsQWLC3yLHU2Pc3cLJyxp9 X-Received: by 2002:a05:6a00:1392:b0:593:91e4:99e2 with SMTP id t18-20020a056a00139200b0059391e499e2mr2425778pfg.34.1675250921053; Wed, 01 Feb 2023 03:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675250921; cv=none; d=google.com; s=arc-20160816; b=wesyyj3x58FkPcR6b0wP4Wj32nkqn2UkSUL5AxDWoKma5aXTtBA1zUKrpU/WQ98LGk tbPZzIpOJcjZBQUO7uC1Q/M+OTw3jwtqwRh+iSRItJ5h/n45zxUnUzyx+NRa9UVQwcnB 9VNjKPBpmf5doIxXwtmEqzJL7HRWc22uO40iebtsaNBuQC4MkpIudXz/BCH1KsFMYHWh ma9nHP7mrXx7OguuMV07qx3roiBJ4Y5N+hol8S+e1x4Z0BZMxgHPAQPSiQ7kYQooBf0x q1OiFY7C0NQwQJWj+xq98v1jOgox+I9iU/Wh/FHb35WvnVj+Ff6fqb6wCJV4yCgarEwC nw7Q== 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=pGw5R3ZgMO0gRGs+sYyGsHi2rKtgKPV7RPiyyoGds3o=; b=nsCW9AtMEr6/o/EMq/OMygLfbkylWeHYKn2vUXdoe0Wbl0ZiUyiV2vqtqix+luBq5k IV/En3LZ7elESOB/hppygSaf5Mfagrnzsuhtm4optIGUBCGCD5uqzE52N7k6/TqYk0mJ nhH2Stz4cu62rIZ8otNyI8qhJz/PlO9S7ZeMS4v8hBm9/iutldzQP5IKqano18B2Oilf Ck/nUEzzIAvXvEZNwAYiI40AMO27c7IicrA5q7HXWckxQxEuVf8Lsw0uvg+SNSmN9igd RIsjTZxOQjiU1Kq3vZihVc3uSyWlHzDFmReGyadeEiZ7vrrnLnDPjWVX0Y6Sqvlv5hFt 3pgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a623803000000b00592d5c262aasi15942001pfa.137.2023.02.01.03.28.29; Wed, 01 Feb 2023 03:28:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjBALXJ (ORCPT + 99 others); Wed, 1 Feb 2023 06:23:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjBALXA (ORCPT ); Wed, 1 Feb 2023 06:23:00 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19FAC3C1A; Wed, 1 Feb 2023 03:22:59 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4P6KK94q4lz4f3jYx; Wed, 1 Feb 2023 19:22:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R+NS9pj_j45Cg--.57546S5; Wed, 01 Feb 2023 19:22:55 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH 1/5] jbd2: introduce callback for recovery journal Date: Wed, 1 Feb 2023 19:46:47 +0800 Message-Id: <20230201114651.4090446-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230201114651.4090446-1-yebin@huaweicloud.com> References: <20230201114651.4090446-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R+NS9pj_j45Cg--.57546S5 X-Coremail-Antispam: 1UD129KBjvJXoWrtryrCryxJrW7Aw4UWry7Awb_yoW8JrW8pa s5Cwn3CFW8uFy7Cr1fJa18AFWIv3yv9r4UGF98u3s0y347trZ2qaykGw15try5Ar43K3yj qr1UCrW3Cw1YkrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUzoGQUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756627910009140691?= X-GMAIL-MSGID: =?utf-8?q?1756627910009140691?= From: Ye Bin EXT4 file system's super block may submited by journal, however it maybe submited directly when do error handle and also other scene. So super block isn't uptodate in journal. So there is need to do some extra handle when recover journal. Signed-off-by: Ye Bin --- include/linux/jbd2.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 5962072a4b19..ab0e1a435a50 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1308,6 +1308,17 @@ struct journal_s struct buffer_head *bh, enum passtype pass, int off, tid_t expected_commit_id); + /* + * EXT4 file system's super block may submited by journal, however it + * maybe submited directly when do error handle. So super block isn't + * uptodate in journal. So there is need to do some extra handle when + * recover journal. + */ + void *j_replay_private_data; + int (*j_replay_prepare_callback)(struct journal_s *journal); + int (*j_replay_callback)(struct journal_s *journal, + struct buffer_head *bh); + void (*j_replay_end_callback)(struct journal_s *journal); }; #define jbd2_might_wait_for_commit(j) \ From patchwork Wed Feb 1 11:46:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 51307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp219991wrn; Wed, 1 Feb 2023 03:30:30 -0800 (PST) X-Google-Smtp-Source: AK7set9QDLRKxUUIEM2UsLJlg1Pz4UhA8VydFyYlCGtgOYhTmL3WRYtXXTfg8tXniZW6dInb/vgE X-Received: by 2002:a05:6a20:671c:b0:bc:42f9:6b21 with SMTP id q28-20020a056a20671c00b000bc42f96b21mr2107868pzh.15.1675251030555; Wed, 01 Feb 2023 03:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675251030; cv=none; d=google.com; s=arc-20160816; b=IFWr9SO4sD/nSlBSW/50gy5wkkhsrOWwhychoZb2lC25dlxhGPkezRPvdjiAAbyd0M PuNu4Aa7gJbvBv0ybLTDc3VxQfFpGG4ayE9rNOGZGcP9kklSalu/lt+u5wDeI6Weconi sT/yL9G5+TtTb34lRMtLqjQv9bXcM6Q0LJUmGPamv2V+sUdNvDDEd2v09fCllWoAAf01 lx9BkcTt0oUCOQPxA/DLivgwXkO1bhvSIz1Rx936ylyRqSYYUwn1k3zZnwKSwdr5cVxQ p8VowZgHjHF4BBiLOZfpuh1hgQ5Xd2oFcK6RBoIksOsrY6/4VGjRasB69zeHZYIZMVQ+ qwWw== 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=2Anl5acYXMkIm2BXOGe+IaRBGCmTyOllSVJWWg3gcBc=; b=cIxxDS4zGxjb2bKPDkx7mfCbd7ht8XRbMNq1PACBTFhw2tn2bp+X5RwToM4VqDz9+r Kf+IRvoikrbjUoNo4fesyR+tbZWHyZWkMqVm4ppMNwva4GkRNdJ/kwhhCvPdOCZzp9fX mw8raU5UTN3kS1lh6FUCgahLiQqhzKhNDYGz6DrmQoA0/T+u51qYBU2ZGldKjwyU94JF rhEZO+fVvmSyyMXZEwN2PR+uALGN40Gam/DG4S4UZ0b6oRZR+9z721juujwLvvSw87/R oa92/hTiVU/v0W3McMwHQ8t4MKpsh3Ocq/tU03GikDDWeO1uLqD6n9eXMTnzrERzvUR6 INKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a623803000000b00592d5c262aasi15942001pfa.137.2023.02.01.03.30.17; Wed, 01 Feb 2023 03:30:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232406AbjBALXS (ORCPT + 99 others); Wed, 1 Feb 2023 06:23:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjBALXB (ORCPT ); Wed, 1 Feb 2023 06:23:01 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2CD44A1; Wed, 1 Feb 2023 03:22:59 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4P6KK96zdfz4f3jHb; Wed, 1 Feb 2023 19:22:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R+NS9pj_j45Cg--.57546S6; Wed, 01 Feb 2023 19:22:56 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH 2/5] ext4: introudce helper for jounral recover handle Date: Wed, 1 Feb 2023 19:46:48 +0800 Message-Id: <20230201114651.4090446-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230201114651.4090446-1-yebin@huaweicloud.com> References: <20230201114651.4090446-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R+NS9pj_j45Cg--.57546S6 X-Coremail-Antispam: 1UD129KBjvJXoWxAFy5KFyfGF13Jr43Zr13urg_yoW5tFy5pr WrCr1FyrW8u3Zruw43GrsrXF9Ivw40ka45Gry3CasIka47tryxAayktF1UCFWYqrWUWw1r X3Wjy3y8Gw15KrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2_MaUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756628024914909232?= X-GMAIL-MSGID: =?utf-8?q?1756628024914909232?= From: Ye Bin Now, ext4 file system only need to handle super block when do recover journal. Signed-off-by: Ye Bin --- fs/ext4/ext4_jbd2.c | 65 +++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/ext4_jbd2.h | 2 ++ fs/ext4/super.c | 1 + 3 files changed, 68 insertions(+) diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 77f318ec8abb..7c0f2bed0ec4 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c @@ -395,3 +395,68 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, } return err; } + +void ext4_replay_end_callback(struct journal_s *journal) +{ + kfree(journal->j_replay_private_data); + journal->j_replay_private_data = NULL; + journal->j_replay_callback = NULL; + journal->j_replay_end_callback = NULL; +} + +static int ext4_replay_callback(struct journal_s *journal, + struct buffer_head *bh) +{ + struct super_block *sb = journal->j_private; + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_super_block *es = sbi->s_es; + struct ext4_super_block *nes; + unsigned long offset; + + if (likely(sbi->s_sbh != bh)) + return 0; + + offset = (void*)es - (void*)sbi->s_sbh->b_data; + nes = (struct ext4_super_block*)(bh->b_data + offset); + /* + * If super block has error flag in journal record, there isn't need to + * cover error information, as in this case is errors=continue mode, + * error handle submit super block through journal. + */ + if (le16_to_cpu(nes->s_state) & EXT4_ERROR_FS) + return 0; + + memcpy(((char *)es) + EXT4_S_ERR_START, + journal->j_replay_private_data, EXT4_S_ERR_LEN); + if (sbi->s_mount_state & EXT4_ERROR_FS) + es->s_state |= cpu_to_le16(EXT4_ERROR_FS); + + return 0; +} + +static int ext4_replay_prepare_callback(struct journal_s *journal) +{ + struct super_block *sb = journal->j_private; + struct ext4_sb_info *sbi = EXT4_SB(sb); + char *private; + struct ext4_super_block *es = sbi->s_es; + + if (!(sbi->s_mount_state & EXT4_ERROR_FS)) + return 0; + + private = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); + if (!private) + return -ENOMEM; + memcpy(private, ((char *)es) + EXT4_S_ERR_START, EXT4_S_ERR_LEN); + + journal->j_replay_private_data = private; + journal->j_replay_callback = ext4_replay_callback; + journal->j_replay_end_callback = ext4_replay_end_callback; + + return 0; +} + +void ext4_init_replay(journal_t *journal) +{ + journal->j_replay_prepare_callback = ext4_replay_prepare_callback; +} diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index 0c77697d5e90..8dcc7ef5028c 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -513,4 +513,6 @@ static inline int ext4_should_dioread_nolock(struct inode *inode) return 1; } +void ext4_init_replay(journal_t *journal); + #endif /* _EXT4_JBD2_H */ diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dc3907dff13a..ea0fea04907c 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5677,6 +5677,7 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) journal->j_commit_interval = sbi->s_commit_interval; journal->j_min_batch_time = sbi->s_min_batch_time; journal->j_max_batch_time = sbi->s_max_batch_time; + ext4_init_replay(journal); ext4_fc_init(sb, journal); write_lock(&journal->j_state_lock); From patchwork Wed Feb 1 11:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 51309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp220272wrn; Wed, 1 Feb 2023 03:31:06 -0800 (PST) X-Google-Smtp-Source: AK7set96flRvBstn5ftHNYHAZ+sX4ryT2VcMseNPFXXXlTTyoWZmEVJIkNUWscBAc/lk+EcILcQg X-Received: by 2002:a17:906:da19:b0:87d:f32b:40fd with SMTP id fi25-20020a170906da1900b0087df32b40fdmr5322912ejb.39.1675251066027; Wed, 01 Feb 2023 03:31:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675251066; cv=none; d=google.com; s=arc-20160816; b=vDe8tMLraHc5rj/hVsws6ManGmvea6gJHq1rlFwvZYTDi6zwLLzZFYYuyZ5q5xUdEE LEEW5BbTshR+vy+6k8IIPXYIQgPQgmaOjPScxEscRO1oWvPMwWavX0uUQaPnkiuJZlq4 Chw3q78F9ne2LJNQ2RtzVbpXxhJUolAVW04tHFv7z4WPtAS1+GGKJwA8Rxz8HDIxOxxt krBZgnEMcCP9nIkJINI6SSKGR38yQ+TKecx8jLzmFUkUQ0Az3+fsrQG72a7v0BN5Y2Ta M6bssLbvEOn+D/50tBTKOYQ0Ou6pSoXYd4QTcFTzaUHGcDDfN6ANXKd61Ja2auP/xmyR MjVg== 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=zKmLM1RXmbEKnKWLvRAlvlY/jQxS9cDwELVNsHZrzjY=; b=qVkCmnyj+fGZAUtz8tOXWuLhBb/JpasxtGUtAacTYSVa3BNAa/tYjzpQHNI17gD9/n GS1OrR4Nj+VAedaITntSCjlLouAI+m+ncgjkgr6rWOu342J77D93bsFJJE7TuV/veajv Hdj5W04yJRpsAxPp6HzM0RWX5X0FpmIh+DoDXR4YbWWZpV41yrw4EMO50WdDSVq8HlpE 0hka6vz77V7mXnjqSfsRo/Iqd466IujT8xfQOrYgKVvPqh7BFTjw84Pwr6V7/r5oBPoF 7eo6dZ6xP1zBbpqtKHzYByMFierkS3vAzc88ZPV8du7zQde7k/ZQvy8sipzKFFioPNoR aSrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 27-20020a170906021b00b0087f3e78aad1si16452645ejd.341.2023.02.01.03.30.42; Wed, 01 Feb 2023 03:31:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232502AbjBALXU (ORCPT + 99 others); Wed, 1 Feb 2023 06:23:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbjBALXC (ORCPT ); Wed, 1 Feb 2023 06:23:02 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AFF449E; Wed, 1 Feb 2023 03:22:59 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4P6KKB1KlDz4f3mJX; Wed, 1 Feb 2023 19:22:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R+NS9pj_j45Cg--.57546S7; Wed, 01 Feb 2023 19:22:56 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH 3/5] ext4: fix error flag covered by journal recovery Date: Wed, 1 Feb 2023 19:46:49 +0800 Message-Id: <20230201114651.4090446-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230201114651.4090446-1-yebin@huaweicloud.com> References: <20230201114651.4090446-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R+NS9pj_j45Cg--.57546S7 X-Coremail-Antispam: 1UD129KBjvJXoWxur43Jw15Cw4kCw1fCr45Wrg_yoW5CFy5pr WrCrySyFWqvr17Awn3JF4DWFWYg340yFWUGrnF93Zayay5Jrn2v3y8t3WrtFy0qrWrKa4r JF1UJ3yUCw15KrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2PEfUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756628061923559535?= X-GMAIL-MSGID: =?utf-8?q?1756628061923559535?= From: Ye Bin Super block in journal maybe not uptodate, when file system has error, we need set error information when do recover super block. Signed-off-by: Ye Bin --- fs/ext4/super.c | 38 ++++++++++++++++---------------------- fs/jbd2/recovery.c | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ea0fea04907c..ab136d08d93d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5887,7 +5887,7 @@ static int ext4_load_journal(struct super_block *sb, ext4_msg(sb, KERN_ERR, "journal device read-only, try mounting with '-o ro'"); err = -EROFS; - goto err_out; + goto out; } /* @@ -5904,7 +5904,7 @@ static int ext4_load_journal(struct super_block *sb, "unavailable, cannot proceed " "(try mounting with noload)"); err = -EROFS; - goto err_out; + goto out; } ext4_msg(sb, KERN_INFO, "write access will " "be enabled during recovery"); @@ -5917,29 +5917,21 @@ static int ext4_load_journal(struct super_block *sb, if (!ext4_has_feature_journal_needs_recovery(sb)) err = jbd2_journal_wipe(journal, !really_read_only); if (!err) { - char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); - if (save) - memcpy(save, ((char *) es) + - EXT4_S_ERR_START, EXT4_S_ERR_LEN); - err = jbd2_journal_load(journal); - if (save) - memcpy(((char *) es) + EXT4_S_ERR_START, - save, EXT4_S_ERR_LEN); - kfree(save); + if (journal->j_replay_prepare_callback) + err = journal->j_replay_prepare_callback(journal); + if (!err) + err = jbd2_journal_load(journal); } if (err) { ext4_msg(sb, KERN_ERR, "error loading journal"); - goto err_out; + goto out; } EXT4_SB(sb)->s_journal = journal; err = ext4_clear_journal_err(sb, es); - if (err) { - EXT4_SB(sb)->s_journal = NULL; - jbd2_journal_destroy(journal); - return err; - } + if (err) + goto out; if (!really_read_only && journal_devnum && journal_devnum != le32_to_cpu(es->s_journal_dev)) { @@ -5948,11 +5940,13 @@ static int ext4_load_journal(struct super_block *sb, /* Make sure we flush the recovery flag to disk. */ ext4_commit_super(sb); } - - return 0; - -err_out: - jbd2_journal_destroy(journal); +out: + if (unlikely(journal->j_replay_end_callback)) + journal->j_replay_end_callback(journal); + if (err) { + EXT4_SB(sb)->s_journal = NULL; + jbd2_journal_destroy(journal); + } return err; } diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 8286a9ec122f..8175d0a8d5f7 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -687,6 +687,20 @@ static int do_one_pass(journal_t *journal, *((__be32 *)nbh->b_data) = cpu_to_be32(JBD2_MAGIC_NUMBER); } + if (unlikely(journal->j_replay_callback)) { + err = journal->j_replay_callback( + journal, nbh); + if (err) { + printk(KERN_ERR + "JBD2: replay " + "call back " + "failed.\n"); + unlock_buffer(nbh); + brelse(obh); + brelse(nbh); + goto failed; + } + } BUFFER_TRACE(nbh, "marking dirty"); set_buffer_uptodate(nbh); From patchwork Wed Feb 1 11:46:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 51308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp220025wrn; Wed, 1 Feb 2023 03:30:35 -0800 (PST) X-Google-Smtp-Source: AK7set9G7Ym1BYOVKZ05fSKqAFZ7LULptsCBfhNyjg9BbK3P7uKTrMsxND+vH0IXo5327jNmOBgk X-Received: by 2002:a05:6a20:669e:b0:bc:c86a:f60f with SMTP id o30-20020a056a20669e00b000bcc86af60fmr1882085pzh.54.1675251035501; Wed, 01 Feb 2023 03:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675251035; cv=none; d=google.com; s=arc-20160816; b=SJ+UdbxJFnTLVZzt1zhbXmG6Nz9y20Db2M1kef6d/YkazdXO949QG8qmwLVhh/v346 J44Dncqz2xiDxJjQNoQ4K3/Kt9i0DKMpsNYBeN+cjmSwxcAIxjtEbWrDgmsu5gVA4FzG 9f60x7GutUWk7xVDCZpHvOUDg6ow1NP7QvEjXGtozI0NqL/iftqjeNWMYwMMarCoB1cH zchH8cB0XeKxnHuovX8BB7ks1nxBfEZGgwjsnfbFh3hCZlM+knqTOF5ACIJRytUtwqx4 gT3b5JgoLxnp8QFJDeYuzw3I1rXYFcjrfHn2xjfVuEXh+vAR2hT5IBs/xEMpDckYDEvt M9xA== 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=Y/7bnLZ/1w68OdKODJQ2xpRUhFmHxJIYcYViAGhb7rg=; b=qy75fTvWJNwwT+8YvHtKf30UDaBeq4BSwC19J1Ma4FSNWLEIVVygPAVmIqlxyo9VI1 wgcARvLnob8fDlWuXpPOU/JgQMocGlvx9tYDaVoYRx4DqIkDjGoG3YpFxXXK3YAZ4aTX aWLNORIJlhvJwK34hDLfwRa2QDVd2Jp2vtABfslXBzxFyi5x+/k3CrLUhQts0q71fucE we2RsVPGPzhkgvNUxqquhC7NYQs2htijVcw0tHbiDEtAGE4MrDKs+uvHwaQQU9hL0MPD dn6IsgMktfvkkGAw+kVKC7UrqCN+fTkNzStS+8Q0Cem8JyymoHeNAf0oMCjZvI4s6J8d /wsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a63b252000000b004b64146f242si19638209pgo.430.2023.02.01.03.30.23; Wed, 01 Feb 2023 03:30:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbjBALXY (ORCPT + 99 others); Wed, 1 Feb 2023 06:23:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231986AbjBALXC (ORCPT ); Wed, 1 Feb 2023 06:23:02 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21FF96A63; Wed, 1 Feb 2023 03:23:00 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4P6KKB48Pcz4f3jYs; Wed, 1 Feb 2023 19:22:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R+NS9pj_j45Cg--.57546S8; Wed, 01 Feb 2023 19:22:56 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH 4/5] ext4: fix super block checksum error Date: Wed, 1 Feb 2023 19:46:50 +0800 Message-Id: <20230201114651.4090446-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230201114651.4090446-1-yebin@huaweicloud.com> References: <20230201114651.4090446-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R+NS9pj_j45Cg--.57546S8 X-Coremail-Antispam: 1UD129KBjvdXoW7Jr18Jw4xWrWfZw4xJw1rCrg_yoW3KFX_Ga yxXw1rWr4fJa1Sg3W8Kr1Yv3W0grs2vF1rXa93AF1rXF1DXFs2qw4kurZF9rn8Wr4vqr45 Ar48K348Gr97WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756628029464611876?= X-GMAIL-MSGID: =?utf-8?q?1756628029464611876?= From: Ye Bin As commit("ext4: fix error flag covered by journal recovery") update error record when do journal recovery.There is need to recalculate super block checksum after update error record or will lead to super block checksum mismatch to data. Signed-off-by: Ye Bin --- fs/ext4/ext4_jbd2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 7c0f2bed0ec4..21f4f00429a1 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c @@ -430,6 +430,7 @@ static int ext4_replay_callback(struct journal_s *journal, journal->j_replay_private_data, EXT4_S_ERR_LEN); if (sbi->s_mount_state & EXT4_ERROR_FS) es->s_state |= cpu_to_le16(EXT4_ERROR_FS); + ext4_superblock_csum_set(sb); return 0; } From patchwork Wed Feb 1 11:46:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 51305 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp219191wrn; Wed, 1 Feb 2023 03:28:24 -0800 (PST) X-Google-Smtp-Source: AK7set+psuJrV21SIa4lExZveJ7zER2Cq6lFQ3etSzwun0ooQGQAY4WC0v30ZE17I3xwf2rU6x1B X-Received: by 2002:a17:902:f791:b0:198:adc4:2296 with SMTP id q17-20020a170902f79100b00198adc42296mr1157489pln.17.1675250904073; Wed, 01 Feb 2023 03:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675250904; cv=none; d=google.com; s=arc-20160816; b=HO4yj2FkG6YFcVxK1CZHo2zoZ8kSKJE1rrYmnCA3M9/Swax7KXELor7xLnUJ+DrltJ +/TIRc+7gdukrPkkoEWejes7WJy6bcEk/lDB4AJZZiFxNpl1E0Rpt9lYsRQRn7/FHl3Q wYDKgjqul/ApDFwuIOpwkWF84h3UEQXoNBI1dSOTCvu+15+bsia6DN6J5h8W1YPxFUik NH8HNwH+ToM21G3xOGK9Pa1d1gQVIkKxU90Y/k68hJ8maDZ8x9dKwW9d354crnRe4raZ g72kWyiIBqHbwdRUinIGYZqvXjyE6fvQJTEr5iemqmXgBxGJepRePDfZRHEaer1iwww+ durA== 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=24A4JA8Op1esYjaW/MAfPOWKZRMA6mufzV9u8OLwXoo=; b=Ln3ow11JVujvV1o1H5L8s/7+cwRVDgut8YNE/kiOT+m4J5sSqvvrsmz+qCU3TL91ai z/n4Ou3o2kZHSut0ZwlwD+5DN4Xl7KEwrujXxcteZqyr4gkgsA2XXfIJ4XS7pC8Yogfa 3Fr/Wh0nh4Ujd6HteMK0z5MBczm1XZyp+dMRUEflhjOBl7s+ZjFI+xsOZphdTFoShv/U Jv8JxsN07/RatcaG1GJS3SzHCdFZh3tYmE+Jopl2Kx/q3ZKTTXLBwehB2JkstZzYm9VQ gH6mtvPE1WkLTCaNyv9i1UpX5/ybySvbVKxCgHaS/Ysw6BbVU4+lgCanVt9qxdoGstta djTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6386c2000000b0047730e1a823si19195178pgd.858.2023.02.01.03.28.11; Wed, 01 Feb 2023 03:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbjBALXN (ORCPT + 99 others); Wed, 1 Feb 2023 06:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjBALXB (ORCPT ); Wed, 1 Feb 2023 06:23:01 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9CF44EE8; Wed, 1 Feb 2023 03:22:59 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4P6KKB6w1vz4f3nTZ; Wed, 1 Feb 2023 19:22:54 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R+NS9pj_j45Cg--.57546S9; Wed, 01 Feb 2023 19:22:57 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH 5/5] ext4: make sure fs error flag setted before clear journal error Date: Wed, 1 Feb 2023 19:46:51 +0800 Message-Id: <20230201114651.4090446-6-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230201114651.4090446-1-yebin@huaweicloud.com> References: <20230201114651.4090446-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R+NS9pj_j45Cg--.57546S9 X-Coremail-Antispam: 1UD129KBjvdXoWrtryDXF13GrW7XryxXryrZwb_yoWkXwbEq3 yxZan5Wrs3Ar1xK3WrCan8WwnYvws2vrnYqasayF15uryDXa4kCa4kWryfurn8urWrKrZ8 JF18ZFn7KFWkZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756627891819202158?= X-GMAIL-MSGID: =?utf-8?q?1756627891819202158?= From: Ye Bin Now, jounral error number maybe cleared even though ext4_commit_super() failed. This may lead to error flag miss, then fsck will miss to check file system deeply. Signed-off-by: Ye Bin --- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ab136d08d93d..c36cc9708258 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6146,11 +6146,13 @@ static int ext4_clear_journal_err(struct super_block *sb, errstr = ext4_decode_error(sb, j_errno, nbuf); ext4_warning(sb, "Filesystem error recorded " "from previous mount: %s", errstr); - ext4_warning(sb, "Marking fs in need of filesystem check."); EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; es->s_state |= cpu_to_le16(EXT4_ERROR_FS); - ext4_commit_super(sb); + j_errno = ext4_commit_super(sb); + if (j_errno) + return j_errno; + ext4_warning(sb, "Marked fs in need of filesystem check."); jbd2_journal_clear_err(journal); jbd2_journal_update_sb_errno(journal);