#ifndef _BCACHEFS_BTREE_ITER_H
#define _BCACHEFS_BTREE_ITER_H
#include "bset.h"
#include "btree_types.h"
#include "trace.h"
static inline int __bkey_err(const struct bkey *k)
{ … }
#define bkey_err(_k) …
static inline void __btree_path_get(struct btree_path *path, bool intent)
{ … }
static inline bool __btree_path_put(struct btree_path *path, bool intent)
{ … }
static inline void btree_path_set_dirty(struct btree_path *path,
enum btree_path_uptodate u)
{ … }
static inline struct btree *btree_path_node(struct btree_path *path,
unsigned level)
{ … }
static inline bool btree_node_lock_seq_matches(const struct btree_path *path,
const struct btree *b, unsigned level)
{ … }
static inline struct btree *btree_node_parent(struct btree_path *path,
struct btree *b)
{ … }
void __bch2_btree_trans_sort_paths(struct btree_trans *);
static inline void btree_trans_sort_paths(struct btree_trans *trans)
{ … }
static inline unsigned long *trans_paths_nr(struct btree_path *paths)
{ … }
static inline unsigned long *trans_paths_allocated(struct btree_path *paths)
{ … }
#define trans_for_each_path_idx_from(_paths_allocated, _nr, _idx, _start) …
static inline struct btree_path *
__trans_next_path(struct btree_trans *trans, unsigned *idx)
{ … }
#define trans_for_each_path_from(_trans, _path, _idx, _start) …
#define trans_for_each_path(_trans, _path, _idx) …
static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path)
{ … }
static inline struct btree_path *prev_btree_path(struct btree_trans *trans, struct btree_path *path)
{ … }
#define trans_for_each_path_idx_inorder(_trans, _iter) …
struct trans_for_each_path_inorder_iter { … };
#define trans_for_each_path_inorder(_trans, _path, _iter) …
#define trans_for_each_path_inorder_reverse(_trans, _path, _i) …
static inline bool __path_has_node(const struct btree_path *path,
const struct btree *b)
{ … }
static inline struct btree_path *
__trans_next_path_with_node(struct btree_trans *trans, struct btree *b,
unsigned *idx)
{ … }
#define trans_for_each_path_with_node(_trans, _b, _path, _iter) …
btree_path_idx_t __bch2_btree_path_make_mut(struct btree_trans *, btree_path_idx_t,
bool, unsigned long);
static inline btree_path_idx_t __must_check
bch2_btree_path_make_mut(struct btree_trans *trans,
btree_path_idx_t path, bool intent,
unsigned long ip)
{ … }
btree_path_idx_t __must_check
__bch2_btree_path_set_pos(struct btree_trans *, btree_path_idx_t,
struct bpos, bool, unsigned long);
static inline btree_path_idx_t __must_check
bch2_btree_path_set_pos(struct btree_trans *trans,
btree_path_idx_t path, struct bpos new_pos,
bool intent, unsigned long ip)
{ … }
int __must_check bch2_btree_path_traverse_one(struct btree_trans *,
btree_path_idx_t,
unsigned, unsigned long);
static inline void bch2_trans_verify_not_unlocked(struct btree_trans *);
static inline int __must_check bch2_btree_path_traverse(struct btree_trans *trans,
btree_path_idx_t path, unsigned flags)
{ … }
btree_path_idx_t bch2_path_get(struct btree_trans *, enum btree_id, struct bpos,
unsigned, unsigned, unsigned, unsigned long);
btree_path_idx_t bch2_path_get_unlocked_mut(struct btree_trans *, enum btree_id,
unsigned, struct bpos);
struct bkey_s_c bch2_btree_path_peek_slot(struct btree_path *, struct bkey *);
static inline struct bkey_s_c bch2_btree_path_peek_slot_exact(struct btree_path *path, struct bkey *u)
{ … }
struct bkey_i *bch2_btree_journal_peek_slot(struct btree_trans *,
struct btree_iter *, struct bpos);
void bch2_btree_path_level_init(struct btree_trans *, struct btree_path *, struct btree *);
int __bch2_trans_mutex_lock(struct btree_trans *, struct mutex *);
static inline int bch2_trans_mutex_lock(struct btree_trans *trans, struct mutex *lock)
{ … }
#ifdef CONFIG_BCACHEFS_DEBUG
void bch2_trans_verify_paths(struct btree_trans *);
void bch2_assert_pos_locked(struct btree_trans *, enum btree_id, struct bpos);
#else
static inline void bch2_trans_verify_paths(struct btree_trans *trans) {}
static inline void bch2_assert_pos_locked(struct btree_trans *trans, enum btree_id id,
struct bpos pos) {}
#endif
void bch2_btree_path_fix_key_modified(struct btree_trans *trans,
struct btree *, struct bkey_packed *);
void bch2_btree_node_iter_fix(struct btree_trans *trans, struct btree_path *,
struct btree *, struct btree_node_iter *,
struct bkey_packed *, unsigned, unsigned);
int bch2_btree_path_relock_intent(struct btree_trans *, struct btree_path *);
void bch2_path_put(struct btree_trans *, btree_path_idx_t, bool);
int bch2_trans_relock(struct btree_trans *);
int bch2_trans_relock_notrace(struct btree_trans *);
void bch2_trans_unlock(struct btree_trans *);
void bch2_trans_unlock_long(struct btree_trans *);
static inline int trans_was_restarted(struct btree_trans *trans, u32 restart_count)
{ … }
void __noreturn bch2_trans_restart_error(struct btree_trans *, u32);
static inline void bch2_trans_verify_not_restarted(struct btree_trans *trans,
u32 restart_count)
{ … }
void __noreturn bch2_trans_in_restart_error(struct btree_trans *);
static inline void bch2_trans_verify_not_in_restart(struct btree_trans *trans)
{ … }
void __noreturn bch2_trans_unlocked_error(struct btree_trans *);
static inline void bch2_trans_verify_not_unlocked(struct btree_trans *trans)
{ … }
__always_inline
static int btree_trans_restart_nounlock(struct btree_trans *trans, int err)
{ … }
__always_inline
static int btree_trans_restart(struct btree_trans *trans, int err)
{ … }
bool bch2_btree_node_upgrade(struct btree_trans *,
struct btree_path *, unsigned);
void __bch2_btree_path_downgrade(struct btree_trans *, struct btree_path *, unsigned);
static inline void bch2_btree_path_downgrade(struct btree_trans *trans,
struct btree_path *path)
{ … }
void bch2_trans_downgrade(struct btree_trans *);
void bch2_trans_node_add(struct btree_trans *trans, struct btree_path *, struct btree *);
void bch2_trans_node_reinit_iter(struct btree_trans *, struct btree *);
int __must_check __bch2_btree_iter_traverse(struct btree_iter *iter);
int __must_check bch2_btree_iter_traverse(struct btree_iter *);
struct btree *bch2_btree_iter_peek_node(struct btree_iter *);
struct btree *bch2_btree_iter_peek_node_and_restart(struct btree_iter *);
struct btree *bch2_btree_iter_next_node(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *, struct bpos);
struct bkey_s_c bch2_btree_iter_next(struct btree_iter *);
static inline struct bkey_s_c bch2_btree_iter_peek(struct btree_iter *iter)
{ … }
struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_prev(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_next_slot(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_prev_slot(struct btree_iter *);
bool bch2_btree_iter_advance(struct btree_iter *);
bool bch2_btree_iter_rewind(struct btree_iter *);
static inline void __bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
{ … }
static inline void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
{ … }
static inline void bch2_btree_iter_set_pos_to_extent_start(struct btree_iter *iter)
{ … }
static inline void bch2_btree_iter_set_snapshot(struct btree_iter *iter, u32 snapshot)
{ … }
void bch2_trans_iter_exit(struct btree_trans *, struct btree_iter *);
static inline unsigned __bch2_btree_iter_flags(struct btree_trans *trans,
unsigned btree_id,
unsigned flags)
{ … }
static inline unsigned bch2_btree_iter_flags(struct btree_trans *trans,
unsigned btree_id,
unsigned flags)
{ … }
static inline void bch2_trans_iter_init_common(struct btree_trans *trans,
struct btree_iter *iter,
unsigned btree_id, struct bpos pos,
unsigned locks_want,
unsigned depth,
unsigned flags,
unsigned long ip)
{ … }
void bch2_trans_iter_init_outlined(struct btree_trans *, struct btree_iter *,
enum btree_id, struct bpos, unsigned);
static inline void bch2_trans_iter_init(struct btree_trans *trans,
struct btree_iter *iter,
unsigned btree_id, struct bpos pos,
unsigned flags)
{ … }
void bch2_trans_node_iter_init(struct btree_trans *, struct btree_iter *,
enum btree_id, struct bpos,
unsigned, unsigned, unsigned);
void bch2_trans_copy_iter(struct btree_iter *, struct btree_iter *);
void bch2_set_btree_iter_dontneed(struct btree_iter *);
void *__bch2_trans_kmalloc(struct btree_trans *, size_t);
static inline void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
{ … }
static inline void *bch2_trans_kmalloc_nomemzero(struct btree_trans *trans, size_t size)
{ … }
static inline struct bkey_s_c __bch2_bkey_get_iter(struct btree_trans *trans,
struct btree_iter *iter,
unsigned btree_id, struct bpos pos,
unsigned flags, unsigned type)
{ … }
static inline struct bkey_s_c bch2_bkey_get_iter(struct btree_trans *trans,
struct btree_iter *iter,
unsigned btree_id, struct bpos pos,
unsigned flags)
{ … }
#define bch2_bkey_get_iter_typed(_trans, _iter, _btree_id, _pos, _flags, _type) …
static inline int __bch2_bkey_get_val_typed(struct btree_trans *trans,
unsigned btree_id, struct bpos pos,
unsigned flags, unsigned type,
unsigned val_size, void *val)
{ … }
#define bch2_bkey_get_val_typed(_trans, _btree_id, _pos, _flags, _type, _val) …
void bch2_trans_srcu_unlock(struct btree_trans *);
u32 bch2_trans_begin(struct btree_trans *);
#define __for_each_btree_node(_trans, _iter, _btree_id, _start, \
_locks_want, _depth, _flags, _b, _ret) …
#define for_each_btree_node(_trans, _iter, _btree_id, _start, \
_flags, _b, _ret) …
static inline struct bkey_s_c bch2_btree_iter_peek_prev_type(struct btree_iter *iter,
unsigned flags)
{ … }
static inline struct bkey_s_c bch2_btree_iter_peek_type(struct btree_iter *iter,
unsigned flags)
{ … }
static inline struct bkey_s_c bch2_btree_iter_peek_upto_type(struct btree_iter *iter,
struct bpos end,
unsigned flags)
{ … }
int __bch2_btree_trans_too_many_iters(struct btree_trans *);
static inline int btree_trans_too_many_iters(struct btree_trans *trans)
{ … }
#define lockrestart_do(_trans, _do) …
#define nested_lockrestart_do(_trans, _do) …
#define for_each_btree_key_upto_continue(_trans, _iter, \
_end, _flags, _k, _do) …
#define for_each_btree_key_continue(_trans, _iter, _flags, _k, _do) …
#define for_each_btree_key_upto(_trans, _iter, _btree_id, \
_start, _end, _flags, _k, _do) …
#define for_each_btree_key(_trans, _iter, _btree_id, \
_start, _flags, _k, _do) …
#define for_each_btree_key_reverse(_trans, _iter, _btree_id, \
_start, _flags, _k, _do) …
#define for_each_btree_key_commit(_trans, _iter, _btree_id, \
_start, _iter_flags, _k, \
_disk_res, _journal_seq, _commit_flags,\
_do) …
#define for_each_btree_key_reverse_commit(_trans, _iter, _btree_id, \
_start, _iter_flags, _k, \
_disk_res, _journal_seq, _commit_flags,\
_do) …
#define for_each_btree_key_upto_commit(_trans, _iter, _btree_id, \
_start, _end, _iter_flags, _k, \
_disk_res, _journal_seq, _commit_flags,\
_do) …
struct bkey_s_c bch2_btree_iter_peek_and_restart_outlined(struct btree_iter *);
static inline struct bkey_s_c
__bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
struct btree_iter *iter, unsigned flags)
{ … }
#define for_each_btree_key_upto_norestart(_trans, _iter, _btree_id, \
_start, _end, _flags, _k, _ret) …
#define for_each_btree_key_upto_continue_norestart(_iter, _end, _flags, _k, _ret) …
#define for_each_btree_key_norestart(_trans, _iter, _btree_id, \
_start, _flags, _k, _ret) …
#define for_each_btree_key_continue_norestart(_iter, _flags, _k, _ret) …
#define drop_locks_do(_trans, _do) …
#define allocate_dropping_locks_errcode(_trans, _do) …
#define allocate_dropping_locks(_trans, _ret, _do) …
#define bch2_trans_run(_c, _do) …
void bch2_trans_updates_to_text(struct printbuf *, struct btree_trans *);
void bch2_btree_path_to_text(struct printbuf *, struct btree_trans *, btree_path_idx_t);
void bch2_trans_paths_to_text(struct printbuf *, struct btree_trans *);
void bch2_dump_trans_updates(struct btree_trans *);
void bch2_dump_trans_paths_updates(struct btree_trans *);
struct btree_trans *__bch2_trans_get(struct bch_fs *, unsigned);
void bch2_trans_put(struct btree_trans *);
bool bch2_current_has_btree_trans(struct bch_fs *);
extern const char *bch2_btree_transaction_fns[BCH_TRANSACTIONS_NR];
unsigned bch2_trans_get_fn_idx(const char *);
#define bch2_trans_get(_c) …
void bch2_btree_trans_to_text(struct printbuf *, struct btree_trans *);
void bch2_fs_btree_iter_exit(struct bch_fs *);
void bch2_fs_btree_iter_init_early(struct bch_fs *);
int bch2_fs_btree_iter_init(struct bch_fs *);
#endif