All of lore.kernel.org
 help / color / mirror / Atom feed
From: jeffm@suse.com
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 1/5] btrfs: add dynamic debug support
Date: Tue, 20 Sep 2016 10:04:59 -0400	[thread overview]
Message-ID: <1474380303-25995-2-git-send-email-jeffm@suse.com> (raw)
In-Reply-To: <1474380303-25995-1-git-send-email-jeffm@suse.com>

From: Jeff Mahoney <jeffm@suse.com>

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>

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 33fe035..9267436 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -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"
@@ -3315,7 +3316,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...) \
-- 
2.7.1


  reply	other threads:[~2016-09-20 14:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 14:04 [PATCH 0/5] btrfs: printing cleanup patchset jeffm
2016-09-20 14:04 ` jeffm [this message]
2016-09-20 14:05 ` [PATCH 2/5] btrfs: unsplit printed strings jeffm
2016-09-20 14:05 ` [PATCH 3/5] btrfs: convert printk(KERN_* to use pr_* calls jeffm
2016-09-20 14:05 ` [PATCH 4/5] btrfs: convert pr_* to btrfs_* where possible jeffm
2016-09-21 15:36   ` David Sterba
2016-09-23 12:37   ` David Sterba
2016-09-20 14:05 ` [PATCH 5/5] btrfs: convert send's verbose_printk to btrfs_debug jeffm
2016-09-21 15:43 ` [PATCH] btrfs: silence compiler warning when fs_info is not used David Sterba
2016-09-21 15:47   ` Jeff Mahoney
2016-09-21 16:16     ` Jeff Mahoney
2016-09-21 15:46 ` [PATCH 0/5] btrfs: printing cleanup patchset David Sterba
2016-09-21 16:17 ` [PATCH] btrfs: btrfs_debug should consume fs_info when DEBUG is not defined Jeff Mahoney
2016-09-22 14:43   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474380303-25995-2-git-send-email-jeffm@suse.com \
    --to=jeffm@suse.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.