Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6520624ybf; Thu, 5 Mar 2020 22:54:22 -0800 (PST) X-Google-Smtp-Source: ADFU+vt0CvxDByOpx4h2QMit7zhQgrNWdDagPlKn2crGy/svaVbqU55qYsnR5NNJCOKY8ubs7oI9 X-Received: by 2002:a9d:b89:: with SMTP id 9mr1349687oth.297.1583477662327; Thu, 05 Mar 2020 22:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583477662; cv=none; d=google.com; s=arc-20160816; b=AJFCo8LHU7J7MmUzktqlfNmNh5+B5GnqTt8lRubcs4urdGVqOCjb0kpqZWAx4vdftN Cz+dP4DdYD4zCPt/fGqeNbVFWmKR+dKwird0/ga6IvbfMEa7nP2JcJ+7bf+WgCdiizxx eK64TJfDZznXy+daVYz/+1suTgH9w8DNFNo/0WSeQDxbFC1g0q9iJVqagOAgqUEktxzB y+iG6r3xPFpMDdlrVTIkgwDgA601Y7F4QLTwHWbOjn5fDdyshMmGVhLcFVx2usDo09KF FpdJ1tE+HS1Xn+uJ9zI/Kk2r2nPRKjw+25uiaK8uvt1zQ9Sge288z1itwO23Y3aaXlTV 125w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=k8lKr+jkEueNL9fiDMUF+wF+sa4NlM0pOjvW8vJZPto=; b=MS213Z7HX8p5Ww/IrTUOZIFIyTiSw3gap7re76o7yoNj0t5LC+6mcREjAS15oUZqNY ULxI0ltOzdhULHSUEYicvUJxt6BZYxZDx8TDvCvho9tz/m+w6rHNUjNC+F8Xbrp6l+yR E7t5Xq1p9+7YZ0CjR03vWilW9D0aSeBhSaP617BA3pn4wy95vK+B/iF3rnSrzN+CUi41 oObixJ+lGn0D86UpPeYY+z21t9DOrcgv4XHI+/uhr9t45++xmuQQVBhU5nkmikpazQqs 9YpG+4CNHvC3dE+p2pMuRbUbsHpL3fjz7v0xAjo9nx+K/9sdFOlO+QYM/5SuzsQ4v/x+ rTLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cI9wU8hP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si793787otf.135.2020.03.05.22.54.09; Thu, 05 Mar 2020 22:54:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cI9wU8hP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726094AbgCFGx3 (ORCPT + 99 others); Fri, 6 Mar 2020 01:53:29 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33210 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbgCFGx3 (ORCPT ); Fri, 6 Mar 2020 01:53:29 -0500 Received: by mail-pg1-f195.google.com with SMTP id m5so648937pgg.0; Thu, 05 Mar 2020 22:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k8lKr+jkEueNL9fiDMUF+wF+sa4NlM0pOjvW8vJZPto=; b=cI9wU8hPNsjkX13N5xuTNuhILzY8O37rL4z49B2r3Sl2m+mTrOpiijZrJ+s1hZy9JF Ffh37HbRNWMdQSWID4UP9DwYCCUZvqlesBGTlCZUNcaLW+nAAXYat0ZZRPLh1vjWXOK2 EmOuLRn0bARfNXVKwuH5TT1eSKzAvkiDVhoOXYZMnXqsKrNnw08CGnaycDboR2/D2xNa V1KsrJmo+2XUu6C66+gD0PLVG4IR5WviMRkJc3cv5BaERJLRT5BW+bi1Bk07knJ5dZa5 94Co+hy/mTXKtWefGbrGYv1tk19yg/lYfDkKaY+7obsLDdCb22T/aG5LSxqOdB0nidwr 5OWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k8lKr+jkEueNL9fiDMUF+wF+sa4NlM0pOjvW8vJZPto=; b=uj9DtviZooPPOqOPhOzO4oFG+wDHa3FnVeyzAuZ/db5yR8yfCrcwD3dkJfZBx4WdZ3 xIJ5JHy7pCsd15ngYdQinSFKutyXDZNHkp4gaGk+B6WLe/8hFEGqRXY89Yac0Cy3rldz cVDsPZzGgR9EUEcxVhnxnVkpoETzYDEivtg61nxCI3t7MhPlvVvQj+dHxI7r7Ipqr8wW xmZR27wG7gVmfPmw5+Wb9qgWguziDxgfQRLxGj5l6vDV/l0/jEykjsjH/JEIOsjhmHEq 6+dwUGB+NU1mHWHLAJ4OG4RzSSERa+10cUcv8LscRNk4wZx8YMaiLTDk2n0jXKOn2bI6 YXlg== X-Gm-Message-State: ANhLgQ2qLNEMn91nAdV36rfaIGmCimiNeod8twk1QlB+T7MwgXLvwo6c FXSEHc0Dybe3wfdyvIEQXA== X-Received: by 2002:a63:4a19:: with SMTP id x25mr1943435pga.167.1583477607968; Thu, 05 Mar 2020 22:53:27 -0800 (PST) Received: from madhuparna-HP-Notebook.nitk.ac.in ([2402:3a80:1ee2:ecde:d483:e483:cccb:2577]) by smtp.gmail.com with ESMTPSA id x2sm32683411pge.2.2020.03.05.22.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 22:53:27 -0800 (PST) From: madhuparnabhowmik10@gmail.com To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, joel@joelfernandes.org, linux-kernel-mentees@lists.linuxfoundation.org, paulmck@kernel.org, frextrite@gmail.com, linux@roeck-us.net, Madhuparna Bhowmik Subject: [PATCH] fs: btrfs: block-group.c: Fix suspicious RCU usage warning Date: Fri, 6 Mar 2020 12:22:43 +0530 Message-Id: <20200306065243.11699-1-madhuparnabhowmik10@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik 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 Signed-off-by: Madhuparna Bhowmik --- 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) 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: -- 2.17.1