Re: [PATCH 05/46] mm/truncate: look again if a folio left the mapping

From: Rik van Riel

Date: Mon Oct 26 2026 - 22:18:56 EST


On Tue, 2026-10-27 at 00:17 +0100, David Hildenbrand (Arm) wrote:
>
> In that scenario, the collapsed folio with the data from before the
> write
> stays in the page cache after the write has returned.
>
> This used to be impossible, as khugepaged only collapsed files that
> nobody
> had open for writing.
>
> Restart the lookup at that index, like shmem_undo_range() does. The
> same
> problem seems to exist in truncate_inode_pages_range() as well when
> truncate_inode_folio() fails, so handle it there as well.
>
> Fixes: 1b6444331beb ("mm/khugepaged: enable clean pagecache folio
> collapse for writable files")
> Cc: stable@xxxxxxxxxxxxxxx
> Reported-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>

--
All Rights Reversed.