summaryrefslogtreecommitdiff
path: root/fs/bcachefs/lru.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-09 15:15:36 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:31 -0400
commita9c0a4cbf1ceb9842fee5d7084817509a5e962aa (patch)
tree844f0302ef7afff7d4dd9cb89e73dc7c06f711c4 /fs/bcachefs/lru.c
parent502f973dba660ed04f295e5ba129f2d369cc1aa6 (diff)
bcachefs: Minor device removal fixes
- We weren't clearing the LRU btree - bch2_alloc_read() runs before bch2_check_alloc_key() deletes alloc keys for devices/buckets that don't exists, so it needs to check for that - bch2_check_lrus() needs to check that buckets exists - improve some error messages Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/lru.c')
-rw-r--r--fs/bcachefs/lru.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/bcachefs/lru.c b/fs/bcachefs/lru.c
index 267f2f8fb13b..ef4b4a9f0d5f 100644
--- a/fs/bcachefs/lru.c
+++ b/fs/bcachefs/lru.c
@@ -133,7 +133,7 @@ static int bch2_check_lru_key(struct btree_trans *trans,
struct bch_alloc_v4 a;
struct printbuf buf1 = PRINTBUF;
struct printbuf buf2 = PRINTBUF;
- u64 idx;
+ struct bpos alloc_pos;
int ret;
lru_k = bch2_btree_iter_peek(lru_iter);
@@ -144,10 +144,15 @@ static int bch2_check_lru_key(struct btree_trans *trans,
if (ret)
return ret;
- idx = le64_to_cpu(bkey_s_c_to_lru(lru_k).v->idx);
+ alloc_pos = POS(lru_k.k->p.inode,
+ le64_to_cpu(bkey_s_c_to_lru(lru_k).v->idx));
- bch2_trans_iter_init(trans, &iter, BTREE_ID_alloc,
- POS(lru_k.k->p.inode, idx), 0);
+ if (fsck_err_on(!bch2_dev_bucket_exists(c, alloc_pos), c,
+ "lru key points to nonexistent device:bucket %llu:%llu",
+ alloc_pos.inode, alloc_pos.offset))
+ return bch2_btree_delete_at(trans, lru_iter, 0);
+
+ bch2_trans_iter_init(trans, &iter, BTREE_ID_alloc, alloc_pos, 0);
k = bch2_btree_iter_peek_slot(&iter);
ret = bkey_err(k);
if (ret)