From: Harshad Shirwadkar <harshadshirwadkar@xxxxxxxxx> Introduce "e2fsck_fc_replay_state" structure which is needed for ext4 fast commit replay. Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@xxxxxxxxx> Reviewed-by: Theodore Ts'o <tytso@xxxxxxx> --- e2fsck/e2fsck.h | 16 ++++++++++++++++ e2fsck/journal.c | 15 +++++++++++++++ lib/ext2fs/ext2_fs.h | 1 + 3 files changed, 32 insertions(+) diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 3b9c1874..f75cc343 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -68,6 +68,7 @@ #endif #include "support/quotaio.h" +#include "ext2fs/fast_commit.h" /* * Exit codes used by fsck-type programs @@ -239,6 +240,18 @@ struct extent_list { errcode_t retval; ext2_ino_t ino; }; + +/* State structure for fast commit replay */ +struct e2fsck_fc_replay_state { + struct extent_list fc_extent_list; + int fc_replay_num_tags; + int fc_replay_expected_off; + int fc_current_pass; + int fc_cur_tag; + int fc_crc; + __u16 fc_super_state; +}; + struct e2fsck_struct { ext2_filsys fs; const char *program_name; @@ -431,6 +444,9 @@ struct e2fsck_struct { /* Undo file */ char *undo_file; + + /* Fast commit replay state */ + struct e2fsck_fc_replay_state fc_replay_state; }; /* Data structures to evaluate whether an extent tree needs rebuilding. */ diff --git a/e2fsck/journal.c b/e2fsck/journal.c index 75fefcde..2c8e3441 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -278,6 +278,17 @@ static int process_journal_block(ext2_filsys fs, return 0; } +/* + * Main recovery path entry point. This function returns JBD2_FC_REPLAY_CONTINUE + * to indicate that it is expecting more fast commit blocks. It returns + * JBD2_FC_REPLAY_STOP to indicate that replay is done. + */ +static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, + enum passtype pass, int off, tid_t expected_tid) +{ + return JBD2_FC_REPLAY_STOP; +} + static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) { struct process_block_struct pb; @@ -514,6 +525,10 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) journal->j_sb_buffer = bh; journal->j_superblock = (journal_superblock_t *)bh->b_data; + if (ext2fs_has_feature_fast_commit(ctx->fs->super)) + journal->j_fc_replay_callback = ext4_fc_replay; + else + journal->j_fc_replay_callback = NULL; #ifdef USE_INODE_IO if (j_inode) diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index bfc30c29..b1e4329c 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -543,6 +543,7 @@ struct ext2_inode *EXT2_INODE(struct ext2_inode_large *large_inode) #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ #define EXT2_ERROR_FS 0x0002 /* Errors detected */ #define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */ +#define EXT4_FC_REPLAY 0x0020 /* Ext4 fast commit replay ongoing */ /* * Misc. filesystem flags -- 2.30.0.280.ga3ce27912f-goog