Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp643982ybz; Wed, 22 Apr 2020 05:22:36 -0700 (PDT) X-Google-Smtp-Source: APiQypKAAUWVw71ZVlPAJRSUDR6txn0Aumdt58HOBHJREJHq9kCULwNr0tTc7yAr1trXOtNwdju+ X-Received: by 2002:a05:6402:1b0b:: with SMTP id by11mr22826101edb.269.1587558156323; Wed, 22 Apr 2020 05:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587558156; cv=none; d=google.com; s=arc-20160816; b=xTALLuZRHWQSsKIm6NZaDKNe8qFb8AeiAfrH9eQ2RTV8VTd/w/y2lHWWQgerh6wuk2 Q1KADh9NYr9UfWShn7cf9vx+bKA4CIUzgtj1QqbPkXEptpH8ucZKh+ChxpKsI3dMMCPr K3xW/4iaX5bDiXEBAVdNl1+J2iOA3A2qaz5+8J7GpWj9uvFWiSTWk8cRuZScKNvWjPIF abBqaLaa5Ytqa/wg3x5hJ7W4I4xcyZe4ILwvf0xAISYZpx89hD3mai0Nn3S8wSl1s1Hu 92XQGtXblw07F2e45AaW9ht2tV0dfLAd15knd4QTpjlidpk4XfZqdVbA6+2KFNS3jUNA nBJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BbPZvhViCvFglF7abrRe3qH/5TgS5WRiCnn1q3SVU4U=; b=KWG3djvsAS/5X9yToBrS4VBOEX4WmtJuVxdPml8+dADOB6WlKfnNT5JxEx8u5VVfPa W1OGsTWuqo60aJsEbDAaFYjC7wl+B29w2k5xXiAb3tvWAJRfocFoJuQQS7EVciBd9q3C GIxeZyzwgOqT9VoRpj9ROlDTCF44YerKGrgRJHys5JBUJNmFD1AV5mTjSVMY9J6z68TK LSiR1PcSlq4dAPLLLI3WFijYBWFDwRoW3QPoU/UsLv+z8VkrkzIZAGNG5v07ov/5rT9Q biT5cakltY0zxhUpGLv/9axkHWBfvOYNuKe6+TslixUnsKLosXD/xkZteZpVX7a5zdma 3Fpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iD+4igIj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y97si3642012ede.246.2020.04.22.05.22.11; Wed, 22 Apr 2020 05:22:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iD+4igIj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731246AbgDVKeI (ORCPT + 99 others); Wed, 22 Apr 2020 06:34:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:32844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730426AbgDVKY3 (ORCPT ); Wed, 22 Apr 2020 06:24:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACC882075A; Wed, 22 Apr 2020 10:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587551069; bh=cpi8xhq+oGMQDR0pcONOu5VnjZ2jS7IwZWsgpVsV+8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iD+4igIjAGjChRl6LgDU+5PjVZkDG+Jk2MwZEzeZu2a8HcRrGn05n8JnoUshishQ8 /USGlP5pbSMa/an6wBPgjJ727yDNc68f91a+sUx4tu767Agvlgltsjv7f7zqoYGmfI X94FuQbmvyOi75YSN3IenPmrOBSYn8UCFRmbOTBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Madhuparna Bhowmik , David Sterba , Sasha Levin Subject: [PATCH 5.6 088/166] btrfs: add RCU locks around block group initialization Date: Wed, 22 Apr 2020 11:56:55 +0200 Message-Id: <20200422095058.125383678@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095047.669225321@linuxfoundation.org> References: <20200422095047.669225321@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik [ Upstream commit 29566c9c773456467933ee22bbca1c2b72a3506c ] The space_info list is normally RCU protected and should be traversed with rcu_read_lock held. There's a warning [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!! pointing out that the locking is missing in btrfs_read_block_groups. However this is not necessary as the list traversal happens at mount time when there's no other thread potentially accessing the list. To fix the warning and for consistency let's add the RCU lock/unlock, the code won't be affected much as it's doing some lightweight operations. Reported-by: Guenter Roeck Signed-off-by: Madhuparna Bhowmik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/block-group.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 7f09147872dc7..c9a3bbc8c6afb 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) 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,6 +2008,7 @@ 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); -- 2.20.1