linux/fs/bcachefs/btree_update_interior.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _BCACHEFS_BTREE_UPDATE_INTERIOR_H
#define _BCACHEFS_BTREE_UPDATE_INTERIOR_H

#include "btree_cache.h"
#include "btree_locking.h"
#include "btree_update.h"

#define BTREE_UPDATE_NODES_MAX

#define BTREE_UPDATE_JOURNAL_RES

int bch2_btree_node_check_topology(struct btree_trans *, struct btree *);

#define BTREE_UPDATE_MODES()

enum btree_update_mode {};

/*
 * Tracks an in progress split/rewrite of a btree node and the update to the
 * parent node:
 *
 * When we split/rewrite a node, we do all the updates in memory without
 * waiting for any writes to complete - we allocate the new node(s) and update
 * the parent node, possibly recursively up to the root.
 *
 * The end result is that we have one or more new nodes being written -
 * possibly several, if there were multiple splits - and then a write (updating
 * an interior node) which will make all these new nodes visible.
 *
 * Additionally, as we split/rewrite nodes we free the old nodes - but the old
 * nodes can't be freed (their space on disk can't be reclaimed) until the
 * update to the interior node that makes the new node visible completes -
 * until then, the old nodes are still reachable on disk.
 *
 */
struct btree_update {};

struct btree *__bch2_btree_node_alloc_replacement(struct btree_update *,
						  struct btree_trans *,
						  struct btree *,
						  struct bkey_format);

int bch2_btree_split_leaf(struct btree_trans *, btree_path_idx_t, unsigned);

int bch2_btree_increase_depth(struct btree_trans *, btree_path_idx_t, unsigned);

int __bch2_foreground_maybe_merge(struct btree_trans *, btree_path_idx_t,
				  unsigned, unsigned, enum btree_node_sibling);

static inline int bch2_foreground_maybe_merge_sibling(struct btree_trans *trans,
					btree_path_idx_t path_idx,
					unsigned level, unsigned flags,
					enum btree_node_sibling sib)
{}

static inline int bch2_foreground_maybe_merge(struct btree_trans *trans,
					      btree_path_idx_t path,
					      unsigned level,
					      unsigned flags)
{}

int bch2_btree_node_rewrite(struct btree_trans *, struct btree_iter *,
			    struct btree *, unsigned);
void bch2_btree_node_rewrite_async(struct bch_fs *, struct btree *);
int bch2_btree_node_update_key(struct btree_trans *, struct btree_iter *,
			       struct btree *, struct bkey_i *,
			       unsigned, bool);
int bch2_btree_node_update_key_get_iter(struct btree_trans *, struct btree *,
					struct bkey_i *, unsigned, bool);

void bch2_btree_set_root_for_read(struct bch_fs *, struct btree *);

int bch2_btree_root_alloc_fake_trans(struct btree_trans *, enum btree_id, unsigned);
void bch2_btree_root_alloc_fake(struct bch_fs *, enum btree_id, unsigned);

static inline unsigned btree_update_reserve_required(struct bch_fs *c,
						     struct btree *b)
{}

static inline void btree_node_reset_sib_u64s(struct btree *b)
{}

static inline void *btree_data_end(struct btree *b)
{}

static inline struct bkey_packed *unwritten_whiteouts_start(struct btree *b)
{}

static inline struct bkey_packed *unwritten_whiteouts_end(struct btree *b)
{}

static inline void *write_block(struct btree *b)
{}

static inline bool __btree_addr_written(struct btree *b, void *p)
{}

static inline bool bset_written(struct btree *b, struct bset *i)
{}

static inline bool bkey_written(struct btree *b, struct bkey_packed *k)
{}

static inline ssize_t __bch2_btree_u64s_remaining(struct btree *b, void *end)
{}

static inline size_t bch2_btree_keys_u64s_remaining(struct btree *b)
{}

#define BTREE_WRITE_SET_U64s_BITS

static inline unsigned btree_write_set_buffer(struct btree *b)
{}

static inline struct btree_node_entry *want_new_bset(struct bch_fs *c, struct btree *b)
{}

static inline void push_whiteout(struct btree *b, struct bpos pos)
{}

/*
 * write lock must be held on @b (else the dirty bset that we were going to
 * insert into could be written out from under us)
 */
static inline bool bch2_btree_node_insert_fits(struct btree *b, unsigned u64s)
{}

void bch2_btree_updates_to_text(struct printbuf *, struct bch_fs *);

bool bch2_btree_interior_updates_flush(struct bch_fs *);

void bch2_journal_entry_to_btree_root(struct bch_fs *, struct jset_entry *);
struct jset_entry *bch2_btree_roots_to_journal_entries(struct bch_fs *,
					struct jset_entry *, unsigned long);

void bch2_do_pending_node_rewrites(struct bch_fs *);
void bch2_free_pending_node_rewrites(struct bch_fs *);

void bch2_btree_reserve_cache_to_text(struct printbuf *, struct bch_fs *);

void bch2_fs_btree_interior_update_exit(struct bch_fs *);
void bch2_fs_btree_interior_update_init_early(struct bch_fs *);
int bch2_fs_btree_interior_update_init(struct bch_fs *);

#endif /* _BCACHEFS_BTREE_UPDATE_INTERIOR_H */