MFC: r253926

zfs_ioc_rename should not leave the value of zc_name passed in via zc altered
on return.

(cherry picked from commit 857ef62a911c8189ab813c5edda623f23491fa65)
MFC r253603: zfs: move vnode creation from zfs_znode_cache_constructor
to zfs_znode_alloc

(cherry picked from commit 5489165c9e54261434a51b6b285bf15d36fcf801)
MFC r253606: zfs module: perform cleanup during shutdown in addition to
module unload

(cherry picked from commit a9fc1c509129e3fd4d21a50014d7dc80e0bb097a)
MFC r253772,253773,253989: dtrace disassembler: take the latest/last
CDDL code from OpenSolaris

(cherry picked from commit 5dc7b01aaf19a3b1552df62f266ee8bb347f6b14)
MFC r253996,253997: opensolaris code: translate INVARIANTS to DEBUG and ZFS_DEBUG

Please note that support for compiling ZFS into a kernel is not in this
branch as of now.

(cherry picked from commit ad554d70647291ebe8d9cb6fe9bb313028155455)
MFC r254713: fbt: drop a local write-only variable

(cherry picked from commit 3dc372469a5f6d7367acd4c9e87a1bd99e7a6b9b)
MFC r254445,254711: zfs: inline and remove zfs_vnode_lock

(cherry picked from commit 8d9902b250a4d63d4cb7526a9abc734d9c6813dd)
MFC r254714: zfs: do not reject any operations on a pool just because
it's a boot pool

(cherry picked from commit 97dcf093698c7e4a669352144677d6cb205aedea)
MFC r250953:
The fasttrap provider cleans up probes asynchronously when a process with
USDT probes exits. This was previously done with a callout; however, it is
possible to sleep while holding the DTrace mutexes, so a panic will occur
on INVARIANTS kernels if the callout handler can't immediately acquire one
of these mutexes. This panic will be frequently triggered on systems where
a USDT-enabled program (perl, for instance) is often run.

This revision changes the fasttrap cleanup mechanism so that a dedicated
thread is used instead of a callout. The old behaviour is otherwise
preserved.

MFC r252493:
Be sure to destory the fasttrap cleanup mutex when unloading the fasttrap
module. This should be MFCed with r250953.

(cherry picked from commit 8889efce4ed924f115c553747534c5e30b8fad11)
MFC r252894:
Add SDT_PROBE_DEFINE0 for consistency with SDT_PROBE0.

MFC r253022:
Also define SDT_PROBE_DEFINE0 for the !KDTRACE_HOOKS case.

MFC r254266:
Add event handlers for module load and unload events. The load handlers are
called after the module has been loaded, and the unload handlers are called
before the module is unloaded. Moreover, the module unload handlers may
return an error to prevent the unload from proceeding.

MFC r254267:
Remove some unused fields from struct linker_file. They were added in
r172862 for use by the DTrace SDT framework but don't seem to have ever
been used.

MFC r254268:
FreeBSD's DTrace implementation has a few problems with respect to handling
probes declared in a kernel module when that module is unloaded. In
particular,

* Unloading a module with active SDT probes will cause a panic. [1]
* A module's (FBT/SDT) probes aren't destroyed when the module is unloaded;
  trying to use them after the fact will generally cause a panic.

This change fixes both problems by porting the DTrace module load/unload
handlers from illumos and registering them with the corresponding
EVENTHANDLER(9) handlers. This allows the DTrace framework to destroy all
probes defined in a module when that module is unloaded, and to prevent a
module unload from proceeding if some of its probes are active. The latter
problem has already been fixed for FBT probes by checking lf->nenabled in
kern_kldunload(), but moving the check into the DTrace framework generalizes
it to all kernel providers and also fixes a race in the current
implementation (since a probe may be activated between the check and the
call to linker_file_unload()).

Additionally, the SDT implementation has been reworked to define SDT
providers/probes/argtypes in linker sets rather than using SYSINIT/SYSUNINIT
to create and destroy SDT probes when a module is loaded or unloaded. This
simplifies things quite a bit since it means that pretty much all of the SDT
code can live in sdt.ko, and since it becomes easier to integrate SDT with
the DTrace framework. Furthermore, this allows FreeBSD to be quite flexible
in that SDT providers spanning multiple modules can be created on the fly
when a module is loaded; at the moment it looks like illumos' SDT
implementation requires all SDT probes to be statically defined in a single
kernel table.

MFC r254309:
Use kld_{load,unload} instead of mod_{load,unload} for the linker file load
and unload event handlers added in r254266.

MFC r254350:
Specify SDT probe argument types in the probe definition itself rather than
using SDT_PROBE_ARGTYPE(). This will make it easy to extend the SDT(9) API
to allow probes with dynamically-translated types.

(cherry picked from commit 16f42c20d1717e7474b80159b50743184c7b528f)
MFC	r250574, r250812, r253725;

DTrace: option for time-ordered output

Merge changes from illumos:

3021 option for time-ordered output from dtrace(1M)
3022 DTrace: keys should not affect the sort order when sorting by value
3023 it should be possible to dereference dynamic variables
3024 D integer narrowing needs some work
3025 register leak in D code generation

This brings yet another feature implemented in upstream DTrace.
A complete description is available here:
http://dtrace.org/blogs/ahl/2012/07/28/my-new-dtrace-favorite/

This change bumps the DT_VERS_* number to 1.9.1 in
accordance to what is done in illumos.

Special thanks to Mark Johnston for fixes and testing.

Illumos Revisions:	13758:23432da34147

Reference:
https://www.illumos.org/issues/3021
https://www.illumos.org/issues/3022
https://www.illumos.org/issues/3023
https://www.illumos.org/issues/3024
https://www.illumos.org/issues/3025
https://www.illumos.org/issues/1694

Obtained from:	Illumos

(cherry picked from commit fff8fc280ab3bfae14e4a4e2719a72c38887e4a2)
MFC	r249426;

Merge change from illumos:

3519 DTrace fails to resolve const types from fbt
3520 dtrace internal error -- token type 316 is not a valid D
     compilation token
3521 clean up dtrace unit tests

Illumos Revision:	e98f46c

Reference:
https://www.illumos.org/issues/3519
https://www.illumos.org/issues/3520
https://www.illumos.org/issues/3521

Tested by:	Fabian Keil
Obtained from:	Illumos

(cherry picked from commit 6c4735c1524a5f68f84a84cb5d19ee271a8cadd9)
MFC	r254941;

Merge a couple of CTF fixes from illumos:

2942 CTF tools need to handle files which legitimately lack data
2978 ctfconvert still needs to ignore legitimately dataless files on SPARC

Illumos Revisions:	13745:6b3106b4250f
			13754:7231b684c18b

Reference:

https://www.illumos.org/issues/2942
https://www.illumos.org/issues/2978

Obtained from:	Illumos

(cherry picked from commit 8630214a7614c7d2453fc80a896e19e96993e5de)
MFC r255363:
Micro-optimize cpu_search(), allowing compiler to use more efficient inline
ffsl() implementation, when it is available, instead of homegrown iteration.

On dual-E5645 amd64 system (2x6x2 cores) under heavy I/O load that reduces
time spent inside cpu_search() from 19% to 13%, while IOPS increased by 5%.

(cherry picked from commit ddcc28ccab433f7ef2b026d47d60b5945289a148)
MFC r253604: rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST

(cherry picked from commit c16051b56af88558d73bae715a10813e14a118c4)