linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] btrfs: implement swap file support
@ 2014-11-21 10:08 Omar Sandoval
  2014-11-21 10:08 ` [PATCH v2 1/5] direct-io: don't dirty ITER_BVEC pages on read Omar Sandoval
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Omar Sandoval @ 2014-11-21 10:08 UTC (permalink / raw)
  To: Alexander Viro, Andrew Morton, Chris Mason, Josef Bacik,
	linux-btrfs, linux-fsdevel, linux-kernel, linux-mm, linux-nfs,
	Trond Myklebust, Mel Gorman
  Cc: Omar Sandoval

This patch series, based on 3.18-rc5, implements support for swap files on
BTRFS.

The standard swap file implementation uses the filesystem's implementation of
bmap() to get a list of physical blocks on disk, which the swap file code then
does I/O on directly without going through the filesystem. This doesn't work
for BTRFS, which is copy-on-write and therefore moves disk blocks around (COW
isn't the only thing that can shuffle around disk blocks: consider
defragmentation, balancing, etc.).

Swap-over-NFS introduced an interface through which a filesystem can arbitrate
swap I/O through address space operations:

- swap_activate() is called by swapon() and informs the address space that the
  given file is going to be used for swap, so it should take adequate measures
  like reserving space on disk and pinning block lookup information in memory
- swap_deactivate() is used to clean up on swapoff()
- readpage() is used to page in (read a page from disk)
- direct_IO() is used to page out (write a page out to disk)

Version 2 modifies this interface in the first part of the patch series to use
direct_IO for both reads and writes, which makes things much cleaner.

The second part of the patch series implements support for the interface on
BTRFS, which just means implementing swap_{,de}activate and adding some chattr
checks, which raises the following considerations:

- We can't do direct I/O on compressed or inline extents, so we can't use files
  with either for swap.
- Supporting COW swapfiles might also come with some weird edge cases?

This functionality is tenuously tested in a virtual machine with some
artificial workloads. Comment away.

Omar Sandoval (5):
  direct-io: don't dirty ITER_BVEC pages on read
  nfs: don't dirty ITER_BVEC pages read through direct I/O
  swap: use direct I/O for SWP_FILE swap_readpage
  btrfs: don't allow -C or +c chattrs on a swap file
  btrfs: enable swap file support

v2: use direct_IO for swap_readpage

 fs/btrfs/inode.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/ioctl.c | 50 ++++++++++++++++++++++++---------------
 fs/direct-io.c   |  8 ++++---
 fs/nfs/direct.c  |  5 +++-
 mm/page_io.c     | 32 +++++++++++++++++++++----
 5 files changed, 139 insertions(+), 27 deletions(-)

-- 
2.1.3


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-12-01 18:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-21 10:08 [PATCH v2 0/5] btrfs: implement swap file support Omar Sandoval
2014-11-21 10:08 ` [PATCH v2 1/5] direct-io: don't dirty ITER_BVEC pages on read Omar Sandoval
2014-11-21 15:39   ` Dave Kleikamp
2014-11-21 10:08 ` [PATCH v2 2/5] nfs: don't dirty ITER_BVEC pages read through direct I/O Omar Sandoval
2014-11-21 10:08 ` [PATCH v2 3/5] swap: use direct I/O for SWP_FILE swap_readpage Omar Sandoval
2014-11-21 10:08 ` [PATCH v2 4/5] btrfs: don't allow -C or +c chattrs on a swap file Omar Sandoval
2014-11-21 17:29   ` David Sterba
2014-11-21 10:08 ` [PATCH v2 5/5] btrfs: enable swap file support Omar Sandoval
2014-11-21 18:00   ` David Sterba
2014-11-21 19:07     ` Filipe David Manana
2014-11-22 20:03     ` Omar Sandoval
2014-11-24 22:03       ` Omar Sandoval
2014-11-25  5:55         ` Brendan Hide
2014-12-01 18:18         ` David Sterba
2014-11-21 10:15 ` [PATCH v2 0/5] btrfs: implement " Omar Sandoval
2014-11-21 10:19   ` Christoph Hellwig
2014-11-24 22:17     ` Omar Sandoval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).