linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 1/2] btrfs: free fs roots on failed mount
Date: Thu,  3 Sep 2020 14:29:50 -0400	[thread overview]
Message-ID: <1b78425a6899ac5689e432151b6bf6c6e73fd73c.1599157686.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1599157686.git.josef@toxicpanda.com>

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.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
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 0df589c95d86..7147237d9bf0 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3415,6 +3415,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);
 	free_root_pointers(fs_info, true);
 	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 
-- 
2.24.1


  reply	other threads:[~2020-09-03 18:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 18:29 [PATCH 0/2][v3] Some leaked root fixes Josef Bacik
2020-09-03 18:29 ` Josef Bacik [this message]
2020-09-07 12:50   ` [PATCH 1/2] btrfs: free fs roots on failed mount David Sterba
2020-09-03 18:29 ` [PATCH 2/2] btrfs: pretty print leaked root name Josef Bacik
2020-09-07 12:28   ` David Sterba
2020-09-09  7:37     ` David Sterba
  -- 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-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=1b78425a6899ac5689e432151b6bf6c6e73fd73c.1599157686.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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;
as well as URLs for NNTP newsgroup(s).