diff options
| author | Qu Wenruo <[email protected]> | 2025-03-27 08:50:01 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 12:30:40 +0000 |
| commit | 1e5773e0bab761c853eaf7286394905a544ef02d (patch) | |
| tree | 148daa52be1aebed13b812893ff6ed31ecfa50b0 /fs/btrfs/extent_io.c | |
| parent | btrfs: prepare btrfs_buffered_write() for large data folios (diff) | |
| download | kernel-1e5773e0bab761c853eaf7286394905a544ef02d.tar.gz kernel-1e5773e0bab761c853eaf7286394905a544ef02d.zip | |
btrfs: prepare btrfs_punch_hole_lock_range() for large data folios
The function btrfs_punch_hole_lock_range() needs to make sure there is
no other folio in the range, thus it goes with filemap_range_has_page(),
which works pretty fine.
But if we have large folios, under the following case
filemap_range_has_page() will always return true, forcing
btrfs_punch_hole_lock_range() to do a very time consuming busy loop:
start end
| |
|//|//|//|//| | | | | | | | |//|//|
\ / \ /
Folio A Folio B
In the above case, folio A and B contain our start/end indexes, and there
are no other folios in the range. Thus we do not need to retry inside
btrfs_punch_hole_lock_range().
To prepare for large data folios, introduce a helper,
check_range_has_page(), which will:
- Shrink the search range towards page boundaries
If the rounded down end (exclusive, otherwise it can underflow when @end
is inside the folio at file offset 0) is no larger than the rounded up
start, it means the range contains no other pages other than the ones
covering @start and @end.
Can return false directly in that case.
- Grab all the folios inside the range
- Skip any large folios that cover the start and end indexes
- If any other folios are found return true
- Otherwise return false
This new helper is going to handle both large folios and regular ones.
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/extent_io.c')
0 files changed, 0 insertions, 0 deletions
