aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/data_update.c
diff options
context:
space:
mode:
authorGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-04-29 19:33:09 -0400
committerGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-10-22 17:10:00 -0400
commitbcb79a51cb52033bb12c5ed2eb46770e984b5542 (patch)
tree9474d9d274906a44a8a49fba8cd4bb74144e6c64 /fs/bcachefs/data_update.c
parentbcachefs: bkey_ops.min_val_size (diff)
downloadlinux-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/data_update.c')
-rw-r--r--fs/bcachefs/data_update.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c
index cffb3c14d539..c709538ce9c2 100644
--- a/fs/bcachefs/data_update.c
+++ b/fs/bcachefs/data_update.c
@@ -57,10 +57,9 @@ static int insert_snapshot_whiteouts(struct btree_trans *trans,
whiteout_pos.snapshot = k.k->p.snapshot;
- bch2_trans_iter_init(trans, &iter2, id, whiteout_pos,
- BTREE_ITER_NOT_EXTENTS|
- BTREE_ITER_INTENT);
- k2 = bch2_btree_iter_peek_slot(&iter2);
+ k2 = bch2_bkey_get_iter(trans, &iter2, id, whiteout_pos,
+ BTREE_ITER_NOT_EXTENTS|
+ BTREE_ITER_INTENT);
ret = bkey_err(k2);
if (!ret && k2.k->type == KEY_TYPE_deleted) {