From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 4/7] btrfs: hold a ref on the root on the dead roots list
Date: Tue, 17 Dec 2019 10:44:01 -0500 [thread overview]
Message-ID: <20191217154404.44831-5-josef@toxicpanda.com> (raw)
In-Reply-To: <20191217154404.44831-1-josef@toxicpanda.com>
At the point we add a root to the dead roots list we have no open inodes
for that root, so we need to hold a ref on that root to keep it from
disappearing.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/disk-io.c | 3 +--
fs/btrfs/transaction.c | 6 ++++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index cf242d3c1723..ac96214bb5d9 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2082,8 +2082,7 @@ void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info)
if (test_bit(BTRFS_ROOT_IN_RADIX, &gang[0]->state))
btrfs_drop_and_free_fs_root(fs_info, gang[0]);
- else
- btrfs_put_root(gang[0]);
+ btrfs_put_root(gang[0]);
}
while (1) {
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index e194d3e4e3a9..2252dd967ad8 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1260,8 +1260,10 @@ void btrfs_add_dead_root(struct btrfs_root *root)
struct btrfs_fs_info *fs_info = root->fs_info;
spin_lock(&fs_info->trans_lock);
- if (list_empty(&root->root_list))
+ if (list_empty(&root->root_list)) {
+ btrfs_grab_root(root);
list_add_tail(&root->root_list, &fs_info->dead_roots);
+ }
spin_unlock(&fs_info->trans_lock);
}
@@ -2430,7 +2432,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
ret = btrfs_drop_snapshot(root, NULL, 0, 0);
else
ret = btrfs_drop_snapshot(root, NULL, 1, 0);
-
+ btrfs_put_root(root);
return (ret < 0) ? 0 : 1;
}
--
2.23.0
next prev parent reply other threads:[~2019-12-17 15:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 15:43 [PATCH 0/7] Cleanup how we handle root refs, part 2 Josef Bacik
2019-12-17 15:43 ` [PATCH 1/7] btrfs: make the extent buffer leak check per fs info Josef Bacik
2019-12-17 15:43 ` [PATCH 2/7] btrfs: move the root freeing stuff into btrfs_put_root Josef Bacik
2019-12-17 15:44 ` [PATCH 3/7] btrfs: make inodes hold a ref on their roots Josef Bacik
2019-12-17 15:44 ` Josef Bacik [this message]
2019-12-17 15:44 ` [PATCH 5/7] btrfs: don't take an extra root ref at allocation time Josef Bacik
2019-12-17 15:44 ` [PATCH 6/7] btrfs: make btrfs_cleanup_fs_roots use the fs_roots_radix_lock Josef Bacik
2019-12-17 15:44 ` [PATCH 7/7] btrfs: kill the subvol_srcu 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=20191217154404.44831-5-josef@toxicpanda.com \
--to=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