Use ctl_set_success() instead of direct inlining.

MFC after:	1 week

(cherry picked from commit 029391b08904011dd57ebd772aeb6b7c9620be5d)
Replace home-grown CTL IO allocator with UMA.

Old allocator created significant lock congestion protecting its lists
of preallocated I/Os, while UMA provides much better SMP scalability.
The downside of UMA is lack of reliable preallocation, that could guarantee
successful allocation in non-sleepable environments.  But careful code
review shown, that only CAM target frontend really has that requirement.
Fix that making that frontend preallocate and statically bind CTL I/O for
every ATIO/INOT it preallocates any way.  That allows to avoid allocations
in hot I/O path.  Other frontends either may sleep in allocation context
or can properly handle allocation errors.

On 40-core server with 6 ZVOL-backed LUNs and 7 iSCSI client connections
this change increases peak performance from ~700K to >1M IOPS!  Yay! :)

MFC after:	1 month
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 6c036a86ca2410c1186647bf2d76a30f953ffe92)

Conflicts:
	sys/cam/ctl/scsi_ctl.c
Decouple datamove/done logic from CTL status set.

(cherry picked from commit 15164a21934a9630dff789459335bc2d18cceb10)

Conflicts:
	sys/cam/ctl/scsi_ctl.c
Coalesce last data move and command status for read commands.

Make CTL core and block backend set success status before initiating last
data move for read commands.  Make CAM target and iSCSI frontends detect
such condition and send command status together with data.  New I/O flag
allows to skip duplicate status sending on later fe_done() call.

For Fibre Channel this change saves one of three interrupts per read command,
increasing performance from 126K to 160K IOPS.  For iSCSI this change saves
one of three PDUs per read command, increasing performance from 1M to 1.2M
IOPS.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 115d2f3c0bcc4cd75986c7f6ec8a1e9bd379df14)

Conflicts:
	sys/cam/ctl/ctl.c
Removed unused variable and unify some names.

(cherry picked from commit 5fd40975d0bc93d30eeb8e699153a7c957b25a0e)
Reduce code duplication by creating ctl_set_res_ua() helper.

(cherry picked from commit 01c057650ce8b923893fa2c0e4b7a7e259883752)
Convert persis_offset from global variable to softc field.

(cherry picked from commit 23b376789b87f152bc5cb2e9647422f23bca9b61)
Do not pre-allocate reservation keys memory for every possible initiator.

In configurations with many ports, like iSCSI, each LUN is typically
accessed only by limited subset of ports.  Allocating that memory on
demand allows to reduce CTL memory usage from 5.3MB/LUN to 1.3MB/LUN.

MFC after:	1 month

(cherry picked from commit 826327d5dbd4663217586bd43ca25540e6effa4b)
Remove some unused code.

(cherry picked from commit 3167e2db4c943873e00c698889aa7aa92149f2c9)
Do not pre-allocate UNIT ATTENTIONs storage for every possible initiator.

Abusing ability of major UAs cover minor ones we may not account UAs for
inactive ports.  Allocate UAs storage for port and start accounting only
after some initiator from that port fetched its first POWER ON OCCURRED.

This reduces per-LUN CTL memory usage from >1MB to less then 100K.

MFC after:	1 month

(cherry picked from commit b087af8dc4d3cb722513deff2cf2495435a68e3a)
Unify function names after r275458.

MFC after:	1 month

(cherry picked from commit 4c8c231b28bd5a8a0641516dae108054f908f65e)
Increase CTL ports limit from 128 to 256 and LUNs limit from 256 to 1024.

After recent optimizations this change is no longer blocked by CTL memory
consumption.  Those limits are still not free, but much cheaper now.

MFC after:	1 week
Relnotes:	yes
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 0955bcdd21e020edd95513ac47f8b1f36da050d4)
Add GET LBA STATUS command support to CTL.

It is implemented for LUNs backed by ZVOLs in "dev" mode and files.
GEOM has no such API, so for LUNs backed by raw devices all LBAs will
be reported as mapped/unknown.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 7884d9292abc7321b1da3091721ea068911a877f)
Add to CTL support for threshold notifications for file-backed LUNs.

Previously it was supported only for ZVOL-backed LUNs, but now should work
for file-backed LUNs too.  Used value in this case is a space occupied by
the backing file, while available value is an available space on file
system.  Pool thresholds are still not implemented in this case.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 8f8bb7915235e95da464a872d6afc9737ac4fe8e)
In addition to r275481 allow threshold notifications work without UNMAP.

While without UNMAP support there is not much initiator can do about it,
the administrator still better be notified about the storage overflow.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 04a19682d2176279276964dfe860b5e9e18ec299)
Do not count RCTD bit set as an error.

We can not really implement it, but specification tells that it "shall"
work, so it can be safely ignored.

MFC after:	1 week

(cherry picked from commit 22481bc2c20ca4fd2e3eb219fce7c3b16e226b98)