From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Jan Kara <jack@suse.cz>, Qu Wenruo <wqu@suse.com>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: Limit size of bios submitted from writeback
Date: Mon, 27 Apr 2026 19:20:24 +0930 [thread overview]
Message-ID: <50baea0e-fed6-4d7e-a9d5-d67ac67a7926@gmx.com> (raw)
In-Reply-To: <jfq3okghxlwr2ppqtrfold2emgqu3ermkgs2jwoiig4hivtpwo@s2wxyvncqpw4>
在 2026/4/27 18:33, Jan Kara 写道:
> On Thu 23-04-26 19:24:02, Qu Wenruo wrote:
>>
>>
>> 在 2026/4/23 19:00, Jan Kara 写道:
>>> Currently btrfs_writepages() just accumulates as large bio as possible
>>> (within writeback_control constraints) and then submits it. This can
>>> however lead to significant latency in writeback IO submission (I have
>>> observed tens of miliseconds) because the submitted bio easily has over
>>> hundred of megabytes. Consequently this leads to IO pipeline stalls and
>>> reduced throughput.
>>>
>>> At the same time beyond certain size submitting so large bio provides
>>> diminishing returns because the bio is split by the block layer
>>> immediately anyway. So compute (estimate of) bio size beyond which we
>>> are unlikely to improve performance and just submit the bio for
>>> writeback once we accumulate that much to keep the IO pipeline busy.
>>> This improves writeback throughput for sequential writes by about 15% on
>>> the test machine I was using.
>>>
>>> Signed-off-by: Jan Kara <jack@suse.cz>
>>
>> Looks great!
>>
>> Reviewed-by: Qu Wenruo <wqu@suse.com>
>>
>> Just one minor question inlined below.
>
> Thanks!
>
>>> +int btrfs_init_writeback_bio_size(struct btrfs_fs_info *fs_info)
>>> +{
>>> + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
>>> + struct btrfs_device *device;
>>> + u32 writeback_bio_size = fs_info->sectorsize;
>>> +
>>> + mutex_lock(&fs_devices->device_list_mutex);
>>> + /*
>>> + * Let's take maximum over optimal request sizes for all devices. For
>>> + * RAID profiles writeback will submit stripe (64k) sized bios anyway
>>> + * so our value doesn't matter and for simple profiles this is a good
>>> + * approximation of sensible IO chunking.
>>> + */
>>> + list_for_each_entry(device, &fs_devices->devices, dev_list) {
>>> + struct request_queue *queue;
>>> + unsigned int io_opt;
>>> +
>>> + queue = bdev_get_queue(device->bdev);
>>> + io_opt = queue_io_opt(queue) ? :
>>> + queue_max_sectors(queue) << SECTOR_SHIFT;
>>> + writeback_bio_size = max(writeback_bio_size, io_opt);
>>> + }
>>> + mutex_unlock(&fs_devices->device_list_mutex);
>>> +
>>> + fs_info->writeback_bio_size = writeback_bio_size;
>>
>> With this simplified version of optimal io size detection, do we want to
>> hook dev add/removal/replace to update the calculation?
>>
>> I guess in the real world, the added/removed/replaced disks should have all
>> the same performance parameter for server usages, so no difference there.
>>
>> And for personal/pro users, I doubt if the original performance problem is
>> even noticeable for most end users.
>>
>> So overall I'm fine either way.
>
> Yeah, at this point I'm not sure the complexity is worth it. Normally added
> disks have very similar parameters as existing ones, also even if they are
> somewhat different, it will cost you a few percent of writeback speed at
> worst which doesn't seem too bad and it will "fix" itself on next mount.
Thanks, we're on the same page.
Now the patch is pushed to for-next branch, with one typo "miliseconds"
fixed.
Thanks,
Qu
>
> Honza
next prev parent reply other threads:[~2026-04-27 9:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 9:30 [PATCH v2] btrfs: Limit size of bios submitted from writeback Jan Kara
2026-04-23 9:54 ` Qu Wenruo
2026-04-27 9:03 ` Jan Kara
2026-04-27 9:50 ` Qu Wenruo [this message]
2026-04-27 23:48 ` Qu Wenruo
2026-04-28 9:01 ` Jan Kara
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=50baea0e-fed6-4d7e-a9d5-d67ac67a7926@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=jack@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox