btrfs: switch all message helpers to be RCU safe
authorDavid Sterba <dsterba@suse.com>
Mon, 9 Jun 2025 17:09:24 +0000 (19:09 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:56:38 +0000 (23:56 +0200)
We have two versions of message helpers, one that provides RCU
protection around the call in case we need to dereference device name.
As messages are not performance critical we can set up the RCU
protection for all of them and drop the distinction for those where
device name is needed. This will lead to further simplifications.

Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/messages.h

index f6b3989939b56f3e37ec84f7e6f744cdc746b480..fe9a92da6b1439b0a6df766c4a8a05c2fe60cad0 100644 (file)
@@ -37,14 +37,17 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
        btrfs_no_printk(fs_info, fmt, ##args)
 #endif
 
+/*
+ * Print a message with filesystem info, enclosed in RCU protection.
+ */
 #define btrfs_crit(fs_info, fmt, args...) \
-       btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
+       btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
 #define btrfs_err(fs_info, fmt, args...) \
-       btrfs_printk(fs_info, KERN_ERR fmt, ##args)
+       btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
 #define btrfs_warn(fs_info, fmt, args...) \
-       btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
+       btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
 #define btrfs_info(fs_info, fmt, args...) \
-       btrfs_printk(fs_info, KERN_INFO fmt, ##args)
+       btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
 
 /*
  * Wrappers that use printk in RCU
@@ -74,17 +77,17 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
  * Wrappers that use a ratelimited printk
  */
 #define btrfs_crit_rl(fs_info, fmt, args...) \
-       btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args)
+       btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
 #define btrfs_err_rl(fs_info, fmt, args...) \
-       btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args)
+       btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
 #define btrfs_warn_rl(fs_info, fmt, args...) \
-       btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args)
+       btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
 #define btrfs_info_rl(fs_info, fmt, args...) \
-       btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
+       btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
 
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define btrfs_debug(fs_info, fmt, args...)                             \
-       _dynamic_func_call_no_desc(fmt, btrfs_printk,                   \
+       _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu,            \
                                   fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...)                      \
        _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu,            \
@@ -93,26 +96,26 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
        _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu,         \
                                   fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl(fs_info, fmt, args...)                          \
-       _dynamic_func_call_no_desc(fmt, btrfs_printk_ratelimited,       \
+       _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu,         \
                                   fs_info, KERN_DEBUG fmt, ##args)
 #elif defined(DEBUG)
 #define btrfs_debug(fs_info, fmt, args...) \
-       btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
+       btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
        btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
        btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl(fs_info, fmt, args...) \
-       btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
+       btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #else
 #define btrfs_debug(fs_info, fmt, args...) \
-       btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
+       btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
        btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
        btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl(fs_info, fmt, args...) \
-       btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
+       btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #endif
 
 #define btrfs_printk_in_rcu(fs_info, fmt, args...)     \