summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_trans_commit.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-06-24 16:01:33 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-07-03 01:20:18 -0400
commitd0ffb68c86ade11838acb4d31df55a1a056d8c1c (patch)
tree56fd16b199248ad7d811c115cbc1199b78f564c0 /fs/bcachefs/btree_trans_commit.c
parent100142f6ec4d184a3e78870a878bdd80415852d4 (diff)
bcachefs: Evict/bypass key cache when deleting
Fix a performance bug when doing many unlinks. The btree has optimizations to ensure we don't have too many whiteouts to scan in peek() before we find a real key to return, but unflushed key cache deletions break this. To fix this, tweak the existing code for redirecting updates that create a key to the underlying btree so that we can use it for deletions as well. Reported-by: John Schoenick <johns@valvesoftware.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_trans_commit.c')
-rw-r--r--fs/bcachefs/btree_trans_commit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c
index 454b4c5c1808..7fcf248a9a76 100644
--- a/fs/bcachefs/btree_trans_commit.c
+++ b/fs/bcachefs/btree_trans_commit.c
@@ -46,6 +46,9 @@ void bch2_trans_commit_flags_to_text(struct printbuf *out, enum bch_trans_commit
static void verify_update_old_key(struct btree_trans *trans, struct btree_insert_entry *i)
{
#ifdef CONFIG_BCACHEFS_DEBUG
+ if (i->key_cache_flushing)
+ return;
+
struct bch_fs *c = trans->c;
struct bkey u;
struct bkey_s_c k = bch2_btree_path_peek_slot_exact(trans->paths + i->path, &u);
@@ -337,6 +340,9 @@ static inline void btree_insert_entry_checks(struct btree_trans *trans,
BUG_ON(!bpos_eq(i->k->k.p, path->pos));
BUG_ON(i->cached != path->cached);
+ BUG_ON(i->cached &&
+ !i->key_cache_already_flushed &&
+ bkey_deleted(&i->k->k));;
BUG_ON(i->level != path->level);
BUG_ON(i->btree_id != path->btree_id);
BUG_ON(i->bkey_type != __btree_node_type(path->level, path->btree_id));