summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_key_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-05-28 16:43:46 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-06-05 17:41:01 -0400
commit1ad42f37543f403a7fc6f1ebff30d67f02be7e73 (patch)
tree808c9697020a10153f636d519419296e07887095 /fs/bcachefs/btree_key_cache.c
parent61a64d2944fe690a7a992eac9328a82fb0011f2f (diff)
bcachefs: Btree key cache coherency
This is the last piece for btree key cache coherency: We already have: - btree iterator code checks the key cache when iterating over a cached btree - update path ensures that updates go to the key cache when updating a cached btree But 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. This patch implements that last piece: on a key cache update, if creating a new key, we now also update the underlying btree. This fixes a device removal bug, where deleting alloc info wasn't correctly deleting all keys associated with a given device. It also means we should be able to re-enable the key cache for inodes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.c')
-rw-r--r--fs/bcachefs/btree_key_cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index a575189f358c..5785efc8c276 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -562,6 +562,16 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans,
return true;
}
+void bch2_btree_key_cache_drop(struct btree_trans *trans,
+ struct btree_path *path)
+{
+ struct bkey_cached *ck = (void *) path->l[0].b;
+
+ ck->valid = false;
+
+ BUG_ON(test_bit(BKEY_CACHED_DIRTY, &ck->flags));
+}
+
static unsigned long bch2_btree_key_cache_scan(struct shrinker *shrink,
struct shrink_control *sc)
{