aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>2021-01-21 21:44:59 -0800
committerTheodore Ts'o <tytso@mit.edu>2021-01-27 20:12:33 -0500
commitc8a097c2e13afe5d54b26c879b24eef084369774 (patch)
treee49d7d5956c9c9d80029fbc0d0906d5c14203a89
parent9dc54e46dbc9e85f3735b8288cf217ce3726bb56 (diff)
downloade2fsprogs-c8a097c2e13afe5d54b26c879b24eef084369774.tar.gz
e2fsck: add fast commit setup code
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>
-rw-r--r--e2fsck/e2fsck.h16
-rw-r--r--e2fsck/journal.c15
-rw-r--r--lib/ext2fs/ext2_fs.h1
3 files changed, 32 insertions, 0 deletions
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 3b9c18745..f75cc343a 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 75fefcde0..2c8e34413 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 bfc30c29a..b1e4329c1 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