Re: [RFC PATCH 0/6] btrfs: implement swap file support

From: Omar Sandoval
Date: Wed Nov 19 2014 - 02:22:43 EST


On Mon, Nov 17, 2014 at 07:48:17AM -0800, Christoph Hellwig wrote:
> With the new iov_iter infrastructure that supprots direct I/O to kernel
> pages please get rid of the ->readpage hack first. I'm still utterly
> disapoined that this crap ever got merged.
>
That seems reasonable. Using direct I/O circumvents the need for patches 3, 4,
and 5, which were workarounds for readpage being fed a swapcache page, and
patch 1, which is a big, error-prone mess.

Here's a nice little bit of insanity I put together in that direction --
consider it a discussion point more than a patch. It does two things:

- Uses an ITER_BVEC iov_iter to do direct_IO for swap_readpage. This makes
swap_readpage a synchronous operation, but I think that's the best we can do
with the existing interface.
- Unless I'm missing something, there don't appear to be any instances of
ITER_BVEC | READ in the kernel, so the dio path doesn't know not to dirty
pages it gets that way. Dave Kleikamp and Ming Lei each previously submitted
patches doing this as part of adding an aio_kernel interface. (The NFS direct
I/O implementation doesn't know how to deal with these either, so this patch
actually breaks the only existing user of this code path, but in the interest
of keeping the patch short, I didn't try to fix it :)

Obviously, there's more to be done if that's how you'd prefer I do this. I'm
far from being an expert in any of this, so please let me know if I'm spewing
nonsense :)

--
Omar