Re: [PATCH 07/16] mm/shmem: avoid moving the truncation start backwards

From: Kiryl Shutsemau

Date: Mon Oct 26 2026 - 12:39:21 EST


On Mon, Oct 26, 2026 at 10:40:40AM +0100, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> A nonuniform folio split can fail with -ENOMEM after splitting off some
> smaller folios. shmem_undo_range() then sets start to the end of the
> original folio, which may now lie before the truncation boundary.
>
> The final scan can consequently discard data below the new EOF, or
> keep retrying a large folio whose split point lies outside it.
>
> Keep start at least at its original value when skipping a folio after
> a failed split. The part in the truncated range has already been zeroed.
>
> Fix generated by an LLM and sent by Chris Mason in private.
>
> Fixes: 7460b470a131f ("mm/truncate: use folio_split() in truncate operation")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: split fixes, simplify descriptions, adjust comments ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

Acked-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov