bcachefs: fsck_inode_rm() shouldn't delete subvols
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 14 Jul 2022 04:44:09 +0000 (00:44 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:35 +0000 (17:09 -0400)
We should never see an inode marked as unlinked that's a subvolume root
(or a directory) in fsck, but even if we do it's not correct for fsck to
delete the subvolume: subvolumes are owned by dirents, and if we find a
dangling subvolume (not marked as unlinked) we want fsck to reattach it.

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

index bdf0183d5d214dc6154940edf371740db7c98b34..609ac37ff1e97655df63945d6bd44a36f24c1a6c 100644 (file)
@@ -231,6 +231,7 @@ static int write_inode(struct btree_trans *trans,
 
 static int fsck_inode_rm(struct btree_trans *trans, u64 inum, u32 snapshot)
 {
+       struct bch_fs *c = trans->c;
        struct btree_iter iter = { NULL };
        struct bkey_i_inode_generation delete;
        struct bch_inode_unpacked inode_u;
@@ -263,7 +264,7 @@ retry:
                goto err;
 
        if (!bkey_is_inode(k.k)) {
-               bch2_fs_inconsistent(trans->c,
+               bch2_fs_inconsistent(c,
                                     "inode %llu:%u not found when deleting",
                                     inum, snapshot);
                ret = -EIO;
@@ -273,11 +274,8 @@ retry:
        bch2_inode_unpack(k, &inode_u);
 
        /* Subvolume root? */
-       if (inode_u.bi_subvol) {
-               ret = bch2_subvolume_delete(trans, inode_u.bi_subvol);
-               if (ret)
-                       goto err;
-       }
+       if (inode_u.bi_subvol)
+               bch_warn(c, "deleting inode %llu marked as unlinked, but also a subvolume root!?", inode_u.bi_inum);
 
        bkey_inode_generation_init(&delete.k_i);
        delete.k.p = iter.pos;