hammer2 - freemap part 4, misc fixes

* Revamp the freemap a bit.  Remove Layer 0.  Layer 1 is now the LEAF.
  2GB of media storage is now represented by a single 64KB Layer 1 block.
  Synchronize the FREEMAP document with the current thinking.

  The Layer 1 block contains 1024x64 entries.  Each entry represents 2MBytes
  of media storage.  These entries are no longer blockrefs pointing to
  Layer 0 but are instead terminal structures.

* Each entry represents a 16KB allocation granularity in 2 bits and has
  128 bit pairs (256 bits total), plus additional information to represent
  the 2MBytes of storage.

  Fine-grained allocations are supported via an iterator field, currently
  allowing fine-grained allocations down to 1KB and potentially expandable
  in the future to even smaller allocation sizes.

* Fix a SMP race in voldata handling during flush.  The freemap portion of
  voldata could be updated during crc calculations due to hmp->fchain not
  being held locked, causing random volume header/backups to fail their CRC
  test on remount.

* Add missing BUF_KERNPROC() when chain->bp is replaced.  Fixes a kernel
  lock ownership assertion.

* Add freezone/radix fields to the inode_data structure.  Each inode can
  accomodate four fields.  The fields are not yet utilized.  Current thinking
  is to use them to optimize the bulk free-scan for freeing blocks.
rtld: Sync 1/7 - Handle premature symlook_obj call

It doesn't appear that this code is needed for x86 platforms as this
case should already be caught in early code, but it doesn't hurt
DragonFly to handle every possible case.

  Work around a situation where symlook_obj() could be called for the
  object for which digest_dynamic1() was not done yet.  Just return
  EINVAL and do not try to dereference NULL buckets hash array.

  This seems to happen on ia64 for rtld object itself where the
  R_IA_64_FPTR64LSB relocations require symbol lookup.  The dynamic
  linker itself does not rely on identity of the C-level function
  pointers (i.e. function descriptors).

Taken verbatim from:
FreeBSD SVN 235054 (05 MAY 2012)
rtld: Sync 2/7 - Remove potential map leakage

Eliminate the static buffer used to read the first page of the mapped
object, and eliminate the pread(2) call as well.  Mmap the first page
of the object temporarily and unmap it on error or last use.  Potentially
this leaves a one page gap between succeeding dlopen(3), but there are
other mmap(2) consumers as well.

This fixes several cases where the whole mapping of the object leaked
upon error.  The MAP_PREFAULT_READ code had to be skipped because the
mmap on DragonFly doesn't support this flag.

----

Map libraries linked with -Ttext-segment=base_addr at base_addr.
Normal libraries have a base address of zero and are unaffected by this
change.

Taken from:
FreeBSD SVN 237058 (14 JUN 2012)
FreeBSD SVN 247396 (27 FEB 2013)
rtld: Sync 3/7 - LD_PRELOAD and z_nodeflib fix

Do not reference z_nodeflib for !objgiven case in order to fix LD_PRELOAD
for a non-absolute path.

Taken from:
FreeBSD SVN 240686 (18 SEP 2012)
rtld: Sync 4/7 - Fix token substitution

The origin_subst_one() function limits the length of the string to
PATH_MAX after the token substitution.  This is wrong, because
origin_subst_one() performs the substitution on the whole rpath and
similar strings, which contain several pathes separated by colon.  As
result, a long (but correct) rpath consisting of many path elements is
rejected by the function.

Correct the problem by rewriting the origin_subst_one() to perform two
passes, first pass to calculate the number of substitutions to be
performed, and second pass to generate the resulting string.  Second
pass allocates the memory for the result based on the count from the
first pass, without enforcing a limit.

Taken verbatim from:
FreeBSD SVN 249525 (15 APR 2013)
FreeBSD SVN 250075 (29 APR 2013)
rtld: Sync 5/7 - Fix fd leak with parallel dlopen and fork

Rtld did not set FD_CLOEXEC on its internal file descriptors; therefore,
such a file descriptor may be passed to a process created by another
thread running in parallel to dlopen() or fdlopen().

No other threads are expected to be running during parsing of the hints
and libmap files but the file descriptors need not be passed to child
processes so add O_CLOEXEC there as well.

As the F_DUPFD_CLOEXEC support was added in the kernel today, rtld
will temporarily fall back to separate dup/cloexec commands if
F_DUPFD_CLOEXEC fails.  This fallback should be removed before
3.6 branches.

Taken from:
FreeBSD SVN 242587 (04 NOV 2012)
rtld: Sync 6/7 - Minimize differences from FreeBSD

DragonFly developed some rtld features before FreeBSD, and consequently
those features were ported back to FreeBSD.  Some portions of these
new lines were modified for various reasons, e.g. the variable names
weren't liked or additional constraints were deemed necessary such as
the ability to maintain the old (incorrect) behavior of RUNPATH.

In any case, there were minor differences including whitespace, and
this commit reduces those differences to ease future syncing.
rtld: Sync 7/7 - Use symbol versioning instead of exports mapping

Now that DragonFly has the symbol versioning framework in place, rtld
can leverage it by offloading the symbol export duties to it.  This
further reduces differences between FreeBSD and DragonFly linkers.
Keeping the exports table up to date after FreeBSD removed it was extra
work.
tools/netrate: Add simple tools to calculated multiple netperf results

netperf itself must be installed through dports.
Fix SEE ALSO sorting order in some manual pages.
/usr/share/mk: Install bsd.symver.mk and version_gen.awk
Merge branch 'master' into gsocdrm_jfree
altq: Implement two level "rough" priority queue for plain sub-queue

The "rough" part comes from two sources:
- Hardware queue could be deep, normally 512 or more even for GigE
- Round robin on the transmission queues is used by all of the multiple
  transmission queue capable hardwares supported by DragonFly as of this
  commit.
These two sources affect the packet priority set by DragonFly.

DragonFly's "rough" prority queue has only two level, i.e. high priority
and normal priority, which should be enough.  Each queue has its own
header.  The normal priority queue will be dequeue only when there is no
packets in the high priority queue.  During enqueue, if the sub-queue is
full and the high priority queue length is less than half of the sub-
queue length (both packet count and byte count), drop-head will be
applied on the normal priority queue.

M_PRIO mbuf flag is added to mark that the mbuf is destined for the high
priority queue.  Currently TCP uses it to prioritize SYN, SYN|ACK, and
pure ACK w/o FIN and RST.  This behaviour could be turn off by
net.inet.tcp.prio_synack, which is on by default.

The performance improvement!

The test environment:
All three boxes are using Intel i7-2600 w/ HT enabled

                          +-----+
                          |     |
                +->- emx1 |  B  | TCP_MAERTS
+-----+         |         |     |
|     |         |         +-----+
|  A  | bnx0 ---+
|     |         |         +-----+
+-----+         |         |     |
                +-<- emx1 |  C  | TCP_STREAM/TCP_RR
                          |     |
                          +-----+

A's kernel has this commit compiled.  bnx0 has all four transmission
queues enabled.  For bnx0, the hardware's transmission queue round-robin
is on TSO segment boundry.

Some base line measurement:
B<--A TCP_MAERTS (raw stats) (128 client): 984 Mbps
    (tcp_stream -H A -l 15 -i 128 -r)
C-->A TCP_STREAM (128 client): 942 Mbps (tcp_stream -H A -l 15 -i 128)
C-->A TCP_CC (768 client): 221199 conns/s (tcp_cc -H A -l 15 -i 768)

To effectively measure the TCP_CC, the prefix route's MSL is changed to
10ms: route change 10.1.0.0/24 -msl 10

All stats gather in the following measurement are below the base line
measurement (well, they should be).

C-->A TCP_CC improvement, during test B<--A TCP_MAERTS is running:
                        TCP_MAERTS(raw)  TCP_CC
TSO prio_synack=1       948 Mbps         15988 conns/s
TSO prio_synack=0       965 Mbps          8867 conns/s
non-TSO prio_synack=1   943 Mbps         18128 conns/s
non-TSO prio_synack=0   959 Mbps         11371 conns/s

* 80% TCP_CC performance improvement w/ TSO and 60% w/o TSO!

C-->A TCP_STREAM improvement, during test B<--A TCP_MAERTS is running:
                        TCP_MAERTS(raw)  TCP_STREAM
TSO prio_synack=1       969 Mbps         920 Mbps
TSO prio_synack=0       969 Mbps         865 Mbps
non-TSO prio_synack=1   969 Mbps         920 Mbps
non-TSO prio_synack=0   969 Mbps         879 Mbps

* 6% TCP_STREAM performance improvement w/ TSO and 4% w/o TSO.
libz: Add symbol versions (not active)

Every time symbol versioning is added to a system library, it will
require a full buildworld for the next build.  In addition, if the major
version isn't bumped, it will break the binary packages that link to it.

The working plan is to add versioning to libaries, but not hook it into
the build unless "RELEASE36" is defined.  When all the libraries have
been versioned, then these conditions will be removed so only one full
buildworld will be required to minimize inconvenience to users.

All versioned libraries will be bumped with the exception of libc as it
has already been bumped for branch 3.5, thus libc.so.7 is already
available.  In other words, we bump to avoid package breakage and that's
no longer an issue for libc.

After this commit, libz will build as before unless RELEASE36=yes is
defined in make.conf or passed to make during buildworld.
Merge branch 'master' into gsocdrm_github