freebsd.git
7 years agoWrite up some basic tests for readlink(1)
ngie [Sun, 11 Jun 2017 21:13:12 +0000 (21:13 +0000)]
Write up some basic tests for readlink(1)

The tests exercise -f (f_flag), -n (n_flag), and no arguments (basic).

MFC after: 1 month
Sponsored by: Dell EMC Isilon

7 years agoAdd more simple positive tests for chown(1)
ngie [Sun, 11 Jun 2017 19:31:42 +0000 (19:31 +0000)]
Add more simple positive tests for chown(1)

The tests are largely symmetric with the tests for chmod(1)--added in r319642.

Remove chown-f_test (added in r268030) since the test coverage is now being
provided by `chown_test`.

MFC after: 1 month
Sponsored by: Dell EMC Isilon

7 years agoRemove unnecessary, and mismatched, comment.
pfg [Sun, 11 Jun 2017 19:09:10 +0000 (19:09 +0000)]
Remove unnecessary, and mismatched, comment.

Submitted by: Fedor Uporov

7 years agorc.subr: Optimize repeated sourcing.
jilles [Sun, 11 Jun 2017 19:06:07 +0000 (19:06 +0000)]
rc.subr: Optimize repeated sourcing.

When /etc/rc runs all /etc/rc.d scripts, it has already loaded /etc/rc.subr
but each /etc/rc.d script sources it again (since /etc/rc.d scripts must
also work when started stand-alone).

Therefore, if rc.subr is already loaded, return so sh need not parse the
rest of the file.

A second effect is that there is no longer a compound command around most of
rc.subr. This reduces memory usage while sh is loading rc.subr for the first
time (but this memory is free()d once rc.subr is loaded).

For purposes of porting this to other systems, I do not recommend porting
this to systems with shells that do not have the change to the return
special builtin like in r255215 (before FreeBSD 10.0-RELEASE). This change
ensures that return in the top level of a dot script returns from the dot
script, even if the dot script was sourced from a function.

A comparison of CPU time on an amd64 bhyve virtual machine from a times
command added near the end of /etc/rc, all four values summed:

x orig1
+ quickreturn
+--------------------------------------------------------------------------+
|  +    +              +                             x    x               x|
||______M__A_________|                             |______M___A__________| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         1.704         1.802         1.726         1.744   0.051419841
+   3         1.467         1.559         1.487     1.5043333   0.048387326
Difference at 95.0% confidence
-0.239667 +/- 0.113163
-13.7424% +/- 6.48873%
(Student's t, pooled s = 0.0499266)

7 years agoextfs: fix the build with no UFS_ACL.
pfg [Sun, 11 Jun 2017 19:05:45 +0000 (19:05 +0000)]
extfs: fix the build with no UFS_ACL.

Some people may want to drop UFS-style ACLs for slimmer kernels.
Let's just not assume everyone needs ACLs.

Reported by: bde
Submitted by: Fedor Uporov
Differential Revision: https://reviews.freebsd.org/D11145

7 years agosh: Enable interrupts before executing EXIT trap and doing final flush.
jilles [Sun, 11 Jun 2017 16:54:04 +0000 (16:54 +0000)]
sh: Enable interrupts before executing EXIT trap and doing final flush.

7 years agoMore accurately handle early EFER restoration on resume.
kib [Sun, 11 Jun 2017 14:39:08 +0000 (14:39 +0000)]
More accurately handle early EFER restoration on resume.

Do not try to set LMA bit while CPU is still in legacy mode.
Apparently Intel CPUs ignore non-id writes to LMA, while AMD's
(over-)react with #GP.

Reported and tested by: danfe
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

7 years agoTidy up minor nits raised by mandoc lint:
sevan [Sun, 11 Jun 2017 14:33:16 +0000 (14:33 +0000)]
Tidy up minor nits raised by mandoc lint:
Zap trailing white and double spaces
Remove extra coma which is not required.
Bump date.

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

7 years agoFlag loadpoolfile() (ippool -f) command line syntax errors.
cy [Sun, 11 Jun 2017 04:03:09 +0000 (04:03 +0000)]
Flag loadpoolfile() (ippool -f) command line syntax errors.

7 years agoIdentify poolstats() (ippool -s) command line syntax errors.
cy [Sun, 11 Jun 2017 04:00:26 +0000 (04:00 +0000)]
Identify poolstats() (ippool -s) command line syntax errors.

7 years agoIdentify command line syntax errors in poolflush() (ippool -F).
cy [Sun, 11 Jun 2017 03:56:13 +0000 (03:56 +0000)]
Identify command line syntax errors in poolflush() (ippool -F).

7 years agoConvert from local code and constants for mac<->phy connection type to new
ian [Sun, 11 Jun 2017 00:44:19 +0000 (00:44 +0000)]
Convert from local code and constants for mac<->phy connection type to new
common fdt helper code.

7 years agoAdd a driver for the Vitesse/Microsemi VSC8501 PHY.
ian [Sun, 11 Jun 2017 00:38:16 +0000 (00:38 +0000)]
Add a driver for the Vitesse/Microsemi VSC8501 PHY.

7 years agoAdd some utility functions to help a PHY driver on an FDT-configured
ian [Sun, 11 Jun 2017 00:16:21 +0000 (00:16 +0000)]
Add some utility functions to help a PHY driver on an FDT-configured
system retrieve its config data from the fdt data.

The properties that are common to all phys are decoded and returned in a
structure.  The fdt node handles for the mac and phy devices are also
returned in the config data struct, so a driver can easily obtain additional
hardware-specific config values from the fdt data.

7 years agoAdd a set of constants describing the ways a MAC and PHY can be connected.
ian [Sat, 10 Jun 2017 23:55:13 +0000 (23:55 +0000)]
Add a set of constants describing the ways a MAC and PHY can be connected.

While the initial need for this is to help support phy drivers which are
configured with FDT data, there is nothing devicetree-specific about the
concept or the names, so they are available for use even on non-FDT systems.

The initial list of connection types comes from the current devicetree
bindings documentation, but values not documented there can be added to
the list in the future as needed, the values could be sorted into a
different order without perturbing FDT code, etc.  The only invariant
is that MII_CONTYPE_UNKNOWN should be first (so it has a value of zero,
so that a con-type variable in a softc, for example, is initialized to
MII_CONTYPE_UNKNOWN by default).

7 years agoAllow building if_ffec as a module.
ian [Sat, 10 Jun 2017 23:45:26 +0000 (23:45 +0000)]
Allow building if_ffec as a module.

7 years agoif_ffec bugfixes related to harvesting of hardware-maintained statistics...
ian [Sat, 10 Jun 2017 23:26:25 +0000 (23:26 +0000)]
if_ffec bugfixes related to harvesting of hardware-maintained statistics...

After harvesting the hardware statistics counters and summing them into the
interface stats, properly clear the hardware counters back to zero.  On imx5
and earlier hardware it is necessary to disable collection of stats while
writing zeroes to all the registers.  On imx6 and newer it turns out it's
not even possible to write zeroes, instead you have to toggle a special
"zero everything" control bit in a register.

Count incoming packets with a bad start frame delim as input errors, and
incoming packets dropped due to no fifo space as input drops.

Remove all code related to harvesting the hardware stats less often than
once per second.  It turns out the 32-bit stats registers are backed by
16-bit counters under the hood, and they can easily roll over if you only
harvest them once every 3 seconds like the old code was doing.  Now we just
read all the regs once a second.

The combination of not properly zeroing the stats registers and 16-bit
counters sometimes wrapping between harvest calls resulted in basically
unusable statistics before these changes.

7 years agoRemove redundant assignment of infile from optarg in loadpoolfile()
cy [Sat, 10 Jun 2017 23:16:00 +0000 (23:16 +0000)]
Remove redundant assignment of infile from optarg in loadpoolfile()
which was previously assigned from optarg in the argument list from
main().

7 years agoList DTrace provider pages in a single variable.
markj [Sat, 10 Jun 2017 21:13:39 +0000 (21:13 +0000)]
List DTrace provider pages in a single variable.

MFC after: 1 week

7 years agoRemove an inaccuracy from socket.2.
markj [Sat, 10 Jun 2017 21:07:55 +0000 (21:07 +0000)]
Remove an inaccuracy from socket.2.

SOCK_SEQPACKET is implemented for several protocols.

MFC after: 1 week

7 years agoImprove handling with system state
ngie [Sat, 10 Jun 2017 20:56:31 +0000 (20:56 +0000)]
Improve handling with system state

- Always unlink $cmd after exit via END block.
- The tests don't function well if kern.geom.debugflags != 0. Save debugflags,
  then restore them at the end of the test.

MFC after: 1 month
Sponsored by: Dell EMC Isilon

7 years agoUpdate the variables as well.
gnn [Sat, 10 Jun 2017 20:50:50 +0000 (20:50 +0000)]
Update the variables as well.

7 years agoUpdate Makefile to contain the new DTrace lockstat manual page.
gnn [Sat, 10 Jun 2017 20:47:37 +0000 (20:47 +0000)]
Update Makefile to contain the new DTrace lockstat manual page.

7 years agoManual page for the DTrace lockstat provider
gnn [Sat, 10 Jun 2017 20:41:53 +0000 (20:41 +0000)]
Manual page for the DTrace lockstat provider

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11128

7 years agofstat: catch up with r318997 and use 64 bits to store fsid
avg [Sat, 10 Jun 2017 20:38:52 +0000 (20:38 +0000)]
fstat: catch up with r318997 and use 64 bits to store fsid

Discussed with: kib

7 years agoDon't explicitly get the class to PART in gctl_test_helper.c
ngie [Sat, 10 Jun 2017 19:48:45 +0000 (19:48 +0000)]
Don't explicitly get the class to PART in gctl_test_helper.c

This will allow the tool to be used with arbitrary geom(4) classes, like GEOM.

Specify class=PART explicitly in the tester to keep existing behavior.

MFC after: 1 month
Sponsored by: Dell EMC Isilon

7 years agoSwitch the example name for variables controlling loading memory images
trasz [Sat, 10 Jun 2017 19:05:45 +0000 (19:05 +0000)]
Switch the example name for variables controlling loading memory images
in /boot/defaults/loader.conf to something that's actually commonly used,
"mdroot".  It's arbitrary, but it's easier to find this way.

MFC after: 2 weeks

7 years agoixl(4)/ixlv(4): Fix some busdma tags and improper map NULL.
erj [Sat, 10 Jun 2017 18:56:30 +0000 (18:56 +0000)]
ixl(4)/ixlv(4): Fix some busdma tags and improper map NULL.

Description from Brett:

"The busdma tags used to create mappings for the tx and rx rings did not have
the device's tag as parents, meaning that they did not respect the device's
busdma properties. The other tags used in the driver had their parents set
appropriately.

Also, the dma maps for each buffer in ixl_txeof() were being NULLed after
being unloaded, which is an error because those maps are then reused without
being recreated (I believe this also leaked resources since the maps were not
destroyed). Simply removing the line that sets the maps to NULL gives the
desired behavior. There does not seem to be a similar problem with ixl_rxeof().
Functions to free the tx and rx rings also NULL out the dma maps for each
buffer, but this seems okay because the maps are destroyed and not reused in
this case.

With these fixes, my ixl card seems to be working with the IOMMU enabled."

Submitted by: Brett Gutstein <bgutstein@rice.edu>
Reviewed by: erj
Approved by: Alan Cox <alc@rice.edu>
MFC after: 1 week

7 years agoRemove a few unneeded files from libllvm, libclang and liblldb.
dim [Sat, 10 Jun 2017 18:52:13 +0000 (18:52 +0000)]
Remove a few unneeded files from libllvm, libclang and liblldb.

MFC after: 3 days

7 years agoDisable the -O (output fields) option in poollist() (ippool -l) for
cy [Sat, 10 Jun 2017 17:05:14 +0000 (17:05 +0000)]
Disable the -O (output fields) option in poollist() (ippool -l) for
now. The option does not presently work. However, similar functions in
ipfstat (for state) and ipnat (for nat) do work and provide outputs that
can be easily parsed by shell scripts or subsequently loaded into CSV
files.  The intention here is to return to this option to make it work.
I suspect the problem is in printpoolfields.c.

7 years agoFlag poollist() (ippool -l) command line syntax errors.
cy [Sat, 10 Jun 2017 16:42:39 +0000 (16:42 +0000)]
Flag poollist() (ippool -l) command line syntax errors.

7 years agoRemove an unnecessary field from struct blist. (The comment describing
alc [Sat, 10 Jun 2017 16:11:39 +0000 (16:11 +0000)]
Remove an unnecessary field from struct blist.  (The comment describing
what this field represented was also inaccurate.)  Suggested by: kib

In r178792, blist_create() grew a malloc flag, allowing M_NOWAIT to be
specified.  However, blist_create() was not modified to handle the
possibility that a malloc() call failed.  Address this omission.

Increase the width of the local variable "radix" to 64 bits.  (This
matches the width of the corresponding field in struct blist.)

Reviewed by: kib
MFC after: 6 weeks

7 years agoOverride the locale so that file lists get a consistent sort order.
markj [Sat, 10 Jun 2017 14:47:01 +0000 (14:47 +0000)]
Override the locale so that file lists get a consistent sort order.

Reported by: avg
MFC after: 1 week

7 years agoRemove mentions of recently removed /usr/share/doc/ subdirectories
trasz [Sat, 10 Jun 2017 08:25:46 +0000 (08:25 +0000)]
Remove mentions of recently removed /usr/share/doc/ subdirectories
from hier(7).

7 years ago/usr/share/doc/bind is gone since 20040925.
trasz [Sat, 10 Jun 2017 08:08:14 +0000 (08:08 +0000)]
/usr/share/doc/bind is gone since 20040925.

MFC after: 2 weeks

7 years agoImprove formatting by removing yet another case of '-width ".Pa'.
trasz [Sat, 10 Jun 2017 08:01:05 +0000 (08:01 +0000)]
Improve formatting by removing yet another case of '-width ".Pa'.

MFC after: 2 weeks

7 years agoRemove /usr/include/readline/ from hier(7); it's long gone.
trasz [Sat, 10 Jun 2017 07:47:21 +0000 (07:47 +0000)]
Remove /usr/include/readline/ from hier(7); it's long gone.

7 years agoRemove groff(1) leftovers from hier(7).
trasz [Sat, 10 Jun 2017 07:43:24 +0000 (07:43 +0000)]
Remove groff(1) leftovers from hier(7).

7 years agofollow up to r319746: add the new test files to the make file
avg [Sat, 10 Jun 2017 06:13:52 +0000 (06:13 +0000)]
follow up to r319746: add the new test files to the make file

Reported by: markj
MFC after: 2 days
X-MFC with: r319746

7 years agoDecode arguments to rtprio() and rtprio_thread().
jhb [Sat, 10 Jun 2017 01:32:35 +0000 (01:32 +0000)]
Decode arguments to rtprio() and rtprio_thread().

7 years agoDecode arguments to rtprio_thread() (same as rtprio()).
jhb [Sat, 10 Jun 2017 01:32:18 +0000 (01:32 +0000)]
Decode arguments to rtprio_thread() (same as rtprio()).

7 years agoDecode the 'howto' argument to reboot().
jhb [Sat, 10 Jun 2017 01:22:40 +0000 (01:22 +0000)]
Decode the 'howto' argument to reboot().

7 years agoImprove decoding of RB_AUTOBOOT in the 'howto' argument to reboot().
jhb [Sat, 10 Jun 2017 01:20:08 +0000 (01:20 +0000)]
Improve decoding of RB_AUTOBOOT in the 'howto' argument to reboot().

The reboot() system call accepts a mode (RB_AUTOBOOT, RB_HALT, RB_POWEROFF,
or RB_REROOT) as well as zero or more optional flags in 'howto'.
However, RB_AUTOBOOT was only displayed if 'howto' was exactly 0.
Combinations like 'RB_AUTOBOOT | RB_DUMP' were decoded as 'RB_DUMP'.
Instead, imply that RB_AUTOBOOT was specified if none of the other "mode"
flags were specified.

7 years agoDecode the arguments to quotactl().
jhb [Sat, 10 Jun 2017 00:53:00 +0000 (00:53 +0000)]
Decode the arguments to quotactl().

7 years agoDecode the arguments to ptrace().
jhb [Sat, 10 Jun 2017 00:45:07 +0000 (00:45 +0000)]
Decode the arguments to ptrace().

This does not decode structures returned by ptrace().

7 years agoDecode arguments to getpriority() and setpriority().
jhb [Sat, 10 Jun 2017 00:37:02 +0000 (00:37 +0000)]
Decode arguments to getpriority() and setpriority().

7 years agoFix decoding of setpriority() arguments.
jhb [Sat, 10 Jun 2017 00:35:45 +0000 (00:35 +0000)]
Fix decoding of setpriority() arguments.

The PRIO_* 'which' value is stored in the first argument to setpriority(2),
not the last.  While here, decode the arguments to getpriority(2).

7 years agoRemove an unnecessary variable from the switch softc structure and make the
loos [Fri, 9 Jun 2017 20:38:18 +0000 (20:38 +0000)]
Remove an unnecessary variable from the switch softc structure and make the
functions that are used as booleans return real boolean values.

Sponsored by: Rubicon Communications, LLC (Netgate)

7 years agoFollow up r313841 on powerpc
jhibbits [Fri, 9 Jun 2017 20:26:42 +0000 (20:26 +0000)]
Follow up r313841 on powerpc

Close a potential race in reading the CPU dtrace flags, where a thread can
start on one CPU, and partway through retrieving the flags be swapped out,
while another thread traps and sets the CPU_DTRACE_NOFAULT.  This could
cause the first thread to return without handling the fault.

Discussed with: markj@

7 years agoImplement pci_disable_device() in the LinuxKPI.
markj [Fri, 9 Jun 2017 19:57:27 +0000 (19:57 +0000)]
Implement pci_disable_device() in the LinuxKPI.

Submitted by: kmacy
MFC after: 2 weeks

7 years agoAugment wait queue support in the LinuxKPI.
markj [Fri, 9 Jun 2017 19:41:12 +0000 (19:41 +0000)]
Augment wait queue support in the LinuxKPI.

In particular:
- Don't evaluate event conditions with a sleepqueue lock held, since such
  code may attempt to acquire arbitrary locks.
- Fix the return value for wait_event_interruptible() in the case that the
  wait is interrupted by a signal.
- Implement wait_on_bit_timeout() and wait_on_atomic_t().
- Implement some functions used to test for pending signals.
- Implement a number of wait_event_*() variants and unify the existing
  implementations.
- Unify the mechanism used by wait_event_*() and schedule() to put the
  calling thread to sleep.

This is required to support updated DRM drivers. Thanks to hselasky for
finding and fixing a number of bugs in the original revision.

Reviewed by: hselasky
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10986

7 years agoStyle and comment fixes only.
alc [Fri, 9 Jun 2017 17:19:27 +0000 (17:19 +0000)]
Style and comment fixes only.

Reviewed by: kib
MFC after: 6 weeks

7 years agoblist_fill()'s return type is too narrow. blist_fill() accepts a 64-bit
alc [Fri, 9 Jun 2017 16:19:24 +0000 (16:19 +0000)]
blist_fill()'s return type is too narrow.  blist_fill() accepts a 64-bit
quantity as the size of the range to fill, but returns a 32-bit quantity
as the number of blocks that were allocated to fill that range.  This
revision corrects that mismatch.  Currently, swaponsomething() limits
the size of a swap area to prevent arithmetic arithmetic overflow in
other parts of the blist allocator.  That limit has also prevented this
type mismatch from causing problems.

Reviewed by: kib, markj
MFC after: 6 weeks
Differential Revision: https://reviews.freebsd.org/D11096

7 years agoFix stat(2) on a listening socket.
glebius [Fri, 9 Jun 2017 15:54:48 +0000 (15:54 +0000)]
Fix stat(2) on a listening socket.

7 years agoAllow the arm64 machine/vfp.h to be included without first including
andrew [Fri, 9 Jun 2017 15:47:14 +0000 (15:47 +0000)]
Allow the arm64 machine/vfp.h to be included without first including
machine/pcb.h. It he latter is only needed for struct pcb.

7 years agoStore the read-only thread pointer when scheduling a new thread. This is
andrew [Fri, 9 Jun 2017 15:37:17 +0000 (15:37 +0000)]
Store the read-only thread pointer when scheduling a new thread. This is
not currently set, however we may wish to set it later.

7 years agoMFV r319740: 8168 NULL pointer dereference in zfs_create()
avg [Fri, 9 Jun 2017 15:30:41 +0000 (15:30 +0000)]
MFV r319740: 8168 NULL pointer dereference in zfs_create()

illumos/illumos-gate@690031d326342fa4ea28b5e80f1ad6a16281519d
https://github.com/illumos/illumos-gate/commit/690031d326342fa4ea28b5e80f1ad6a16281519d

https://www.illumos.org/issues/8168
  If we manage to export the pool on which we are creating a dataset (filesystem
  or zvol) between entering libzfs`zfs_create() and libzfs`zpool_open() call (for
  which we never check the return value) we end up dereferencing a NULL pointer
  in libzfs`zpool_close().
  This was discovered on ZFS on Linux. The same issue can be reproduced on
  Illumos running in parallel:
    while :; do zpool import -d /tmp testpool ; zpool export testpool ; done
    while :; do zfs create testpool/fs; zfs destroy testpool/fs ; done
  Eventually this will result in several core dumps like this one:
  [root@52-54-00-d3-7a-01 /cores]# mdb core.zfs.4244
  Loading modules: [ libumem.so.1 libc.so.1 libtopo.so.1 libavl.so.1
  libnvpair.so.1 ld.so.1 ]
  > ::stack
  libzfs.so.1`zpool_close+0x17(0, 0, 0, 8047450)
  libzfs.so.1`zfs_create+0x1bb(8090548, 8047e6f, 1, 808cba8)
  zfs_do_create+0x545(2, 8047d74, 80778a0, 801, 0, 3)
  main+0x22c(8047d2c, fef5c6e8, 8047d64, 8055a17, 3, 8047d70)
  _start+0x83(3, 8047e64, 8047e68, 8047e6f, 0, 8047e7b)
  >
  Fix and reproducer (systemtap): https://github.com/zfsonlinux/zfs/pull/6096

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>
MFC after: 2 weeks

7 years agoMFV r319741: 8156 dbuf_evict_notify() does not need dbuf_evict_lock
avg [Fri, 9 Jun 2017 15:28:57 +0000 (15:28 +0000)]
MFV r319741: 8156 dbuf_evict_notify() does not need dbuf_evict_lock

illumos/illumos-gate@dbfd9f930004c390a2ce2cf850c71b4f880eef9c
https://github.com/illumos/illumos-gate/commit/dbfd9f930004c390a2ce2cf850c71b4f880eef9c

https://www.illumos.org/issues/8156
  dbuf_evict_notify() holds the dbuf_evict_lock while checking if it should do
  the eviction itself (because the evict thread is not able to keep up).
  This can result in massive lock contention.
  It isn't necessary to hold the lock, because if we make the wrong choice
  occasionally, nothing bad will happen.

Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Matthew Ahrens <mahrens@delphix.com>
MFC after: 1 week

7 years agoMFV r319739: 8005 poor performance of 1MB writes on certain RAID-Z configurations
avg [Fri, 9 Jun 2017 15:27:22 +0000 (15:27 +0000)]
MFV r319739: 8005 poor performance of 1MB writes on certain RAID-Z configurations

illumos/illumos-gate@5b062782532a1d5961c4a4b655906e1238c7c908
https://github.com/illumos/illumos-gate/commit/5b062782532a1d5961c4a4b655906e1238c7c908

https://www.illumos.org/issues/8005
  RAID-Z requires that space be allocated in multiples of P+1 sectors,
  because this is the minimum size block that can have the required amount
  of parity. Thus blocks on RAIDZ1 must be allocated in a multiple of 2
  sectors; on RAIDZ2 multiple of 3; and on RAIDZ3 multiple of 4. A sector
  is a unit of 2^ashift bytes, typically 512B or 4KB.
  To satisfy this constraint, the allocation size is rounded up to the
  proper multiple, resulting in up to 3 "pad sectors" at the end of some
  blocks. The contents of these pad sectors are not used, so we do not
  need to read or write these sectors. However, some storage hardware
  performs much worse (around 1/2 as fast) on mostly-contiguous writes
  when there are small gaps of non-overwritten data between the writes.
  Therefore, ZFS creates "optional" zio's when writing RAID-Z blocks that
  include pad sectors. If writing a pad sector will fill the gap between
  two (required) writes, we will issue the optional zio, thus doubling
  performance. The gap-filling performance improvement was introduced in
  July 2009.
  Writing the optional zio is done by the io aggregation code in
  vdev_queue.c. The problem is that it is also subject to the limit on
  the size of aggregate writes, zfs_vdev_aggregation_limit, which is by
  default 128KB. For a given block, if the amount of data plus padding
  written to a leaf device exceeds zfs_vdev_aggregation_limit, the
  optional zio will not be written, resulting in a ~2x performance
  degradation.
  The problem occurs only for certain values of ashift, compressed block
  size, and RAID-Z configuration (number of parity and data disks). It
  cannot occur with the default recordsize=128KB. If compression is
  enabled, all configurations with recordsize=1MB or larger will be
  impacted to some degree.
  The problem notably occurs with recordsize=1MB, compression=off, with 10
  disks in a RAIDZ2 or RAIDZ3 group (with 512B or 4KB sectors). Therefore

Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Matthew Ahrens <mahrens@delphix.com>
MFC after: 10 days

7 years agoMFV r319738: 8155 simplify dmu_write_policy handling of pre-compressed buffers
avg [Fri, 9 Jun 2017 15:26:03 +0000 (15:26 +0000)]
MFV r319738: 8155 simplify dmu_write_policy handling of pre-compressed buffers

illumos/illumos-gate@adaec86ad212d9fd756bee322934fa54d1258605
https://github.com/illumos/illumos-gate/commit/adaec86ad212d9fd756bee322934fa54d1258605

https://www.illumos.org/issues/8155
  When writing pre-compressed buffers, arc_write() requires that the compression
  algorithm used to compress the buffer matches the compression algorithm
  requested by the zio_prop_t, which is set by dmu_write_policy().
  This makes dmu_write_policy() and its callers a bit more complicated.
  We can simplify this by making arc_write() trust the caller to supply the type
  of pre-compressed buffer that it wants to write, and override the compression
  setting in the zio_prop_t.

Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Matthew Ahrens <mahrens@delphix.com>
MFC after: 10 days

7 years agoremove an unrelated local change from r319746
avg [Fri, 9 Jun 2017 15:21:28 +0000 (15:21 +0000)]
remove an unrelated local change from r319746

MFC after: 1 day
X-MFC with: r319746

7 years agoMFV r319744,r319745: 8269 dtrace stddev aggregation is normalized incorrectly
avg [Fri, 9 Jun 2017 15:16:39 +0000 (15:16 +0000)]
MFV r319744,r319745: 8269 dtrace stddev aggregation is normalized incorrectly

illumos/illumos-gate@79809f9cf402f130667349b2d4007ecd65d63c6f
https://github.com/illumos/illumos-gate/commit/79809f9cf402f130667349b2d4007ecd65d63c6f

https://www.illumos.org/issues/8269
  It seems that currently normalization of stddev aggregation is done
  incorrectly.
  We divide both the sum of values and the sum of their squares by the
  normalization factor. But we should divide the sum of squares by the
  normalization factor squared to scale the original values properly.

FreeBSD note: the actual change was committed in r316853, this commit
adds the test files and record merge information.

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>
MFC after: 1 week
Sponsored by: Panzura

7 years agofix up r319744, add new files
avg [Fri, 9 Jun 2017 15:06:50 +0000 (15:06 +0000)]
fix up r319744, add new files

8269 dtrace stddev aggregation is normalized incorrectly

illumos/illumos-gate@79809f9cf402f130667349b2d4007ecd65d63c6f
https://github.com/illumos/illumos-gate/commit/79809f9cf402f130667349b2d4007ecd65d63c6f

https://www.illumos.org/issues/8269
  It seems that currently normalization of stddev aggregation is done
  incorrectly.
  We divide both the sum of values and the sum of their squares by the
  normalization factor. But we should divide the sum of squares by the
  normalization factor squared to scale the original values properly.

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>

7 years ago8269 dtrace stddev aggregation is normalized incorrectly
avg [Fri, 9 Jun 2017 15:04:10 +0000 (15:04 +0000)]
8269 dtrace stddev aggregation is normalized incorrectly

illumos/illumos-gate@79809f9cf402f130667349b2d4007ecd65d63c6f
https://github.com/illumos/illumos-gate/commit/79809f9cf402f130667349b2d4007ecd65d63c6f

https://www.illumos.org/issues/8269
  It seems that currently normalization of stddev aggregation is done
  incorrectly.
  We divide both the sum of values and the sum of their squares by the
  normalization factor. But we should divide the sum of squares by the
  normalization factor squared to scale the original values properly.

Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Andriy Gapon <avg@FreeBSD.org>

7 years ago8108 zdb -l fails to read labels 2 and 3
avg [Fri, 9 Jun 2017 15:03:07 +0000 (15:03 +0000)]
8108 zdb -l fails to read labels 2 and 3

illumos/illumos-gate@22c8b9583d07895c16549075a53668d7bc988cf3
https://github.com/illumos/illumos-gate/commit/22c8b9583d07895c16549075a53668d7bc988cf3

https://www.illumos.org/issues/8108

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

7 years ago8168 NULL pointer dereference in zfs_create()
avg [Fri, 9 Jun 2017 15:00:13 +0000 (15:00 +0000)]
8168 NULL pointer dereference in zfs_create()

illumos/illumos-gate@690031d326342fa4ea28b5e80f1ad6a16281519d
https://github.com/illumos/illumos-gate/commit/690031d326342fa4ea28b5e80f1ad6a16281519d

https://www.illumos.org/issues/8168
  If we manage to export the pool on which we are creating a dataset (filesystem
  or zvol) between entering libzfs`zfs_create() and libzfs`zpool_open() call (for
  which we never check the return value) we end up dereferencing a NULL pointer
  in libzfs`zpool_close().
  This was discovered on ZFS on Linux. The same issue can be reproduced on
  Illumos running in parallel:
    while :; do zpool import -d /tmp testpool ; zpool export testpool ; done
    while :; do zfs create testpool/fs; zfs destroy testpool/fs ; done
  Eventually this will result in several core dumps like this one:
  [root@52-54-00-d3-7a-01 /cores]# mdb core.zfs.4244
  Loading modules: [ libumem.so.1 libc.so.1 libtopo.so.1 libavl.so.1
  libnvpair.so.1 ld.so.1 ]
  > ::stack
  libzfs.so.1`zpool_close+0x17(0, 0, 0, 8047450)
  libzfs.so.1`zfs_create+0x1bb(8090548, 8047e6f, 1, 808cba8)
  zfs_do_create+0x545(2, 8047d74, 80778a0, 801, 0, 3)
  main+0x22c(8047d2c, fef5c6e8, 8047d64, 8055a17, 3, 8047d70)
  _start+0x83(3, 8047e64, 8047e68, 8047e6f, 0, 8047e7b)
  >
  Fix and reproducer (systemtap): https://github.com/zfsonlinux/zfs/pull/6096

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: loli10K <ezomori.nozomu@gmail.com>

7 years agoRemove msdosfs -o large support.
kib [Fri, 9 Jun 2017 12:06:22 +0000 (12:06 +0000)]
Remove msdosfs -o large support.

Its purpose was to translate the values for msdosfs inode numbers,
which is calculated from the msdosfs structures describing the file,
into the range representable by 32bit ino_t.  The translation acted
for filesystems larger than 128Gb, it reserved the range 0xf0000000
(FILENO_FIRST_DYN) to UINT32_MAX and remembered some arbitrary
translation of ino >= FILENO_FIRST_DYN into this range.  It consumed
memory that could be only freed by unmount, and the translation was
not stable across remounts.

With ino_t type extended to 64 bit, there is no such issue and values
can be returned without compaction to 32bit.  That is, for the native
environments, the translation layer is not necessary and adds
significant undeserved code complexity.  For compat ABIs which use
32bit ino_t, the vfs.ino64_trunc_error sysctl provides some measures
to soften the failure mode when inode numbers truncation is not safe.

Discussed with: bde
Sponsored by: The FreeBSD Foundation

7 years agoEnhance vfs.ino64_trunc_error sysctl.
kib [Fri, 9 Jun 2017 11:17:08 +0000 (11:17 +0000)]
Enhance vfs.ino64_trunc_error sysctl.

Provide a new mode "2" which returns a special overflow indicator in
the non-representable field instead of the silent truncation (mode
"0") or EOVERFLOW (mode "1").

In particular, the typical use of st_ino to detect hard links with
mode "2" reports false positives, which might be more suitable for
some uses.

Discussed with: bde
Sponsored by: The FreeBSD Foundation

7 years agortwn: rename module (if_rtwn.ko -> rtwn.ko) to match module name + drop
avos [Fri, 9 Jun 2017 07:08:58 +0000 (07:08 +0000)]
rtwn: rename module (if_rtwn.ko -> rtwn.ko) to match module name + drop
manpage link.

Reported by: mav, hselasky

7 years agoImport libxo-0.8.1 with official fix to today's build break.
phil [Fri, 9 Jun 2017 03:32:49 +0000 (03:32 +0000)]
Import libxo-0.8.1 with official fix to today's build break.

Submitted by: phil

7 years agoAdd the ccr0 device to the opencrypto tests against the NIST KAT tests.
jhb [Thu, 8 Jun 2017 21:34:54 +0000 (21:34 +0000)]
Add the ccr0 device to the opencrypto tests against the NIST KAT tests.

The ccr0 device supports both AES and SHA tests.

Sponsored by: Chelsio Communications

7 years agoWhen we are in UMA_STARTUP use startup_alloc() for any zone, not for
glebius [Thu, 8 Jun 2017 21:33:19 +0000 (21:33 +0000)]
When we are in UMA_STARTUP use startup_alloc() for any zone, not for
internal zones only.  This allows to create new zones at early stages
of boot, without need to mark them as internal to UMA, which isn't
always true.

Reviewed by: alc

7 years agoFix the software fallback for GCM to validate the existing tag for decrypts.
jhb [Thu, 8 Jun 2017 21:33:10 +0000 (21:33 +0000)]
Fix the software fallback for GCM to validate the existing tag for decrypts.

Sponsored by: Chelsio Communications

7 years agoListening sockets improvements.
glebius [Thu, 8 Jun 2017 21:30:34 +0000 (21:30 +0000)]
Listening sockets improvements.

o Separate fields of struct socket that belong to listening from
  fields that belong to normal dataflow, and unionize them.  This
  shrinks the structure a bit.
  - Take out selinfo's from the socket buffers into the socket. The
    first reason is to support braindamaged scenario when a socket is
    added to kevent(2) and then listen(2) is cast on it. The second
    reason is that there is future plan to make socket buffers pluggable,
    so that for a dataflow socket a socket buffer can be changed, and
    in this case we also want to keep same selinfos through the lifetime
    of a socket.
  - Remove struct struct so_accf. Since now listening stuff no longer
    affects struct socket size, just move its fields into listening part
    of the union.
  - Provide sol_upcall field and enforce that so_upcall_set() may be called
    only on a dataflow socket, which has buffers, and for listening sockets
    provide solisten_upcall_set().

o Remove ACCEPT_LOCK() global.
  - Add a mutex to socket, to be used instead of socket buffer lock to lock
    fields of struct socket that don't belong to a socket buffer.
  - Allow to acquire two socket locks, but the first one must belong to a
    listening socket.
  - Make soref()/sorele() to use atomic(9).  This allows in some situations
    to do soref() without owning socket lock.  There is place for improvement
    here, it is possible to make sorele() also to lock optionally.
  - Most protocols aren't touched by this change, except UNIX local sockets.
    See below for more information.

o Reduce copy-and-paste in kernel modules that accept connections from
  listening sockets: provide function solisten_dequeue(), and use it in
  the following modules: ctl(4), iscsi(4), ng_btsocket(4), ng_ksocket(4),
  infiniband, rpc.

o UNIX local sockets.
  - Removal of ACCEPT_LOCK() global uncovered several races in the UNIX
    local sockets.  Most races exist around spawning a new socket, when we
    are connecting to a local listening socket.  To cover them, we need to
    hold locks on both PCBs when spawning a third one.  This means holding
    them across sonewconn().  This creates a LOR between pcb locks and
    unp_list_lock.
  - To fix the new LOR, abandon the global unp_list_lock in favor of global
    unp_link_lock.  Indeed, separating these two locks didn't provide us any
    extra parralelism in the UNIX sockets.
  - Now call into uipc_attach() may happen with unp_link_lock hold if, we
    are accepting, or without unp_link_lock in case if we are just creating
    a socket.
  - Another problem in UNIX sockets is that uipc_close() basicly did nothing
    for a listening socket.  The vnode remained opened for connections.  This
    is fixed by removing vnode in uipc_close().  Maybe the right way would be
    to do it for all sockets (not only listening), simply move the vnode
    teardown from uipc_detach() to uipc_close()?

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D9770

7 years agoAdd explicit handling for requests with an empty payload.
jhb [Thu, 8 Jun 2017 21:06:18 +0000 (21:06 +0000)]
Add explicit handling for requests with an empty payload.

- For HMAC requests, construct a special input buffer to request an empty
  hash result.
- For plain cipher requests and requests that chain an AES cipher with an
  HMAC, fail with EINVAL if there is no cipher payload.  If needed in
  the future, chained requests that only contain AAD could be serviced as
  HMAC-only requests.
- For GCM requests, the hardware does not support generating the tag for
  an AAD-only request.  Instead, complete these requests synchronously
  in software on the assumption that such requests are rare.

Sponsored by: Chelsio Communications

7 years agoWith EARLY_AP_STARTUP enabled, we are seeing crashes in softclock_call_cc()
jtl [Thu, 8 Jun 2017 20:47:18 +0000 (20:47 +0000)]
With EARLY_AP_STARTUP enabled, we are seeing crashes in softclock_call_cc()
during bootup. Debugging information shows that softclock_call_cc() is
trying to execute the vt_consdev.vd_timer callout, and the callout
structure contains a NULL c_func.

This appears to be due to a race between vt_upgrade() running
callout_reset() and vt_resume_flush_timer() calling callout_schedule().

Fix the race by ensuring that vd_timer_armed is always set before
attempting to (re)schedule the callout.

Discussed with: emaste
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D9828

7 years agoAdd the infrastructure to support loading multiple versions of TCP
jtl [Thu, 8 Jun 2017 20:41:28 +0000 (20:41 +0000)]
Add the infrastructure to support loading multiple versions of TCP
stack modules.

It adds support for mangling symbols exported by a module by prepending
a string to them. (This avoids overlapping symbols in the kernel linker.)

It allows the use of a macro as the module name in the DECLARE_MACRO()
and MACRO_VERSION() macros.

It allows the code to register stack aliases (e.g. both a generic name
["default"] and version-specific name ["default_10_3p1"]).

With these changes, it is trivial to compile TCP stack modules with
the name defined in the Makefile and to load multiple versions of the
same stack simultaneously. This functionality can be used to enable
side-by-side testing of an old and new version of the same TCP stack.
It also could support upgrading the TCP stack without a reboot.

Reviewed by: gnn, sjg (makefiles only)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D11086

7 years agoarm64: add ".arch armv8-a+crc" to allow use of crc instructions
emaste [Thu, 8 Jun 2017 20:06:09 +0000 (20:06 +0000)]
arm64: add ".arch armv8-a+crc" to allow use of crc instructions

With Clang 5.0 the .arch directive is required, otherwise Clang
complains "error: instruction requires: crc".

This was reported in D10499 but not added initially, because clang 3.8
available on a ref machine reported unknown directive.  Clang 4.0 allows
but does not require the directive.

Submitted by: andrew
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

7 years agoImport mandoc snapshot 2017-06-08
bapt [Thu, 8 Jun 2017 19:40:00 +0000 (19:40 +0000)]
Import mandoc snapshot 2017-06-08

It implements missing man(7) macros used in base by kerberos/ntp and makes them
supported by mandoc.

This import should have been done before the removal of groff.

Reported by: gordon

7 years agoImport mandoc 2017-06-08
bapt [Thu, 8 Jun 2017 19:29:07 +0000 (19:29 +0000)]
Import mandoc 2017-06-08

7 years agoAdd tests for ln(1)
asomers [Thu, 8 Jun 2017 19:09:55 +0000 (19:09 +0000)]
Add tests for ln(1)

* Verify that when creating a hard link to a symbolic link, '-L' option
  creates a hard link to the target of the symbolic link
* Verify that when creating a hard link to a symbolic link, '-P' option
  creates a hard link to the symbolic link itself
* Verify that if the target file already exists, '-f' option unlinks it so
  that link may occur
* Verify that if the target file or directory is a symbolic link, '-shf'
  option prevents following the link
* Verify that if the target file or directory is a symbolic link, '-snf'
  option prevents following the link
* Verify that '-s' option creates a symbolic link
* Verify that '-w' option produces a warning if the source of a symbolic
  link does not currently exist

Submitted by: shivansh
Reviewed by: asomers, ngie
MFC after: 1 month
Sponsored by: Google, Inc (GSoC 2017)
Differential Revision: https://reviews.freebsd.org/D11084

7 years agoCorrect an obsolete path to delete.
jkim [Thu, 8 Jun 2017 18:20:32 +0000 (18:20 +0000)]
Correct an obsolete path to delete.

7 years agoBump _FreeBSD_version after removal of groff
bapt [Thu, 8 Jun 2017 17:06:16 +0000 (17:06 +0000)]
Bump _FreeBSD_version after removal of groff

Reported by: antoine

7 years agoremove xo_color_t dup typedef
phil [Thu, 8 Jun 2017 17:00:40 +0000 (17:00 +0000)]
remove xo_color_t dup typedef

7 years agoAdd function to dump PCIE MBUS decoding windows and bars
zbb [Thu, 8 Jun 2017 16:57:06 +0000 (16:57 +0000)]
Add function to dump PCIE MBUS decoding windows and bars

This commit allows to dump PCIE MBUS and bars configuration
for Marvell platforms.

Submitted by:   Michal Mazur <mkm@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Netgate
Differential revision: https://reviews.freebsd.org/D10908

7 years agoRestore DTS node of PCIe controller for A38X boards
zbb [Thu, 8 Jun 2017 16:55:58 +0000 (16:55 +0000)]
Restore DTS node of PCIe controller for A38X boards

Add pcie-controller node as a bus-parent of pcie nodes for Armada38x
boards. This reduces diff between Linux and FreeBSD PCIe device tree
representation to the minimum. This commit also allows for using multiple
PCIe ports, thanks to the recent driver updates, which support such
hierarchy. Restore original PCIe nodes in armada-385.dtsi and
apply necessary changes in hitherto unused armada-380.dtsi.

Submitted by: Michal Mazur <mkm@semihalf.com>
Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield, Netgate
Differential revision: https://reviews.freebsd.org/D10907

7 years agoSupport multi-port PCIe hierarchy in Marvell boards DTS
zbb [Thu, 8 Jun 2017 16:54:02 +0000 (16:54 +0000)]
Support multi-port PCIe hierarchy in Marvell boards DTS

This commit is another part of preparation for PCIe multi-port
support for Marvell SoCs. Some device trees include pcie-controller
node as a bus-parent of pcie nodes. This patch adds support for
new bus, collects and configures device informations and finally
adds PCIB devices as a childs of pcie-controller in Newbus hierarchy.

Submitted by: Marcin Mazurek <mma@semihalf.com>
Obtained form: Semihalf
Sponsored by: Stormshield
Reviewed by:    https://reviews.freebsd.org/D10906

7 years agoFix PCIe window decoding on Armada 38x
zbb [Thu, 8 Jun 2017 16:51:46 +0000 (16:51 +0000)]
Fix PCIe window decoding on Armada 38x

Original PCIe nodes for Marvell SoCs consists of ports' nodes
under main controller node. In order to properly parse
this kind of representation in DT a mechanism for traversing
through the tree required an update. Moreover, processing FDT
data consisting of more than 2 cells had to be fixed,
because the 'reg' property of mrvl,pcie node have additional
parameter in front of 64-bit address. It should be skipped
by default. This commit works properly with old mrvl,pcie
representation for Kirkwood and ArmadaXP SoCs.

Submitted by: Wojciech Macek <wma@semihalf.com>
Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield, Netgate
Differential revision: https://reviews.freebsd.org/D10905

7 years agoEnable MBUS bridge configuration in mv_rtc driver
zbb [Thu, 8 Jun 2017 16:48:09 +0000 (16:48 +0000)]
Enable MBUS bridge configuration in mv_rtc driver

This patch fixes sporadic problems with updating time
with mv_rtc driver by configuring access to it via MBUS.
For this purpose already existing second set of resources
in rtc@3800 node of Armada 38x DT is used.

Submitted by: Dominik Ermel <der@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10901

7 years agoAdd reset capability to mv_rtc driver
zbb [Thu, 8 Jun 2017 16:46:38 +0000 (16:46 +0000)]
Add reset capability to mv_rtc driver

This commit enables optional reset of the RTC, in case
its registers' contents did not sustain the reboot or power-off/on
sequence. Without it, further usage of RTC is impossible
(e.g. writing values to RTC_TIME register will not succeed).

The reset is performed only if Clock Correction register
does not comprise RTC_NOMINAL_TIMING, what helps to distinguish,
whether the software configured RTC before or it comprises
the default value.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10900

7 years agoFix an off-by-one error in the VM page array on some systems.
jhb [Thu, 8 Jun 2017 16:18:41 +0000 (16:18 +0000)]
Fix an off-by-one error in the VM page array on some systems.

r31386 changed how the size of the VM page array was calculated to be
less wasteful.  For most systems, the amount of memory is divided by
the overhead required by each page (a page of data plus a struct vm_page)
to determine the maximum number of available pages.  However, if the
remainder for the first non-available page was at least a page of data
(so that the only memory missing was a struct vm_page), this last page
was left in phys_avail[] but was not allocated an entry in the VM page
array.  Handle this case by explicitly excluding the page from
phys_avail[].

Reviewed by: alc
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D11000

7 years agoWhen allocating swap blocks, if the available number of free blocks in a
alc [Thu, 8 Jun 2017 15:48:54 +0000 (15:48 +0000)]
When allocating swap blocks, if the available number of free blocks in a
subtree is already zero, then setting the "largest contiguous free block"
hint for that subtree to anything other than zero makes no sense.  To be
clear, assigning a value to the hint that is too large is not a correctness
problem, only a pessimization.

Dragonfly BSD has applied the same change to blst_meta_alloc() but not
blst_meta_fill().

MFC after: 6 weeks

7 years agoImport libxo-0.8.0:
phil [Thu, 8 Jun 2017 13:04:01 +0000 (13:04 +0000)]
Import libxo-0.8.0:
 - addition of --libxo colors=xxxxx color map (so I never see "blue")
 - fix bugs from -fsanitize=address and =undefined
 - utf-8 changes (remove support fore 6 byte utf-8 values, which are "historical")
 - add comments
 - fix man pages
 - update test cases

Submitted by: phil
Reviewed by: sjg
Approved by: sjg (mentor)

7 years agohyperv/pcib: use the device serial number as PCI domain
dexuan [Thu, 8 Jun 2017 12:11:30 +0000 (12:11 +0000)]
hyperv/pcib: use the device serial number as PCI domain

Currently the PCI domain is initialized with the instance GUID in
vmbus_pcib_attach(). It turns out the GUID can change across VM reboot,
while some users want a persistent value for PCI domain. The solution is
that we can change to use the device serial number, which starts with 1
and is unique within a VM.

Obtained from: Haiyang Zhang
MFC after: 1 day
Sponsored by: Microsoft

7 years agoDecode arguments passed to msync().
jhb [Thu, 8 Jun 2017 08:10:57 +0000 (08:10 +0000)]
Decode arguments passed to msync().

7 years agoDecode flags passed to mount(), nmount(), and unmount().
jhb [Thu, 8 Jun 2017 08:07:51 +0000 (08:07 +0000)]
Decode flags passed to mount(), nmount(), and unmount().

7 years agoThis code was missing socket unlock and socket buffer lock, but it
glebius [Thu, 8 Jun 2017 06:37:11 +0000 (06:37 +0000)]
This code was missing socket unlock and socket buffer lock, but it
worked since right now these two locks are the same.

7 years agoThe desired lock here is socket buffer, not socket.
glebius [Thu, 8 Jun 2017 06:34:09 +0000 (06:34 +0000)]
The desired lock here is socket buffer, not socket.

Right now they match, but won't in future.

7 years agoFix a degenerate case when soisdisconnected() would call soisconnected().
glebius [Thu, 8 Jun 2017 06:16:47 +0000 (06:16 +0000)]
Fix a degenerate case when soisdisconnected() would call soisconnected().

This happens when closing a socket with upcall, and trace is: soclose()->
... protocol ... -> soisdisconnected() -> socantrcvmore_locked() ->
sowakeup() -> soisconnected().

Right now this case is innocent for two reasons.  First, soisconnected()
doesn't clear SS_ISDISCONNECTED flag.  Second, the mutex to lock the
socket is the socket receive buffer mutex, and sodisconnected() first
disables the receive buffer. But in future code, the mutex to lock
socket is different to buffer mutex, and we would get undesired mutex
recursion.

The fix is to check SS_ISDISCONNECTED flag before calling upcall.

7 years agoMake the test to leave one connection on the incomplete queue
glebius [Thu, 8 Jun 2017 06:13:53 +0000 (06:13 +0000)]
Make the test to leave one connection on the incomplete queue
before exiting.  This examines some race conditions in kernel.