MFV r269223:

Change dn->dn_dbufs from linked list to AVL tree.

Illumos issues:
  4873 zvol unmap calls can take a very long time for larger datasets

MFC after:	2 weeks

(cherry picked from commit 1747d793b5742aae99af6a1caf438bbb5e76b892)

Ticket: #6089
Split gethrtime() and gethrtime_waitfree() and make the former use
nanouptime() instead of getnanouptime().  nanouptime(9) provides more
precise result at expense of being slower.

In r269223, gethrtime() is used as creation time of dbuf, which in turn
acts as portion of lookup key to maintain AVL invariant where there can
not be duplicate items.  Before this change, gethrtime() have preferred
better execution time by sacrificing precision, which may lead to panic
on busy systems with:

	panic: avl_find() succeeded inside avl_add()

Reported by:	allanjude, mav
PR:		kern/192284
MFC after:	11 days
X-MFC-with:	r269223

(cherry picked from commit 3582d4b4c2b42c1ec0bcb73779e4f08ec87cbf4d)

This intermediate commit is merged only for completeness.

Ticket: #6089
Revert r269404 and use cpu_ticks() for dbuf allocation.

Encode CPU's number by XOR'ing the CPU ID against the 64-bit cpu_ticks().

Reviewed by:	mav, gibbs
Differential Revision: https://phabric.freebsd.org/D521
MFC after:	2 weeks

(cherry picked from commit 6ba22f8d1a754be2ddd46bea93f513a0980caa7c)

This intermediate commit is merged only for completeness.

Ticket: #6089
Instead of using timestamp in the AVL, use the memory address when
comparing.

Illumos issue:
    5095 panic when adding a duplicate dbuf to dn_dbufs

MFC after:	3 days

(cherry picked from commit d89e74165bb75cd2e02693e8f18d45101f63014b)

Ticket: #6089
MFV r271223:

In dnode_sync(), do dnode_increase_indirection() before processing
the dn_next_nblkptr.

Illumos issue:
    5117 space map reallocation can cause corruption

MFC after:	3 days

(cherry picked from commit 52c704852742f9802a8ed19c1ecec396033abf60)
MFV r271515:

Add a new tunable/sysctl, vfs.zfs.free_max_blocks, which can be used to
limit how many blocks can be free'ed before a new transaction group is
created.  The default is no limit (infinite), but we should probably have
a lower default, e.g. 100,000.

With this limit, we can guard against the case where ZFS could run out of
memory when destroying large numbers of blocks in a single transaction
group, as the entire DDT needs to be brought into memory.

Illumos issue:
    5138 add tunable for maximum number of blocks freed in one txg

MFC after:	2 weeks

(cherry picked from commit 3a202e2324f1044b4475f6e0fa21e72569f9cdfe)
MFV r271517:

In zil_claim, don't issue warning if we get EBUSY (inconsistent) when
opening an objset, instead, ignore it silently.

Illumos issue:

    5140 message about "%recv could not be opened" is printed when booting after crash

MFC after:	1 week

(cherry picked from commit 9cdf61a6da9c49a596f561cb9c6c9b423c0dc512)