linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] xfs: support debug mode with assert warnings
@ 2017-04-28 17:29 Brian Foster
  2017-05-02  7:37 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Foster @ 2017-04-28 17:29 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---

Hi all,

Every now and then I find myself wanting to enable DEBUG mode code
without having to BUG the kernel every time an assert fails. Currently,
I end up just commenting out the BUG() call from assfail(). Any thoughts
on something like the below to update our configuration to support the
ability to enable debug mode with assert warnings?

While this appears as a new option in Kconfig, it just reuses the
existing XFS_WARN definition to convert asserts into warnings regardless
of whether debug mode is enabled or not. There are probably multiple
other ways to do something like this (e.g., a Kconfig 'choice' selection
for various XFS debug modes, dropping the BUG() entirely, etc.).
Thoughts?

Brian

 fs/xfs/Kconfig     |  9 +++++++++
 fs/xfs/xfs_linux.h | 32 +++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig
index 35faf12..db6d830 100644
--- a/fs/xfs/Kconfig
+++ b/fs/xfs/Kconfig
@@ -96,3 +96,12 @@ config XFS_DEBUG
 	  not useful unless you are debugging a particular problem.
 
 	  Say N unless you are an XFS developer, or you play one on TV.
+
+config XFS_WARN
+	bool "Non-fatal Asserts"
+	default n
+	depends on XFS_FS && XFS_DEBUG
+	help
+	  Say Y here to convert DEBUG mode ASSERT failures into warnings.
+	  Otherwise, ASSERT failures are considered fatal errors and BUG the
+	  kernel.
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 044fb0e..3432863 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -245,37 +245,43 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
 	return x;
 }
 
+/*
+ * ASSERT() definitions
+ */
 #define ASSERT_ALWAYS(expr)	\
 	(likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
 
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(XFS_WARN)
+
 #define ASSERT(expr)	\
 	(likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
 
-#ifndef STATIC
-# define STATIC noinline
-#endif
-
-#else	/* !DEBUG */
-
-#ifdef XFS_WARN
+#elif defined(XFS_WARN)
 
 #define ASSERT(expr)	\
 	(likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__))
 
-#ifndef STATIC
-# define STATIC static noinline
+#else
+
+#define ASSERT(expr)	((void)0)
+
 #endif
 
-#else	/* !DEBUG && !XFS_WARN */
+/*
+ * STATIC definitions
+ */
+#ifdef DEBUG
+
+#ifndef STATIC
+# define STATIC noinline
+#endif
 
-#define ASSERT(expr)	((void)0)
+#else	/* !DEBUG */
 
 #ifndef STATIC
 # define STATIC static noinline
 #endif
 
-#endif /* XFS_WARN */
 #endif /* DEBUG */
 
 #ifdef CONFIG_XFS_RT
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-04 16:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28 17:29 [PATCH RFC] xfs: support debug mode with assert warnings Brian Foster
2017-05-02  7:37 ` Christoph Hellwig
2017-05-02 12:14   ` Brian Foster
2017-05-04 11:57     ` Christoph Hellwig
2017-05-04 12:44       ` Brian Foster
2017-05-04 16:41         ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).