summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2023-04-19 11:47:03 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-05-12 19:42:33 -0400
commitc81152a99afd9dfe57c744f4c54e0c28b6a5d3a2 (patch)
treeab8b4f05bb682b5f343cb523467819acbe25df64
parentc543942b76934d2df994095b902be2b3526933a4 (diff)
bcachefs: remove bucket_gens btree keys on device removal
If a device has keys in the bucket_gens btree associated with its buckets and is removed from a bcachefs volume, fsck will complain about the presence of keys associated with an invalid device index. A repair removes the associated keys and restores correctness. Update bch2_dev_remove_alloc() to remove device related keys at device removal time to avoid the problem. Signed-off-by: Brian Foster <bfoster@redhat.com>
-rw-r--r--fs/bcachefs/super.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 2829467bfb84..696ea1386101 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1432,6 +1432,8 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
bch2_btree_delete_range(c, BTREE_ID_backpointers, start, end,
BTREE_TRIGGER_NORUN, NULL) ?:
bch2_btree_delete_range(c, BTREE_ID_alloc, start, end,
+ BTREE_TRIGGER_NORUN, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end,
BTREE_TRIGGER_NORUN, NULL);
if (ret)
bch_err(c, "error removing dev alloc info: %s", bch2_err_str(ret));