From b71841e54343e7e7095dd8b66cae1e6e3fa6b8d5 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 22 Nov 2022 20:15:33 -0500 Subject: bcachefs: Bring back key cache for inodes The btree key cache now works for snapshots btrees, where doing a lookup requires searching through keys in older snapshots - we can finaly re-enable it for inodes. Signed-off-by: Kent Overstreet --- fs/bcachefs/inode.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'fs/bcachefs/inode.c') diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index 8860301e4af3..b1a0ed13728f 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -663,19 +663,8 @@ again: while ((k = bch2_btree_iter_peek(iter)).k && !(ret = bkey_err(k)) && bkey_lt(k.k->p, POS(0, max))) { - while (pos < iter->pos.offset) { - if (!bch2_btree_key_cache_find(c, BTREE_ID_inodes, POS(0, pos))) - goto found_slot; - - pos++; - } - - if (k.k->p.snapshot == snapshot && - !bkey_is_inode(k.k) && - !bch2_btree_key_cache_find(c, BTREE_ID_inodes, SPOS(0, pos, snapshot))) { - bch2_btree_iter_advance(iter); - continue; - } + if (pos < iter->pos.offset) + goto found_slot; /* * We don't need to iterate over keys in every snapshot once @@ -685,12 +674,8 @@ again: bch2_btree_iter_set_pos(iter, POS(0, pos)); } - while (!ret && pos < max) { - if (!bch2_btree_key_cache_find(c, BTREE_ID_inodes, POS(0, pos))) - goto found_slot; - - pos++; - } + if (!ret && pos < max) + goto found_slot; if (!ret && start == min) ret = -BCH_ERR_ENOSPC_inode_create; @@ -713,11 +698,6 @@ found_slot: return ret; } - /* We may have raced while the iterator wasn't pointing at pos: */ - if (bkey_is_inode(k.k) || - bch2_btree_key_cache_find(c, BTREE_ID_inodes, k.k->p)) - goto again; - *hint = k.k->p.offset; inode_u->bi_inum = k.k->p.offset; inode_u->bi_generation = bkey_generation(k); -- cgit v1.2.3