Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp830603rwl; Thu, 10 Aug 2023 02:11:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY+h9sBrXMbM9prwD5QsgoHjv6bOsWKD7mNSUyzE4BDPFCGEVciM1/tiY9rOKmxv47cjWQ X-Received: by 2002:a05:6a20:8f17:b0:133:faf4:ed2f with SMTP id b23-20020a056a208f1700b00133faf4ed2fmr1919502pzk.40.1691658689268; Thu, 10 Aug 2023 02:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691658689; cv=none; d=google.com; s=arc-20160816; b=wzuuxoOuDtoOd1HSfhlg+roNmrF9AQplG08TLJ8kOJHf02ktphHSzL2S/rWTiW1gZT J7ukB16joijkfs+YHJWs+CGzrw0BQbm3MhhpNivbuV2w64VPyHQTSMOLr8nyJVhhtT9d RaBGiWCM8H0FPG0j4fXuiImVWx6WeMVmNiExihSXKJJRSKt8Cjn5j2xLh6pOXX2NhYe+ DjOyRcT0qQfJYPlymPlTZ7j4pStgoo8D8NyvtZCiXsZzJjtXy+sRNnUlfPZizpAEBR6g F8j6pbJ5ND00/YMZO2qdFdhH1ClizjVO0HSz7a04iJ8e4cM2YLhSnoI+Zk5B76PDT1f8 F0Lw== 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=yo1gvguYbqbGsQZIQqahL9MYi5PM82UC27fHbD6banY=; fh=fTSaBofNXp03thGUSjn2fCTzw7oFshHI80Fe6i8kpiM=; b=ITX3/SzWKdlMgzOFlt3NPPsnBEj2i4dzmHtRTje+wVI5NrOVQwmeHQSDEDE7kgF9Ar bZ1g+5ZaIGLHaHRC7ve24r7SCEsHE0kjRJi2hXgvPTJIDOft5nO8ouaMk4T226LCtcnJ y+OK1nhrrrFoVdQxZYNM54qrH7SBSmbdtGfW4BdGJ1eB9tNXObC2xKDJwxwXf555ptrp LstyAPscDD0+edfCj6Q6cbKg9QoLnjz3Oi9Lf1NbgUxybGixwRjGM6MNI60NcIVSs5Fd u0f19pG1qVyb0u5lEBsf/3w4rBbTPz0NRmfMS+gy4Z3V3VHUSwCqq0zBilEpEHiziHCP ZgHQ== 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 fh3-20020a056a00390300b0068708a8a803si1200029pfb.106.2023.08.10.02.11.15; Thu, 10 Aug 2023 02:11:29 -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 S233590AbjHJIym (ORCPT + 99 others); Thu, 10 Aug 2023 04:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbjHJIyg (ORCPT ); Thu, 10 Aug 2023 04:54:36 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4FE213C for ; Thu, 10 Aug 2023 01:54:35 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RM12C6wf2z4f3tCn for ; Thu, 10 Aug 2023 16:54:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.170]) by APP4 (Coremail) with SMTP id gCh0CgD3hqm6pdRkGjJ7AQ--.1500S6; Thu, 10 Aug 2023 16:54:30 +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 v2 02/12] jbd2: move load_superblock() into journal_init_common() Date: Thu, 10 Aug 2023 16:54:07 +0800 Message-Id: <20230810085417.1501293-3-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20230810085417.1501293-1-yi.zhang@huaweicloud.com> References: <20230810085417.1501293-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3hqm6pdRkGjJ7AQ--.1500S6 X-Coremail-Antispam: 1UD129KBjvJXoWxJrWfAw1xZr4xAr4DZr1rCrg_yoW8AFyxpr y3C348ZrWvvrWUZ3W8XFW8GFWUX3yIkFW7Gr4Duw1ktayrJrnxtw1Dtrn5JFy8ZFWUGw18 JF1UCasrCw1qqa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUfwIDUUUUU= 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 Move the call to load_superblock() from jbd2_journal_load() and jbd2_journal_wipe() early into journal_init_common(), the journal superblock gets read and the in-memory journal_t structure gets initialised after calling jbd2_journal_init_{dev,inode}, it's safe to do following initialization according to it. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 48c44c7fccf4..b247d374e7a6 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1582,6 +1582,10 @@ static journal_t *journal_init_common(struct block_device *bdev, journal->j_sb_buffer = bh; journal->j_superblock = (journal_superblock_t *)bh->b_data; + err = load_superblock(journal); + if (err) + goto err_cleanup; + journal->j_shrink_transaction = NULL; journal->j_shrinker.scan_objects = jbd2_journal_shrink_scan; journal->j_shrinker.count_objects = jbd2_journal_shrink_count; @@ -2056,13 +2060,7 @@ EXPORT_SYMBOL(jbd2_journal_update_sb_errno); int jbd2_journal_load(journal_t *journal) { int err; - journal_superblock_t *sb; - - err = load_superblock(journal); - if (err) - return err; - - sb = journal->j_superblock; + journal_superblock_t *sb = journal->j_superblock; /* * If this is a V2 superblock, then we have to check the @@ -2521,10 +2519,6 @@ int jbd2_journal_wipe(journal_t *journal, int write) J_ASSERT (!(journal->j_flags & JBD2_LOADED)); - err = load_superblock(journal); - if (err) - return err; - if (!journal->j_tail) goto no_recovery; -- 2.34.3