linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Subject: [PATCH v6 20/20] ext4: add debug mount option to test fast commit replay
Date: Wed,  8 Apr 2020 14:55:30 -0700	[thread overview]
Message-ID: <20200408215530.25649-20-harshads@google.com> (raw)
In-Reply-To: <20200408215530.25649-1-harshads@google.com>

From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Add a debug mount option to simulate errors while replaying. If
fc_debug_max_replay is set, ext4 will replay only as many fast
commit blocks as passed as an argument.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/ext4.h      |  3 +++
 fs/ext4/ext4_jbd2.c |  6 ++++++
 fs/ext4/super.c     | 12 +++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index df88e408d0bf..72e8b7078e77 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1660,6 +1660,9 @@ struct ext4_sb_info {
 	struct list_head s_fc_dentry_q;
 	struct ext4_fc_replay_state s_fc_replay_state;
 	spinlock_t s_fc_lock;
+#ifdef EXT4_FC_DEBUG
+	int s_fc_debug_max_replay;
+#endif
 	struct ext4_fc_stats s_fc_stats;
 };
 
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 5effa1389705..f1865a97f6f8 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -1557,6 +1557,12 @@ static int ext4_journal_fc_replay_cb(journal_t *journal, struct buffer_head *bh,
 		return sbi->s_fc_replay_state.fc_replay_error;
 	}
 
+#ifdef EXT4_FC_DEBUG
+	if (sbi->s_fc_debug_max_replay && off >= sbi->s_fc_debug_max_replay) {
+		pr_warn("Dropping fc block %d because max_replay set\n", off);
+		return -EINVAL;
+	}
+#endif
 	sbi->s_mount_state |= EXT4_FC_REPLAY;
 	fc_hdr = (struct ext4_fc_commit_hdr *)
 		  ((__u8 *)bh->b_data + sizeof(journal_header_t));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 16548b0cbe71..995c61d19327 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1539,7 +1539,7 @@ enum {
 	Opt_dioread_nolock, Opt_dioread_lock,
 	Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
 	Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache,
-	Opt_no_fc, Opt_fc_soft_consistency
+	Opt_no_fc, Opt_fc_soft_consistency, Opt_fc_debug_max_replay
 };
 
 static const match_table_t tokens = {
@@ -1625,6 +1625,9 @@ static const match_table_t tokens = {
 	{Opt_noinit_itable, "noinit_itable"},
 	{Opt_no_fc, "no_fc"},
 	{Opt_fc_soft_consistency, "fc_soft_consistency"},
+#ifdef EXT4_FC_DEBUG
+	{Opt_fc_debug_max_replay, "fc_debug_max_replay=%u"},
+#endif
 	{Opt_max_dir_size_kb, "max_dir_size_kb=%u"},
 	{Opt_test_dummy_encryption, "test_dummy_encryption"},
 	{Opt_nombcache, "nombcache"},
@@ -1844,6 +1847,9 @@ static const struct mount_opts {
 	 MOPT_CLEAR | MOPT_2 | MOPT_EXT4_ONLY},
 	{Opt_fc_soft_consistency, EXT4_MOUNT2_JOURNAL_FC_SOFT_CONSISTENCY,
 	 MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY},
+#ifdef EXT4_FC_DEBUG
+	{Opt_fc_debug_max_replay, 0, MOPT_GTE0},
+#endif
 	{Opt_err, 0, 0}
 };
 
@@ -2003,6 +2009,10 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 		sbi->s_li_wait_mult = arg;
 	} else if (token == Opt_max_dir_size_kb) {
 		sbi->s_max_dir_size_kb = arg;
+#ifdef EXT4_FC_DEBUG
+	} else if (token == Opt_fc_debug_max_replay) {
+		sbi->s_fc_debug_max_replay = arg;
+#endif
 	} else if (token == Opt_stripe) {
 		sbi->s_stripe = arg;
 	} else if (token == Opt_resuid) {
-- 
2.26.0.110.g2183baf09c-goog


  parent reply	other threads:[~2020-04-08 21:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 21:55 [PATCH v6 01/20] ext4: update docs for fast commit feature Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 02/20] ext4: add handling for extended mount options Harshad Shirwadkar
2020-04-09 19:47   ` Andreas Dilger
2020-04-08 21:55 ` [PATCH v6 03/20] ext4, jbd2: add fast commit initialization routines Harshad Shirwadkar
2020-04-10 12:12   ` Andreas Dilger
2020-04-10 17:51     ` harshad shirwadkar
2020-04-08 21:55 ` [PATCH v6 04/20] jbd2: add fast commit block tracker variables Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 05/20] jbd2: disable fast commits if journal is empty Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 06/20] jbd2: fast commit main commit path changes Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 07/20] ext4: add generic diff tracking routines and range tracking Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 08/20] ext4: add directory entry tracking routines Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 09/20] ext4: add inode tracking and ineligible marking routines Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 10/20] ext4: break ext4_unlink() and ext4_link() Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 11/20] ext4: add fast commit track points Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 12/20] ext4: add fast commit on-disk format structs Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 13/20] jbd2: add new APIs for commit path of fast commits Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 14/20] ext4: main commit routine for " Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 15/20] jbd2: add fast commit recovery path support Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 16/20] ext4: fast commit recovery path preparation Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 17/20] ext4: add idempotent helpers to manipulate bitmaps Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 18/20] ext4: disable certain features in replay path Harshad Shirwadkar
2020-04-08 21:55 ` [PATCH v6 19/20] ext4: add fast commit " Harshad Shirwadkar
2020-04-08 21:55 ` Harshad Shirwadkar [this message]
2020-04-09 22:01 ` [PATCH v6 01/20] ext4: update docs for fast commit feature Andreas Dilger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200408215530.25649-20-harshads@google.com \
    --to=harshadshirwadkar@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).