From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-bcachefs@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH 6/6] bcachefs: Add a recovery pass for making sure root inode is readable
Date: Wed, 16 Apr 2025 09:37:24 -0400 [thread overview]
Message-ID: <20250416133724.3653606-6-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20250416133724.3653606-1-kent.overstreet@linux.dev>
If the root inode/subvolume is unreadable we can repair automatically -
but only if we're still in recovery, so that we can rewind to the
appropriate recovery pass.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/recovery_passes.c | 15 +++++++++++++++
fs/bcachefs/recovery_passes_types.h | 3 ++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/recovery_passes.c b/fs/bcachefs/recovery_passes.c
index d0b8a852efae..92e431af9ac3 100644
--- a/fs/bcachefs/recovery_passes.c
+++ b/fs/bcachefs/recovery_passes.c
@@ -51,6 +51,21 @@ static int bch2_set_may_go_rw(struct bch_fs *c)
return 0;
}
+/*
+ * Make sure root inode is readable while we're still in recovery and can rewind
+ * for repair:
+ */
+static int bch2_lookup_root_inode(struct bch_fs *c)
+{
+ subvol_inum inum = BCACHEFS_ROOT_SUBVOL_INUM;
+ struct bch_inode_unpacked inode_u;
+ struct bch_subvolume subvol;
+
+ return bch2_trans_do(c,
+ bch2_subvolume_get(trans, inum.subvol, true, &subvol) ?:
+ bch2_inode_find_by_inum_trans(trans, inum, &inode_u));
+}
+
struct recovery_pass_fn {
int (*fn)(struct bch_fs *);
unsigned when;
diff --git a/fs/bcachefs/recovery_passes_types.h b/fs/bcachefs/recovery_passes_types.h
index e89b9c783285..4671ccf2d560 100644
--- a/fs/bcachefs/recovery_passes_types.h
+++ b/fs/bcachefs/recovery_passes_types.h
@@ -60,7 +60,8 @@
x(resume_logged_ops, 23, PASS_ALWAYS) \
x(delete_dead_inodes, 32, PASS_ALWAYS) \
x(fix_reflink_p, 33, 0) \
- x(set_fs_needs_rebalance, 34, 0)
+ x(set_fs_needs_rebalance, 34, 0) \
+ x(lookup_root_inode, 42, PASS_ALWAYS|PASS_SILENT)
/* We normally enumerate recovery passes in the order we run them: */
enum bch_recovery_pass {
--
2.49.0
prev parent reply other threads:[~2025-04-16 13:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 13:37 [PATCH 1/6] bcachefs: bch2_run_explicit_recovery_pass_printbuf() Kent Overstreet
2025-04-16 13:37 ` [PATCH 2/6] bcachefs: Simplify bch2_count_fsck_err() Kent Overstreet
2025-04-16 13:37 ` [PATCH 3/6] bcachefs: bch2_dev_missing_bkey() Kent Overstreet
2025-04-16 13:37 ` [PATCH 4/6] bcachefs: print_str_as_lines() -> print_str() Kent Overstreet
2025-04-16 13:37 ` [PATCH 5/6] bcachefs: Flag for repair on missing subvolume Kent Overstreet
2025-04-16 13:37 ` Kent Overstreet [this message]
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=20250416133724.3653606-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.