summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_key_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-01-12 01:14:47 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:23 -0400
commit12ce5b7df1e0e432bcac22079e4493cab5cd8b23 (patch)
tree26c734e453b9a614bc05dc7c42db3dd45affb479 /fs/bcachefs/btree_key_cache.c
parentf7b6ca23b6456b8b441b506ef977ff53972b35c2 (diff)
downloadlinux-12ce5b7df1e0e432bcac22079e4493cab5cd8b23.tar.gz
linux-12ce5b7df1e0e432bcac22079e4493cab5cd8b23.tar.bz2
linux-12ce5b7df1e0e432bcac22079e4493cab5cd8b23.zip
bcachefs: Btree key cache coherency
- Updates to non key cache iterators will now be transparently redirected to the key cache for cached btrees. - Except when creating new keys: then the update goes to underlying btree For for iterating over a cached btree to work, we need to ensure that if a key exists in the key cache, it also exists in the btree - otherwise the iterator code will skip past it and not check the key cache. Otherwise, for consistency, all updates should go to the same place - the key cache. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.c')
-rw-r--r--fs/bcachefs/btree_key_cache.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index 29d46d0aa5d3..72a54b9d1335 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -414,6 +414,7 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
* */
ret = bch2_btree_iter_traverse(&b_iter) ?:
bch2_trans_update(trans, &b_iter, ck->k,
+ BTREE_UPDATE_KEY_CACHE_RECLAIM|
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE|
BTREE_TRIGGER_NORUN) ?:
bch2_trans_commit(trans, NULL, NULL,
@@ -555,13 +556,15 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans,
return true;
}
-#ifdef CONFIG_BCACHEFS_DEBUG
-void bch2_btree_key_cache_verify_clean(struct btree_trans *trans,
- enum btree_id id, struct bpos pos)
+void bch2_btree_key_cache_drop(struct btree_trans *trans,
+ struct btree_path *path)
{
- BUG_ON(bch2_btree_key_cache_find(trans->c, id, pos));
+ struct bkey_cached *ck = (void *) path->l[0].b;
+
+ ck->valid = false;
+
+ BUG_ON(test_bit(BKEY_CACHED_DIRTY, &ck->flags));
}
-#endif
static unsigned long bch2_btree_key_cache_scan(struct shrinker *shrink,
struct shrink_control *sc)