ext4: fix unaligned edge handling in FALLOC_FL_WRITE_ZEROES
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest6 patches 11 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | ext4: move partial block zeroing earlier in ext4_zero_range()fs/ | +7 | 1 reply | |
| 2/6 | ext4: clarify return semantics of ext4_load_tail_bh()fs/ | +5 | 6 replies | |
| 3/6 | ext4: track partial-zero outcome per edge in ext4_zero_partial_blocks()fs/ fs/ fs/ | +35 | 1 reply | |
| 4/6 | ext4: zero out whole block for clean edges in WRITE_ZEROESfs/ | +15 | 0 replies | |
| 5/6 | ext4: write back partial-zeroed edges in WRITE_ZEROESfs/ | +9 | 1 reply | |
| 6/6 | ext4: skip ext4_update_disksize_before_punch() in WRITE_ZEROESfs/ | +5 | 2 replies |
Reviews trailers per patch
3 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Jan Kara |
|---|---|
| 1/6 | R-b |
| 2/6 | |
| 3/6 | R-b |
| 4/6 | |
| 5/6 | R-b |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/6] ext4: fix unaligned edge handling in FALLOC_FL_WRITE_ZEROES
From: Zhang Yi <[email protected]>
Hi,
The current FALLOC_FL_WRITE_ZEROES implementation in ext4 does not correctly handle unaligned edge blocks. FALLOC_FL_WRITE_ZEROES is needed to convert the requested range to written extents with zeroed content, but the existing code only partially zero the edges and never guarantees that:
1) edges that are clean unwritten extents or holes get promoted to written extents, and
2) edges that are dirty unwritten or delalloc get their underlying extents converted to written before the syscall returns.
Both cases leave the on-disk extent type unwritten, violating the WRITE_ZEROES contract, and in these cases a subsequent sync buffered overwrite would still observe pending metadata changes from the conversion work that should have been completed by WRITE_ZEROES itself.
This series fixes the unaligned edge handling and cleans up a related redundant i_disksize update. The first three patches are preparatory:
moving ext4_zero_partial_blocks() earlier in ext4_zero_range(), documenting the return semantics of ext4_load_tail_bh(), and replacing the single bool output of ext4_zero_partial_blocks() with a per-edge bitmask (EXT4_PARTIAL_ZERO_START/END). The next two patches fix the two scenarios above by expanding the aligned allocation range outward for skipped (clean unwritten or hole) edges, and by writing back partial-zeroed edges so the underlying extents are converted to written. The final patch drops the now-redundant ext4_update_disksize_before_punch() call on the WRITE_ZEROES path, since WRITE_ZEROES is mutually exclusive with KEEP_SIZE and the i_disksize update is already handled by ext4_alloc_file_blocks().
Thanks,
Yi.
Discussion Link:
https://lore.kernel.org/linux-xfs/[email protected]/
Zhang Yi (6):
ext4: move partial block zeroing earlier in ext4_zero_range()
ext4: clarify return semantics of ext4_load_tail_bh()
ext4: track partial-zero outcome per edge in
ext4_zero_partial_blocks()
ext4: zero out whole block for clean edges in WRITE_ZEROES
ext4: write back partial-zeroed edges in WRITE_ZEROES
ext4: skip ext4_update_disksize_before_punch() in WRITE_ZEROES
fs/ext4/ext4.h | 5 ++++- fs/ext4/extents.c | 47 +++++++++++++++++++++++++++++++++++++---------- fs/ext4/inode.c | 42 +++++++++++++++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 18 deletions(-)
Signature · 1 line
2.53.0