Whamcloud - gitweb
e2fsck: add fast commit setup code
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Fri, 22 Jan 2021 05:44:59 +0000 (21:44 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 28 Jan 2021 01:12:33 +0000 (20:12 -0500)
Introduce "e2fsck_fc_replay_state" structure which is needed for ext4
fast commit replay.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/e2fsck.h
e2fsck/journal.c
lib/ext2fs/ext2_fs.h

index 3b9c187..f75cc34 100644 (file)
@@ -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. */
index 75fefcd..2c8e344 100644 (file)
@@ -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)
index bfc30c2..b1e4329 100644 (file)
@@ -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