Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Naohiro Aota <naota@elisp.net>
Cc: linux-btrfs@vger.kernel.org, Naohiro Aota <naohiro.aota@wdc.com>
Subject: Re: [PATCH] btrfs: zoned: do not limit delalloc size to fs_info->max_extent_size
Date: Tue, 13 Jun 2023 00:22:49 +0200	[thread overview]
Message-ID: <20230612222249.GI13486@twin.jikos.cz> (raw)
In-Reply-To: <a2f4a2162fdc3457830fa997c70ffa7c231759ad.1686582572.git.naohiro.aota@wdc.com>

On Tue, Jun 13, 2023 at 12:10:29AM +0900, Naohiro Aota wrote:
> There is an issue writing out huge buffered data with the compressed mount
> option on zoned mode. For example, when you buffered write 16GB data and
> call "sync" command on "mount -o compress" file-system on a zoned device,
> it takes more than 3 minutes to finish the sync, invoking the hung_task
> timeout.
> 
> Before the patch:
> 
>     + xfs_io -f -c 'pwrite -b 8M 0 16G' /mnt/test/foo
>     wrote 17179869184/17179869184 bytes at offset 0
>     16.000 GiB, 2048 ops; 0:00:23.74 (690.013 MiB/sec and 86.2516 ops/sec)
> 
>     real    0m23.770s
>     user    0m0.005s
>     sys     0m23.599s
>     + sync
> 
>     real    3m55.921s
>     user    0m0.000s
>     sys     0m0.134s
> 
> After the patch:
> 
>     + xfs_io -f -c 'pwrite -b 8M 0 16G' /mnt/test/foo
>     wrote 17179869184/17179869184 bytes at offset 0
>     16.000 GiB, 2048 ops; 0:00:28.11 (582.648 MiB/sec and 72.8311 ops/sec)
> 
>     real    0m28.146s
>     user    0m0.004s
>     sys     0m27.951s
>     + sync
> 
>     real    0m12.310s
>     user    0m0.000s
>     sys     0m0.048s
> 
> This slow "sync" comes from inefficient async chunk building due to
> needlessly limited delalloc size.
> 
> find_lock_delalloc_range() looks for pages for the delayed allocation at
> most fs_info->max_extent_size in its size. For the non-compress write case,
> that range directly corresponds to num_bytes at cow_file_range() (= size of
> allocation). So, limiting the size to the max_extent_size seems no harm as
> we will split the extent even if we can have a larger allocation.
> 
> However, things are different with the compression case. The
> run_delalloc_compressed() divides the delalloc range into 512 KB sized
> chunks and queues a worker for each chunk. The device of the above test
> case has 672 KB zone_append_max_bytes, which is equal to
> fs_info->max_extent_size. Thus, one run_delalloc_compressed() call can
> build only two chunks at most, which is really smaller than
> BTRFS_MAX_EXTENT_SIZE / 512KB = 256, making it inefficient.
> 
> Also, as 672 KB is not aligned to 512 KB, it is creating ceil(16G / 672K) *
> 2 = 49934 async chunks for the above case. OTOH, with BTRFS_MAX_EXTENT_SIZE
> delalloced, we will create 32768 chunks, which is 34% reduced.
> 
> This patch reverts the delalloc size to BTRFS_MAX_EXTENT_SIZE, as it does
> not directly corresponds to the size of one extent. Instead, this patch
> will limit the allocation size at cow_file_range() for the zoned mode.
> 
> As shown above, with this patch applied, the "sync" time is reduced from
> almost 4 minutes to 12 seconds.
> 
> Fixes: f7b12a62f008 ("btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size")
> CC: stable@vger.kernel.org # 6.1+

Missing S-O-B, I've used the one with @wdc.com address. Added to
misc-next, thanks.

  reply	other threads:[~2023-06-12 22:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 15:10 [PATCH] btrfs: zoned: do not limit delalloc size to fs_info->max_extent_size Naohiro Aota
2023-06-12 22:22 ` David Sterba [this message]
2023-06-13  3:35   ` Naohiro Aota
2023-06-13  5:17 ` Christoph Hellwig
2023-06-13  5:53   ` Naohiro Aota
2023-06-14  1:59     ` Naohiro Aota
2023-06-14  5:44       ` hch
2023-06-19  4:35         ` Naohiro Aota
2023-06-14  2:05 ` Naohiro Aota
2023-06-14 22:08   ` David Sterba

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=20230612222249.GI13486@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=naota@elisp.net \
    /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