]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: limit size of bios submitted from writeback
authorJan Kara <jack@suse.cz>
Thu, 23 Apr 2026 09:30:53 +0000 (11:30 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:30 +0000 (15:53 +0200)
commitd8d89ba2e556d1ed8648262fceadc91834cb5ffd
tree884c9874c0c3acca47f114445deddba4729cb1a4
parentbac3c2910c0c37f2e504994eeb1d2102ec8a0d23
btrfs: limit size of bios submitted from writeback

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 milliseconds) 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.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
[ Fix the handling of missing device to avoid NULL pointer dereference. ]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/fs.h
fs/btrfs/volumes.c
fs/btrfs/volumes.h