btrfs: add debug build only WARN
authorDavid Sterba <dsterba@suse.com>
Thu, 17 Apr 2025 09:17:01 +0000 (11:17 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:47 +0000 (14:30 +0200)
Add conditional WARN() wrapper that's enabled only in debug build. It
should be used for unexpected conditions that should be noisy.  Use it
instead of ASSERT(0). As it will not lead to BUG() make sure that
continuing is still possible, e.g. the error is handled anyway.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/messages.h

index d4e85485d824d91e925f3416645d88964b35b5ad..6abf81bb00c2fe24059c776cbe4377c88bab2a21 100644 (file)
@@ -243,6 +243,13 @@ do {                                                                               \
 #define ASSERT(cond, args...)                  (void)(cond)
 #endif
 
+#ifdef CONFIG_BTRFS_DEBUG
+/* Verbose warning only under debug build. */
+#define DEBUG_WARN(args...)                    WARN(1, KERN_ERR args)
+#else
+#define DEBUG_WARN(...)                                do {} while(0)
+#endif
+
 __printf(5, 6)
 __cold
 void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,