From: Zhang Yi <yi.zhang@xxxxxxxxxx> 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 jbd2's 'JBD2_CYCLE_RECORD' 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 <yi.zhang@xxxxxxxxxx> --- 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