From patchwork Fri Feb 10 03:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp716817wrn; Thu, 9 Feb 2023 19:00:16 -0800 (PST) X-Google-Smtp-Source: AK7set+DuGBAatRXtcWEWn1s0RnEx8SET1pT3H/Cp2sYACoxHyDA1Wrrld0ru0mB8nUiT1p1gUNa X-Received: by 2002:a05:6a20:4403:b0:bf:e16:f3f with SMTP id ce3-20020a056a20440300b000bf0e160f3fmr18592399pzb.33.1675998015749; Thu, 09 Feb 2023 19:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675998015; cv=none; d=google.com; s=arc-20160816; b=LYSbj+p3xMCpuMzPLitJshroRUWSdNncxnYQzh9YW1LBMQqq/CiMc1xx0Z+y3uxSo3 hYMDpBHncHefgGpjNGs+GN774UYDsp1YwF1l6VuZOSOXeXyTHdNP7a+Tg57zkQC50YbZ Kgom9fCmshwlRBbWVmXy/7+8Qg8UHkH+xaOiKydOUqK0vL+ADVkVNoaMr5E7gvZrRydx 5LjBLG9wlUUdBDxnEfvI/F6hTMk/SHXNla/lqr3OmNVQeA1C7k+fqr4jB4cYxVBjVxXG k1mD6XxFF2S+6tOibtHpPj6oz3BbAyfOe+JlKNXTmm7QES4pUbqZ7qaDRmnsjgN3tT+8 rTaw== 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=Ek1O6nEMwizr71LHXcDt0iVWsydMwaSBtzs96C/PRKZOxSxqc5XDmFc5uizhJlEUWg mQ7YWxy///u4NJWexhs5bp3lg2eomEIS6NYZDMtaFWTUnANRXCbDvAeBgPBIkjMh5qeM mi1GI6RxlD9/w0WdGZZc1MRl+gBwWqwiNI86Xq1J2ICljHIQiGNzs/vCCsCMJ82ODOc6 5GYUdkm8KArr4RWeru5FERukTUC+EoaHyj74BBKBAm875jSGWgtL/1NitVvoZhSl0Xcc 0OsmUHoSBb9E9aflBfpIzsSHsC4cYjjJnuPXQxyIrrGE7WXBxq7xTTTTpY9kCvVYsLgb vE2Q== 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 n18-20020a639712000000b004e2968fe1fcsi3512317pge.211.2023.02.09.19.00.02; Thu, 09 Feb 2023 19:00:15 -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 S230470AbjBJC5J (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjBJC5F (ORCPT ); Thu, 9 Feb 2023 21:57:05 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCB6658CD; Thu, 9 Feb 2023 18:57:03 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCdgG5pfCz4f3jHb; Fri, 10 Feb 2023 10:56:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S5; Fri, 10 Feb 2023 10:57:00 +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 v2 1/6] jbd2: introduce callback for recovery journal Date: Fri, 10 Feb 2023 11:20:39 +0800 Message-Id: <20230210032044.146115-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S5 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,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?1757411295295639635?= X-GMAIL-MSGID: =?utf-8?q?1757411295295639635?= 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 Fri Feb 10 03:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp716915wrn; Thu, 9 Feb 2023 19:00:26 -0800 (PST) X-Google-Smtp-Source: AK7set9MK0RMFm/0ILGfSwkHbPMUkX3YqY+DO+zLNBTocM3qqA88MNr+caPrE3EC3U0R2hqOsATW X-Received: by 2002:a17:90a:1bcc:b0:22b:b375:ec3f with SMTP id r12-20020a17090a1bcc00b0022bb375ec3fmr14458807pjr.21.1675998026101; Thu, 09 Feb 2023 19:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675998026; cv=none; d=google.com; s=arc-20160816; b=m9G4D2FKwWsf3dXGYQiyr90WF6frTqqpWWubRuTTqcnUT3hy8F5Cwsfi9PTrZWogDe DO/2xiVY9N5BN633TNWOHFx0fiFO6/zBqBSA0hZWJXGqn61XTmLdRt22KYfB2cyz00qS 4B6OmUboXD8NZTpxmXnX+eFXW91WNMKuxFOEvN7TdHgpNbjJDtHcPSUlB8yTKUYKmlU3 W0p2OAqE3DOJuSRPoRagKVCnw+nwCrN7NwbDfLgkDI3mDdGk5mJgnj+SR3Bjq+Q6QFtH fcAFHOSrZhwDDgWEUs3hpZopmKmRUpzyGXxcxlbFSuqK8q9P4lAb1GPkVkp/+HOb6qb2 D0jw== 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=11t41xOxnm4KXCAFWkSisHZDYSDHHpiWH0KgODAuRQM=; b=S9O4jVkRZIllOoCa+MUW02s7evW9rwJuSliUbBVrdsPhTt8hYxmAoAuEL/SO8CcPJt GdFZMUrKQnt1mdm0pywPMy1F6uX0LQLCLMVx8va/9AEuga5gMNAzbAlwnuJWNwrKIBrG 1QwkwKDTiiaLVo9YHYGmwQJL56O4KqLIxUu31DBkr/bNuW3WqxZgGa8F0KbhD5qwF0Aw uJZuuCNZf5u/3oLVawJNgTwIF11YsDzYXpHVMNZjlPtl2sG+yUn99B4p8JDRel+Lfqln Q7QXvAOpqLPqEowoVoUWlHdf9FZEu+/SAwh4JzCYBg7TIW4O5gkZ74NSQoGfkynb+ego GDWw== 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 s21-20020a17090aad9500b002271de285easi3451432pjq.139.2023.02.09.19.00.10; Thu, 09 Feb 2023 19:00:26 -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 S230506AbjBJC5N (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjBJC5F (ORCPT ); Thu, 9 Feb 2023 21:57:05 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD84663CD; Thu, 9 Feb 2023 18:57:03 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCdgH1MP9z4f3nTG; Fri, 10 Feb 2023 10:56:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S6; Fri, 10 Feb 2023 10:57:01 +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 v2 2/6] ext4: introudce helper for jounral recover handle Date: Fri, 10 Feb 2023 11:20:40 +0800 Message-Id: <20230210032044.146115-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S6 X-Coremail-Antispam: 1UD129KBjvJXoWxAFy5KFyfGF13Jr43Kry7GFg_yoW5tFyDpr WrCr1FyrW8u3Zrua13GrsrJF9Ivw40ka45Gry3CasIka47tryxAayktF1UCFWYqrWUWw1r Xa4jy348Gw45KrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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,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?1757411306007721234?= X-GMAIL-MSGID: =?utf-8?q?1757411306007721234?= 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..af03035606e1 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; } + +static 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 Fri Feb 10 03:20:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp724717wrn; Thu, 9 Feb 2023 19:20:08 -0800 (PST) X-Google-Smtp-Source: AK7set/EX3v3jhQZRMrJhmr+5i28W2LAUzLOD+Sf6riNJt8yENHLyLURxDjNDIasryC+m1mJF337 X-Received: by 2002:a17:906:adb:b0:889:f989:d8ee with SMTP id z27-20020a1709060adb00b00889f989d8eemr15125340ejf.22.1675999207889; Thu, 09 Feb 2023 19:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675999207; cv=none; d=google.com; s=arc-20160816; b=xLsmeMLE2bmPFeZ5gCYLCL8cnSwLAKmzBzJa/45NTHlNPgCufaGckibIVi9V+imoAR nuW3Q8SxWPfNOp4VUuUcHIYZxQ8RtCqZP5ImUQKUwcE4cWFOIXXm32xLiPqQXyf5nWbI KyZRQ5D7ScGZ6VhbmsvmTI9Ui975n6Rc2ibR+zjC9UFmF49BkkQpIyXiyG207xbpX+MW MNupVF7auqoKf6MySvoGQBf9f9QqaMv0voWH+Ws0MPR+bkHEOC44B+uZpDRH8JY/l0PG evH0w+bXDEK3UyVTjdiQSTG78F/r87ZPxSQteRc4VXpOPINAuhdi9HwyZ5Dlo91dtW2H 1Qlw== 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=vwOxubZryF24mdPy/+vOitoZ6hvca82za1SQgfxTf0E=; b=HSDAC1FFa9M0fQqK+MuuQTqbhzq/HSKQzGdi88lXyOMpGGKpObYgl8MPwYSpnsrrGN 9EQwGGmWJokey20Jd+bZBzGEonjj2pFiQPonGp/yUEj3Isvmrw3DFsuJwfoaFkppt/TT 245QFuojr+Ex9zb2zk6j1M1pSQbyoTxTsIfZyIKJZdqC+841Rs17PdDE05cXmjg2ERhO R2zHSZ7ar3U2ym04NkB3LYf3UJ/q+IXm1MnFYQO/2SC17aBoc54dz6qo8pxQ0xqBK4Pm tP9U3jxlTRtWYexZMzs0g5FwUCe4N+yMFx60PJ8IE1CPfmHkgBNCdO+09D4CYEjIv9Fu H43A== 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 eu4-20020a170907298400b0087bdacdb25esi4114630ejc.299.2023.02.09.19.19.42; Thu, 09 Feb 2023 19:20:07 -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 S230510AbjBJC5Q (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjBJC5F (ORCPT ); Thu, 9 Feb 2023 21:57:05 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25381663D2; Thu, 9 Feb 2023 18:57:04 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCdgH3YWsz4f3nTL; Fri, 10 Feb 2023 10:56:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S7; Fri, 10 Feb 2023 10:57:01 +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 v2 3/6] jbd2: do extra handle when do journal recovery Date: Fri, 10 Feb 2023 11:20:41 +0800 Message-Id: <20230210032044.146115-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S7 X-Coremail-Antispam: 1UD129KBjvJXoW7urWfWr1fuw4xtr4rWF4UArb_yoW8Xw13pw 15Cr95KrWqvr17A3Z3JwsFgFWaqr4FyFWUGFsI93Zayay5trZFk3yxtwn0gFW8Jr15K3yr JF15J3y8KwnYkw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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?1757412545001027570?= X-GMAIL-MSGID: =?utf-8?q?1757412545001027570?= From: Ye Bin Ext4 file system's super block in journal maybe not uptodate, when file system has error, we need set error information when do recover uper block. Signed-off-by: Ye Bin --- fs/jbd2/recovery.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 8286a9ec122f..83b1a9689984 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -309,6 +309,15 @@ int jbd2_journal_recover(journal_t *journal) return 0; } + if (journal->j_replay_prepare_callback) { + err = journal->j_replay_prepare_callback(journal); + if (err) { + jbd2_debug(1, "JBD2: failed to prepare replay %d", + err); + return err; + } + } + err = do_one_pass(journal, &info, PASS_SCAN); if (!err) err = do_one_pass(journal, &info, PASS_REVOKE); @@ -335,6 +344,10 @@ int jbd2_journal_recover(journal_t *journal) if (!err) err = err2; } + + if (journal->j_replay_end_callback) + journal->j_replay_end_callback(journal); + return err; } @@ -687,6 +700,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 Fri Feb 10 03:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp725533wrn; Thu, 9 Feb 2023 19:22:43 -0800 (PST) X-Google-Smtp-Source: AK7set/3LGF14llEQZVSboawo6EQE+Czz5FHbiTIamjJONa2ipqGEG+xYf224GP1TewfMgtchdoD X-Received: by 2002:a17:907:204c:b0:7c4:fa17:7203 with SMTP id pg12-20020a170907204c00b007c4fa177203mr14134143ejb.63.1675999363216; Thu, 09 Feb 2023 19:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675999363; cv=none; d=google.com; s=arc-20160816; b=jU7z4rqfcGb3mguqkHJfv626iUkGtAJ3PsRPFK+74KzjcGP/jZY7uHBWe0J7rnIRM6 VeRchDCkyITTBPT96FXvjq4iXmL/Y0cdtrpgQMttJH/LXuTDVacsyMJ77deCmpwg55fF PijdugmKGokPV1AEU0qcxvjXcck++3iZ+QkIFYh+w7m+h6jQXSQbeQe2LBmNlsWA9FXc VlnTanAEEd9Nd+u0C6IS/mRdoJQJtyQSGHl6zfoie3JoUpO4Owel/jq0uLEEUpiJo6E7 b98rkD7BQYX7S0G89lE1jQFs1TgV3j6YSOw9ooVQSnokruiiLSVH0RRftrqWQL64+x5v yz8g== 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=u4TE7KHc3DjBS0eDMlEcI2xzsbmNC/TCqjKUp3aYTEQ=; b=aHWzL9UaeQVsfN/si64M3n7bhVyTaPnqIEbNommnM2BE+OKh2Ov8pqdrRCMmsVrqz1 GmSZ/0SyFbVHRt7hS+zmxC4HqBo6FtibKhDLEayx0DbBXKx+FwFqeRGsizfg/74oz80V sU2aLQ30dRkiD8MD7i1URRhbLSTS7A5E8u1/nP1bfq9OEFJRNhoHty03Ho3QPB/XUgq1 /EIQWSIW+zg6qtyE8OkGKjcOXGrpyOEV7fyh7b7DGXNnT83CGIiHAshrZIuL6sZS1KIF 6IC8t3yvd91SatQJ0xbPT539T5UZnXNC440GZPlJinjoLt8HQCvTFpcvtx8kclTFgd0t jYsw== 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 e30-20020a170906749e00b00878a893027csi4348922ejl.985.2023.02.09.19.22.19; Thu, 09 Feb 2023 19:22:43 -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 S231129AbjBJC5S (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjBJC5G (ORCPT ); Thu, 9 Feb 2023 21:57:06 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C6066EEF; Thu, 9 Feb 2023 18:57:04 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PCdgH4XyGz4f3l7T; Fri, 10 Feb 2023 10:56:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S8; Fri, 10 Feb 2023 10:57:01 +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 v2 4/6] ext4: remove backup for super block when recovery journal Date: Fri, 10 Feb 2023 11:20:42 +0800 Message-Id: <20230210032044.146115-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S8 X-Coremail-Antispam: 1UD129KBjvdXoWrZFW3XFWDGry3ZF43CF4DJwb_yoWDuFbEga yxJFWfXrnxJw4agFZYkws2qa1Fvrs2vr1rG3s3twsY9FyUXrsxGwnFyrW0vr1ruF4rKr98 Ar4UJFy8trykWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= 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?1757412708503865173?= X-GMAIL-MSGID: =?utf-8?q?1757412708503865173?= From: Ye Bin As previous commit "jbd2: do extra handle when do journal recovery" already do extra handle for super block. There's no need to do in ext4_load_journal(), so remove it. Signed-off-by: Ye Bin --- fs/ext4/super.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ea0fea04907c..d86ee5af2db9 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5916,17 +5916,8 @@ 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); + if (!err) err = jbd2_journal_load(journal); - if (save) - memcpy(((char *) es) + EXT4_S_ERR_START, - save, EXT4_S_ERR_LEN); - kfree(save); - } if (err) { ext4_msg(sb, KERN_ERR, "error loading journal"); From patchwork Fri Feb 10 03:20:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp721132wrn; Thu, 9 Feb 2023 19:09:52 -0800 (PST) X-Google-Smtp-Source: AK7set89Jn1zgQ/K6qx+f0i0SErJTH016oyxUXtfGC7xCcb1qwz9OhoP76+e0G/DDWckZzOm6ZK7 X-Received: by 2002:a17:906:2971:b0:7c0:e30a:d3e5 with SMTP id x17-20020a170906297100b007c0e30ad3e5mr13132368ejd.18.1675998591883; Thu, 09 Feb 2023 19:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675998591; cv=none; d=google.com; s=arc-20160816; b=gm8bLRCj/buWJ//QBoB6+KIPwSs1rOODoso+2SDDNXmJKmvp6Z0sdNJv9t2F+zwXw8 ujWOk7y2MRjWfIyW/9OTZIM2vx4fDCDhlew9YCzdnM1BEX3ns7HA0ThbBel8r5puw4lX FQ0in3stehTBa4PvH1CjDf7zyMGoh6jVfCN3vXtWUBrungiqcrIJC8D2Jevyo91nKGIv qbNgzwBerWmQJgA/QDP4LYN0YQJGQClksZiXSpLQFEq6lJLCSbTnaO0fP66upAyibUAZ ZIb7W5271/dk5fDM4F8SoqjPpLg56EvLq4cgRsHkLqKlQ2ysl014xEjdTc3aWlaLCiSu 6Qwg== 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=OfOPx3Zaqi5Uoa2sREu0p4j/s/QLrOS+x6DZjeo1srg=; b=niUVFLOO7OLreHXuWG4CTVAGWPFSQsVTKXtE2ArFfOtwe1/FmmYgFpvhLbN4FdrE3B 7/6dBGso1l2q1a6Fa/uzxXNuv7aUkGyW/peJf82w7cjr/HgX5kzjtvoItTh3f+9CKLKR 8DBrPgZgocd401Th5Ax7dRNyTiONlPShm+ssof3FcyX/t2tgd07mtYes7K2kk2N6mb8z oVpPx/m2+L4gKAROyXhAx3q+V/QGb+M7iYkLjWush0Hu0rCd7EndLOStwoMG4YU2Ek2Q y9+oD7etAdQTMzegF5xSoEAv2XCUI8q9DUoUxREVCi8E3EXQ81uSugI2udrG2pi/z4j9 jllA== 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 gg19-20020a170906899300b00883ec4c63e2si4157196ejc.645.2023.02.09.19.09.26; Thu, 09 Feb 2023 19:09:51 -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 S231139AbjBJC5U (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbjBJC5F (ORCPT ); Thu, 9 Feb 2023 21:57:05 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6C5663D3; Thu, 9 Feb 2023 18:57:04 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCdgJ0tC0z4f3nTN; Fri, 10 Feb 2023 10:57:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S9; Fri, 10 Feb 2023 10:57:02 +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 v2 5/6] ext4: fix super block checksum error Date: Fri, 10 Feb 2023 11:20:43 +0800 Message-Id: <20230210032044.146115-6-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S9 X-Coremail-Antispam: 1UD129KBjvdXoW7Jr18Jw4xWrWfZw4xJw1rCrg_yoW3KFX_Ga yxXw4rWrn3Aa1S93W8Gr4Yv3W0grs2vF1rJas3Cr1rXF1DXFs2qw4kCrZF9rn8ur4ktr45 Ar48Kry8Gr97XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= 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?1757411899395430888?= X-GMAIL-MSGID: =?utf-8?q?1757411899395430888?= 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 af03035606e1..ffcb0d58d407 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 Fri Feb 10 03:20:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 55202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp721374wrn; Thu, 9 Feb 2023 19:10:28 -0800 (PST) X-Google-Smtp-Source: AK7set+Umuy8rmOVfTw5pLoWeRETJbPeV5uoSSlPeFqs9+/RG4PeteIHChwXj5M62i99OV1hpVh2 X-Received: by 2002:a17:906:3812:b0:839:74cf:7c4f with SMTP id v18-20020a170906381200b0083974cf7c4fmr13427176ejc.8.1675998628610; Thu, 09 Feb 2023 19:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675998628; cv=none; d=google.com; s=arc-20160816; b=o/zetkxzcbpR5Ak7V4/ybCkbxQRRzqGoFydX7izJ7ovsOYnPvWNUlq9xtWJX1BCOsQ lrFrJgFcOYaZMPwKgN8cwFcmjyT6Ot9w924D1+rtjexaDGW8pvfMQj/EKahIoAXAvQFM 2SRuyRngy2HPvHqhk0ITAMHmyar+2OE2G2+d64G01XfG91hvUZHwqoMXbcV5Q1OfgBLX G33CIpeA27DAI2jJXhOadTKP/pPFDdlNaxnQgXLdX+z61yM85rDZbAxCQvrUAnjfYCKx Qk5CPQXBOfrTgm5Hts3/cNQzMgtvNsUTX30T/n3g1Lef6WZJgDDHaJEh8A5bC9T7yoO7 xYMg== 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=qYt4o5icjkSSfK2YqcJ/2bmkjV5m71mGT/zCDkgmpoA=; b=Oyl1b5c/3zTnTjKQl5c0TkilqyAwY0ZCYq2CaUyZ3SK66nn0Jlw2yy2rOckdbE9oFy jKRPvYxVTAeOsNqXBO1zlKYgtbU3pxKj8txRLNAENZl6PV5a6bW+OX249jkmQvPWCE5c QRTxweDweqAyC7Okl7V2QUDSIxyFsIX8JSz/i+aTX2g+mug2dLjS0GhEvOIK/5SxkqWl HCF9kT1JCwcf7hoUNq8rymTlbnQvBt/jX3bNlDUmHVdbbio3HqzBRNf2gb7COBgurQLr q+C5Tfo575nOFpcLYNgk3F9VlSJDZ2S+UQbz2JvOEp1/q7JbtVdGdulsdwzNyKCGz0AG lySw== 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 um32-20020a170907cb2000b008aac51f31desi4645488ejc.269.2023.02.09.19.10.04; Thu, 09 Feb 2023 19:10:28 -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 S231161AbjBJC5W (ORCPT + 99 others); Thu, 9 Feb 2023 21:57:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbjBJC5G (ORCPT ); Thu, 9 Feb 2023 21:57:06 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC28663CD; Thu, 9 Feb 2023 18:57:06 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCdgJ2fhPz4f3jM0; Fri, 10 Feb 2023 10:57:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCHgR96suVjIkgqDA--.35208S10; Fri, 10 Feb 2023 10:57:02 +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 v2 6/6] ext4: make sure fs error flag setted before clear journal error Date: Fri, 10 Feb 2023 11:20:44 +0800 Message-Id: <20230210032044.146115-7-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230210032044.146115-1-yebin@huaweicloud.com> References: <20230210032044.146115-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCHgR96suVjIkgqDA--.35208S10 X-Coremail-Antispam: 1UD129KBjvdXoWrtryDXF13GrW7XryxXryrZwb_yoWkXwbEq3 yxAan5Wrs3Ar1xKa18Can8Ww1vvws2vFnYqasayF15uryDXa4kCa4kWryfurn8uFWrKrZ8 JF18ZF1fGrWkZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= 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?1757411938195493266?= X-GMAIL-MSGID: =?utf-8?q?1757411938195493266?= 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 d86ee5af2db9..b458af1cbf5c 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6143,11 +6143,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);