]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Add a recovery pass for making sure root inode is readable
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 15 Apr 2025 23:21:52 +0000 (19:21 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:19 +0000 (20:14 -0400)
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
fs/bcachefs/recovery_passes_types.h

index de1a14c4bc3c38c62428dc8a594be823b36938be..b4de21f80811c44b7c2f3635c9a5ba726cb6fdd4 100644 (file)
@@ -52,6 +52,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;
index e89b9c7832855f760740d6265baa8fa4ccfb7df2..4671ccf2d5600d771bced638a079a440d2c26e6c 100644 (file)
@@ -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 {