summaryrefslogtreecommitdiff
path: root/fs/bcachefs/lru.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-04-30 02:33:09 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:10:00 +0300
commitbcb79a51cb52033bb12c5ed2eb46770e984b5542 (patch)
tree9474d9d274906a44a8a49fba8cd4bb74144e6c64 /fs/bcachefs/lru.c
parent174f930b8e1cad3915819a46bb20da214f68f2b5 (diff)
downloadlinux-bcb79a51cb52033bb12c5ed2eb46770e984b5542.tar.xz
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.c3
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;