Commit e4085b70 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 597dee1c
...@@ -231,6 +231,7 @@ static int write_inode(struct btree_trans *trans, ...@@ -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) 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 btree_iter iter = { NULL };
struct bkey_i_inode_generation delete; struct bkey_i_inode_generation delete;
struct bch_inode_unpacked inode_u; struct bch_inode_unpacked inode_u;
...@@ -263,7 +264,7 @@ static int fsck_inode_rm(struct btree_trans *trans, u64 inum, u32 snapshot) ...@@ -263,7 +264,7 @@ static int fsck_inode_rm(struct btree_trans *trans, u64 inum, u32 snapshot)
goto err; goto err;
if (!bkey_is_inode(k.k)) { if (!bkey_is_inode(k.k)) {
bch2_fs_inconsistent(trans->c, bch2_fs_inconsistent(c,
"inode %llu:%u not found when deleting", "inode %llu:%u not found when deleting",
inum, snapshot); inum, snapshot);
ret = -EIO; ret = -EIO;
...@@ -273,11 +274,8 @@ static int fsck_inode_rm(struct btree_trans *trans, u64 inum, u32 snapshot) ...@@ -273,11 +274,8 @@ static int fsck_inode_rm(struct btree_trans *trans, u64 inum, u32 snapshot)
bch2_inode_unpack(k, &inode_u); bch2_inode_unpack(k, &inode_u);
/* Subvolume root? */ /* Subvolume root? */
if (inode_u.bi_subvol) { if (inode_u.bi_subvol)
ret = bch2_subvolume_delete(trans, inode_u.bi_subvol); bch_warn(c, "deleting inode %llu marked as unlinked, but also a subvolume root!?", inode_u.bi_inum);
if (ret)
goto err;
}
bkey_inode_generation_init(&delete.k_i); bkey_inode_generation_init(&delete.k_i);
delete.k.p = iter.pos; delete.k.p = iter.pos;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment