Illumos #3116 zpool reguid may log negative guids to internal SPA history

The change to fix Illumos 3116 was accidentally included int he
libzfs_core merge to ZFSOnLinux, so I have created this commit to
provide it as a backport to 0.6.2.

Ported-by: Richard Yao <ryao@gentoo.org>

References:

https://www.illumos.org/issues/3561
https://www.illumos.org/issues/3116
illumos/illumos-gate@20128a0826f9c53167caa9215c12f08beee48e30
Illumos #3578, #3579

3578 transferring the freed map to the defer map should be constant time
3579 ztest trips assertion in metaslab_weight()
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Richard Elling <richard.elling@dey-sys.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
Ported-by: Richard Yao <ryao@gentoo.org>

References:

https://www.illumos.org/issues/3578
https://www.illumos.org/issues/3579
illumos/illumos-gate@9eb57f7f3fbb970d4b9b89dcd5ecf543fe2414d5
3552 condensing one space map burns 3 seconds of CPU in spa_sync() thread (fix race condition)

Ported-by: Richard Yao <ryao@gentoo.org>

References:
https://www.illumos.org/issues/3552
illumos/illumos-gate@03f8c366886542ed249a15d755ae78ea4e775d9d

Porting notes:

zfsonlinux/zfs@e51be06697762215dc3b679f8668987034a5a048 claimed to have
included this, but it did not. I discovered this when comparing our
metaslab.c to the illumos metaslab.c.
Illumos #3603, #3604: bobj improvements

3603 panic from bpobj_enqueue_subobj()
3604 zdb should print bpobjs more verbosely
3871 GCC 4.5.3 does not like issue 3604 patch

https://www.illumos.org/issues/3603
https://www.illumos.org/issues/3604
https://www.illumos.org/issues/3871

Reviewed by: Henrik Mattson <henrik.mattson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Dan McDonald <danmcd@nexenta.com>
Ported-by: Richard Yao <ryao@gentoo.org>

Note that the patch from Illumos issue 3871 is not accepted into Illumos
at the time of this writing. It is something that I wrote when porting
this. Documentation is in the Illumos issue.
Illumos #3517

3517 importing pool with autoreplace=on and "hole" vdevs crashes syseventd
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Jeffry Molanus <jeffry.molanus@nexenta.com>
Reviewed by: George Wilson <gwilson@zfsmail.com>
Approved by: Christopher Siden <christopher.siden@delphix.com>
Ported-by: Richard Yao <ryao@gentoo.org>

https://www.illumos.org/issues/3517
illumos/illumos-gate@efb4a871d8fd510a833bdca610528dde5ed69e42
Illumos #3745, #3811

3745 zpool create should treat -O mountpoint and -m the same
3811 zpool create -o altroot=/xyz -O mountpoint=/mnt ignores the mountpoint option
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Christopher Siden <christopher.siden@delphix.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>

References:

https://www.illumos.org/issues/3745
https://www.illumos.org/issues/3811
illumos/illumos-gate@8b713775314bbbf24edd503b4869342d8711ce95
Illumos #3964

3964 L2ARC should always compress metadata buffers
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Elling <richard.elling@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
Ported-by: Richard Yao <ryao@gentoo.org>

Closes zfsonlinux/zfs#1688