bcachefs: bch2_bkey_get_iter() helpers
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 29 Apr 2023 23:33:09 +0000 (19:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:00 +0000 (17:10 -0400)
commitbcb79a51cb52033bb12c5ed2eb46770e984b5542
tree9474d9d274906a44a8a49fba8cd4bb74144e6c64
parent174f930b8e1cad3915819a46bb20da214f68f2b5
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>
15 files changed:
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_foreground.c
fs/bcachefs/backpointers.c
fs/bcachefs/btree_iter.h
fs/bcachefs/btree_key_cache.c
fs/bcachefs/data_update.c
fs/bcachefs/ec.c
fs/bcachefs/fsck.c
fs/bcachefs/inode.c
fs/bcachefs/io.c
fs/bcachefs/lru.c
fs/bcachefs/movinggc.c
fs/bcachefs/quota.c
fs/bcachefs/recovery.c
fs/bcachefs/subvolume.c