Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Jan Kara <jack@suse.cz>, David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: Limit size of bios submitted from writeback
Date: Thu, 23 Apr 2026 19:24:02 +0930	[thread overview]
Message-ID: <5e19c224-b007-43f9-aa73-3016b5e8ce2c@suse.com> (raw)
In-Reply-To: <20260423093052.13219-2-jack@suse.cz>



在 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.

[...]

> +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.

Thanks,
Qu

  reply	other threads:[~2026-04-23  9:54 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 [this message]
2026-04-27  9:03   ` Jan Kara
2026-04-27  9:50     ` Qu Wenruo
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=5e19c224-b007-43f9-aa73-3016b5e8ce2c@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.com \
    --cc=jack@suse.cz \
    --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