Allow three IOCTLs to be used on suspended pool, restoring state that
existed before IOCTL code refactoring merged change 4445fffb from illumos
at r248571.

This change allows `zpool clear` to be used again to recover suspended pool.
It seems the only was supposed by the code to restore pool operation after
reconnecting lost disks that were required for data completeness.  There
are still cases where `zpool clear` command can just safely stuck due to
deadlocks inside ZFS kernel part, but probably that is better then having
no chances to recover at all.

(cherry picked from commit c034c95e67abdb7eef95a34c9dc188f227a085cf)
Make ZFS to use separate thread to handle SPA_ASYNC_REMOVE async events.
Existing async thread is running only on successfull spa_sync() completion,
that is impossible in case of pool loosing required (last) disk(s).  That
indefinite delay of SPA_ASYNC_REMOVE processing made ZFS to not close the
lost disks, preventing GEOM/CAM from destroying devices and reusing names
on later disk reattach.

In earlier version of the patch I've tried to just run existing thread
immediately, unrelated to spa_sync() completion, but that exposed number
of situations where it could stuck due to locks held by stuck spa_sync(),
that are required for other kinds of async events.

Experiments with OpenIndiana snapshot confirmed that they also have this
issue with lost disks reattach.

(cherry picked from commit 070e8f39ecaa8deb6d80ad9f485ffb7d62225c9a)
Make `zpool clear` to reopen also reconnected cache and spare devices.
Since `zpool status` reports about such kinds of errors, it is strange
that they are not cleared by `zpool clear`.

(cherry picked from commit 3cc4899abadb075e1a1c87b9fe540fec982c89e5)
Block reporting of ZFS features for suspended pools.

Before executing any subcommand, zpool tool fetches pools configuration from
the kernel.  Before features support was added, kernel was regenerating that
configuration based on data always present in memory.  Unfortunately, pool
features list and activity counters are not such. They are stored in ZAP,
that normally resides in ARC, but under heavy memory pressure may be swapped
out.  If pool is suspended at this point, there is no way to recover it back
since any zpool command will stuck.

This change has one predictable flaw: `zpool upgrade` always wish to upgrade
suspended pools, but fortunately it can't do it due to the suspension.

(cherry picked from commit 2a26325c0f59f3a7e507ea2b1c10158ffe46590b)
Detect unsupported PREVENT ALLOW MEDIUM REMOVAL and SYNCHRONIZE CACHE(10)
to not spam devices with useless commands and logs with errors.

(cherry picked from commit 3be5fcbcfd0d79067617f4be3e084cf64188a218)
Oops, revert unwanted part of r253721.

(cherry picked from commit 1e4488ade806c781c177abec051ee54bfc5143a6)
Improve r253721 by reporting detected lack of BIO_FLUSH support to GEOM.
That prevents more of such requests from coming and errors from logging.

(cherry picked from commit 329753c36e1e9d64afce0bc82c9a4f02a64b7934)
Synchronize device cache on close only if there were some write operations.
While these operations are not really needed otherwise, at least for SCSI
they may cause extra errors if some other initiator holds write exclusive
reservation on the LUN (SYNCHRONIZE CACHE handled as "write" operation).

Conflicts:
	sys/cam/ata/ata_da.c

(cherry picked from commit 6761e997d0a0fa65f172398e3801639bb4de5ce1)
Remove dialog from rescue Makefile.

dialog introduces unwanted dependencies in rescue.
If we want to add a binary to the installation ISO,
we should explicitly add it to the scripts which create
the install ISO, and not modify src/rescue/rescue/Makefile.

In FreeNAS, we cleaned up the create_iso.sh script in these changesets:
d29cbfcc8e9bed8510b59dd86e3e93f3c0e00ea2
db5e03a1451c6e3cac5bb3765897feda6ab940be

so that the install ISO takes dialog from /usr/bin/dialog and *not* /rescue/dialog.
Merge pull request #5 from rodrigc/freenas-9-stable

Remove dialog from rescue Makefile.
Revert "Build dialog(1) as part of rescue binary."
Add a tunable for the default timeout.

(cherry picked from commit 65c945d5837493805e85471f2482c74e902d3cc2)
Merge pull request #6 from rodrigc/freenas-9-stable

Add a tunable for the default timeout.
fix header for C++ s/class/cls
Revert "Add extra tools to the rescue image"

This reverts commit c7deb3988cbd01c34c79aaa7c4182aabbb5c92df.

This is not needed, because the extra tools were added
to the FreeNAS build/create_iso.sh script in b62da2ce813980107859e319cd4a174201aed683 .
In future, if we need to add new binaries to the install ISO, we should
add them in build/create_iso.sh instead of adding to the rescue image.

This minimizes differences to FreeBSD.
Merge in kernel iscsi from FreeBSD HEAD.

Work actually performed by Davide Italiano.