Revert "3246 ZFS I/O deadman thread"

This reverts commit cc92e9d0c3e67a7e66c844466f85696a087bf60a.

Signed-off-by: Richard Yao <ryao@gentoo.org>

Conflicts:
	cmd/zinject/zinject.c
	include/sys/fm/fs/zfs.h
	include/sys/spa_impl.h
	include/sys/vdev_impl.h
	include/sys/zfs_context.h
	include/sys/zfs_ioctl.h
	include/sys/zio.h
	lib/libzpool/taskq.c
	module/zfs/spa.c
	module/zfs/spa_misc.c
	module/zfs/vdev.c
	module/zfs/vdev_queue.c
	module/zfs/zfs_fm.c
	module/zfs/zio.c
	module/zfs/zio_inject.c
Remove assert

Signed-off-by: Richard Yao <ryao@gentoo.org>
Revert "Switch KM_SLEEP to KM_PUSHPAGE"

This reverts commit 0ef0ff546eeab2f85690d59ee23fe30fa634dd38.
Revert "Use a dedicated taskq for vdev_file"

This reverts commit bc25c9325b0e5ced897b9820dad239539d561ec9.
Revert "vdev_file_io_start() to use taskq_dispatch(TQ_PUSHPAGE)"

This reverts commit 04aa2de8f788654dda15e0b598fc874915b0fc06.
Fix use of uninitialized where in zfs_range_add_reader

Under certain circumstances, zfs_range_add_reader will pass an
uninitialized where from avl_find() to avl_nearest(), which triggers
undefined behavior. When assertions are enabled, the where is
initialized to 0, which triggers an assertion:

SPLError: 31638:0:(avl.c:222:avl_nearest()) ASSERTION(tree->avl_root == NULL) failed

In this situation, we must also call avl_add() instead of avl_insert(),
or a similar failure should result.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Improve dirty page writeout performance

This refactors ->writepages and ->writepage to improve performance.

->writepages has been refactored to call zfs_range_lock() once per call.
Each zfs_range_lock() does its own memory allocation and various tree
operations, so making it occur only once reduces the computational
complexity of writepages, by at least a factor of log(N) where N is the
number of pages. This avoids significant virtual memory contention that
is prevalent in Linux's vmalloc(). In addition, we now pass WB_SYNC_NONE
to write_cache_pages. This moves responsibility for ensuring synchronous
semantics entirely to zil_commit(), where it should have been in the
first place. It also eliminates an opportunity for concurrent threads to
block each other on writeback.

->writepage has been refactored to permit the changes to ->writepages.
Situations where it is told to write out an invalidated page is now
properly handled by ignoring them. This avoids a theoretical NULL
pointer dereference.

These changes substantially improve 32-thread 4K randomwrite IO on a RAM
disk in filebench's randomwrite benchmark. This has been tested with the
following commands on a boot that passed ramdisk_size=8388604 to the
kernel commandline:

modprobe loop
losetup loop0 /dev/ram0
zpool create -o ashift=12 -O recordsize=4K test /dev/loop0
zpool export test
losetup -D
zpool import -d /dev test

filebench << END
load randomwrite
set \$dir=/test
set \$nthreads=32
set \$iosize=4096
run 60
END

zpool destroy test

Previous tests on Gentoo Linux using a kernel compiled from the CentOS
2.6.32-431.11.2.el6.x86_64 kernel with the default .config showed single
threaded performance at roughly 10k to 11k IOPS with 32-thread
performance at 5k-6k in this benchmark. Tests with this patch show a
performance improvement to 15k to 17k in the 32-thread case. These tests
were conducted on a single processor Xeon E5-2620 with 64GB of RAM.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Initial taskq import

A namespace collision occurs between the OpenSolaris/Illumos `struct
proc` and the Linux `struct proc`, which are used for different things
on each platform. On OpenSolaris/Illumos, this type can also be
referenced through the proc_t typdef, so some adjustments have been made
to use that in place of `struct proc`. First, the forwarding definition
in taskq.h has been removed. Second, the definitions of
taskq_create_proc and taskq_create_sysdc have been changed to use proc_t
instead of struct proc. Lastly, In addition, the tq_proc field of the
taskq struct has had its type changed from struct proc to proc_t.

Also return statements used NULL in functions that return integers.
These have been changed to 0 to avoid the following GCC warning/error:

error: return makes integer from pointer without a cast [-Werror]

Another complaint of GCC is in taskq_d_thread() where we can have an
uninitialized access to the variable `w` when the TQBUCKET_CLOSE flag is
set. This is harmless because the logical expression in question is ((w
== -1) || (bucket->tqbucket_flags & TQBUCKET_CLOSE)), which means that
the result will be the same regardless, but this breaks some builds, so
we fix it by preinitializing w to 0.

taskq_id_arena has been removed with preprocessor directives in favor of
making the instance id always be 0 on Linux.

The code needed for THREADS_CPU_PCT has been disabled with #ifdef.

Some mutex initialization was added.

Signed-off-by: Richard Yao <ryao@gentoo.org>
taskq: Always initialize cprinfo to make GCC happy

Signed-off-by: Richard Yao <ryao@gentoo.org>
taskq: Create threads with taskq names

On Solaris, each taskq is given a single process identifier which is
shared among all taskq threads. This enables the thread scheduler to
view all taskq threads as sharing a single quantum. Consequently, they
appear as a single process to userland utilities such as ps. On Linux,
we do not have the ability to do this, so all taskq threads are the
equivalent of separate kernel level processes on Solaris. Consequently,
they are all given the name taskq. This is not useful for debugging, so
we change things to hook into a low level detail of the SPL so that we
each thread receives a descriptive name.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Initial import of Cyclic Interface

Signed-off-by: Richard Yao <ryao@gentoo.org>