summaryrefslogtreecommitdiff
path: root/fs/bcachefs/quota.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-04-29 19:33:09 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:00 -0400
commitbcb79a51cb52033bb12c5ed2eb46770e984b5542 (patch)
tree9474d9d274906a44a8a49fba8cd4bb74144e6c64 /fs/bcachefs/quota.c
parent174f930b8e1cad3915819a46bb20da214f68f2b5 (diff)
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/quota.c')
-rw-r--r--fs/bcachefs/quota.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c
index 22cd662429d3..7734e0dfe523 100644
--- a/fs/bcachefs/quota.c
+++ b/fs/bcachefs/quota.c
@@ -901,10 +901,8 @@ static int bch2_set_quota_trans(struct btree_trans *trans,
struct bkey_s_c k;
int ret;
- bch2_trans_iter_init(trans, &iter, BTREE_ID_quotas, new_quota->k.p,
- BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
- k = bch2_btree_iter_peek_slot(&iter);
-
+ k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_quotas, new_quota->k.p,
+ BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
ret = bkey_err(k);
if (unlikely(ret))
return ret;