[PATCH v3 0/3] mm/truncate: fix data loss when truncating straddling large folios

Zhang Yi posted 3 patches 1 week, 1 day ago
There is a newer version of this series
mm/internal.h |   4 +-
mm/shmem.c    |  13 +++----
mm/truncate.c | 105 ++++++++++++++++++++++++++++++++++----------------
3 files changed, 79 insertions(+), 43 deletions(-)
[PATCH v3 0/3] mm/truncate: fix data loss when truncating straddling large folios
Posted by Zhang Yi 1 week, 1 day ago
From: Zhang Yi <yi.zhang@huawei.com>

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@huaweicloud.com/

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@huaweicloud.com/
v1: https://lore.kernel.org/linux-mm/20260903115018.2034541-1-yi.zhang@huaweicloud.com/


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