linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-bcachefs@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH 1/3] bcachefs: opts.journal_rewind_no_extents
Date: Mon, 30 Jun 2025 17:31:16 -0400	[thread overview]
Message-ID: <20250630213118.2063622-1-kent.overstreet@linux.dev> (raw)

Add an option to skip rewinding extents when rewinding the journal.

If the only extents operatinos that have occurred are data move
operations, then this will give a higher probability of successful
recovery - until we implement the "buffer discards by a percentage of
device size" functionality.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 fs/bcachefs/btree_journal_iter.c | 17 ++++++++++++++---
 fs/bcachefs/opts.h               |  5 +++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/fs/bcachefs/btree_journal_iter.c b/fs/bcachefs/btree_journal_iter.c
index ea839560a136..341d31b3a1f1 100644
--- a/fs/bcachefs/btree_journal_iter.c
+++ b/fs/bcachefs/btree_journal_iter.c
@@ -717,6 +717,18 @@ static void __journal_keys_sort(struct journal_keys *keys)
 	keys->nr = dst - keys->data;
 }
 
+static bool should_rewind_entry(struct bch_fs *c, struct jset_entry *entry)
+{
+	if (entry->level)
+		return false;
+	if (btree_id_is_alloc(entry->btree_id))
+		return false;
+	if (c->opts.journal_rewind_no_extents &&
+	    entry->btree_id == BTREE_ID_extents)
+		return false;
+	return true;
+}
+
 int bch2_journal_keys_sort(struct bch_fs *c)
 {
 	struct genradix_iter iter;
@@ -735,9 +747,8 @@ int bch2_journal_keys_sort(struct bch_fs *c)
 		cond_resched();
 
 		vstruct_for_each(&i->j, entry) {
-			bool rewind = !entry->level &&
-				!btree_id_is_alloc(entry->btree_id) &&
-				le64_to_cpu(i->j.seq) >= rewind_seq;
+			bool rewind = le64_to_cpu(i->j.seq) >= rewind_seq &&
+				should_rewind_entry(c, entry);
 
 			if (entry->type != (rewind
 					    ? BCH_JSET_ENTRY_overwrite
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index b0a76bd6d6f5..9301f318c4d4 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -384,6 +384,11 @@ enum fsck_err_opts {
 	  OPT_UINT(0, U64_MAX),						\
 	  BCH2_NO_SB_OPT,		0,				\
 	  NULL,		"Rewind journal")				\
+	x(journal_rewind_no_extents,	bool,				\
+	  OPT_FS|OPT_MOUNT,						\
+	  OPT_BOOL(),							\
+	  BCH2_NO_SB_OPT,		0,				\
+	  NULL,		"Don't rewind extents when rewinding journal")	\
 	x(recovery_passes,		u64,				\
 	  OPT_FS|OPT_MOUNT,						\
 	  OPT_BITFIELD(bch2_recovery_passes),				\
-- 
2.50.0


             reply	other threads:[~2025-06-30 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 21:31 Kent Overstreet [this message]
2025-06-30 21:31 ` [PATCH 2/3] bcachefs: Before removing dangling dirents, check for contents Kent Overstreet
2025-06-30 21:31 ` [PATCH 3/3] bcachefs: check_key_has_inode() reconstructs more aggressively Kent Overstreet

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=20250630213118.2063622-1-kent.overstreet@linux.dev \
    --to=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    /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).