* [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root [not found] <20200415113445.11881-1-sashal@kernel.org> @ 2020-04-15 11:33 ` Sasha Levin 2020-04-15 13:22 ` David Sterba 2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 052/129] btrfs: add RCU locks around block group initialization Sasha Levin 1 sibling, 1 reply; 4+ messages in thread From: Sasha Levin @ 2020-04-15 11:33 UTC (permalink / raw) To: linux-kernel, stable Cc: Josef Bacik, Nikolay Borisov, David Sterba, Sasha Levin, linux-btrfs From: Josef Bacik <josef@toxicpanda.com> [ Upstream commit 4cdfd93002cb84471ed85b4999cd38077a317873 ] We want to use this for dropping all roots, and in some error cases we may not have a root, so handle this to make the cleanup code easier. Make btrfs_grab_fs_root the same so we can use it in cases where the root may not exist (like the quota root). Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/btrfs/disk-io.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 8c2d6cf1ce596..424c9c97b1ce8 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -97,6 +97,8 @@ struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info); */ static inline struct btrfs_root *btrfs_grab_fs_root(struct btrfs_root *root) { + if (!root) + return NULL; if (refcount_inc_not_zero(&root->refs)) return root; return NULL; @@ -104,6 +106,8 @@ static inline struct btrfs_root *btrfs_grab_fs_root(struct btrfs_root *root) static inline void btrfs_put_fs_root(struct btrfs_root *root) { + if (!root) + return; if (refcount_dec_and_test(&root->refs)) kfree(root); } -- 2.20.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root 2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root Sasha Levin @ 2020-04-15 13:22 ` David Sterba 2020-04-22 0:50 ` Sasha Levin 0 siblings, 1 reply; 4+ messages in thread From: David Sterba @ 2020-04-15 13:22 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Josef Bacik, Nikolay Borisov, David Sterba, linux-btrfs On Wed, Apr 15, 2020 at 07:33:26AM -0400, Sasha Levin wrote: > From: Josef Bacik <josef@toxicpanda.com> > > [ Upstream commit 4cdfd93002cb84471ed85b4999cd38077a317873 ] > > We want to use this for dropping all roots, and in some error cases we > may not have a root, so handle this to make the cleanup code easier. > Make btrfs_grab_fs_root the same so we can use it in cases where the > root may not exist (like the quota root). This is another patch from the preparatory series, not needed for stable. Please drop it, thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root 2020-04-15 13:22 ` David Sterba @ 2020-04-22 0:50 ` Sasha Levin 0 siblings, 0 replies; 4+ messages in thread From: Sasha Levin @ 2020-04-22 0:50 UTC (permalink / raw) To: dsterba, linux-kernel, stable, Josef Bacik, Nikolay Borisov, David Sterba, linux-btrfs On Wed, Apr 15, 2020 at 03:22:24PM +0200, David Sterba wrote: >On Wed, Apr 15, 2020 at 07:33:26AM -0400, Sasha Levin wrote: >> From: Josef Bacik <josef@toxicpanda.com> >> >> [ Upstream commit 4cdfd93002cb84471ed85b4999cd38077a317873 ] >> >> We want to use this for dropping all roots, and in some error cases we >> may not have a root, so handle this to make the cleanup code easier. >> Make btrfs_grab_fs_root the same so we can use it in cases where the >> root may not exist (like the quota root). > >This is another patch from the preparatory series, not needed for >stable. Please drop it, thanks. Dropped, thanks! -- Thanks, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 5.6 052/129] btrfs: add RCU locks around block group initialization [not found] <20200415113445.11881-1-sashal@kernel.org> 2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root Sasha Levin @ 2020-04-15 11:33 ` Sasha Levin 1 sibling, 0 replies; 4+ messages in thread From: Sasha Levin @ 2020-04-15 11:33 UTC (permalink / raw) To: linux-kernel, stable Cc: Madhuparna Bhowmik, Guenter Roeck, David Sterba, Sasha Levin, linux-btrfs From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com> [ 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 <linux@roeck-us.net> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-22 0:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200415113445.11881-1-sashal@kernel.org>
2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 051/129] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root Sasha Levin
2020-04-15 13:22 ` David Sterba
2020-04-22 0:50 ` Sasha Levin
2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 052/129] btrfs: add RCU locks around block group initialization Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).