From e4085b70f21f0e4b578a50a9fd7e84f2a055010f Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 14 Jul 2022 00:44:09 -0400 Subject: [PATCH] bcachefs: fsck_inode_rm() shouldn't delete subvols 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 --- fs/bcachefs/fsck.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index bdf0183d5d21..609ac37ff1e9 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -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; -- 2.25.1