btrfs: add dynamic debug support
authorJeff Mahoney <jeffm@suse.com>
Thu, 1 Sep 2016 03:55:33 +0000 (23:55 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 6 Sep 2016 17:16:36 +0000 (19:16 +0200)
We can re-use the dynamic debugging descriptor to make use of the dynamic
debugging mechanism but still use our own printk interface.

Defining the DEBUG macro works as it did before.  When it's defined,
all of the messages default to print.  We can also enable all debug
messages at boot or module-load time using the 'dyndbg' and
'btrfs.dyndbg' options.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h

index eff3993c77b333f875ade96769e6f6dad5b47143..abb274d7900e4a63804d0053f0510cfd8fc97384 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/workqueue.h>
 #include <linux/security.h>
 #include <linux/sizes.h>
+#include <linux/dynamic_debug.h>
 #include "extent_io.h"
 #include "extent_map.h"
 #include "async-thread.h"
@@ -3314,7 +3315,35 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
        btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args)
 #define btrfs_info_rl(fs_info, fmt, args...) \
        btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
-#ifdef DEBUG
+
+#if defined(CONFIG_DYNAMIC_DEBUG)
+#define btrfs_debug(fs_info, fmt, args...)                             \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk(fs_info, KERN_DEBUG fmt, ##args);          \
+} while (0)
+#define btrfs_debug_in_rcu(fs_info, fmt, args...)                      \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))                 \
+               btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args);   \
+} while (0)
+#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...)                   \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt,         \
+                                      ##args);\
+} while (0)
+#define btrfs_debug_rl(fs_info, fmt, args...)                          \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt,       \
+                                        ##args);                       \
+} while (0)
+#elif defined(DEBUG)
 #define btrfs_debug(fs_info, fmt, args...) \
        btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
This page took 0.026955 seconds and 5 git commands to generate.