[PATCH v3 0/3] mm/truncate: fix data loss when truncating straddling large folios
From: Zhang Yi
Date: Wed Sep 16 2026 - 05:42:08 EST
From: Zhang Yi <yi.zhang@xxxxxxxxxx>
Hello,
This is the third version fixing data loss when truncating straddling
large folios caught on the upcomming ext4 + iomap buffered I/O
conversion[1]. I've clarify the split logic as Joanne and Brian
suggested, also slove the concurrent issue pointed out by sashiko and
split the patch into 3 small ones as Zi Yan suggested.
Patch 1: Add pstart and pend parameters to
truncate_inode_partial_folio() and fix the data loss issue when
the second splitting straddling large folios fails.
Patch 2: Fix the similar data loss issue also could encountered on the
filesystem with min_order > 0.
Patch 3: Clarify the existing confusing return value of
truncate_inode_partial_folio().
Thanks,
Yi.
[1] https://lore.kernel.org/linux-fsdevel/a638a8fb-c184-4069-ae33-379ec12cd514@xxxxxxxxxxxxxxx/
v2->v3:
- Rework the folio2 validity check logic to fix the invalid
folio->index issue. (sashiko)
- Clarify the pstart and pend setting logic and the corresponding
comments to make it more readable. (Brian, Joanne)
- Split the patch into 3 small patches. (Zi Yan)
v1->v2:
- Export pstart as a new parameter so that the generic and shmem
truncate paths don't need to recompute the start value from the
return value. (Brian)
- When min_order is nonzero, align [pstart, pend] to the inner
boundaries of the folio to ensure they do not point into the middle
of a large folio, which could otherwise cause valid data within the
folio to be incorrectly cleared. (Joanne)
v2: https://lore.kernel.org/linux-mm/20260909062339.473816-1-yi.zhang@xxxxxxxxxxxxxxx/
v1: https://lore.kernel.org/linux-mm/20260903115018.2034541-1-yi.zhang@xxxxxxxxxxxxxxx/
Zhang Yi (3):
mm/truncate: fix data loss when splitting straddling large folios
fails
mm/truncate: align truncation boundaries to mapping minimum folio
order
mm/truncate: clarify return value of truncate_inode_partial_folio()
mm/internal.h | 4 +-
mm/shmem.c | 13 +++----
mm/truncate.c | 105 ++++++++++++++++++++++++++++++++++----------------
3 files changed, 79 insertions(+), 43 deletions(-)
--
2.52.0