]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: simplify internal btrfs_printk helpers
authorDavid Sterba <dsterba@suse.com>
Tue, 9 Dec 2025 17:10:30 +0000 (18:10 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:49:09 +0000 (07:49 +0100)
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 <dsterba@suse.com>
fs/btrfs/messages.h

index d8c0bd17dcdaf018ac4f444618b50fd53068cf86..7049976342a57ad204b6532da8c5c7e7f7fbd051 100644 (file)
@@ -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)