Skip to content

Commit

Permalink
bcachefs: Simplify btree key cache fill path
Browse files Browse the repository at this point in the history
Don't allocate the new bkey_cached until after we've done the btree
lookup; this means we can kill bkey_cached.valid.

Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
Kent Overstreet committed Jun 13, 2024
1 parent 27126f9 commit c5095f4
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 199 deletions.
9 changes: 4 additions & 5 deletions fs/bcachefs/btree_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1801,13 +1801,12 @@ struct bkey_s_c bch2_btree_path_peek_slot(struct btree_path *path, struct bkey *
goto hole;
} else {
struct bkey_cached *ck = (void *) path->l[0].b;

EBUG_ON(ck &&
(path->btree_id != ck->key.btree_id ||
!bkey_eq(path->pos, ck->key.pos)));
if (!ck || !ck->valid)
if (!ck)
return bkey_s_c_null;

EBUG_ON(path->btree_id != ck->key.btree_id ||
!bkey_eq(path->pos, ck->key.pos));

*u = ck->k->k;
k = bkey_i_to_s_c(ck->k);
}
Expand Down
Loading

0 comments on commit c5095f4

Please sign in to comment.