From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 07/13] btrfs: kick off async delayed ref flushing if we are over time budget
Date: Thu, 9 Apr 2020 16:26:26 +0300 [thread overview]
Message-ID: <e55347cd-d107-65cd-ce78-e959dada6aac@suse.com> (raw)
In-Reply-To: <20200313212330.149024-8-josef@toxicpanda.com>
On 13.03.20 г. 23:23 ч., Josef Bacik wrote:
> For very large file systems we cannot rely on the space reservation
> system to provide enough pressure to flush delayed refs in a timely
> manner. We have the infrastructure in place to keep track of how much
> theoretical time it'll take to run our outstanding delayed refs, but
> unfortunately I ripped all of that out when I added the delayed refs
> rsv. This code originally was added to address the problem of too many
> delayed refs building up and thus causing transaction commits to take
> several minutes to finish.
>
> Fix this by adding back the ability to flush delayed refs based on the
> time budget for them. We want to limit to around 1 seconds worth of
> delayed refs to be pending at any given time. In order to keep up with
> demand we will start the async flusher once we are at the 500ms mark,
> and the async flusher will attempt to keep us in this ballpark.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/ctree.h | 4 ++++
> fs/btrfs/disk-io.c | 3 +++
> fs/btrfs/extent-tree.c | 44 ++++++++++++++++++++++++++++++++++++++++++
> fs/btrfs/transaction.c | 8 ++++++++
> 4 files changed, 59 insertions(+)
>
<snip>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 645ae95f465e..0e81990b57e0 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2249,6 +2249,50 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
> return 0;
> }
>
> +static void btrfs_async_run_delayed_refs(struct work_struct *work)
> +{
> + struct btrfs_fs_info *fs_info;
> + struct btrfs_trans_handle *trans;
> +
> + fs_info = container_of(work, struct btrfs_fs_info,
> + async_delayed_ref_work);
> +
> + while (!btrfs_fs_closing(fs_info)) {
> + unsigned long count;
> + int ret;
> +
> + trans = btrfs_attach_transaction(fs_info->extent_root);
> + if (IS_ERR(trans))
> + break;
> +
> + smp_rmb();
What is this barrier ordering? IMO its usage is bogus here, because in
btrfs_should_end_transaction we use a full barrier and here only an RMB.
Further more in btrfs_should_end_transaction we don't have any memory
accesses preceding the check of the flushing state. Looking at the
callers of btrfs_should_end_transaction I also don't see any ordering
guaranteed i.e I think it could be removed altogether. Or perhahps we
really want acquire/release semantics e.g. accesses to
delayed_refs.flushing should be done via
smp_load_acquire/smp_store_release functions?
> + if (trans->transaction->delayed_refs.flushing) {
> + btrfs_end_transaction(trans);
> + break;
> + }
> +
> + /* No longer over our threshold, lets bail. */
> + if (!btrfs_should_throttle_delayed_refs(trans, true)) {
> + btrfs_end_transaction(trans);
> + break;
> + }
> +
> + count = atomic_read(&trans->transaction->delayed_refs.num_entries);
> + count >>= 2;
> +
> + ret = btrfs_run_delayed_refs(trans, count);
> + btrfs_end_transaction(trans);
> + if (ret < 0)
> + break;
> + }
> +}
> +
<snip>
next prev parent reply other threads:[~2020-04-09 13:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 21:23 [PATCH 00/13] Throttle delayed refs based on time Josef Bacik
2020-03-13 21:23 ` [PATCH 01/13] btrfs: use a stable rolling avg for delayed refs avg Josef Bacik
2020-03-13 21:23 ` [PATCH 02/13] btrfs: change btrfs_should_throttle_delayed_refs to a bool Josef Bacik
2020-03-13 21:23 ` [PATCH 03/13] btrfs: make btrfs_should_throttle_delayed_refs only check run time Josef Bacik
2020-03-13 21:23 ` [PATCH 04/13] btrfs: make should_end_transaction check time to run delayed refs Josef Bacik
2020-03-13 21:23 ` [PATCH 05/13] btrfs: squash should_end_transaction Josef Bacik
2020-03-13 21:23 ` [PATCH 06/13] btrfs: add a mode for delayed ref time based throttling Josef Bacik
2020-03-13 21:23 ` [PATCH 07/13] btrfs: kick off async delayed ref flushing if we are over time budget Josef Bacik
2020-04-09 13:11 ` Nikolay Borisov
2020-04-09 13:26 ` Nikolay Borisov [this message]
2020-03-13 21:23 ` [PATCH 08/13] btrfs: adjust the arguments for btrfs_should_throttle_delayed_refs Josef Bacik
2020-03-13 21:23 ` [PATCH 09/13] btrfs: throttle delayed refs based on time Josef Bacik
2020-03-13 21:23 ` [PATCH 10/13] btrfs: handle uncontrolled delayed ref generation Josef Bacik
2020-03-13 21:23 ` [PATCH 11/13] btrfs: check delayed refs while relocating Josef Bacik
2020-03-13 21:23 ` [PATCH 12/13] btrfs: throttle truncate for delayed ref generation Josef Bacik
2020-03-13 21:23 ` [PATCH 13/13] btrfs: throttle snapshot delete on delayed refs 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=e55347cd-d107-65cd-ce78-e959dada6aac@suse.com \
--to=nborisov@suse.com \
--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;
as well as URLs for NNTP newsgroup(s).