We need to make sure we're not missing any fragmenation entries in the LRU BTREE after repairing ALLOC BTREE
Signed-off-by: Daniel Hill <[email protected]> --- fs/bcachefs/alloc_background.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 3bf2a2daad93..c0894680ac4c 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1566,6 +1566,32 @@ static int bch2_check_alloc_to_lru_ref(struct btree_trans *trans, a = bch2_alloc_to_v4(alloc_k, &a_convert); + if (a->fragmentation_lru) { + lru_k = bch2_bkey_get_iter(trans, &lru_iter, BTREE_ID_lru, + lru_pos(BCH_LRU_FRAGMENTATION_START, + bucket_to_u64(alloc_k.k->p), + a->fragmentation_lru), 0); + ret = bkey_err(lru_k); + + if (ret) + return ret; + + if (fsck_err_on(lru_k.k->type != KEY_TYPE_set, c, + alloc_key_to_missing_lru_entry, + "missing fragmentation_lru entry\n" + " %s", + (printbuf_reset(&buf), + bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) { + ret = bch2_lru_set(trans, + BCH_LRU_FRAGMENTATION_START, + bucket_to_u64(alloc_k.k->p), + a->fragmentation_lru); + if (ret) + goto err; + } + bch2_trans_iter_exit(trans, &lru_iter); + } + if (a->data_type != BCH_DATA_cached) return 0; -- 2.43.0
