Add a postinit debugger hook to rtld. This will be used by dtrace(1) to halt
the victim process before its entry point is called, at which point probes
and DOF data are registered with the kernel. The r_debug_state hook cannot
be used for this purpose, as it is called before the program's init routines
are invoked and in particular before DOF data is registered (via drti.o).

Reviewed by:	kib
MFC after:	2 weeks
Import George Wilson's change for Illumos #4730:

	4730 metaslab group taskq should be destroyed in metaslab_group_destroy()
	Reviewed by: Alex Reece <alex.reece@delphix.com>
	Reviewed by: Matthew Ahrens <mahrens@delphix.com>
	Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>

	Original author: George Wilson

MFC after:	3 days
In apm_write(), both fd and imgsz are referenced, so don't mark the
arguments as unused.
Due to reasons unknown at this time, the system can be forced to write
a journal block even when there are no journal entries to be written.
Until the root cause is found, handle this case by ensuring that a
valid journal segment is always written.

Second, the data buffer used for writing journal entries was never
being scrubbed of old data.  Fix this.

Submitted by:	Takehara Mikihito
Obtained from:	Netflix, Inc.
MFC after:	3 days
Sort .ALLSRC before concatenating files together.  This makes sure that the
file are always built the same.

(Note that Header and Localstuff must appear first and in that order, the
sorting does not affect as a coincident effect).

Submitted by:	sjg
MFC after:	3 days
Don't reply monlist request when it's not enabled.

No objection from:	roberto (but all bugs are mine)
MFC after:	2 weeks
Add missing svn:keywords property.
Add mkimg_write() which combines lseek(2) and write(2) and uses
sector granularity for both offset and length. Have all schemes
use mkimg_write() instead of mkimg_seek() followed by write(2).

Now that schemes don't use lseek(2) nor write(2) directly, it's
easier to support output formats other than raw disks.
dd(1) uses gettimeofday(2) to compute the throughput statistics.  However,
gettimeofday returns the system clock, which may jump forward or back,
especially if NTP is in use.  If the time jumps backwards, then dd will see
negative elapsed time, round it up to 1usec, and print an absurdly fast
transfer rate.

The solution is to use clock_gettime(2) with CLOCK_MONOTONIC_PRECISE as the
clock_id.  That clock advances steadily, regardless of changes to the system
clock.

Reviewed by:	delphij
MFC after:	3 days
Sponsored by:	Spectra Logic
Change the device name for mpr(4) from /dev/mpr_N to /dev/mprN.

This is more consistent with the existing mps(4) behavior.

Reviewed by:	Steve McConnell <stephen.mcconnell@avagotech.com>
MFC after:	3 days
Bump the default C-state to Cmax, rather than the kernel default
of C1.

This may not stay through 11.0-RELEASE, but at least having it
on by default in -HEAD will expose (more) issues with broken hardware.

Note: I have no plans or desire to MFC this to stable/10.
Merge -fstandalone-debug from Clang r198655:

  Implement a new -fstandalone-debug option. rdar://problem/15685848
  It controls everything that -flimit-debug-info used to, plus the
  vtable type optimization. The old -fno-limit-debug-info option is now an
  alias to -fstandalone-debug and vice versa.

  Standalone is the default on Darwin until dtrace is updated to work with
  non-standalone debug info (rdar://problem/15758808).

  Note: I kept the LimitedDebugInfo name in CodeGenOptions::DebugInfoKind
  because NoStandaloneDebugInfo sounded even more confusing.
Remove some debugging code.

Submitted by:	Steve McConnell <stephen.mcconnell@avagotech.com>
MFC after:	3 days
Hold the SIM lock when calling xpt_create_path() and xpt_action() in
mprsas_SSU_to_SATA_devices().

This fixes an assertion on shutdown with INVARIANTS enabled with SATA
drives present on an IR firmware controller.

Reviewed by:	Steve McConnell <stephen.mcconnell@avagotech.com>.
MFC after:	3 days
There's no need to be this paranoid - ni is deferenced before this
point.

Coverity ID:	 CID 1211937
msync(2) must return ENOMEM and not EINVAL when the address is outside the
allowed range or when one or more pages are not mapped. This according to
The Open Group Base Specifications Issue 7.

Discussed with:	 attilio, Bruce Evans
Reviewed by:	 alc, Garrett Cooper
Reported by:	 ATF
MFC after:	 2 weeks
Sponsored by:	EMC / Isilon storage division
- Sprinkle const and static as appropriate.
- Fix whitespace bugs.
- Remove pointless returns in void functions.
- Nuke pointless switch cases mirroring the default.

MFC after:	3 days
Sponsored by:	Bally Wulff Games & Entertainment GmbH
It is safe to allow shrinking, when aligned size is bigger than current.

Tested by:	jmg
MFC after:	1 week
Document r265236, addition of mpr(4).

Sponsored by:	The FreeBSD Foundation
Document r265348, Atheros AR1111 support.

Sponsored by:	The FreeBSD Foundation