From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 5/5] btrfs: stop running all delayed refs during snapshot
Date: Fri, 13 Mar 2020 17:12:20 -0400 [thread overview]
Message-ID: <20200313211220.148772-6-josef@toxicpanda.com> (raw)
In-Reply-To: <20200313211220.148772-1-josef@toxicpanda.com>
This was added a very long time ago to work around issues with delayed
refs and with qgroups. Both of these issues have since been properly
fixed, so all this does is cause a lot of lock contention with anybody
else who is running delayed refs.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/transaction.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index c3b3b524b8c3..8d34d7e0adb6 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1184,10 +1184,6 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)
btrfs_tree_unlock(eb);
free_extent_buffer(eb);
- if (ret)
- return ret;
-
- ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
if (ret)
return ret;
@@ -1205,10 +1201,6 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)
if (ret)
return ret;
- /* run_qgroups might have added some more refs */
- ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
- if (ret)
- return ret;
again:
while (!list_empty(&fs_info->dirty_cowonly_roots)) {
struct btrfs_root *root;
@@ -1223,15 +1215,24 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)
ret = update_cowonly_root(trans, root);
if (ret)
return ret;
- ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
- if (ret)
- return ret;
}
+ /* Now flush any delayed refs generated by updating all of the roots. */
+ ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
+ if (ret)
+ return ret;
+
while (!list_empty(dirty_bgs) || !list_empty(io_bgs)) {
ret = btrfs_write_dirty_block_groups(trans);
if (ret)
return ret;
+
+ /*
+ * We're writing the dirty block groups, which could generate
+ * delayed refs, which could generate more dirty block groups,
+ * so we want to keep this flushing in this loop to make sure
+ * everything gets run.
+ */
ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
if (ret)
return ret;
--
2.24.1
next prev parent reply other threads:[~2020-03-13 21:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 21:12 [PATCH 0/5] Fix up some stupid delayed ref flushing behaviors Josef Bacik
2020-03-13 21:12 ` [PATCH 1/5] btrfs: set delayed_refs.flushing for the first delayed ref flushing Josef Bacik
2020-03-13 21:12 ` [PATCH 2/5] btrfs: delayed refs pre-flushing should only run the heads we have Josef Bacik
2020-04-03 14:31 ` Nikolay Borisov
2020-03-13 21:12 ` [PATCH 3/5] btrfs: only run delayed refs once before committing Josef Bacik
2020-04-03 14:34 ` Nikolay Borisov
2020-03-13 21:12 ` [PATCH 4/5] btrfs: run delayed refs less often in commit_cowonly_roots Josef Bacik
2020-04-03 14:43 ` Nikolay Borisov
2020-03-13 21:12 ` Josef Bacik [this message]
2020-04-03 14:46 ` [PATCH 5/5] btrfs: stop running all delayed refs during snapshot Nikolay Borisov
2020-03-25 13:51 ` [PATCH 0/5] Fix up some stupid delayed ref flushing behaviors David Sterba
2020-03-25 14:12 ` Josef Bacik
2020-03-26 15:36 ` Zygo Blaxell
2020-03-26 19:58 ` 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=20200313211220.148772-6-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;
as well as URLs for NNTP newsgroup(s).