MFV r275549:

Add a loader tunable, vfs.zfs.arc_meta_min, which controls how much metadata
ZFS should keep in ARC at minimum.

In arc_evict(), when doing recycle, take more factors into account by
applying the following policy:

  1. If no evictable data, evict metadata;
  2. If no evictable metadata, evict data;
  3. If we hit arc_meta_limit, evict metadata;
  4. If we haven't hit arc_meta_min, evict data;
  5* (Illumos only, not present in new FreeBSD code, yet) evict the oldest
     cached element from data and metadata.
     (FreeBSD) evict the data type specified by caller, which is the
     existing behavior.

Note that because of our splitted locks (implemented in r205231 to improve
scalability by reducing lock contention), implementing the fifth Illumos
behavior will not be cheap, so for now just implement the 1-4 and fall back
to current behavior for 5.

Illumos issue:
    5368 ARC should cache more metadata

MFC after:	2 months (assuming we didn't found better solution)


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

In addition to r273158, make the code in spa_sync() that checks if the
current TXG is a no-op TXG less fragile.

Illumos issue:
    5347 idle pool may run itself out of space

MFC after:	2 weeks


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

Remove "dbuf phys" db->db_data pointer aliases.

Use function accessors that cast db->db_data to the appropriate
"phys" type, removing the need for clients of the dmu buf user
API to keep properly typed pointer aliases to db->db_data in order
to conveniently access their data.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c:
        In zap_leaf() and zap_leaf_byteswap, now that the pointer alias
        field l_phys has been removed, use the db_data field in an on
        stack dmu_buf_t to point to the leaf's phys data.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:
        Remove the db_user_data_ptr_ptr field from dbuf and all logic
        to maintain it.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c:
        Modify the DMU buf user API to remove the ability to specify
        a db_data aliasing pointer (db_user_data_ptr_ptr).

cddl/contrib/opensolaris/cmd/zdb/zdb.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_diff.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_bookmark.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h:
        Create and use the new "phys data" accessor functions
        dsl_dir_phys(), dsl_dataset_phys(), zap_m_phys(),
        zap_f_phys(), and zap_leaf_phys().

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h:
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h:
        Remove now unused "phys pointer" aliases to db->db_data
        from clients of the DMU buf user API.

Illumos issue:
    5314 Remove "dbuf phys" db->db_data pointer aliases in ZFS

MFC after:	2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275782 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Resolve USB driver identification conflict.

Reported by:	Anish Mistry <amistry@am-productions.biz>
MFC after:	1 week


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

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275791 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Eliminate fdt_data_verify(). The verification it proceed is wrong
disallowing us to encode 64-bit register numbers.

Discussed with:	nwhitehorn, andrew


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275792 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Follow r275792 eliminating fdt_data_verify().


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275799 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add a facility for non-init process to declare itself the reaper of
the orphaned descendants.  Base of the API is modelled after the same
feature from the DragonFlyBSD.

Requested by:	bapt
Reviewed by:	jilles (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks


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


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275802 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remove empty generated file upon gperf failure

Prior to this change the build could fail as follows, if gperf is not
available (or fails):

  - make(1) stops due to the gperf error, but an empty target file
    (cfns.h) is still created
  - the empty cfns.h is newer than the source cfns.gperf so it is not
    regenerated on subsequent builds
  - the gcc build fails (undefined reference to libc_name_p)

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275804 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix incorrect type of "invalids" argument in __iconv() prototype.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275805 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Markup fixes for kqueue(2), no content changes.

Reviewed by:	brueffer (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275806 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Check for SS_NBIO in so->so_state instead of sb->sb_flags in
soreceive_stream().

Differential Revision:	https://reviews.freebsd.org/D1299
Reviewed by:	bz, gnn
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275808 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Correct elftoolchain strip(1) memory size calculation

Calculate the segment's memory size (p_memsz) using the virtual
addresses, not the file offsets. Otherwise padding preceeding SHT_NOBITS
sections may be excluded from the calculation, resulting in a segment
that is too small.

PR:		195653
Sponsored by:	The FreeBSD Foundation


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

Convert ARC flags to use enum.  Previously, public flags are defined in
arc.h and private flags are defined in arc.c which can lead to confusion
and programming errors.

Consistently use 'hdr' (when referencing arc_buf_hdr_t) instead of 'buf'
or 'ab' because arc_buf_t are often named 'buf' as well.

Illumos issue:
    5369 arc flags should be an enum
    5370 consistent arc_buf_hdr_t naming scheme

MFC after:	2 weeks


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

Plug a memory leak in libzfs.  In zfs_iter_bookmarks, an nvlist is allocated
before calling lzc_get_bookmarks, which allocates the nvlist again (and
overwrites the pointer to previously allocated list).

Illumos issue:
    5427 memory leak in libzfs when doing rollback

MFC after:	2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275812 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Properly sort Xr to silence mandoc warnings.

Differential Revision:	https://reviews.freebsd.org/D1314
Reviewed by:	wblock
MFC after:	1 Month


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275813 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Use standard BSD license disclaimer text

Approved by:	benno, nwhitehorn


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275815 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix a bug introdiced in r217548.  According to NS DP83815 data
sheet, RX filter should be disabled before programming.
Previously it was clearing wrong bits so RX filter was not
disabled in RX filter configuration.

Reported by:	brad@OpenBSD.org


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275816 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
For level triggered interrupts clear the PIC IRR bit when the interrupt pin
is deasserted. Prior to this change each assertion on a level triggered irq
pin resulted in two interrupts being delivered to the CPU.

Differential Revision:	https://reviews.freebsd.org/D1310
Reviewed by:	tychon
MFC after:	1 week


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