From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 1/2] btrfs: free fs roots on failed mount
Date: Fri, 21 Aug 2020 17:07:36 +0300 [thread overview]
Message-ID: <743efacd-a3fc-fb05-e758-e34e94b8568f@suse.com> (raw)
In-Reply-To: <410d3d2b-0b79-68ca-c3c1-a9ebd2ee1933@toxicpanda.com>
On 21.08.20 г. 16:59 ч., Josef Bacik wrote:
> On 8/21/20 3:31 AM, Nikolay Borisov wrote:
>>
>>
>> On 20.08.20 г. 23:00 ч., Josef Bacik wrote:
>>> While testing a weird problem with -o degraded, I noticed I was getting
>>> leaked root errors
>>>
>>> BTRFS warning (device loop0): writable mount is not allowed due to
>>> too many missing devices
>>> BTRFS error (device loop0): open_ctree failed
>>> BTRFS error (device loop0): leaked root -9-0 refcount 1
>>>
>>> This is the DATA_RELOC root, which gets read before the other fs roots,
>>> but is included in the fs roots radix tree. Handle this by adding a
>>> btrfs_drop_and_free_fs_root() on the data reloc root if it exists. This
>>> is ok to do here if we fail further up because we will only drop the ref
>>> if we delete the root from the radix tree, and all other cleanup won't
>>> be duplicated.
>>>
>>> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>>> ---
>>> fs/btrfs/disk-io.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>>> index 814f8de395fe..ac6d6fddd5f4 100644
>>> --- a/fs/btrfs/disk-io.c
>>> +++ b/fs/btrfs/disk-io.c
>>> @@ -3418,6 +3418,8 @@ int __cold open_ctree(struct super_block *sb,
>>> struct btrfs_fs_devices *fs_device
>>> btrfs_put_block_group_cache(fs_info);
>>> fail_tree_roots:
>>> + if (fs_info->data_reloc_root)
>>> + btrfs_drop_and_free_fs_root(fs_info, fs_info->data_reloc_root);
>>
>> But will this really free the root? So the newly allocated
>> data_reloc_root has it's ref set to 1 from
>> btrfs_get_root_ref->btrfs_read_tree_root->btrfs_alloc_root and to 2 from
>> being added to the radix tree in btrfs_insert_fs_root().
>>
>> But btrfs_drop_and_free_fs_root makes a single call to btrfs_put_root.
>> So won't the reloc tree be left with a refcount of 1 ?
>
> It's a global root, so it's final put happens in btrfs_free_fs_info(),
> we just need to drop the radix tree ref here. Thanks,
Fair enough, but this really shows that btrfs_drop_and_free_fs_root has
a horrible name which doesn't reflect what it does fully...
Any case the patch itself is good, so :
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> Josef
>
next prev parent reply other threads:[~2020-08-21 14:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 20:00 [PATCH 0/2][v2] Some leaked root fixes Josef Bacik
2020-08-20 20:00 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-08-21 7:31 ` Nikolay Borisov
2020-08-21 13:59 ` Josef Bacik
2020-08-21 14:07 ` Nikolay Borisov [this message]
2020-08-20 20:00 ` [PATCH 2/2] btrfs: pretty print leaked root name Josef Bacik
2020-08-21 7:35 ` Nikolay Borisov
2020-08-21 10:13 ` David Sterba
2020-08-21 10:25 ` Nikolay Borisov
2020-08-21 14:00 ` Josef Bacik
2020-08-24 11:30 ` David Sterba
2020-08-24 12:46 ` David Sterba
-- strict thread matches above, loose matches on Subject: below --
2020-09-03 18:29 [PATCH 0/2][v3] Some leaked root fixes Josef Bacik
2020-09-03 18:29 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-09-07 12:50 ` David Sterba
2020-07-22 16:07 Josef Bacik
2020-07-27 14:19 ` David Sterba
2020-07-27 14:33 ` Josef Bacik
2020-07-27 15:17 ` David Sterba
2020-07-27 15:37 ` Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=743efacd-a3fc-fb05-e758-e34e94b8568f@suse.com \
--to=nborisov@suse.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox