Re: [PATCH] mm, THP, swap: fix allocating cluster for swapfile by mistake

From: Andrew Morton
Date: Wed Aug 19 2020 - 16:05:10 EST


On Thu, 20 Aug 2020 03:56:13 +0800 Gao Xiang <hsiangkao@xxxxxxxxxx> wrote:

> SWP_FS doesn't mean the device is file-backed swap device,
> which just means each writeback request should go through fs
> by DIO. Or it'll just use extents added by .swap_activate(),
> but it also works as file-backed swap device.

This is very hard to understand :(

> So in order to achieve the goal of the original patch,
> SWP_BLKDEV should be used instead.
>
> FS corruption can be observed with SSD device + XFS +
> fragmented swapfile due to CONFIG_THP_SWAP=y.
>
> Fixes: f0eea189e8e9 ("mm, THP, swap: Don't allocate huge cluster for file backed swap device")
> Fixes: 38d8b4e6bdc8 ("mm, THP, swap: delay splitting THP during swap out")

Why do you think it has taken three years to discover this?