]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: fsck: Fix reattach_inode() for subvol roots
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 16 Jun 2025 18:41:27 +0000 (14:41 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 16 Jun 2025 23:04:59 +0000 (19:04 -0400)
bch_subvolume.fs_path_parent needs to be updated as well, it should
match inode.bi_parent_subvol.

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

index a3f73e7a21138ff5e9f684a45fce55604cf718b5..6e64af4ccc36d791e4c45d6d5339e9db4d5a5e73 100644 (file)
@@ -372,6 +372,18 @@ static int reattach_inode(struct btree_trans *trans, struct bch_inode_unpacked *
        if (inode->bi_subvol) {
                inode->bi_parent_subvol = BCACHEFS_ROOT_SUBVOL;
 
+               struct btree_iter subvol_iter;
+               struct bkey_i_subvolume *subvol =
+                       bch2_bkey_get_mut_typed(trans, &subvol_iter,
+                                               BTREE_ID_subvolumes, POS(0, inode->bi_subvol),
+                                               0, subvolume);
+               ret = PTR_ERR_OR_ZERO(subvol);
+               if (ret)
+                       return ret;
+
+               subvol->v.fs_path_parent = BCACHEFS_ROOT_SUBVOL;
+               bch2_trans_iter_exit(trans, &subvol_iter);
+
                u64 root_inum;
                ret = subvol_lookup(trans, inode->bi_parent_subvol,
                                    &dirent_snapshot, &root_inum);