diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-04-29 19:33:09 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:00 -0400 |
commit | bcb79a51cb52033bb12c5ed2eb46770e984b5542 (patch) | |
tree | 9474d9d274906a44a8a49fba8cd4bb74144e6c64 /fs/bcachefs/btree_key_cache.c | |
parent | 174f930b8e1cad3915819a46bb20da214f68f2b5 (diff) | |
download | linux-bcb79a51cb52033bb12c5ed2eb46770e984b5542.tar.gz linux-bcb79a51cb52033bb12c5ed2eb46770e984b5542.tar.bz2 linux-bcb79a51cb52033bb12c5ed2eb46770e984b5542.zip |
bcachefs: bch2_bkey_get_iter() helpers
Introduce new helpers for a common pattern:
bch2_trans_iter_init();
bch2_btree_iter_peek_slot();
- bch2_bkey_get_iter_type() returns -ENOENT if it doesn't find a key of
the correct type
- bch2_bkey_get_val_typed() copies the val out of the btree to a
(typically stack allocated) variable; it handles the case where the
value in the btree is smaller than the current version of the type,
zeroing out the remainder.
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.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index a483bd23a336..727ea2d0e58d 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -386,10 +386,9 @@ static int btree_key_cache_fill(struct btree_trans *trans, struct bkey_i *new_k = NULL; int ret; - bch2_trans_iter_init(trans, &iter, ck->key.btree_id, ck->key.pos, - BTREE_ITER_KEY_CACHE_FILL| - BTREE_ITER_CACHED_NOFILL); - k = bch2_btree_iter_peek_slot(&iter); + k = bch2_bkey_get_iter(trans, &iter, ck->key.btree_id, ck->key.pos, + BTREE_ITER_KEY_CACHE_FILL| + BTREE_ITER_CACHED_NOFILL); ret = bkey_err(k); if (ret) goto err; |