#include "bcachefs.h"
#include "btree_locking.h"
#include "btree_types.h"
static struct lock_class_key bch2_btree_node_lock_key;
void bch2_btree_lock_init(struct btree_bkey_cached_common *b,
enum six_lock_init_flags flags)
{ … }
struct six_lock_count bch2_btree_node_lock_counts(struct btree_trans *trans,
struct btree_path *skip,
struct btree_bkey_cached_common *b,
unsigned level)
{ … }
void bch2_btree_node_unlock_write(struct btree_trans *trans,
struct btree_path *path, struct btree *b)
{ … }
struct trans_waiting_for_lock { … };
struct lock_graph { … };
static noinline void print_cycle(struct printbuf *out, struct lock_graph *g)
{ … }
static noinline void print_chain(struct printbuf *out, struct lock_graph *g)
{ … }
static void lock_graph_up(struct lock_graph *g)
{ … }
static noinline void lock_graph_pop_all(struct lock_graph *g)
{ … }
static void __lock_graph_down(struct lock_graph *g, struct btree_trans *trans)
{ … }
static void lock_graph_down(struct lock_graph *g, struct btree_trans *trans)
{ … }
static bool lock_graph_remove_non_waiters(struct lock_graph *g)
{ … }
static void trace_would_deadlock(struct lock_graph *g, struct btree_trans *trans)
{ … }
static int abort_lock(struct lock_graph *g, struct trans_waiting_for_lock *i)
{ … }
static int btree_trans_abort_preference(struct btree_trans *trans)
{ … }
static noinline int break_cycle(struct lock_graph *g, struct printbuf *cycle)
{ … }
static int lock_graph_descend(struct lock_graph *g, struct btree_trans *trans,
struct printbuf *cycle)
{ … }
static bool lock_type_conflicts(enum six_lock_type t1, enum six_lock_type t2)
{ … }
int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle)
{ … }
int bch2_six_check_for_deadlock(struct six_lock *lock, void *p)
{ … }
int __bch2_btree_node_lock_write(struct btree_trans *trans, struct btree_path *path,
struct btree_bkey_cached_common *b,
bool lock_may_not_fail)
{ … }
void bch2_btree_node_lock_write_nofail(struct btree_trans *trans,
struct btree_path *path,
struct btree_bkey_cached_common *b)
{ … }
static inline bool btree_path_get_locks(struct btree_trans *trans,
struct btree_path *path,
bool upgrade,
struct get_locks_fail *f)
{ … }
bool __bch2_btree_node_relock(struct btree_trans *trans,
struct btree_path *path, unsigned level,
bool trace)
{ … }
bool bch2_btree_node_upgrade(struct btree_trans *trans,
struct btree_path *path, unsigned level)
{ … }
int bch2_btree_path_relock_intent(struct btree_trans *trans,
struct btree_path *path)
{ … }
__flatten
bool bch2_btree_path_relock_norestart(struct btree_trans *trans, struct btree_path *path)
{ … }
int __bch2_btree_path_relock(struct btree_trans *trans,
struct btree_path *path, unsigned long trace_ip)
{ … }
bool bch2_btree_path_upgrade_noupgrade_sibs(struct btree_trans *trans,
struct btree_path *path,
unsigned new_locks_want,
struct get_locks_fail *f)
{ … }
bool __bch2_btree_path_upgrade(struct btree_trans *trans,
struct btree_path *path,
unsigned new_locks_want,
struct get_locks_fail *f)
{ … }
void __bch2_btree_path_downgrade(struct btree_trans *trans,
struct btree_path *path,
unsigned new_locks_want)
{ … }
void bch2_trans_downgrade(struct btree_trans *trans)
{ … }
static inline void __bch2_trans_unlock(struct btree_trans *trans)
{ … }
static noinline __cold int bch2_trans_relock_fail(struct btree_trans *trans, struct btree_path *path,
struct get_locks_fail *f, bool trace)
{ … }
static inline int __bch2_trans_relock(struct btree_trans *trans, bool trace)
{ … }
int bch2_trans_relock(struct btree_trans *trans)
{ … }
int bch2_trans_relock_notrace(struct btree_trans *trans)
{ … }
void bch2_trans_unlock_noassert(struct btree_trans *trans)
{ … }
void bch2_trans_unlock(struct btree_trans *trans)
{ … }
void bch2_trans_unlock_long(struct btree_trans *trans)
{ … }
int __bch2_trans_mutex_lock(struct btree_trans *trans,
struct mutex *lock)
{ … }
#ifdef CONFIG_BCACHEFS_DEBUG
void bch2_btree_path_verify_locks(struct btree_path *path)
{ … }
static bool bch2_trans_locked(struct btree_trans *trans)
{ … }
void bch2_trans_verify_locks(struct btree_trans *trans)
{ … }
#endif