swap: lock i_mutex for swap_writepage direct_IO

The generic write code locks i_mutex for a direct_IO. Swap-over-NFS
doesn't grab the mutex because nfs_direct_IO doesn't expect i_mutex to
be held, but most direct_IO implementations do.
swap: don't add ITER_BVEC flag to direct_IO rw

The rw argument to direct_IO has some ill-defined semantics. Some
filesystems (e.g., ext4, FAT) decide whether they're doing a write with
rw == WRITE, but others (e.g., XFS) check rw & WRITE. Let's set a good
example in the swap file code and say ITER_BVEC belongs in
iov_iter->flags but not in rw. This caters to the least common
denominator and avoids a sweeping change of every direct_IO
implementation.
iov_iter: add iov_iter_bvec and convert callers
swap: use direct I/O for SWP_FILE swap_readpage

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.

Cc: Mel Gorman <mgorman@suse.de>
vfs: update swap_{,de}activate documentation

Parameters were added to swap_activate in the same patch series that
introduced it without updating the documentation. Additionally, the
documentation claims that non-existent address space operations
swap_{in,out} are used for swap I/O, but it's (now) direct_IO.
btrfs: prevent ioctls from interfering with a swap file

There are several ioctls which can work around constraints enforced by
btrfs_swap_activate and lead to an unsafe situation. We cannot do any of
the following on an active swap file in order to avoid creating
compressed or shared extents:

- chattr -C or +c
- snapshot create
- defrag
- clone
- dedup
btrfs: add EXTENT_FLAG_SWAPFILE

Extents mapping a swap file should remain pinned in memory in order to
avoid doing allocations to look up an extent when we're already low on
memory. Rather than overloading EXTENT_FLAG_PINNED, add a new flag
specifically for this purpose.

Reviewed-by: David Sterba <dsterba@suse.cz>
btrfs: enable swap file support

Implement the swap file a_ops on btrfs.

Activation does two things:

1. Checks for a usable swap file: it must be fully allocated (no holes),
   support direct I/O (so no compressed or inline extents) and must be
   eligible for nocow in its entirety in order to avoid doing a bunch of
   allocations for a COW when we're already low on memory
2. Pins the extent maps in memory with EXTENT_FLAG_SWAPFILE

Deactivation unpins all of the extent maps.