Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27703932rwd; Tue, 4 Jul 2023 06:47:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPdz2YGPQMrmx90HDp3wjm37tULfv4nd9KT+LpSg6f6xpGwKWbrilaBwPpoF3uVxP8OSKA X-Received: by 2002:a17:90b:2d82:b0:263:41d2:75e with SMTP id sj2-20020a17090b2d8200b0026341d2075emr10513149pjb.21.1688478435011; Tue, 04 Jul 2023 06:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688478434; cv=none; d=google.com; s=arc-20160816; b=QspqLSlNFgYzPtRGr4hCKxB237bOy9aZRlNVOcnxRwTVB/wwe9B8655Ud7vtPQeHwL Z+PJrvr/UdRNp0xwRCYBYxV/vJh7283ee8jLPDXbKK4E9Zc9y2w4kShRYyu7wixi7btB OcXZD3lItLrxyy+TPmjQFunifLjuRHU7jRvkA3e4ExZzf6Ye+OJRchmZxSvEgT4w1ATa wzM2UIef2c4eveOPV0EaCFFEEy45FU4o0jhu5MFaQfhJvDyNzXvwvTs7AuBPog8HRBvw Cr1JRxOmdqlc4b+IbduuNRmQGxclw7LCDvhuph/JeamoBTWbg3JEP3XtKiky2FWbDC29 uvyQ== 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=so+1kADpd47FSX7zeqOQiHv+8XNqshxYJUOAP9n5iX8=; fh=Uq/HK0tePPZ4uFSrjmAoQ+8fm8HBRKIYZPcFTEYnhm4=; b=uk8x+9dyQ3nX4H8TVGp9HdBf1Jz8a7G8arjwwdQibDC52QPvaBq/uNl003orlnoQ9l XokTqBJu8NV3PYYDaUrvYyWkKJrKTxB5PybUXy+VGXzzxbq9jed/e5W3Ztb0uEeeY7gR /MUXayk0/snNgvCImAH5pQ65Fw05EpNaatHCMOHO5rf6zpLJPFCdpzpHIZdMzatzzpan sFhFaHMM+sNViC5oTGERQu/kYJ+Ppy63FUjoRhvratVKODjtJqzJn3fWNGKUoTd/NUxP o1qq5bWHURkQ0NhcH5KlTjE//L1GnlicRf4Y5TvAfmIXTfNJLX/glPrecSRzQdDGhBfb u5Vg== 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 bj20-20020a17090b089400b0025690f8610bsi9418705pjb.59.2023.07.04.06.47.01; Tue, 04 Jul 2023 06:47: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 S231562AbjGDNoP (ORCPT + 99 others); Tue, 4 Jul 2023 09:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231576AbjGDNoI (ORCPT ); Tue, 4 Jul 2023 09:44:08 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2106EE6D for ; Tue, 4 Jul 2023 06:44:06 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4QwPCM3WlQz4f3lXL for ; Tue, 4 Jul 2023 21:43:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3rLASIqRk9WjENA--.31120S8; Tue, 04 Jul 2023 21:44:01 +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, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH 04/12] jbd2: checking valid features early in journal_get_superblock() Date: Tue, 4 Jul 2023 21:42:25 +0800 Message-Id: <20230704134233.110812-5-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230704134233.110812-1-yi.zhang@huaweicloud.com> References: <20230704134233.110812-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3rLASIqRk9WjENA--.31120S8 X-Coremail-Antispam: 1UD129KBjvJXoW7tw18Zw48AF18GF17AFWrZrb_yoW8AF4kpw 1fAa45ZrykZry7u3Z3tFsrXFWFv340yFWUGr4ku3W8Ka13Gwnrt34qkFn5J34kCa4UW3y8 WF15GanrC34qq3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,SPF_HELO_NONE,SPF_NONE,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 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 --- 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.39.2