summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-16 20:36:26 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2021-12-25 17:37:12 -0500
commit6a0a48246e1baec687884fe1720715f155673f6b (patch)
tree21c02936f10c8bb1ca2e00240d4de9920ec7bfd3
parentd45807a9cf5bcf9b5ee47212039207e91d981253 (diff)
bcachefs: Sysfs internal/btree_transactions is now always enabled
This highly-useful debugging feature helps with debugging deadlocks, and it doesn't cost much, so let's have it always enabled. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/btree_iter.c13
-rw-r--r--fs/bcachefs/btree_types.h2
2 files changed, 1 insertions, 14 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index cbf7018d007c..bdbb90014b5c 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -377,19 +377,16 @@ bool __bch2_btree_node_lock(struct btree_trans *trans,
if (six_trylock_type(&b->c.lock, type))
return true;
-#ifdef CONFIG_BCACHEFS_DEBUG
trans->locking_path_idx = path->idx;
trans->locking_pos = pos;
trans->locking_btree_id = path->btree_id;
trans->locking_level = level;
trans->locking = b;
-#endif
ret = six_lock_type(&b->c.lock, type, should_sleep_fn, p) == 0;
-#ifdef CONFIG_BCACHEFS_DEBUG
trans->locking = NULL;
-#endif
+
if (ret)
bch2_time_stats_update(&trans->c->times[lock_to_time_stat(type)],
start_time);
@@ -2804,12 +2801,10 @@ void bch2_trans_init(struct btree_trans *trans, struct bch_fs *c,
trans->srcu_idx = srcu_read_lock(&c->btree_trans_barrier);
-#ifdef CONFIG_BCACHEFS_DEBUG
trans->pid = current->pid;
mutex_lock(&c->btree_trans_lock);
list_add(&trans->list, &c->btree_trans_list);
mutex_unlock(&c->btree_trans_lock);
-#endif
}
static void check_btree_paths_leaked(struct btree_trans *trans)
@@ -2848,11 +2843,9 @@ void bch2_trans_exit(struct btree_trans *trans)
check_btree_paths_leaked(trans);
-#ifdef CONFIG_BCACHEFS_DEBUG
mutex_lock(&c->btree_trans_lock);
list_del(&trans->list);
mutex_unlock(&c->btree_trans_lock);
-#endif
srcu_read_unlock(&c->btree_trans_barrier, trans->srcu_idx);
@@ -2896,7 +2889,6 @@ bch2_btree_path_node_to_text(struct printbuf *out,
bch2_bpos_to_text(out, btree_node_pos(_b, cached));
}
-#ifdef CONFIG_BCACHEFS_DEBUG
static bool trans_has_locks(struct btree_trans *trans)
{
struct btree_path *path;
@@ -2906,11 +2898,9 @@ static bool trans_has_locks(struct btree_trans *trans)
return true;
return false;
}
-#endif
void bch2_btree_trans_to_text(struct printbuf *out, struct bch_fs *c)
{
-#ifdef CONFIG_BCACHEFS_DEBUG
struct btree_trans *trans;
struct btree_path *path;
struct btree *b;
@@ -2964,7 +2954,6 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct bch_fs *c)
}
}
mutex_unlock(&c->btree_trans_lock);
-#endif
}
void bch2_fs_btree_iter_exit(struct bch_fs *c)
diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h
index 2c2e2f794b8f..22dbbe365bbe 100644
--- a/fs/bcachefs/btree_types.h
+++ b/fs/bcachefs/btree_types.h
@@ -366,7 +366,6 @@ struct btree_trans_commit_hook {
struct btree_trans {
struct bch_fs *c;
-#ifdef CONFIG_BCACHEFS_DEBUG
struct list_head list;
struct btree *locking;
unsigned locking_path_idx;
@@ -374,7 +373,6 @@ struct btree_trans {
u8 locking_btree_id;
u8 locking_level;
pid_t pid;
-#endif
unsigned long ip;
int srcu_idx;