Fix reported errno.

MFC after: 3 days


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234460 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Use the same pattern for mbuf logging everywhere.

MFC after: 3 days


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234461 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Properly use SHA1_Final() instead of SHA_Final().

In this case it doesn't really matter, as long as we turn a TTY name
into a set of shuffled bytes. Still, for correctness we should use the
proper function.

MFC after:	2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234462 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Document swi_remove(9).

Reviewed by:	jhb
MFC after:	1 week


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

MFC after: 3 days


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234464 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
- Update the rest of struct ithd references.
- net_ih and softclock_ih cookies have gone away.

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234465 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Do a better job at determining the username of the login session.

When multiple users share the same UID, the old code will simply pick an
arbitrary username to attach to the utmpx entries. Make the code a bit
more accurate by first checking whether getlogin() returns a username
which corresponds to the uid of the calling process. If this fails,
simply fall back to picking an arbitrary username.

Reported by:	saurik on GitHub
MFC after:	2 weeks


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


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234481 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This change creates a new list of active vnodes associated with
a mount point. Active vnodes are those with a non-zero use or hold
count, e.g., those vnodes that are not on the free list. Note that
this list is in addition to the list of all the vnodes associated
with a mount point.

To avoid adding another set of linkage pointers to the vnode
structure, the active list uses the existing linkage pointers
used by the free list (previously named v_freelist, now renamed
v_actfreelist).

This update adds the MNT_VNODE_FOREACH_ACTIVE interface that loops
over just the active vnodes associated with a mount point (typically
less than 1% of the vnodes associated with the mount point).

Reviewed by: kib
Tested by:   Peter Holm
MFC after:   2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234482 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This update uses the MNT_VNODE_FOREACH_ACTIVE interface that loops
over just the active vnodes associated with a mount point to replace
MNT_VNODE_FOREACH_ALL in the vfs_msync, ffs_sync_lazy, and qsync
routines.

The vfs_msync routine is run every 30 seconds for every writably
mounted filesystem. It ensures that any files mmap'ed from the
filesystem with modified pages have those pages queued to be
written back to the file from which they are mapped.

The ffs_lazy_sync and qsync routines are run every 30 seconds for
every writably mounted UFS/FFS filesystem. The ffs_lazy_sync routine
ensures that any files that have been accessed in the previous
30 seconds have had their access times queued for updating in the
filesystem. The qsync routine ensures that any files with modified
quotas have those quotas queued to be written back to their
associated quota file.

In a system configured with 250,000 vnodes, less than 1000 are
typically active at any point in time. Prior to this change all
250,000 vnodes would be locked and inspected twice every minute
by the syncer. For UFS/FFS filesystems they would be locked and
inspected six times every minute (twice by each of these three
routines since each of these routines does its own pass over the
vnodes associated with a mount point). With this change the syncer
now locks and inspects only the tiny set of vnodes that are active.

Reviewed by: kib
Tested by:   Peter Holm
MFC after:   2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234483 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Introduce the matching PCI ath(4) fixup code from ar71xx_pci into
ar724x_pci.c.

* Move out the code which populates the firmware into ar71xx_fixup.c
* Shuffle around the ar724x fixup code to match what the ar71xx fixup
  code does.

I've validated this on an AR7240 with AR9285 on-board NIC. It doesn't
yet load, as the AR9285 EEPROM code needs to be made "flash aware."

TODO:

* Validate that I haven't broken AR71xx
* Test AR9285/AR9287 onboard NICs, complete with EEPROM code changes
* Port over the needed BAR hacks for AR7240, AR7241 and AR7242 from
  Linux OpenWRT.  The current WAR has only been tested on the AR7240
  and I'm not sure the way the BAR register is treated is "right".
  The "fixup" method here is right when setting the BAR for local access -
  ie, the BAR address is either 0xffff (AR7240) or 0x1000ffff (AR7241/AR7242),
  but the ath9k-fixup.c code (Linux OpenWRT) does this when setting the
  initial "fixup" BAR.  It then restores the original BAR.
  I'll have to read the ar724x PCI bus glue to see what other special cases
  await.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234485 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add linkstate to bridge(4), set the link to up when at least one underlying
interface is up, otherwise the link is down.

This, among other things, allows carp to work on a bridge.

Prodded by:	glebius
Tested by:	Alexander Lunev


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234487 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Move the interface media check to a taskqueue, some interfaces (usb) sleep
during SIOCGIFMEDIA and we were holding locks.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234488 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
The value of flags matching VNOVAL can't be supported. Return EOPNOTSUPP
from setfflags() in this case. This fixes the return value of
chflags(path, -1).

Discussed with:	bde
MFC after:	2 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234489 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix some compile warnings.

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234491 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Build a 32-bit EFI loader on amd64. This to match the rest of the
code that is used to construct a loader (e.g. libstand, ficl, etc).

There is such a thing as a 64-bit EFI application, but it's not
as standard as 32-bit is. Let's make the 32-bit functional (as in
we can load and actualy boot a kernel) before solving the 64-bit
loader problem.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234493 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Include the associated wait channel message for context switch ktrace
records.  kdump supports both the old and new messages.

Submitted by:	Andrey Zonov  andrey zonov org
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234494 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
The amr(4) firmware contains a rather dubious "feature" where it
assumes for small buffers (< 64k) that the OS driver is actually using
a buffer rounded up to the next power of 2.  It also assumes that the
buffer is at least 4k in size.  Furthermore, there is at least one
known instance of megarc sending a request with a 12k buffer where the
firmware writes out a 24k-ish reply.

To workaround the data corruption triggered by this "feature", ensure
that buffers for user commands use a minimum size of 32k, and that
buffers between 32k and 64k use a 64k buffer.

PR:		kern/155658
Submitted by:	Andreas Longwitz  longwitz incore de
Reviewed by:	scottl
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234501 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
After r217375, some startup objects under lib/csu are built in a special
way: first they are compiled to assembly, then some sed'ing is done on
the assembly, and lastly the assembly is compiled to an object file.

This last step is done using ${CC}, and not ${AS}, because when the
compiler is clang, it outputs directives that are too advanced for our
old gas.  So we use clang's integrated assembler instead.  (When the
compiler is gcc, it just calls gas, and nothing is different, except one
extra fork.)

However, in the .s to .o rules in lib/csu/$ARCH/Makefile, I still passed
CFLAGS to the compiler, instead of ACFLAGS, which are specifically for
compiling .s files.

In case you are using '-g' for debug info anywhere in your CFLAGS, it
causes the .s files to already contain debug information in the assembly
itself.  In the next step, the .s files are also compiled using '-g',
and if the compiler is clang, it complains: "error: input can't have
.file dwarf directives when -g is used to generate dwarf debug info for
assembly code".

Fix this by using ${ACFLAGS} for compiling the .s files instead.

Reported by:	jasone
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@234502 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Replace homegrown list implementation in sys/dev/asr/asr.c with
STAILQ().  While here, fix another clang warning about a switch which
tests an enum type for a regular integer value.

Submitted by:	jhb
MFC after:	1 week


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