[Linux-kernel-mentees] [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning

Qu Wenruo quwenruo.btrfs at gmx.com
Fri Mar 6 07:16:53 UTC 2020



On 2020/3/6 下午2:52, madhuparnabhowmik10 at gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10 at gmail.com>
> 
> The space_info list is rcu protected.
> Hence, it should be traversed with rcu_read_lock held.
> 
> Warning:
> [   29.104591] =============================
> [   29.104756] WARNING: suspicious RCU usage
> [   29.105046] 5.6.0-rc4-next-20200305 #1 Not tainted
> [   29.105231] -----------------------------
> [   29.105401] fs/btrfs/block-group.c:2011 RCU-list traversed in non-reader section!!
> 
> Reported-by: Guenter Roeck <linux at roeck-us.net>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10 at gmail.com>
> ---
>  fs/btrfs/block-group.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 404e050ce8ee..9cabeef66f5b 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1987,6 +1987,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)

This function is only triggered at mount time, where no other rcu
operation can happen.

Thanks,
Qu
>  		btrfs_release_path(path);
>  	}
>  
> +	rcu_read_lock();
>  	list_for_each_entry_rcu(space_info, &info->space_info, list) {
>  		if (!(btrfs_get_alloc_profile(info, space_info->flags) &
>  		      (BTRFS_BLOCK_GROUP_RAID10 |
> @@ -2007,7 +2008,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
>  				list)
>  			inc_block_group_ro(cache, 1);
>  	}
> -
> +	rcu_read_unlock();
> +		
>  	btrfs_init_global_block_rsv(info);
>  	ret = check_chunk_block_group_mappings(info);
>  error:
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxfoundation.org/pipermail/linux-kernel-mentees/attachments/20200306/9ab7051a/attachment.sig>


More information about the Linux-kernel-mentees mailing list