public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] btrfs: reduce btrfs_get_extent() calls for buffered write path
@ 2025-11-20  9:16 Qu Wenruo
  2025-11-20  9:16 ` [PATCH v3 1/4] btrfs: make sure all ordered extents beyond EOF is properly truncated Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Qu Wenruo @ 2025-11-20  9:16 UTC (permalink / raw)
  To: linux-btrfs

[CHANGELOG]
v3:
- Use @cur_len for btrfs_get_extent() in the last patch
  And remove the hole related comment.
  This should not cause any behavior change.

  The @len parameter for btrfs_get_extent() is only going to cause a
  difference when the range is completely a hole (e.g. beyond EOF).

  For our writeback routine, there should be an extent map for us thus
  it's no different passing @cur_len or sectorsize.

  I think this @len parameter of btrfs_get_extent() is causing
  unnecessary complexity, and want to remove it completely. But that
  will be a new series.

v2:
- Fix a potential bug where OEs beyond EOF are not truncated properly
  This replace the original patch to extract the code into a helper.

- Replace more for_each_set_bit() with for_each_set_bitrange()

- Fix several copy-n-pasted incorrect range inside submit_range()


Although btrfs has bs < ps support for a long time, and the larger data
folios support is also going to be graduate from experimental features
soon, the write path is still iterating each fs block and call
btrfs_get_extent() on each fs block.

What makes the situation worse is that, for the write path we do not
have any cached extent map, meaning even with large folios and we got a
continuous range that can be submitted in one go, we still call
btrfs_get_extent() many times and get the same range extent map again
and again.

This series will reduce the duplicated btrfs_get_extent() calls by only
call it once for each range, other than for each fs block.

The first one is a potential bug inspired by Boris' review.
Patch 2~3 are minor cleanups.
Patch 4 is the core of the optimization.

Although I don't expect there will be much difference in the real world though.


Qu Wenruo (4):
  btrfs: make sure all ordered extents beyond EOF is properly truncated
  btrfs: integrate the error handling of submit_one_sector()
  btrfs: replace for_each_set_bit() with for_each_set_bitmap()
  btrfs: reduce extent map lookup during writes

 fs/btrfs/extent_io.c    | 230 ++++++++++++++++++++--------------------
 fs/btrfs/ordered-data.c |  38 +++++++
 fs/btrfs/ordered-data.h |   2 +
 3 files changed, 156 insertions(+), 114 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-11-24 23:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20  9:16 [PATCH v3 0/4] btrfs: reduce btrfs_get_extent() calls for buffered write path Qu Wenruo
2025-11-20  9:16 ` [PATCH v3 1/4] btrfs: make sure all ordered extents beyond EOF is properly truncated Qu Wenruo
2025-11-21 11:55   ` Filipe Manana
2025-11-21 15:38     ` David Sterba
2025-11-21 19:26       ` Qu Wenruo
2025-11-21 20:25         ` Daniel Vacek
2025-11-21 20:46           ` Qu Wenruo
2025-11-24 22:25             ` David Sterba
2025-11-24 23:16               ` Qu Wenruo
2025-11-22  1:14     ` Qu Wenruo
2025-11-24 12:22       ` Filipe Manana
2025-11-24 21:00         ` Qu Wenruo
2025-11-20  9:16 ` [PATCH v3 2/4] btrfs: integrate the error handling of submit_one_sector() Qu Wenruo
2025-11-20  9:16 ` [PATCH v3 3/4] btrfs: replace for_each_set_bit() with for_each_set_bitmap() Qu Wenruo
2025-11-20  9:16 ` [PATCH v3 4/4] btrfs: reduce extent map lookup during writes Qu Wenruo
2025-11-21  1:02 ` [PATCH v3 0/4] btrfs: reduce btrfs_get_extent() calls for buffered write path Boris Burkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox