Skip to content

btrfs: go extent-by-extent submission for buffered reads and writes

Qu Wenruo linux-btrfs 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 0 repliesNew
  2. v32 patches 0 repliesSuperseded
  3. v22 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches0 repliesSuperseded

Changes in v4 from the cover letter

- Make the writeback_bio_size limit check more robust
Only clamp @cur_len and do round_up() when the writeback_bio_size is larger than the current bio size.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: read a folio extent-by-extent instead of block-by-blockfs/btrfs/extent_io.c fs/btrfs/subpage.c fs/btrfs/subpage.h+90 -250 replies
2/2btrfs: write back a folio extent-by-extent instead of block-by-blockfs/btrfs/extent_io.c+159 -1060 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/2] btrfs: go extent-by-extent submission for buffered reads and writes

[CHANGELOG]
v4:
- Make the writeback_bio_size limit check more robust
Only clamp @cur_len and do round_up() when the writeback_bio_size is larger than the current bio size.

This will handle unaligned writeback_bio_size more robustly.

v3:
- Enhance the writeback_bio_size limit check
Now we limit the writeback size early.

This will follow the writeback_bio_size better.

- Do a better microbenchmark for the writeback patch
It turns out that writeback throttle is making submit_bio() sleep, masking the improvement in extent_writepage_io().

With wbt_late_nsec set to 0, now the improvement is way more obvious. Now it's over 90% reduce in average runtime, other than no improvement in the average runtime.

v2:
- Fix the length of advancement when no OE is found
We should still retry the next block, as there may be only a block of gap.

Exposed by Sashiko on the 2nd patch.

Although it also exposed a false alert on the truncate_ordered_extents_beyond_eof().
Where all the blocks in the range should have an OE, or we're having a bigger problem.

Although we have large data folio support for a while, the buffered reads and writes are still iterating a large folio block-by-block.

For a large buffered IO, the large folio has a very high chance to contain only one single extent.

In that case, although doing block-by-block checks is good for readability, it's not really performant.

The series changes the behavior to do extent-by-extent iteration instead, this can bring a very slight performance improve.

For best case scenario, the runtime to submit a folio read can be reduced from 32us to 2.5us, and a much better distribution. The runtime to submit a folio write can be reduced from 177us to 9us.

Qu Wenruo (2):
btrfs: read a folio extent-by-extent instead of block-by-block
btrfs: write back a folio extent-by-extent instead of block-by-block

 fs/btrfs/extent_io.c | 323 ++++++++++++++++++++++++++-----------------
 fs/btrfs/subpage.c   |  49 +++++++
 fs/btrfs/subpage.h   |   4 +
 3 files changed, 247 insertions(+), 129 deletions(-)
Signature · 1 line
2.55.0