Add sequence counters with memory barriers.

Current implementation is somewhat simplistic and hackish,
will be improved later after possible memory barrier overhaul.

Reviewed by:	kib
MFC after:	3 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@272503 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFV r272494:

Make space_map_truncate() always do space_map_reallocate().  Without
this, setting space_map_max_blksz would cause panic for existing pool,
as dmu_objset_set_blocksize would fail if the object have multiple blocks.

Illumos issues:
   5164 space_map_max_blksz causes panic, does not work
   5165 zdb fails assertion when run on pool with recently-enabled
	spacemap_histogram feature

MFC after:	2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@272504 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Plug capability races.

fp and appropriate capability lookups were not atomic, which could result in
improper capabilities being checked.

This could result either in protection bypass or in a spurious ENOTCAPABLE.

Make fp + capability check atomic with the help of sequence counters.

Reviewed by:	kib
MFC after:	3 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@272505 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFV r272495:

In arc_kmem_reap_now(), reap range_seg_cache too to reclaim memory in
response of memory pressure.

Illumos issue:
    5163 arc should reap range_seg_cache

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@272506 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f