]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Split out CONFIG_BCACHEFS_DEBUG_TRANSACTIONS
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 17 Dec 2021 01:36:26 +0000 (20:36 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:19 +0000 (17:09 -0400)
This puts the btree_transactions sysfs/debugfs file behind a separate
config option - it's highly useful, but not cheap enough to enable
permenantly.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/Kconfig
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_types.h

index bfe7e6c9c0649df42d26542cc2d0085eb782a1aa..d2eb65e9032b14e891925e591b3d78a5273c14e5 100644 (file)
@@ -35,6 +35,15 @@ config BCACHEFS_POSIX_ACL
        depends on BCACHEFS_FS
        select FS_POSIX_ACL
 
+config BCACHEFS_DEBUG_TRANSACTIONS
+       bool "bcachefs runtime info"
+       depends on BCACHEFS_FS
+       default y
+       help
+       This makes the list of running btree transactions available in debugfs.
+
+       This is a highly useful debugging feature but does add a small amount of overhead.
+
 config BCACHEFS_DEBUG
        bool "bcachefs debugging"
        depends on BCACHEFS_FS
index 1ad81cad36f1895503bf1191d05584d84c493c13..cc1dd788cdd5719de096b7d066fd70b41f574dc1 100644 (file)
@@ -364,19 +364,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);
@@ -2822,12 +2819,12 @@ 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
+       if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG_TRANSACTIONS)) {
+               trans->pid = current->pid;
+               mutex_lock(&c->btree_trans_lock);
+               list_add(&trans->list, &c->btree_trans_list);
+               mutex_unlock(&c->btree_trans_lock);
+       }
 }
 
 static void check_btree_paths_leaked(struct btree_trans *trans)
@@ -2866,11 +2863,11 @@ 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
+       if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG_TRANSACTIONS)) {
+               mutex_lock(&c->btree_trans_lock);
+               list_del(&trans->list);
+               mutex_unlock(&c->btree_trans_lock);
+       }
 
        srcu_read_unlock(&c->btree_trans_barrier, trans->srcu_idx);
 
@@ -2914,7 +2911,7 @@ bch2_btree_path_node_to_text(struct printbuf *out,
        bch2_bpos_to_text(out, btree_node_pos(_b, cached));
 }
 
-#ifdef CONFIG_BCACHEFS_DEBUG
+#ifdef CONFIG_BCACHEFS_DEBUG_TRANSACTIONS
 static bool trans_has_locks(struct btree_trans *trans)
 {
        struct btree_path *path;
@@ -2928,7 +2925,7 @@ static bool trans_has_locks(struct btree_trans *trans)
 
 void bch2_btree_trans_to_text(struct printbuf *out, struct bch_fs *c)
 {
-#ifdef CONFIG_BCACHEFS_DEBUG
+#ifdef CONFIG_BCACHEFS_DEBUG_TRANSACTIONS
        struct btree_trans *trans;
        struct btree_path *path;
        struct btree *b;
index 25b0df22366bfd0752fa93763a1918eb7fc2332e..e1b417df4b73aa3e83ec076b67ed90a0f2091f43 100644 (file)
@@ -363,7 +363,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;
@@ -371,7 +370,6 @@ struct btree_trans {
        u8                      locking_btree_id;
        u8                      locking_level;
        pid_t                   pid;
-#endif
        unsigned long           ip;
        int                     srcu_idx;