From c53d61e24086fc7893fa03b148f930c08bd3cd77 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 9 Dec 2025 18:10:30 +0100 Subject: [PATCH] btrfs: simplify internal btrfs_printk helpers The printk() can be compiled out depending on CONFIG_PRINTK, this is reflected in our helpers. The indirection is provided by btrfs_printk() used in the ratelimited and RCU wrapper macros. Drop the btrfs_printk() helper and define the ratelimit and RCU helpers directly when CONFIG_PRINTK is undefined. This will allow further changes to the _btrfs_printk() interface (which is internal), any message in other code should use the level-specific helpers. Signed-off-by: David Sterba --- fs/btrfs/messages.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h index d8c0bd17dcdaf..7049976342a57 100644 --- a/fs/btrfs/messages.h +++ b/fs/btrfs/messages.h @@ -23,9 +23,6 @@ void btrfs_no_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) #ifdef CONFIG_PRINTK -#define btrfs_printk(fs_info, fmt, args...) \ - _btrfs_printk(fs_info, fmt, ##args) - __printf(2, 3) __cold void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...); @@ -34,6 +31,13 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...); #define btrfs_printk(fs_info, fmt, args...) \ btrfs_no_printk(fs_info, fmt, ##args) + +#define btrfs_printk_in_rcu(fs_info, fmt, args...) \ + btrfs_no_printk(fs_info, fmt, ##args) + +#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_no_printk(fs_info, fmt, ##args) + #endif /* @@ -78,10 +82,12 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...); #define btrfs_debug_rl(fs_info, fmt, args...) do { (void)(fs_info); } while(0) #endif +#ifdef CONFIG_PRINTK + #define btrfs_printk_in_rcu(fs_info, fmt, args...) \ do { \ rcu_read_lock(); \ - btrfs_printk(fs_info, fmt, ##args); \ + _btrfs_printk(fs_info, fmt, ##args); \ rcu_read_unlock(); \ } while (0) @@ -93,10 +99,12 @@ do { \ \ rcu_read_lock(); \ if (__ratelimit(&_rs)) \ - btrfs_printk(fs_info, fmt, ##args); \ + _btrfs_printk(fs_info, fmt, ##args); \ rcu_read_unlock(); \ } while (0) +#endif + #ifdef CONFIG_BTRFS_ASSERT __printf(1, 2) -- 2.47.3