linux/fs/bcachefs/snapshot.h

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

enum bch_validate_flags;

void bch2_snapshot_tree_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
int bch2_snapshot_tree_invalid(struct bch_fs *, struct bkey_s_c,
			       enum bch_validate_flags, struct printbuf *);

#define bch2_bkey_ops_snapshot_tree

struct bkey_i_snapshot_tree *__bch2_snapshot_tree_create(struct btree_trans *);

int bch2_snapshot_tree_lookup(struct btree_trans *, u32, struct bch_snapshot_tree *);

void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
int bch2_snapshot_invalid(struct bch_fs *, struct bkey_s_c,
			  enum bch_validate_flags, struct printbuf *);
int bch2_mark_snapshot(struct btree_trans *, enum btree_id, unsigned,
		       struct bkey_s_c, struct bkey_s,
		       enum btree_iter_update_trigger_flags);

#define bch2_bkey_ops_snapshot

static inline struct snapshot_t *__snapshot_t(struct snapshot_table *t, u32 id)
{}

static inline const struct snapshot_t *snapshot_t(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_tree(struct bch_fs *c, u32 id)
{}

static inline u32 __bch2_snapshot_parent_early(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_parent_early(struct bch_fs *c, u32 id)
{}

static inline u32 __bch2_snapshot_parent(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_parent(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_nth_parent(struct bch_fs *c, u32 id, u32 n)
{}

u32 bch2_snapshot_skiplist_get(struct bch_fs *, u32);

static inline u32 bch2_snapshot_root(struct bch_fs *c, u32 id)
{}

static inline u32 __bch2_snapshot_equiv(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_equiv(struct bch_fs *c, u32 id)
{}

static inline int bch2_snapshot_is_internal_node(struct bch_fs *c, u32 id)
{}

static inline int bch2_snapshot_is_leaf(struct bch_fs *c, u32 id)
{}

static inline u32 bch2_snapshot_depth(struct bch_fs *c, u32 parent)
{}

bool __bch2_snapshot_is_ancestor(struct bch_fs *, u32, u32);

static inline bool bch2_snapshot_is_ancestor(struct bch_fs *c, u32 id, u32 ancestor)
{}

static inline bool bch2_snapshot_has_children(struct bch_fs *c, u32 id)
{}

static inline bool snapshot_list_has_id(snapshot_id_list *s, u32 id)
{}

static inline bool snapshot_list_has_ancestor(struct bch_fs *c, snapshot_id_list *s, u32 id)
{}

static inline int snapshot_list_add(struct bch_fs *c, snapshot_id_list *s, u32 id)
{}

static inline int snapshot_list_add_nodup(struct bch_fs *c, snapshot_id_list *s, u32 id)
{}

static inline int snapshot_list_merge(struct bch_fs *c, snapshot_id_list *dst, snapshot_id_list *src)
{}

int bch2_snapshot_lookup(struct btree_trans *trans, u32 id,
			 struct bch_snapshot *s);
int bch2_snapshot_get_subvol(struct btree_trans *, u32,
			     struct bch_subvolume *);

/* only exported for tests: */
int bch2_snapshot_node_create(struct btree_trans *, u32,
			      u32 *, u32 *, unsigned);

int bch2_check_snapshot_trees(struct bch_fs *);
int bch2_check_snapshots(struct bch_fs *);
int bch2_reconstruct_snapshots(struct bch_fs *);
int bch2_check_key_has_snapshot(struct btree_trans *, struct btree_iter *, struct bkey_s_c);

int bch2_snapshot_node_set_deleted(struct btree_trans *, u32);
void bch2_delete_dead_snapshots_work(struct work_struct *);

int __bch2_key_has_snapshot_overwrites(struct btree_trans *, enum btree_id, struct bpos);

static inline int bch2_key_has_snapshot_overwrites(struct btree_trans *trans,
					  enum btree_id id,
					  struct bpos pos)
{}

int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *, enum btree_id,
					  struct bkey_s_c, struct bpos *);

int bch2_snapshots_read(struct bch_fs *);
void bch2_fs_snapshots_exit(struct bch_fs *);

#endif /* _BCACHEFS_SNAPSHOT_H */