Re: [PATCH 01/18] Structural cleanup for filesystem-based swap

From: Christoph Hellwig
Date: Tue Dec 21 2021 - 03:34:25 EST


On Fri, Dec 17, 2021 at 10:48:22AM +1100, NeilBrown wrote:
> Linux primarily uses IO to block devices for swap, but can send the IO
> requests to a filesystem. This has only ever worked for NFS, and that
> hasn't worked for a while due to a lack of testing. This seems like a
> good time for some tidy-up before restoring swap-over-NFS functionality.

The changes look good to me, but I think this needs to be split into
separate, self-contained patches.

>
> This patch:

Patch 1:

> - updates the documentation (both copies!) for swap_activate which
> is woefully out-of-date

Patch 2:

> - drops the call to the filesystem for ->set_page_dirty(). These
> pages do not belong to the filesystem, and it has no interest
> in the dirty status.

Patch 3:


> - move the responsibility for setting SWP_FS_OPS to ->swap_activate()
> and also requires it to always call add_swap_extent(). This makes
> it much easier to find filesystems that require SWP_FS_OPS.

Patch 4:

> - introduces a new address_space operation "swap_rw" for swap IO.
> The code currently used ->readpage for reads and ->direct_IO for
> writes. The former imposes a limit of one-page-at-a-time, the
> later means that direct writes and swap writes are encouraged to
> use the same path. While similar, swap can often be simpler as
> it can assume that no allocation is needed, and coherence with the
> page cache is irrelevant.