From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 1/2] btrfs: free fs roots on failed mount
Date: Mon, 27 Jul 2020 16:19:47 +0200 [thread overview]
Message-ID: <20200727141947.GN3703@twin.jikos.cz> (raw)
In-Reply-To: <20200722160722.8641-1-josef@toxicpanda.com>
On Wed, Jul 22, 2020 at 12:07:21PM -0400, 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, and thus gets freed by
> btrfs_free_fs_roots. Fix this by moving the call into fail_tree_roots:
> in open_ctree. With this fix we no longer leak that root on mount
> failure.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/disk-io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index c850d7f44fbe..f1fdbdd44c02 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3421,7 +3421,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
> fail_trans_kthread:
> kthread_stop(fs_info->transaction_kthread);
> btrfs_cleanup_transaction(fs_info);
> - btrfs_free_fs_roots(fs_info);
> fail_cleaner:
> kthread_stop(fs_info->cleaner_kthread);
>
> @@ -3441,6 +3440,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
> btrfs_put_block_group_cache(fs_info);
>
> fail_tree_roots:
> + btrfs_free_fs_roots(fs_info);
> free_root_pointers(fs_info, true);
The data reloc tree is freed inside free_root_pointers, that it's also
in the radix tree is for convenience so I'd rather fix it inside
free_root_pointers and not reorder btrfs_free_fs_roots.
> invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
>
> --
> 2.24.1
next prev parent reply other threads:[~2020-07-27 14:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 16:07 [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-07-22 16:07 ` [PATCH 2/2] btrfs: fix root leak printk to use %lld instead of %llu Josef Bacik
2020-07-23 14:20 ` David Sterba
2020-07-24 0:40 ` Qu Wenruo
2020-07-27 14:03 ` David Sterba
2020-07-27 14:07 ` David Sterba
2020-07-27 23:47 ` Qu Wenruo
2020-07-28 15:09 ` David Sterba
2020-07-27 14:19 ` David Sterba [this message]
2020-07-27 14:33 ` [PATCH 1/2] btrfs: free fs roots on failed mount Josef Bacik
2020-07-27 15:17 ` David Sterba
2020-07-27 15:37 ` Josef Bacik
-- strict thread matches above, loose matches on Subject: below --
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
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
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=20200727141947.GN3703@twin.jikos.cz \
--to=dsterba@suse.cz \
--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