summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2025-04-17 11:17:01 +0200
committerDavid Sterba <dsterba@suse.com>2025-05-15 14:30:47 +0200
commit3db15c6ca6feb2c5000a1cbb39c33866e0349abd (patch)
treeac3182235a80a475823adfcf90c5f6fa352f5c5a
parent94cb8d7144340e760644b2f104586da4717d1f32 (diff)
btrfs: add debug build only WARN
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>
-rw-r--r--fs/btrfs/messages.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index d4e85485d824..6abf81bb00c2 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -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,