]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: move ref-verify under CONFIG_BTRFS_DEBUG
authorLeo Martins <loemra.dev@gmail.com>
Tue, 12 Aug 2025 23:28:27 +0000 (16:28 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 22 Sep 2025 08:54:32 +0000 (10:54 +0200)
Remove CONFIG_BTRFS_FS_REF_VERIFY Kconfig and add it as part of
CONFIG_BTRFS_DEBUG. This should not be impactful to the performance
of debug. The struct btrfs_ref takes an additional u64, btrfs_fs_info
takes an additional spinlock_t and rb_root. All of the ref_verify logic
is still protected by a mount option.

Signed-off-by: Leo Martins <loemra.dev@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/Kconfig
fs/btrfs/Makefile
fs/btrfs/delayed-ref.c
fs/btrfs/delayed-ref.h
fs/btrfs/fs.h
fs/btrfs/ref-verify.h
fs/btrfs/super.c

index ea95c90c847489a475f0ef6494dcfece92718d74..86d791210c393fe604d96faff9d1b0e383aec78a 100644 (file)
@@ -117,14 +117,3 @@ config BTRFS_EXPERIMENTAL
          - large folio support
 
          If unsure, say N.
-
-config BTRFS_FS_REF_VERIFY
-       bool "Btrfs with the ref verify tool compiled in"
-       depends on BTRFS_FS
-       default n
-       help
-         Enable run-time extent reference verification instrumentation.  This
-         is meant to be used by btrfs developers for tracking down extent
-         reference problems or verifying they didn't break something.
-
-         If unsure, say N.
index 2d5f0482678b827f6dc4ece715f771d7470b2118..743d7677b175dfd4d6a3fcddb7ff75273a9e177d 100644 (file)
@@ -36,7 +36,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
           lru_cache.o raid-stripe-tree.o fiemap.o direct-io.o
 
 btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
-btrfs-$(CONFIG_BTRFS_FS_REF_VERIFY) += ref-verify.o
+btrfs-$(CONFIG_BTRFS_DEBUG) += ref-verify.o
 btrfs-$(CONFIG_BLK_DEV_ZONED) += zoned.o
 btrfs-$(CONFIG_FS_VERITY) += verity.o
 
index ca382c5b186f47701b6820fadc74dee97142aa99..5d8361bac497fcb4d35a5414e5bc8dc5c55f5ddc 100644 (file)
@@ -952,7 +952,7 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
 void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
                         bool skip_qgroup)
 {
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
+#ifdef CONFIG_BTRFS_DEBUG
        /* If @real_root not set, use @root as fallback */
        generic_ref->real_root = mod_root ?: generic_ref->ref_root;
 #endif
@@ -969,7 +969,7 @@ void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
 void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ino, u64 offset,
                         u64 mod_root, bool skip_qgroup)
 {
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
+#ifdef CONFIG_BTRFS_DEBUG
        /* If @real_root not set, use @root as fallback */
        generic_ref->real_root = mod_root ?: generic_ref->ref_root;
 #endif
index 552ec4fa645d4b2ac9203086986d09cd527fe1c6..5ce940532144521bef645d9548310b29e04207ea 100644 (file)
@@ -276,10 +276,6 @@ struct btrfs_ref {
         */
        bool skip_qgroup;
 
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
-       /* Through which root is this modification. */
-       u64 real_root;
-#endif
        u64 bytenr;
        u64 num_bytes;
        u64 owning_root;
@@ -296,6 +292,11 @@ struct btrfs_ref {
                struct btrfs_data_ref data_ref;
                struct btrfs_tree_ref tree_ref;
        };
+
+#ifdef CONFIG_BTRFS_DEBUG
+       /* Through which root is this modification. */
+       u64 real_root;
+#endif
 };
 
 extern struct kmem_cache *btrfs_delayed_ref_head_cachep;
index f0b090d4ac0466fbd2caa01526ca61274867be7f..66e08e20ff5acc8c1c90f12ea110e97d2327f2e9 100644 (file)
@@ -880,12 +880,10 @@ struct btrfs_fs_info {
        struct lockdep_map btrfs_trans_pending_ordered_map;
        struct lockdep_map btrfs_ordered_extent_map;
 
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
+#ifdef CONFIG_BTRFS_DEBUG
        spinlock_t ref_verify_lock;
        struct rb_root block_tree;
-#endif
 
-#ifdef CONFIG_BTRFS_DEBUG
        struct kobject *debug_kobj;
        struct list_head allocated_roots;
 
index 559bd25a2b7ab1816233cd111317774e68f64391..1ce544d53cc569940985d4a556aca2cecdee037e 100644 (file)
@@ -12,7 +12,7 @@
 struct btrfs_fs_info;
 struct btrfs_ref;
 
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
+#ifdef CONFIG_BTRFS_DEBUG
 
 #include <linux/spinlock.h>
 
@@ -53,6 +53,6 @@ static inline void btrfs_init_ref_verify(struct btrfs_fs_info *fs_info)
 {
 }
 
-#endif /* CONFIG_BTRFS_FS_REF_VERIFY */
+#endif /* CONFIG_BTRFS_DEBUG */
 
 #endif
index ee2418bb2efd0b4c8a4227d5c0c3a923615acbde..3bc19989e7fbf3607411257dbafd5ac639c4bd58 100644 (file)
@@ -133,8 +133,6 @@ enum {
        Opt_enospc_debug,
 #ifdef CONFIG_BTRFS_DEBUG
        Opt_fragment, Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all,
-#endif
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
        Opt_ref_verify,
 #endif
        Opt_err,
@@ -257,8 +255,6 @@ static const struct fs_parameter_spec btrfs_fs_parameters[] = {
        fsparam_flag_no("enospc_debug", Opt_enospc_debug),
 #ifdef CONFIG_BTRFS_DEBUG
        fsparam_enum("fragment", Opt_fragment, btrfs_parameter_fragment),
-#endif
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
        fsparam_flag("ref_verify", Opt_ref_verify),
 #endif
        {}
@@ -646,8 +642,6 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
                        return -EINVAL;
                }
                break;
-#endif
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
        case Opt_ref_verify:
                btrfs_set_opt(ctx->mount_opt, REF_VERIFY);
                break;
@@ -2483,9 +2477,6 @@ static int __init btrfs_print_mod_info(void)
 #ifdef CONFIG_BTRFS_ASSERT
                        ", assert=on"
 #endif
-#ifdef CONFIG_BTRFS_FS_REF_VERIFY
-                       ", ref-verify=on"
-#endif
 #ifdef CONFIG_BLK_DEV_ZONED
                        ", zoned=yes"
 #else