bcachefs: Repair subvol dirents that point to non subvols
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 21 Jan 2024 19:57:58 +0000 (14:57 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 14 Mar 2024 01:22:24 +0000 (21:22 -0400)
when repair switches d_type to or from DT_SUBVOL, we need to update the
target accordingly

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

index ff7347cc395fd8d8a8bd3da5cb480761c4afef04..0d405b960a7c4b112c21d412e550b0021679dfb7 100644 (file)
@@ -1678,6 +1678,12 @@ static int check_dirent_target(struct btree_trans *trans,
 
                bkey_reassemble(&n->k_i, d.s_c);
                n->v.d_type = inode_d_type(target);
+               if (n->v.d_type == DT_SUBVOL) {
+                       n->v.d_parent_subvol = cpu_to_le32(target->bi_parent_subvol);
+                       n->v.d_child_subvol = cpu_to_le32(target->bi_subvol);
+               } else {
+                       n->v.d_inum = cpu_to_le64(target->bi_inum);
+               }
 
                ret = bch2_trans_update(trans, iter, &n->k_i, 0);
                if (ret)