MFC r253494:
id_t is 64bit, provide the compat32 wrapper for clock_getcpuclockid2(2).

Reminded by:	Petr Salinger <Petr.Salinger@seznam.cz>
Regenerate.
Revert r254626 to fix the build.
MFC r253604: rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST
MFC r253603: zfs: move vnode creation from zfs_znode_cache_constructor
to zfs_znode_alloc
MFC r253606: zfs module: perform cleanup during shutdown in addition to
module unload
MFC r253772,253773,253989: dtrace disassembler: take the latest/last
CDDL code from OpenSolaris
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.
MFC r253677,253679: make path matching in devfs rules consistent and
sane (and safer)
MFC r254581:

Pull in r188716 from upstream clang trunk:

  PR16727: don't try to evaluate a potentially value-dependent
  expression when checking for missing parens in &&/|| expressions.

This fixes an assertion encountered when building the lang/sdcc port.

Reported by:	kwm
MFC r254582:

Pull in r182983 from upstream clang trunk:

  Fix handling of braced-init-list as reference initializer within
  aggregate initialization. Previously we would incorrectly require an
  extra set of braces around such initializers.

Pull in r188718 from upstream clang trunk:

  Handle init lists and _Atomic fields.

  Fixes PR16931.

These fixes are needed for the atomic_flag type to work correctly in our
stdatomic.h.

Requested by:	theraven
MFC r254438:
Fix some USB controller names according to pciconf output.

Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC r253282:

A complete duplication of binding should be allowed if on both new and
duplicated sockets a multicast address is bound and either
SO_REUSEPORT or SO_REUSEADDR is set.

But actually it works for the following combinations:

  * SO_REUSEPORT is set for the fist socket and SO_REUSEPORT for the new;
  * SO_REUSEADDR is set for the fist socket and SO_REUSEADDR for the new;
  * SO_REUSEPORT is set for the fist socket and SO_REUSEADDR for the new;

and fails for this:

  * SO_REUSEADDR is set for the fist socket and SO_REUSEPORT for the new.

Fix the last case.

PR:		179901
MFC r254465: Correct implementation of atomic_flag_test_and_set

(This is a direct commit to stable/9 as atomic_flag_test_and_set_explicit
is an inline function on HEAD and in a different file.)
MFC	r253651, r253652, r253657;

ext2fs: Don't assume that on-disk format of a directory is the same
as in <sys/dirent.h>

ext2_readdir() has always been very fs specific and different
with respect to its ufs_ counterpart. Recent changes from UFS
have made it possible to share more closely the implementation.

Always start parsing at DIRBLKSIZ aligned offset, skip first entries if
uio_offset is not DIRBLKSIZ aligned. Return EINVAL if buffer is too
small for single entry.

Preallocate buffer for cookies.

Skip entries with zero inode number.

Reviewed by:	gleb, Zheng Liu
Merge r226837 & r226839 from head:

r226837:
Improve AES-NI performance for AES-XTS:
- Operate on uint64_t types when doing XORing, etc. instead of uint8_t.
- Don't bzero() temporary block for every AES block. Do it once for entire
  data block.
- AES-NI is available only on little endian architectures. Simplify code
  that takes block number from IV.

r226839:
Update Copyright.
MFC r226840: AESNI-related commit, from a long time ago:

Before this change when GELI detected hardware crypto acceleration it will
start only one worker thread. For software crypto it will start by default
N worker threads where N is the number of available CPUs.

This is not optimal if hardware crypto is AES-NI, which uses CPU for AES
calculations.

Change that to always start one worker thread for every available CPU.
Number of worker threads per GELI provider can be easly reduced with
kern.geom.eli.threads sysctl/tunable and even for software crypto it
should be reduced when using more providers.

While here, when number of threads exceeds number of CPUs avilable don't
reduce this number, assume the user knows what he is doing.

Submitted by:	Michael Moll <kvedulv@kvedulv.de>
MFC r254651:

Update Bind to 9.9.3-P2

Notable new features:

*  Elliptic Curve Digital Signature Algorithm keys and signatures in
   DNSSEC are now supported per RFC 6605. [RT #21918]

*  Introduces a new tool "dnssec-verify" that validates a signed zone,
   checking for the correctness of signatures and NSEC/NSEC3 chains.
   [RT #23673]

*  BIND now recognizes the TLSA resource record type, created to
   support IETF DANE (DNS-based Authentication of Named Entities)
   [RT #28989]

*  The new "inline-signing" option, in combination with the
   "auto-dnssec" option that was introduced in BIND 9.7, allows
   named to sign zones completely transparently.

Approved by:	delphij (mentor)
Sponsored by:	DK Hostmaster A/S
MFC mps(4) driver changes 253460, 253549, 253550 and 254615.

There are some slight changes here from the version in head.

__FreeBSD_version has been bumped to 902502 for the inclusion of the
PIM_RESCAN CAM path inquiry flag.  The ifdefs in the mps(4) driver
have been changed accordingly.

In head, the TDP_NOSLEEPING thread flag has been removed but it
still exists in stable/9.

  ------------------------------------------------------------------------
  r253460 | scottl | 2013-07-18 18:12:41 -0600 (Thu, 18 Jul 2013) | 5 lines

  Overhaul error, information, and debug logging.

  Obtained from:	Netflix

  ------------------------------------------------------------------------
  r253549 | ken | 2013-07-22 12:37:07 -0600 (Mon, 22 Jul 2013) | 57 lines

  CAM and mps(4) driver scanning changes.

  Add a PIM_NOSCAN flag to the CAM path inquiry CCB.  This tells CAM
  not to perform a rescan on a bus when it is registered.

  We now use this flag in the mps(4) driver.  Since it knows what
  devices it has attached, it is more efficient for it to just issue
  a target rescan on the targets that are attached.

  Also, remove the private rescan thread from the mps(4) driver in
  favor of the rescan thread already built into CAM.  Without this
  change, but with the change above, the MPS scanner could run before
  or during CAM's initial setup, which would cause duplicate device
  reprobes and announcements.

  sys/param.h:
  	Bump __FreeBSD_version to 1000039 for the inclusion of the
  	PIM_RESCAN CAM path inquiry flag.

  sys/cam/cam_ccb.h:
  sys/cam/cam_xpt.c:
  	Added a PIM_NOSCAN flag.  If a SIM sets this in the path
  	inquiry ccb, then CAM won't rescan the bus in
  	xpt_bus_regsister.

  sys/dev/mps/mps_sas.c
  	For versions of FreeBSD that have the PIM_NOSCAN path
  	inquiry flag, don't freeze the sim queue during scanning,
  	because CAM won't be scanning this bus.  Instead, hold
  	up the boot.  Don't call mpssas_rescan_target in
  	mpssas_startup_decrement; it's redundant and I don't
  	know why it was in there.

  	Set PIM_NOSCAN in path inquiry CCBs.

  	Remove methods related to the internal rescan daemon.

  	Always use async events to trigger a probe for EEDP support.
  	In older versions of FreeBSD where AC_ADVINFO_CHANGED is
  	not available, use AC_FOUND_DEVICE and issue the
  	necessary READ CAPACITY manually.

  	Provide a path to xpt_register_async() so that we only
  	receive events for our own SCSI domain.

  	Improve error reporting in cases where setup for EEDP
  	detection fails.

  sys/dev/mps/mps_sas.h:
  	Remove softc flags and data related to the scanner thread.

  sys/dev/mps/mps_sas_lsi.c:
  	Unconditionally rescan the target whenever a device is added.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
  r253550 | ken | 2013-07-22 12:41:53 -0600 (Mon, 22 Jul 2013) | 93 lines

  Merge in phase 14+ -> 16 mps driver fixes from LSI:

  ---------------------------------------------------------------
  System panics during a Port reset with ouststanding I/O
  ---------------------------------------------------------------
  It is possible to call mps_mapping_free_memory after this
  memory is already freed, causing a panic. Removed this extra
  call to mps_mappiing_free_memory and call mps_mapping_exit
  in place of the mps_mapping_free_memory call so that any
  outstanding mapping items can be flushed before memory is
  freed.

  ---------------------------------------------------------------
  Correct memory leak during a Port reset with ouststanding I/O
  ---------------------------------------------------------------
  In mps_reinit function, the mapping memory was not being
  freed before being re-allocated. Added line to call the
  memory free function for mapping memory.

  ---------------------------------------------------------------
  Use CAM_SIM_QUEUED flag in Driver IO path.
  ---------------------------------------------------------------
  This flag informs the XPT that successful abort of a CCB
  requires an abort ccb to be issued to the SIM.  While
  processing SCSI IO's, set the CAM_SIM_QUEUED flag in the
  status for the IO. When the command completes, clear this
  flag.

  ---------------------------------------------------------------
  Check for CAM_REQ_INPROG in I/O path.
  ---------------------------------------------------------------
  Added a check in mpssas_action_scsiio for the In Progress
  status for the IO. If this flag is set, the IO has already
  been aborted by the upper layer (before CAM_SIM_QUEUED was
  set) and there is no need to send the IO. The request will
  be completed without error.

  ---------------------------------------------------------------
  Improve "doorbell handshake method" for mps_get_iocfacts
  ---------------------------------------------------------------
  Removed call to get Port Facts since this information is
  not used currently.

  Added mps_iocfacts_allocate function to allocate memory
  that is based on IOC Facts data.  Added mps_iocfacts_free
  function to free memory that is based on IOC Facts data.
  Both of the functions are used when a Diag Reset is performed
  or when the driver is attached/detached. This is needed in
  case IOC Facts changes after a Diag Reset, which could
  happen if FW is upgraded.

  Moved call of mps_bases_static_config_pages from the attach
  routine to after the IOC is ready to process accesses based
  on the new memory allocations (instead of polling through
  the Doorbell).

  ---------------------------------------------------------------
  Set TimeStamp in INIT message in millisecond format Set the IOC
  ---------------------------------------------------------------

  ---------------------------------------------------------------
  Prefer mps_wait_command to mps_request_polled
  ---------------------------------------------------------------
  Instead of using mps_request_polled, call mps_wait_command
  whenever possible. Change the mps_wait_command function to
  check the current context and either use interrupt context
  or poll if required by using the pause or DELAY function.
  Added a check after waiting 50mSecs to see if the command
  has timed out. This is only done if polliing, the msleep
  command will automatically timeout if the command has taken
  too long to complete.

  ---------------------------------------------------------------
  Integrated RAID: Volume Activation Failed error message is
  displayed though the volume has been activated.
  ---------------------------------------------------------------
  Instead of failing an IOCTL request that does not have a
  large enough buffer to hold the complete reply, copy as
  much data from the reply as possible into the user's buffer
  and log a message saying that the user's buffer was smaller
  than the returned data.

  ---------------------------------------------------------------
  mapping_add_new_device failure due to persistent table FULL
  ---------------------------------------------------------------
  When a new device is added, if it is determined that the
  device persistent table is being used and is full, instead
  of displaying a message for this condition every time, only
  log a message if the MPS_INFO bit is set in the debug_flags.

  Submitted by:	LSI

  ------------------------------------------------------------------------
  r254615 | ken | 2013-08-21 15:30:56 -0600 (Wed, 21 Aug 2013) | 32 lines

  Fix mps(4) driver breakage that came in in change 253550 that
  manifested itself in out of chain frame conditions.

  When the driver ran out of chain frames, the request in question
  would get completed early, and go through mpssas_scsiio_complete().

  In mpssas_scsiio_complete(), the negation of the CAM status values
  (CAM_STATUS_MASK | CAM_SIM_QUEUED) was ORed in instead of being
  ANDed in.  This resulted in a bogus CAM CCB status value.  This
  didn't show up in the non-error case, because the status was reset
  to something valid (e.g. CAM_REQ_CMP) later on in the function.

  But in the error case, such as when the driver ran out of chain
  frames, the CAM_REQUEUE_REQ status was ORed in to the bogus status
  value.  This led to the CAM transport layer repeatedly releasing
  the SIM queue, because it though that the CAM_RELEASE_SIMQ flag had
  been set.  The symptom was messages like this on the console when
  INVARIANTS were enabled:

  xpt_release_simq: requested 1 > present 0
  xpt_release_simq: requested 1 > present 0
  xpt_release_simq: requested 1 > present 0

  mps_sas.c:	In mpssas_scsiio_complete(), use &= to take status
  		bits out.  |= adds them in.

  		In the error case in mpssas_scsiio_complete(), set
  		the status to CAM_REQUEUE_REQ, don't OR it in.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
Partial MFC of r253927 (by attilio):
Remove unnecessary soft busy of the page before to do vn_rdwr() in
kern_sendfile() which is unnecessary.

MFC note:
NFS implementation of VOP_READ() sometimes upgrades the vnode lock,
which causes drop of the shared lock and sleep for exclusive.  As
result, busying of the page before the call to vn_rdwr() makes NFS
code to wait for vnode lock while page is busy, which contradicts the
proper order of vnode lock -> busy.

The r250027, merged as part of r250907, started calling vm_page_grab()
under the vnode lock.  The page grab waits for the page busy state to
drain, which makes the parallel sendfile(2) invocations on the same
vnode vulnerable to the LOR described above.

Note that r250027 only exposed the problem, which might be caused by
other means as well, e.g. by parallel sendfile(2) and truncate(2).

Sponsored by:	The FreeBSD Foundation