diff mbox series

btrfs: ctree.h: Fix suspicious rcu usage warning in btrfs_debug_in_rcu()

Message ID c79f9ff1-e451-d2b4-a800-738053e47df8@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series btrfs: ctree.h: Fix suspicious rcu usage warning in btrfs_debug_in_rcu() | expand

Commit Message

Misono Tomohiro Aug. 24, 2018, 2:35 a.m. UTC
commit 672d599041c8 ("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 message is not printed), leading suspicious RCU usage warning
when CONFIG_PROVE_RCU is on.

Fix this by adding a wrapper to call lock/unlock for non debug case too.

Fixes: 672d599041c8 ("btrfs: Use wrapper macro for rcu string to remove
duplicate code")
Reported-by: David Howells <dhowells@redhat.com>
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 fs/btrfs/ctree.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

David Sterba Aug. 24, 2018, 11:46 a.m. UTC | #1
On Fri, Aug 24, 2018 at 11:35:28AM +0900, Misono Tomohiro wrote:
> commit 672d599041c8 ("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 message is not printed), leading suspicious RCU usage warning
> when CONFIG_PROVE_RCU is on.
> 
> Fix this by adding a wrapper to call lock/unlock for non debug case too.
> 
> Fixes: 672d599041c8 ("btrfs: Use wrapper macro for rcu string to remove
> duplicate code")
> Reported-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.com>

Thanks, I'll add it to the 4.19 queue, expected to appear in rc2.
David Howells Aug. 24, 2018, 12:08 p.m. UTC | #2
Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> wrote:

> commit 672d599041c8 ("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 message is not printed), leading suspicious RCU usage warning
> when CONFIG_PROVE_RCU is on.
> 
> Fix this by adding a wrapper to call lock/unlock for non debug case too.
> 
> Fixes: 672d599041c8 ("btrfs: Use wrapper macro for rcu string to remove
> duplicate code")
> Reported-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>

Tested-by: David Howells <dhowells@redhat.com>
diff mbox series

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 53af9f5253f4..cc8b4ff8dcea 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3390,9 +3390,9 @@  do {									\
 #define btrfs_debug(fs_info, fmt, args...) \
 	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(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_rl_in_rcu(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_rl(fs_info, fmt, args...) \
 	btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
 #endif
@@ -3404,6 +3404,13 @@  do {							\
 	rcu_read_unlock();				\
 } while (0)
 
+#define btrfs_no_printk_in_rcu(fs_info, fmt, args...)	\
+do {							\
+	rcu_read_lock();				\
+	btrfs_no_printk(fs_info, fmt, ##args);		\
+	rcu_read_unlock();				\
+} while (0)
+
 #define btrfs_printk_ratelimited(fs_info, fmt, args...)		\
 do {								\
 	static DEFINE_RATELIMIT_STATE(_rs,			\