#include "bcachefs.h"
#include "bbpos.h"
#include "alloc_background.h"
#include "backpointers.h"
#include "bkey_buf.h"
#include "btree_cache.h"
#include "btree_update.h"
#include "btree_update_interior.h"
#include "btree_write_buffer.h"
#include "checksum.h"
#include "error.h"
#include <linux/mm.h>
static bool extent_matches_bp(struct bch_fs *c,
enum btree_id btree_id, unsigned level,
struct bkey_s_c k,
struct bpos bucket,
struct bch_backpointer bp)
{ … }
int bch2_backpointer_invalid(struct bch_fs *c, struct bkey_s_c k,
enum bch_validate_flags flags,
struct printbuf *err)
{ … }
void bch2_backpointer_to_text(struct printbuf *out, const struct bch_backpointer *bp)
{ … }
void bch2_backpointer_k_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c k)
{ … }
void bch2_backpointer_swab(struct bkey_s k)
{ … }
static noinline int backpointer_mod_err(struct btree_trans *trans,
struct bch_backpointer bp,
struct bkey_s_c bp_k,
struct bkey_s_c orig_k,
bool insert)
{ … }
int bch2_bucket_backpointer_mod_nowritebuffer(struct btree_trans *trans,
struct bch_dev *ca,
struct bpos bucket,
struct bch_backpointer bp,
struct bkey_s_c orig_k,
bool insert)
{ … }
int bch2_get_next_backpointer(struct btree_trans *trans,
struct bch_dev *ca,
struct bpos bucket, int gen,
struct bpos *bp_pos,
struct bch_backpointer *bp,
unsigned iter_flags)
{ … }
static void backpointer_not_found(struct btree_trans *trans,
struct bpos bp_pos,
struct bch_backpointer bp,
struct bkey_s_c k)
{ … }
struct bkey_s_c bch2_backpointer_get_key(struct btree_trans *trans,
struct btree_iter *iter,
struct bpos bp_pos,
struct bch_backpointer bp,
unsigned iter_flags)
{ … }
struct btree *bch2_backpointer_get_node(struct btree_trans *trans,
struct btree_iter *iter,
struct bpos bp_pos,
struct bch_backpointer bp)
{ … }
static int bch2_check_btree_backpointer(struct btree_trans *trans, struct btree_iter *bp_iter,
struct bkey_s_c k)
{ … }
int bch2_check_btree_backpointers(struct bch_fs *c)
{ … }
struct extents_to_bp_state { … };
static int drop_dev_and_update(struct btree_trans *trans, enum btree_id btree,
struct bkey_s_c extent, unsigned dev)
{ … }
static int check_extent_checksum(struct btree_trans *trans,
enum btree_id btree, struct bkey_s_c extent,
enum btree_id o_btree, struct bkey_s_c extent2, unsigned dev)
{ … }
static int check_bp_exists(struct btree_trans *trans,
struct extents_to_bp_state *s,
struct bpos bucket,
struct bch_backpointer bp,
struct bkey_s_c orig_k)
{ … }
static int check_extent_to_backpointers(struct btree_trans *trans,
struct extents_to_bp_state *s,
enum btree_id btree, unsigned level,
struct bkey_s_c k)
{ … }
static int check_btree_root_to_backpointers(struct btree_trans *trans,
struct extents_to_bp_state *s,
enum btree_id btree_id,
int *level)
{ … }
static inline struct bbpos bp_to_bbpos(struct bch_backpointer bp)
{ … }
static u64 mem_may_pin_bytes(struct bch_fs *c)
{ … }
static size_t btree_nodes_fit_in_ram(struct bch_fs *c)
{ … }
static int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
u64 btree_leaf_mask,
u64 btree_interior_mask,
struct bbpos start, struct bbpos *end)
{ … }
static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
struct extents_to_bp_state *s)
{ … }
int bch2_check_extents_to_backpointers(struct bch_fs *c)
{ … }
static int check_one_backpointer(struct btree_trans *trans,
struct bbpos start,
struct bbpos end,
struct bkey_s_c_backpointer bp,
struct bkey_buf *last_flushed)
{ … }
static int bch2_check_backpointers_to_extents_pass(struct btree_trans *trans,
struct bbpos start,
struct bbpos end)
{ … }
int bch2_check_backpointers_to_extents(struct bch_fs *c)
{ … }