#ifndef _BCACHEFS_BTREE_CACHE_H
#define _BCACHEFS_BTREE_CACHE_H
#include "bcachefs.h"
#include "btree_types.h"
#include "bkey_methods.h"
extern const char * const bch2_btree_node_flags[];
struct btree_iter;
void bch2_recalc_btree_reserve(struct bch_fs *);
void bch2_btree_node_hash_remove(struct btree_cache *, struct btree *);
int __bch2_btree_node_hash_insert(struct btree_cache *, struct btree *);
int bch2_btree_node_hash_insert(struct btree_cache *, struct btree *,
unsigned, enum btree_id);
void bch2_btree_node_update_key_early(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, struct bkey_i *);
void bch2_btree_cache_cannibalize_unlock(struct btree_trans *);
int bch2_btree_cache_cannibalize_lock(struct btree_trans *, struct closure *);
struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *);
struct btree *bch2_btree_node_mem_alloc(struct btree_trans *, bool);
struct btree *bch2_btree_node_get(struct btree_trans *, struct btree_path *,
const struct bkey_i *, unsigned,
enum six_lock_type, unsigned long);
struct btree *bch2_btree_node_get_noiter(struct btree_trans *, const struct bkey_i *,
enum btree_id, unsigned, bool);
int bch2_btree_node_prefetch(struct btree_trans *, struct btree_path *,
const struct bkey_i *, enum btree_id, unsigned);
void bch2_btree_node_evict(struct btree_trans *, const struct bkey_i *);
void bch2_fs_btree_cache_exit(struct bch_fs *);
int bch2_fs_btree_cache_init(struct bch_fs *);
void bch2_fs_btree_cache_init_early(struct btree_cache *);
static inline u64 btree_ptr_hash_val(const struct bkey_i *k)
{ … }
static inline struct btree *btree_node_mem_ptr(const struct bkey_i *k)
{ … }
static inline bool btree_node_hashed(struct btree *b)
{ … }
#define for_each_cached_btree(_b, _c, _tbl, _iter, _pos) …
static inline size_t btree_buf_bytes(const struct btree *b)
{ … }
static inline size_t btree_buf_max_u64s(const struct btree *b)
{ … }
static inline size_t btree_max_u64s(const struct bch_fs *c)
{ … }
static inline size_t btree_sectors(const struct bch_fs *c)
{ … }
static inline unsigned btree_blocks(const struct bch_fs *c)
{ … }
#define BTREE_SPLIT_THRESHOLD(c) …
#define BTREE_FOREGROUND_MERGE_THRESHOLD(c) …
#define BTREE_FOREGROUND_MERGE_HYSTERESIS(c) …
static inline unsigned btree_id_nr_alive(struct bch_fs *c)
{ … }
static inline struct btree_root *bch2_btree_id_root(struct bch_fs *c, unsigned id)
{ … }
static inline struct btree *btree_node_root(struct bch_fs *c, struct btree *b)
{ … }
const char *bch2_btree_id_str(enum btree_id);
void bch2_btree_id_to_text(struct printbuf *, enum btree_id);
void bch2_btree_pos_to_text(struct printbuf *, struct bch_fs *, const struct btree *);
void bch2_btree_node_to_text(struct printbuf *, struct bch_fs *, const struct btree *);
void bch2_btree_cache_to_text(struct printbuf *, const struct btree_cache *);
#endif