Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 306CCC6FD1C for ; Tue, 14 Mar 2023 14:12:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbjCNOMS (ORCPT ); Tue, 14 Mar 2023 10:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjCNOMC (ORCPT ); Tue, 14 Mar 2023 10:12:02 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA267A72BB for ; Tue, 14 Mar 2023 07:11:38 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Pbb6N3jVJz4f3kp5 for ; Tue, 14 Mar 2023 22:11:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.170]) by APP4 (Coremail) with SMTP id gCh0CgD3X7NygBBkPBlyFQ--.57348S5; Tue, 14 Mar 2023 22:11:10 +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 1/4] lib/ext2fs: record and show journal head block Date: Tue, 14 Mar 2023 22:10:55 +0800 Message-Id: <20230314141058.3267404-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230314141058.3267404-1-yi.zhang@huaweicloud.com> References: <20230314141058.3267404-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3X7NygBBkPBly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0xZFpf9x0JUkPEfUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zhang Yi Add a new parameter into on-disk journal head block to record the head block number of a clean journal image. This is used to support 'journal_cycle_record' mount option in kernel, which will be continue to record new journal transactions between each mount, instead of always recording from the first block. Note that the s_head is only uptodate while the image is clean, we still need to walk through to find the head block if the journal is not empty. Signed-off-by: Zhang Yi --- lib/e2p/ljs.c | 3 +++ lib/ext2fs/kernel-jbd.h | 6 ++++-- lib/ext2fs/mkjournal.c | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/e2p/ljs.c b/lib/e2p/ljs.c index 59728198..769f635a 100644 --- a/lib/e2p/ljs.c +++ b/lib/e2p/ljs.c @@ -108,6 +108,9 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf, "Journal start: %u\n", (unsigned int)ntohl(jsb->s_sequence), (unsigned int)ntohl(jsb->s_start)); + if (ntohl(jsb->s_start) == 0) + fprintf(f, "Journal head: %u\n", + (unsigned int)ntohl(jsb->s_head)); if (nr_users != 1) fprintf(f, "Journal number of users: %u\n", nr_users); if (jsb->s_feature_compat & e2p_be32(JBD2_FEATURE_COMPAT_CHECKSUM)) diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h index e5695006..1a7857c0 100644 --- a/lib/ext2fs/kernel-jbd.h +++ b/lib/ext2fs/kernel-jbd.h @@ -221,8 +221,10 @@ typedef struct journal_superblock_s __u8 s_padding2[3]; /* 0x0054 */ __be32 s_num_fc_blks; /* Number of fast commit blocks */ -/* 0x0058 */ - __be32 s_padding[41]; + __be32 s_head; /* blocknr of head of log, only uptodate + * while the filesystem is clean */ +/* 0x005C */ + __be32 s_padding[40]; __be32 s_checksum; /* crc32c(superblock) */ /* 0x0100 */ diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index 54772dd5..24245bb7 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -79,6 +79,7 @@ errcode_t ext2fs_create_journal_superblock2(ext2_filsys fs, jsb->s_nr_users = 0; jsb->s_first = htonl(ext2fs_journal_sb_start(fs->blocksize) + 1); } + jsb->s_head = jsb->s_first; *ret_jsb = (char *) jsb; return 0; -- 2.31.1