Skip to content

Commit b6fdfbf

Browse files
t-msnkdave
authored andcommitted
btrfs: Fix suspicious RCU usage warning in btrfs_debug_in_rcu
Commit 672d599 ("btrfs: Use wrapper macro for rcu string to remove duplicate code") replaces some open coded RCU string handling with macro. It turns out that btrfs_debug_in_rcu() is used for the first time and the macro lacks lock/unlock of RCU string for non-debug case (i.e. when the message is not printed), leading to suspicious RCU usage warning when CONFIG_PROVE_RCU is on. Fix this by adding a wrapper to call lock/unlock for the non-debug case too. Fixes: 672d599 ("btrfs: Use wrapper macro for rcu string to remove duplicate code") Reported-by: David Howells <dhowells@redhat.com> Tested-by: David Howells <dhowells@redhat.com> Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent b9b8a41 commit b6fdfbf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/btrfs/ctree.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,9 +3390,9 @@ do { \
33903390
#define btrfs_debug(fs_info, fmt, args...) \
33913391
btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
33923392
#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
3393-
btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
3393+
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
33943394
#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
3395-
btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
3395+
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
33963396
#define btrfs_debug_rl(fs_info, fmt, args...) \
33973397
btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
33983398
#endif
@@ -3404,6 +3404,13 @@ do { \
34043404
rcu_read_unlock(); \
34053405
} while (0)
34063406

3407+
#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
3408+
do { \
3409+
rcu_read_lock(); \
3410+
btrfs_no_printk(fs_info, fmt, ##args); \
3411+
rcu_read_unlock(); \
3412+
} while (0)
3413+
34073414
#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
34083415
do { \
34093416
static DEFINE_RATELIMIT_STATE(_rs, \

0 commit comments

Comments
 (0)