Add TRIM support for disk vdevs using Linux DISCARD interface.

This adds DISCARD support to vdev_disk_physio(), and uses it to execute
DKIOCTRIM requests. The implementation is inspired by the Linux
blkdev_issue_discard() function.
Add TRIM support for file vdevs.

This adds TRIM support for file vdevs, using the newly-added VOP_SPACE
compatibility interface which translates to Linux
fallocate(FALLOC_FL_PUNCH_HOLE). When a TRIM request is issued to a
file vdev, ZFS will "punch a hole" (deallocate space) inside the
underlying file. Note that few Linux filesystems support hole punching
(currently OCFS2, XFS, and ext4).

Note that for this to work, you need to build against a kernel that
supports file hole punching (i.e. Linux >= 2.6.38). In addition, for
this to work in userspace (e.g. ztest), the installed userspace
kernel headers (i.e. /usr/include/linux) must be up-to-date.

NOTE: you need VOP_SPACE() support in SPL for this patch to build.
Add zfs_trim_zero parameter.

This patch adds a new module tunable: zfs_trim_zero. When this
parameter is set to 1, ZFS makes sure that DKIOCTRIM zeroes the range
being TRIMmed. This makes data corruption issues easier to reproduce,
at the cost of greatly decreased performance.

On disk vdevs, zfs_trim_zero replaces DISCARD with zero page writes,
which means it will work even with vdevs that do not support DISCARD.
Note that DISCARD won't be used even on vdevs that support it.

On file vdevs, if FALLOC_FL_PUNCH_HOLE fails and zfs_trim_zero=1, then
a zero buffer will be written instead. It is not necessary to write
zeroes if hole punching works because FALLOC_FL_PUNCH_HOLE specifies
that the specified range must appear as zeroes after hole punching.
Use zfs_trim_zero=1 in ztest.

For ztest to reliably check for corruption issues in the TRIM code, we
need to make sure TRIM zeroes data, even if the underlying filesystem
doesn't support file hole punching.
Fix assertion failure due to stale inflight writes.

ztest runs with TRIM enabled on a backing filesystem that doesn't
support hole punching revealed the following race condition:

 1. A write is issued to a vdev and added to the TRIM map inflight
    writes tree.
 2. The very first TRIM request for this vdev is issued.
 3. The TRIM request fails with EOPNOTSUPP, as expected. vdev_notrim
    is set.
 4. The write completes. trim_map_write_done() is called.
 5. trim_map_write_done() sees that vdev_notrim is set, and returns
    immediately.
 6. As a result, the write stays in the TRIM map inflight writes tree
    forever.
 7. When the vdev is closed, trim_map_destroy() tries to destroy the
    inflight writes tree, which triggers an assertion failure because
    it isn't empty.

This patch fixes the issue by removing the check on vdev_notrim in
trim_map_write_done().
Fix assertion failure due to inflight frees.

ztest runs with TRIM enabled revealed a race condition which occurs when
a vdev close is pending while there are TRIM requests in flight. When
the TRIM ZIOs complete, the SPA lock is released. The SPA lock is then
immediately taken by the vdev close path, which calls trim_map_destroy()
before trim_map_vdev_commit_done() has a chance to run.
trim_map_destroy() then tries to destroy the inflight free tree, which
fails with an assertion failure because it is non-empty.

This patch fixes the issue by making trim_map_destroy() call
trim_map_vdev_commit_done() before destroying the TRIM map.
Fix TRIM with ashift=12.

With ashift=12, zio_vdev_io_start() expands all ZIOs with size < 4096
using zio_push_transform(), allocating a new ZIO buffer in the process.

The allocation is of course unnecessary for DKIOCTRIM ZIOs, which don't
hold any data. This patch makes sure a new buffer is only allocated on
read/write ZIOs.

This also fixes an assertion failure in __vdev_disk_physio because it
was called with DISCARD and a non-null data buffer, which makes no
sense.