All of lore.kernel.org
 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 v3 3/6] btrfs: delayed refs pre-flushing should only run the heads we have
Date: Wed, 16 Dec 2020 11:49:31 -0500	[thread overview]
Message-ID: <a32cf92bd7cfc7bc4b2baaa1e251860626c39231.1608137316.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1608137316.git.josef@toxicpanda.com>

Previously our delayed ref running used the total number of items as the
items to run.  However we changed that to number of heads to run with
the delayed_refs_rsv, as generally we want to run all of the operations
for one bytenr.

But with btrfs_run_delayed_refs(trans, 0) we set our count to 2x the
number of items that we have.  This is generally fine, but if we have
some operation generation loads of delayed refs while we're doing this
pre-flushing in the transaction commit, we'll just spin forever doing
delayed refs.

Fix this to simply pick the number of delayed refs we currently have,
that way we do not end up doing a lot of extra work that's being
generated in other threads.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d79b8369e6aa..b6d774803a2c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2160,7 +2160,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
 
 	delayed_refs = &trans->transaction->delayed_refs;
 	if (count == 0)
-		count = atomic_read(&delayed_refs->num_entries) * 2;
+		count = delayed_refs->num_heads_ready;
 
 again:
 #ifdef SCRAMBLE_DELAYED_REFS
-- 
2.26.2


  parent reply	other threads:[~2020-12-16 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 16:49 [PATCH v3 0/6] A variety of lock contention fixes Josef Bacik
2020-12-16 16:49 ` [PATCH v3 1/6] btrfs: do not block on deleted bgs mutex in the cleaner Josef Bacik
2020-12-16 16:49 ` [PATCH v3 2/6] btrfs: only let one thread pre-flush delayed refs in commit Josef Bacik
2020-12-16 16:49 ` Josef Bacik [this message]
2020-12-16 16:49 ` [PATCH v3 4/6] btrfs: only run delayed refs once before committing Josef Bacik
2020-12-16 16:49 ` [PATCH v3 5/6] btrfs: run delayed refs less often in commit_cowonly_roots Josef Bacik
2020-12-16 16:49 ` [PATCH v3 6/6] btrfs: stop running all delayed refs during snapshot 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=a32cf92bd7cfc7bc4b2baaa1e251860626c39231.1608137316.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.