diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-04-30 01:33:09 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:10:00 +0200 |
commit | bcb79a51cb52033bb12c5ed2eb46770e984b5542 (patch) | |
tree | 9474d9d274906a44a8a49fba8cd4bb74144e6c64 /fs/bcachefs/lru.c | |
parent | bcachefs: bkey_ops.min_val_size (diff) | |
download | linux-bcb79a51cb52033bb12c5ed2eb46770e984b5542.tar.xz 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/lru.c')
-rw-r--r-- | fs/bcachefs/lru.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/bcachefs/lru.c b/fs/bcachefs/lru.c index 0e6193d6b5f8..4f23e88f6ae1 100644 --- a/fs/bcachefs/lru.c +++ b/fs/bcachefs/lru.c @@ -114,8 +114,7 @@ static int bch2_check_lru_key(struct btree_trans *trans, alloc_pos.inode, alloc_pos.offset)) return bch2_btree_delete_at(trans, lru_iter, 0); - bch2_trans_iter_init(trans, &iter, BTREE_ID_alloc, alloc_pos, 0); - k = bch2_btree_iter_peek_slot(&iter); + k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_alloc, alloc_pos, 0); ret = bkey_err(k); if (ret) goto err; |