Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp815839rdg; Thu, 10 Aug 2023 23:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRTZ2o2mocXmDhGzlYQB60AloOlyDvaKRbw1As+NLn6E3G0e9Z4huMYbfncKwLZMHIv4D/ X-Received: by 2002:a17:90a:1f42:b0:262:de1a:6028 with SMTP id y2-20020a17090a1f4200b00262de1a6028mr519356pjy.13.1691736974212; Thu, 10 Aug 2023 23:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691736974; cv=none; d=google.com; s=arc-20160816; b=A1NH5x7iOnqB7iIg7S5jWElJ5rbMcxEuAzXWgirTmxPRTFfB9XYVzdcxAPS4miL5Cc w23gVap/eEErcR2Z8VC8o3BC+OHeMBB6P//CaUh4C40uBg0C8eSEEvk0HRWNRDKYnTWj VeN3h0GxPvTY0lukTKo1zLZQOyst6ufODseCyJPydBwSkvww0XNeWMW5EejOK6V25f2Q jh3hC03FaqJl2MRjj5Dm3WjzuETXSQx7RzM2tRzB+AAVCgZRKK7he8UeV6TvIXqce5tF COcZHq28LE9NtxqvjuInleCdGPepO7CdD1lFaG1Btemr5xjYxmQQc+wGB1h1ChrnblCA JrjA== 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=OdqSyVNojlUzVPTohh5sAkdE0LlzcakLLSzBN1Wgl3s=; fh=fTSaBofNXp03thGUSjn2fCTzw7oFshHI80Fe6i8kpiM=; b=kxLjN5w1pSLizKqavnyAANd7HUgjpPMXWlWSSSwxf8ezrisIrDNO1BAS696zJ12/ro 3HWwIHtFy6jMX4p52KexwMEKIlHGEWun3JExy2CPmzuY/j93nW5AtBkOV2hsY5LtWXRm 4slA/fVlhNPvii/OumL+5xbQMF0RANFK2oqvevYJIj7uxw3vap8FL5WzshJZlF/Mw/d1 5D34vhVWlRq0vAhED5QyBURqroATAJgvMU34WpewCNNOiSbB8AZACVimwLI/+vTAVZla o8CNjkvNzwzV2dqcxJKgSu51GNT1Ow+lkvdxwJYwwOzpdVNCI1gqZJoVPpYG9xxPoadN aHBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a17090ab10600b00269154cf655si4874766pjq.126.2023.08.10.23.56.00; Thu, 10 Aug 2023 23:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbjHKGgb (ORCPT + 99 others); Fri, 11 Aug 2023 02:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbjHKGg3 (ORCPT ); Fri, 11 Aug 2023 02:36:29 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B862D41 for ; Thu, 10 Aug 2023 23:36:28 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RMYwS6FwGz4f3vfD for ; Fri, 11 Aug 2023 14:36:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.170]) by APP4 (Coremail) with SMTP id gCh0CgA3x6na1tVkKEbDAQ--.35746S8; Fri, 11 Aug 2023 14:36:25 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, yukuai3@huawei.com Subject: [PATCH v3 04/12] jbd2: checking valid features early in journal_get_superblock() Date: Fri, 11 Aug 2023 14:36:02 +0800 Message-Id: <20230811063610.2980059-5-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230811063610.2980059-1-yi.zhang@huaweicloud.com> References: <20230811063610.2980059-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgA3x6na1tVkKEbDAQ--.35746S8 X-Coremail-Antispam: 1UD129KBjvJXoW7tw18Zw48AF18GF17CF1UGFg_yoW8Aw45pw 1fAa4rZrykZry7u3Z3tFsrXFWrZw10yayUGrWku3W8Ka13Gwnrtw1jkFn5J34kAayUW3y8 WF15GanrC34qv3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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-ext4@vger.kernel.org From: Zhang Yi journal_get_superblock() is used to check validity of the jounal supberblock, so move the features checks from jbd2_journal_load() to journal_get_superblock(). Signed-off-by: Zhang Yi Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index c7cdb434966f..d84f26b08315 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1398,6 +1398,21 @@ static int journal_get_superblock(journal_t *journal) goto out; } + /* + * If this is a V2 superblock, then we have to check the + * features flags on it. + */ + if (!jbd2_format_support_feature(journal)) + return 0; + + if ((sb->s_feature_ro_compat & + ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) || + (sb->s_feature_incompat & + ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) { + printk(KERN_WARNING "JBD2: Unrecognised features on journal\n"); + goto out; + } + if (jbd2_has_feature_csum2(journal) && jbd2_has_feature_csum3(journal)) { /* Can't have checksum v2 and v3 at the same time! */ @@ -2059,21 +2074,6 @@ int jbd2_journal_load(journal_t *journal) int err; journal_superblock_t *sb = journal->j_superblock; - /* - * If this is a V2 superblock, then we have to check the - * features flags on it. - */ - if (jbd2_format_support_feature(journal)) { - if ((sb->s_feature_ro_compat & - ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) || - (sb->s_feature_incompat & - ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) { - printk(KERN_WARNING - "JBD2: Unrecognised features on journal\n"); - return -EINVAL; - } - } - /* * Create a slab for this blocksize */ -- 2.34.3