bcachefs: check_root() can now be run online
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 11 Dec 2023 03:51:16 +0000 (22:51 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:47:41 +0000 (11:47 -0500)
check_root() is simple enough to run as one single transaction, so is
trivial to run online.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fsck.c
fs/bcachefs/recovery_types.h

index 8b77098dde2dcf9b1444983746a181072f9df115..d0cd6020bd9a12455297dfaa2d39fe39b7fa4ef8 100644 (file)
@@ -1950,14 +1950,10 @@ static int check_root_trans(struct btree_trans *trans)
                root_subvol.v.flags     = 0;
                root_subvol.v.snapshot  = cpu_to_le32(snapshot);
                root_subvol.v.inode     = cpu_to_le64(inum);
-               ret = commit_do(trans, NULL, NULL,
-                                     BCH_TRANS_COMMIT_no_enospc,
-                       bch2_btree_insert_trans(trans, BTREE_ID_subvolumes,
-                                           &root_subvol.k_i, 0));
+               ret = bch2_btree_insert_trans(trans, BTREE_ID_subvolumes, &root_subvol.k_i, 0);
                bch_err_msg(c, ret, "writing root subvol");
                if (ret)
                        goto err;
-
        }
 
        ret = __lookup_inode(trans, BCACHEFS_ROOT_INO, &root_inode, &snapshot);
@@ -1984,9 +1980,7 @@ fsck_err:
 /* Get root directory, create if it doesn't exist: */
 int bch2_check_root(struct bch_fs *c)
 {
-       int ret;
-
-       ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
+       int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
                check_root_trans(trans));
        bch_err_fn(c, ret);
        return ret;
index 6a7debe663b97714f78c6402a1c5eaa515968d0a..6dfc4f10948dc5f7635ade3747dcd23b03a7651e 100644 (file)
@@ -42,7 +42,7 @@
        x(check_indirect_extents,               26, PASS_FSCK)                  \
        x(check_dirents,                        27, PASS_FSCK)                  \
        x(check_xattrs,                         28, PASS_FSCK)                  \
-       x(check_root,                           29, PASS_FSCK)                  \
+       x(check_root,                           29, PASS_ONLINE|PASS_FSCK)      \
        x(check_directory_structure,            30, PASS_FSCK)                  \
        x(check_nlinks,                         31, PASS_FSCK)                  \
        x(delete_dead_inodes,                   32, PASS_FSCK|PASS_UNCLEAN)     \