Print remote IP address when we hit an error.
Return proper error code for missing device.

This suppresses numerous error messages in boot logs.
Block support for Gen-I chips in mvs(4) drivers.

I hope legacy ata(4) may work better with those relict pieces, which
I would not find on market even several years ago.

Ticket:	#4524
Use strlcpy().  There should be no functional change.
The issue will be hit when a file has more than 2 variable-length SA
and the total SA size is larger than the bonus buffer's
length -  sizeof (blkptr_t), but less the bonus buffer's length.

In sa_find_sizes(), 'done' is set to TRUE if the SA size + header > the
bonus buffer's length - sizeof (blkptr_t), then hdrsize += sizeof(uint16_t)
will be skipped for the second variable-length SA.  If finally all SA can
fit in the bonus buffer and no spill block is needed, we will get a wrong
hdrsize.

Reproduction case:

touch 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
ln -s 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 file
setfacl -h -m u:root:rwx:allow,g:wheel:rwx:allow file

would trigger an assertion in zdb -vvv:

Assertion failed: (IS_SA_BONUSTYPE(bonustype) && SA_HDR_SIZE_MATCH_LAYOUT(hdr, tb) || !IS_SA_BONUSTYPE(bonustype) || (IS_SA_BONUSTYPE(bonustype) && hdr->sa_layout_info == 0)), file /usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c, line 1509.

Submitted by:	James Pan <jiaming.pan@yahoo.com>
Export the maxio field in the CAM XPT_PATH_INQ CCB in the isp(4)
driver.

This tells consumers up the stack the maximum I/O size that the
controller can handle.

The I/O size is bounded by the number of scatter/gather segments
the controller can handle and the page size.  For an amd64 system,
it works out to around 5MB.

Reviewed by:	mjacob
MFC after:	3 days
Sponsored by:	Spectra Logic

(cherry picked from commit c6e2041529c9c69f395d4780ca05dbd3a9d186e5)
Optimize isp(4) to reduce CPU usage, especially in target mode:
 - Remove two excessive and slow register reads from isp_intr().  Instead
of rereading value every time, assume that registers contain what we have
written there.
 - Avoid sequential search through 4096 array elements when looking for
command tag.  Use hash of lists to store active tags separately from free
ones and so greatly speedup the searches.

Reviewed by:	mjacob

(cherry picked from commit 15c0a70328aa63ca3449f90fd6f9bd79f6a2d3ca)
Partial MFproject/camlock r256671:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs.  Not all CCB flags there belong to them.

(cherry picked from commit c13057cda99bb0e6f77b03f2a0722df6a9aaba82)
Save one more register read per command by not reading rqstoutrp register
every time.  The purpose of that register is unlikely output queue overflow
detection, so read it only when its last known (and probably stale now)
value signals overflow.

This reduces CPU load and lock congestion and rises bottleneck in CTL
while doing target mode via two 8Gbps ports from 100K to 120K IOPS.

(cherry picked from commit f3e02a23492c8e53ed0e8e8231fba7406c24b4dc)
Some more registers access optimizations:
 - Process ATIO queue only if interrupt status tells so;
 - Do not update queue out pointers after each processed command, do it
only once at the end of the loop.

(cherry picked from commit 963d7e1a2a5801201ee0279e94acdb3d2ab5d308)
Use relaxed (write-only) memory barriers when writing some of queue index
registers (for now on ISP2400+).  We never read those registers back and
AFAIK their semantics does not require any immediate reaction on write.

(cherry picked from commit b5ebe2e35e78b419af1fd73654a125ae8a4b14de)
Harvest one no longer used constant string.

Remove another and place it into play in the
normally ifdef protected zone it would be used
int.

Noticed by:	dim

(cherry picked from commit 258c0be375414a2ecddb9f8db57bb16625ef7ca0)
Fix I/O freezes in some cases, caused by r257916.

Delaying isp_reqodx update, we should be ready to update it every time
we read it.  Otherwise requests using several indexes may be requeued
ndefinitely without ever updating the variable.

MFC after:	3 days

(cherry picked from commit 19aa67ecd2dcb656dae87384e2cdf4aed4ef6e69)
cxgbe(4): Assume that CSUM_TSO in the transmit path implies CSUM_IP and
CSUM_TCP too.  They are all set explicitly by the kernel usually.

While here, fix an unrelated bug where hardware L4 checksum calculation
was accidentally disabled for some IPv6 packets.

Reported by:	alfred@
MFC after:	3 days

(cherry picked from commit c37d6a03084a22b73b4dd7bfee296ef9cd6054e4)
Revert "cxgbe(4): Assume that CSUM_TSO in the transmit path implies CSUM_IP and"

This reverts commit d906f3fd22f65677dabef61c954fd3699ef57586.
cxgbe(4): Assume that CSUM_TSO in the transmit path implies CSUM_IP and
CSUM_TCP too.  They are all set explicitly by the kernel usually.

While here, fix an unrelated bug where hardware L4 checksum calculation
was accidentally disabled for some IPv6 packets.

Reported by:	alfred@
MFC after:	3 days

(cherry picked from commit 3c760430882730431f5870f23294cb580e98ea3f)
Now that we support shared locking in vnodes when doing fsync and writing, it
makes no sense to insist exclusive locked vnode for VOP_PUTPAGES so loosen
the constraint.

Ticket: #4578
Print IP address when monitor or unmonitor fails.
In 'zfs send' when sending multiple snapshots in one go and when
verbose is enabled (-V or -v), libzfs would spawn a watcher thread
which periodically pokes the kernel for update.

The watcher thread itself sleep()'s inside to implement the wait
interval.  The current sleep(2) implementation on FreeBSD does not
immediately return when pthread_cancel() is called, which is what
the main thread used to notify that the watcher should quit.

Looking at the code, when a 'zfs send' is completed,
ZFS_IOC_SEND_PROGRESS would bail out with ENOENT so it does not
make much sense to do pthread_cancel and pthread_join is sufficient.

Instead of doing a blind sleep(), we now use pthread_cond_timedwait()
and signals the watcher thread to quit when we know it's ready.

While I'm there, also make 'zfs send -v' only print out the table
header when there is something to show.  This fixes the issue when
sending very small snapshots where one will see:

TIME        SENT   SNAPSHOT
TIME        SENT   SNAPSHOT
TIME        SENT   SNAPSHOT
TIME        SENT   SNAPSHOT
TIME        SENT   SNAPSHOT

But no actual data.  The new code now prevents this from happening
at expense of making the table header showing about 1 second later.

Ticket: #4610
Split filedesc lock into directory lock and entry lock in attempt
of solving a lock order reversal.