summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-22 20:15:33 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2022-12-20 20:01:27 -0500
commitb71841e54343e7e7095dd8b66cae1e6e3fa6b8d5 (patch)
tree15bc25dc97410179810933cdbe5c3f29a2c29f03
parent113119721d67febf0d7e54bc4fbc8d980d6d0a71 (diff)
bcachefs: Bring back key cache for inodesbcachefs-v6.0
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 <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/inode.c28
-rw-r--r--fs/bcachefs/super.c3
2 files changed, 4 insertions, 27 deletions
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);
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 30818e838814..f474f2f298ac 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -743,9 +743,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
bch2_opts_apply(&c->opts, opts);
- /* key cache currently disabled for inodes, because of snapshots: */
- c->opts.inodes_use_key_cache = 0;
-
c->btree_key_cache_btrees |= 1U << BTREE_ID_alloc;
if (c->opts.inodes_use_key_cache)
c->btree_key_cache_btrees |= 1U << BTREE_ID_inodes;