dragonfly.git
12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Sun, 1 Apr 2012 02:03:22 +0000 (19:03 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agoHAMMER VFS - Fix assertion with multi-volume setup
Matthew Dillon [Sun, 1 Apr 2012 01:35:33 +0000 (18:35 -0700)]
HAMMER VFS - Fix assertion with multi-volume setup

* The RB compare code for hammer_io was extracting the volume number
  from the wrong place, creating a situation where duplicate hammer_io's
  would sometimes be inserted in the RB tree (causing an assertion + panic).

* Pull the volume number from a different field.

Reported-by: Mark Saad <nonesuch@longcount.org>
12 years agokernel - Do not use M_USE_INTERRUPT_RESERVE for M_NOWAIT
Matthew Dillon [Sun, 1 Apr 2012 01:33:59 +0000 (18:33 -0700)]
kernel - Do not use M_USE_INTERRUPT_RESERVE for M_NOWAIT

* Redefine M_NOWAIT to not use M_USE_INTERRUPT_RESERVE.  This can result
  in mbuf exhaustion during bursts of mbuf allocations and cause kernel
  kvm expansion to assert and panic.

Reported-by: sephe
12 years agokernel - Fix signal masking race assertion panic w/vkernel
Matthew Dillon [Sun, 1 Apr 2012 01:30:13 +0000 (18:30 -0700)]
kernel - Fix signal masking race assertion panic w/vkernel

* sigsuspend() and pselect() record the old signal mask in order to
  allow an interrupting signal to run its handler before the old mask
  is restored.

* When multiple threads are present a race can ensue where another thread
  changes the signal handler after sigsuspend() or pselect() have interrupted,
  but before they are able to process the signal.

* If the signal is no longer enabled the old signal mask is not restored
  on system call return, resulting in an assertion and panic.

* Fix the problem by checking the flag and restoring the old signal mask
  on return (rather than asserting when the flag is found to be non-zero
  on return).

Reported-by: Venkatesh Srinivas
12 years agolibm: Fix a typo in the MLINKS.
Sascha Wildner [Sat, 31 Mar 2012 22:22:46 +0000 (00:22 +0200)]
libm: Fix a typo in the MLINKS.

12 years agoFix some indentation in various places.
Sascha Wildner [Sat, 31 Mar 2012 18:34:05 +0000 (20:34 +0200)]
Fix some indentation in various places.

12 years agoKernel - Restore the 64KB max. IO size limit
François Tigeot [Sat, 31 Mar 2012 18:23:56 +0000 (20:23 +0200)]
Kernel - Restore the 64KB max. IO size limit

* Some drivers and part of the kernel are dependent on an implicit
  64KB maximum IO size limit

* Explicitely set it to 64KB (or MAXPHYS if it is smaller) for devices
  which do not report a default value

* This should fix ATA DMA errors reported in issue #2342

12 years agoaic(4): Remove ISA attachment.
Sascha Wildner [Sat, 31 Mar 2012 14:48:23 +0000 (16:48 +0200)]
aic(4): Remove ISA attachment.

The only support that remains (and works) is for AHA-1460 PC Card adapters.

While here, reduce differences with FreeBSD a bit.

12 years agoVFS accounting: avoid VOP_GETATTR() calls
François Tigeot [Fri, 30 Mar 2012 21:09:51 +0000 (23:09 +0200)]
VFS accounting: avoid VOP_GETATTR() calls

* Only use them if VFS accounting is not disabled

12 years agoasr(4): Improve readability of an 'if' a bit.
Sascha Wildner [Sat, 31 Mar 2012 03:24:38 +0000 (05:24 +0200)]
asr(4): Improve readability of an 'if' a bit.

12 years agomfi(4): Fix indent.
Sascha Wildner [Sat, 31 Mar 2012 03:19:25 +0000 (05:19 +0200)]
mfi(4): Fix indent.

12 years agorp(4): Fix indent.
Sascha Wildner [Sat, 31 Mar 2012 02:44:50 +0000 (04:44 +0200)]
rp(4): Fix indent.

12 years agopcn(4): Add missing braces.
Sascha Wildner [Sat, 31 Mar 2012 02:10:59 +0000 (04:10 +0200)]
pcn(4): Add missing braces.

12 years agolgue(4): Add missing braces and fix indentation.
Sascha Wildner [Sat, 31 Mar 2012 01:46:53 +0000 (03:46 +0200)]
lgue(4): Add missing braces and fix indentation.

It was returning too early in some cases.

While here, add an error message.

12 years agokernel/netgraph7: Fix whitespace.
Sascha Wildner [Sat, 31 Mar 2012 01:30:32 +0000 (03:30 +0200)]
kernel/netgraph7: Fix whitespace.

12 years agokernel: Indent a debugging kprintf.
Sascha Wildner [Sat, 31 Mar 2012 01:30:07 +0000 (03:30 +0200)]
kernel: Indent a debugging kprintf.

12 years agohptiop(4): Add missing braces.
Sascha Wildner [Sat, 31 Mar 2012 01:26:52 +0000 (03:26 +0200)]
hptiop(4): Add missing braces.

12 years agokernel: Adjust some casts.
Sascha Wildner [Sat, 31 Mar 2012 01:20:34 +0000 (03:20 +0200)]
kernel: Adjust some casts.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 30 Mar 2012 22:51:07 +0000 (15:51 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agoKernel - Completely remove DFLTPHYS
François Tigeot [Thu, 22 Mar 2012 18:17:48 +0000 (19:17 +0100)]
Kernel - Completely remove DFLTPHYS

* There is no need to have two different macros define the maximum
  allowed IO size for low-level operations; replace DFLTPHYS by
  MAXPHYS in the entire kernel.

* Old drivers typically used DFLTPHYS without a second thought,
  assuming it would always be the same value; they may have hard
  limitations and break if bigger I/O sizes are suddenly used.
  Be sure to explicitely limit their maximum allowed I/O size to
  64KB and keep them working.

12 years agortld: allocate obj->vertab only once
John Marino [Fri, 30 Mar 2012 18:07:35 +0000 (20:07 +0200)]
rtld: allocate obj->vertab only once

Verbatim from FreeBSD SVN 233546 (27 MAR 2012)

Prevent rtld_verify_object_versions() from being called several times for
the same object. This can happen when object is a dependency of the
dlopen()ed dso. When called several times, we waste time due to unneeded
processing, and memory, because obj->vertab is allocated anew on each
iteration.

12 years agoVFS accounting: do not count write operations for removed files
Francois Tigeot [Fri, 30 Mar 2012 08:52:07 +0000 (10:52 +0200)]
VFS accounting: do not count write operations for removed files

* vnode operations can and do happen out-of-order in some circumstances
  (multi-job builds with make for example)

* check if the vnode has at least one associated link to be sure it
  still corresponds to an existing file

* do not count the write operation if this is not the case

12 years agomfiutil(8): Fix some 'unused variable' warnings and raise WARNS to 6.
Sascha Wildner [Fri, 30 Mar 2012 16:38:54 +0000 (18:38 +0200)]
mfiutil(8): Fix some 'unused variable' warnings and raise WARNS to 6.

12 years agorwhod(8): Prevent clobbering the neighboring field by a wrong cast.
Sascha Wildner [Fri, 30 Mar 2012 16:36:50 +0000 (18:36 +0200)]
rwhod(8): Prevent clobbering the neighboring field by a wrong cast.

The time stamps in the rwhod(8) network datagram and, based on that,
/var/rwho/whod.* spool files are typed as 32bit int and cannot accept
a 64bit time_t.

The old code clobbered the first bytes of the adjacent "hostname"
field, yielding empty hostnames in local rwho(1) and ruptime(1) output.
(Outgoing datagrams to other hosts were not affected.)

Re-code to let the compiler do the proper coercion (well, until 2038).

Submitted-by: Martin Neitzel
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2339>

12 years agoVFS accounting: small speed optimization
Francois Tigeot [Wed, 28 Mar 2012 11:52:36 +0000 (13:52 +0200)]
VFS accounting: small speed optimization

* Some operations may end up using the accounting macro with an
  effective zero bytes space usage difference

* Avoid calling the whole mess and its associated mount-point spinlock
  in that case.

12 years agokernel -- ffs: Do not dereference NULL inodes in ffs_sync_scan1.
Venkatesh Srinivas [Fri, 30 Mar 2012 06:33:08 +0000 (23:33 -0700)]
kernel -- ffs: Do not dereference NULL inodes in ffs_sync_scan1.

ffs_sync_scan1 is a fast callback from vmntvnodescan; it is not called
with vnodes locked. It is possible for an ffs_reclaim to have reclaimed
the vnode in question, NULL-ing out ip, without having removed the vnode
from the per-mount list. If we see a NULL inode, return failure from the
fast callback.

12 years agokern.cp_time - Add convenience defines
Samuel J. Greear [Fri, 30 Mar 2012 03:27:09 +0000 (21:27 -0600)]
kern.cp_time - Add convenience defines

* Add convenience defines for indexes of the array returned by the kern.cp_time
  sysctl.

* This sync's us with FreeBSD and should un-break and couple of pkgsrc
  packages.

12 years agomfi(4): Update to LSI's version 4.23 of the driver.
Sascha Wildner [Thu, 29 Mar 2012 18:05:12 +0000 (20:05 +0200)]
mfi(4): Update to LSI's version 4.23 of the driver.

Brings in support for newer SAS2208 (aka Thunderbolt) based
controllers. It was tested with an Intel RS25DB080.

A few other things have been fixed too. Most x86_64/i386 specific
parts have been merged, MSI is now setup in mfi_pci.c properly.

Taken-from: FreeBSD (from their projects/ repository)

12 years agopuffs_framebuf.3: Fix typo
Sascha Wildner [Thu, 29 Mar 2012 14:13:56 +0000 (16:13 +0200)]
puffs_framebuf.3: Fix typo

12 years agopuffs_ops.3: Fix typo.
Sascha Wildner [Thu, 29 Mar 2012 13:25:12 +0000 (15:25 +0200)]
puffs_ops.3: Fix typo.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Thu, 29 Mar 2012 05:36:09 +0000 (22:36 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel -- ffs: Replace softupdates critical section locks with lockmgr.
Venkatesh Srinivas [Wed, 28 Mar 2012 18:09:15 +0000 (11:09 -0700)]
kernel -- ffs: Replace softupdates critical section locks  with lockmgr.

ffs softupdates was using a combination of critical sections and the mplock
to construct its acquire_lock/free_lock/interlocked_sleep primitives.

The softupdates I/O completion callback had a few points where it could block,
causing it to lose the mplock and any critical sections it held. When it did
so, front-end softupdates code would try to grab the lock but panic on seeing
the I/O completion callback in progress. This was not a problem in older
systems, as splx() would prevent the I/O callback from starting while
softdep code was executing.

This patch converts to using hard locks (lockmgr), which are held even while
a thread is blocked.

getdirtybuf(), locking a dirty buffer via BUF_LOCK, was changed to not
deadlock against the I/O completion path; specifically it drops the softdep
lock when its non-blocking attempt to lock a dirty buffer fails. One caller
of getdirtybuf() also required changes to retry locking buffers.

Closes-bug: 2291
Partially-from: FreeBSD r140709
Reported-by: tuxillo, marino, Rumko, vsrinivas
Discussed-with: dillon

12 years agoVFS accounting: use vq_vptomp() in kern_ftruncate()
Francois Tigeot [Wed, 28 Mar 2012 11:22:56 +0000 (13:22 +0200)]
VFS accounting: use vq_vptomp() in kern_ftruncate()

* Getting the needed struct mp* from curthread is not a good idea,
  the chain of dependencies is complex and may cause problems.

* Use vq_vptomp() to get it from the vnode we're using instead.

12 years agonetstat: Print SACK related statistics
Sepherosa Ziehau [Wed, 28 Mar 2012 03:23:36 +0000 (11:23 +0800)]
netstat: Print SACK related statistics

While I'm here, indent syncookie statistics into syncache statistics block.

12 years agotcp/sack: Add more statistics
Sepherosa Ziehau [Tue, 27 Mar 2012 01:54:55 +0000 (09:54 +0800)]
tcp/sack: Add more statistics

12 years agokernel - Revert 0d52e78c527ec7ba3ac62d40d9fa588c964d4c55
Matthew Dillon [Wed, 28 Mar 2012 02:11:22 +0000 (19:11 -0700)]
kernel - Revert 0d52e78c527ec7ba3ac62d40d9fa588c964d4c55

* Revert allowance of spinlocks when doing a lockmgr LK_RELEASE operation.
  Spinlocks must not be allowed for release operations due to the possibility
  of a livelock in the IPI code if wakeup() is called.

12 years agokernel - Fix improper BUF_UNLOCK() with spinlock held
Matthew Dillon [Wed, 28 Mar 2012 02:10:14 +0000 (19:10 -0700)]
kernel - Fix improper BUF_UNLOCK() with spinlock held

* Fix improper BUF_UNLOCK()s in the buf daemon threads.  Use a
  marker and rearrange the code to release the spinlock before
  executing BUF_UNLOCK().

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 27 Mar 2012 20:41:14 +0000 (13:41 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel -- DEBUG_LOCKS: Do not panic if releasing a lockmgr lock w/ spinlocks held.
Venkatesh Srinivas [Tue, 27 Mar 2012 14:55:17 +0000 (07:55 -0700)]
kernel -- DEBUG_LOCKS: Do not panic if releasing a lockmgr lock w/ spinlocks held.

12 years agomountlist_exists(): use a TAILQ_FOREACH macro again
Francois Tigeot [Mon, 26 Mar 2012 17:58:30 +0000 (19:58 +0200)]
mountlist_exists(): use a TAILQ_FOREACH macro again

Removing a few lines of code in the process.

12 years agokernel: msdosfs -- Use -1 rather than 32-bit 0xffffffff in mount().
Venkatesh Srinivas [Mon, 26 Mar 2012 15:59:02 +0000 (08:59 -0700)]
kernel: msdosfs -- Use -1 rather than 32-bit 0xffffffff in mount().

Corrects bug mounting 8GB msdosfs filesystem on x86-64.

Submitted-by: G. Isenmann
12 years agotcp: Properly update tcps_rttcantdetect
Sepherosa Ziehau [Mon, 26 Mar 2012 05:39:10 +0000 (13:39 +0800)]
tcp: Properly update tcps_rttcantdetect

- Fix the logic which detects that RTT based spurious retransmition
  detection does not work.
- Add missing tcps_rttcantdetect updating in header prediction code

12 years agonetstat: Print the statistics that Eifel works but RTT based spurious rexmt not
Sepherosa Ziehau [Mon, 26 Mar 2012 05:37:46 +0000 (13:37 +0800)]
netstat: Print the statistics that Eifel works but RTT based spurious rexmt not

12 years agotcp/sack: Prevent invalid SACK option from being processed
Sepherosa Ziehau [Mon, 26 Mar 2012 03:36:53 +0000 (11:36 +0800)]
tcp/sack: Prevent invalid SACK option from being processed

If the received SACK blocks contain one invalid SACK block,
discard the whole SACK blocks.

12 years agoacpi_hp(4): Fix acquisition of acpi's softc.
Sascha Wildner [Sun, 25 Mar 2012 12:34:03 +0000 (14:34 +0200)]
acpi_hp(4): Fix acquisition of acpi's softc.

Now that acpi_hp is acpi_wmi's child, the softc must be taken from
its grandparent (acpi).

This fixes a crash in the setup of the sysctl tree.

Reported-by: tuxillo
12 years agortld: Sync memory allocation with FreeBSD
John Marino [Sun, 25 Mar 2012 10:49:17 +0000 (12:49 +0200)]
rtld: Sync memory allocation with FreeBSD

Taken from:
FreeBSD SVN 233306 (22 March 2012)
FreeBSD SVN 233307 (22 March 2012)
FreeBSD SVN 233357 (22 March 2012)

Remove unused CalTech #ifdef fragments.

Use xmalloc() instead of malloc() in the places where malloc() calls
are assumed to not fail. Make the xcalloc() calling conventions follow
the calloc(3) calling conventions and replace unchecked calls to calloc()
with calls to xcalloc(). Remove redundand declarations from xmalloc.c,
which are already present in rtld.h.

Implement xstrdup() using strlen()/xmalloc()/memcpy() already presented
in rtld, instead of pulling in libc strdup().

12 years agortld: Fix ELF filter implementation
John Marino [Sun, 25 Mar 2012 10:28:13 +0000 (12:28 +0200)]
rtld: Fix ELF filter implementation

Vertatim from FreeBSD SVN 233231 (20 March 2012):

Do not relocate twice an object which happens to be needed by loaded
binary (or dso) and some filtee opened due to symbol resolution when
relocating need objects.  Record the state of the relocation
processing in Obj_Entry and short-circuit relocate_objects() if
current object already processed.

Do not call constructors for filtees loaded during the early
relocation processing before image is initialized enough to run
user-provided code.  Filtees are loaded using dlopen_object(), which
normally performs relocation and initialization.  If filtee is
lazy-loaded during the relocation of dso needed by the main object,
dlopen_object() runs too earlier, when most runtime services are not
yet ready.

Postpone the constructors call to the time when main binary and
depended libraries constructors are run, passing the new flag
RTLD_LO_EARLY to dlopen_object().  Symbol lookups callers inform
symlook_* functions about early stage of initialization with
SYMLOOK_EARLY.  Pass flags through all functions participating in
object relocation.

Use the opportunity and fix flags argument to find_symdef() in
arch-specific reloc.c to use proper name SYMLOOK_IN_PLT instead of
true, which happen to have the same numeric value.

12 years agoVFS accounting: use an explicit TAILQ_FIRST/TAILQ_NEXT loop in mountlist_exists()
Francois Tigeot [Sun, 25 Mar 2012 10:38:51 +0000 (12:38 +0200)]
VFS accounting: use an explicit TAILQ_FIRST/TAILQ_NEXT loop in mountlist_exists()

The previous TAILQ_FOREACH loop body was never executed

12 years agoVFS accounting: do not set vp->v_pfsmp for non-nullfs mounts
Francois Tigeot [Sun, 25 Mar 2012 08:27:07 +0000 (10:27 +0200)]
VFS accounting: do not set vp->v_pfsmp for non-nullfs mounts

* the test in _cache_setvp() was wrong and was initializing a pfs-specific
  accounting variable in vnodes for all filesystem types, possibly causing
  unnecessary work for each filesystem write operation.

12 years agodefaults: remove /usr/lib/gcc* from ldconfig search path
John Marino [Sat, 24 Mar 2012 08:55:38 +0000 (09:55 +0100)]
defaults: remove /usr/lib/gcc* from ldconfig search path

It is not necessary for ldconfig to add /usr/lib/gcc44 and /usr/lib/gcc41
directories to the default library search path.  Every binary built with
gcc41 and gcc44 embeds these paths into the DT_RPATH dynamic tag which
tells the runtime linker to look their first.  In effect, this means these
paths are potentially searched multiple times: once due to the rpath and
again due to the ldconfig hints file.  Let's do away will the redundant,
always-fails check here.

Another reason is that the gcc libraries have different versions of the
same libraries.  Surely the gcc41 version isn't preferred over the gcc44
version, but it gets searched first.  Again, let rpath take care of this
for gcc.

To update the rc.conf defaults, "make upgrade" after building world is
required.

12 years agogcc41: remove /usr/lib from rpath
John Marino [Sat, 24 Mar 2012 08:14:15 +0000 (09:14 +0100)]
gcc41: remove /usr/lib from rpath

The gcc41 specs were unconditionally adding /usr/lib to the rpath, making
it impossible to use the -z nodefaultlibs linker flag.  RTLD will look in
/usr/lib by default as the last priority of the library search path as
long as the object wasn't built with -z nodefaultlibs.

Also the __DragonFly__ macro was bumped from 1 to 3.  It's supposed to
reflect the major version of DragonFly.

12 years agogcc44: remove /usr/lib from rpath
John Marino [Sat, 24 Mar 2012 08:08:48 +0000 (09:08 +0100)]
gcc44: remove /usr/lib from rpath

The gcc44 specs were unconditionally adding /usr/lib to the rpath, making
it impossible to use the -z nodefaultlibs linker flag.  RTLD will look in
/usr/lib by default as the last priority of the library search path as
long as the object wasn't built with -z nodefaultlibs.

12 years agortld: Implement DT_RUNPATH and -z nodefaultlib
John Marino [Sat, 24 Mar 2012 05:40:50 +0000 (06:40 +0100)]
rtld: Implement DT_RUNPATH and -z nodefaultlib

DT_RUNPATH is incorrectly being considered as an alias of DT_RPATH.  The
purpose of DT_RUNPATH is to have two different types of rpath: one that
can be overridden by the environment variable LD_LIBRARY_PATH and one that
can't.  With the currently implementation, LD_LIBRARY_PATH will always
trump any embedded rpath or runpath tags.

Current path search order by rtld:
==================================
LD_LIBRARY_PATH
DT_RPATH / DT_RUNPATH (always the same)
ldconfig hints file (default: /var/run/ld-elf.so.hints)
/usr/lib

New path search order by rtld:
==============================
DT_RPATH of the calling object if no DT_RUNPATH
DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj
LD_LIBRARY_PATH
DT_RUNPATH
ldconfig hints file
/usr/lib

The new path search matches how the linux runtime loader works.  The other
major added feature is support for linker flag "-z nodefaultlib".  When
this flag is passed to the linker, rtld will skip all references to the
standard library search path ("/usr/lib" in this case but it could handle
more color delimited paths) except in DT_RPATH and DT_RUNPATH.

New path search order by rtld with -z nodefaultlib flag set:
============================================================
DT_RPATH of the calling object if no DT_RUNPATH
DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj
LD_LIBRARY_PATH
DT_RUNPATH
ldconfig hints file (skips all references to /usr/lib)

Currently gcc41 and gcc44 are embedding /usr/lib directly in every
DT_RPATH tag of every binary and shared library it creates.  This is
both unnecessary due to rtld default search path order and it also
defaults the purpose of -z nodefaultlib, so this behavior must be
changed before the flag works.  This will be done in a separate commit.

12 years agoELF: Update header, sync with binutils 2.22
John Marino [Tue, 20 Mar 2012 18:40:41 +0000 (19:40 +0100)]
ELF: Update header, sync with binutils 2.22

12 years agoVFS accounting: fix an issue with unlink operations
Francois Tigeot [Sat, 24 Mar 2012 12:40:27 +0000 (13:40 +0100)]
VFS accounting: fix an issue with unlink operations

* Space counters were previously decreased for every unlink(2)
  on regular files.

* They are only updated for the last link now

12 years agovquota(8): Only count files with more than 2 hard links once
Francois Tigeot [Sat, 24 Mar 2012 13:43:47 +0000 (14:43 +0100)]
vquota(8): Only count files with more than 2 hard links once

True, false, what's the difference ?

12 years agolibc - Do not allow a stuck syslogd to screw up the entire system
Matthew Dillon [Sat, 24 Mar 2012 00:33:51 +0000 (17:33 -0700)]
libc - Do not allow a stuck syslogd to screw up the entire system

* If syslogd gets stuck the socket buffer will still full forever.
  Only try writing a limited number of times before giving up.

12 years agokernel - Add workaround for errata #721 on AMD cpus (found by Matt Dillon)
Matthew Dillon [Fri, 23 Mar 2012 22:49:54 +0000 (15:49 -0700)]
kernel - Add workaround for errata #721 on AMD cpus (found by Matt Dillon)

* Official reference for errata 721:

    http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf

* This is the cpu bug found by Matthew Dillon, present on all K10 cores
  (so far).  AMD has indicated that the bug is not present on Bulldozer
  cpus.

* The MSR workaround is now reported and programmed during kernel boot.

* No discernable difference in performance was detected running GCC
  with and without the MSR adjustment.

* Verified to have fixed our test case w/GCC.  It no longer seg-faults.

12 years agorpc.yppasswdd(8): Fix some warnings and raise WARNS to 5.
Sascha Wildner [Fri, 23 Mar 2012 21:06:37 +0000 (22:06 +0100)]
rpc.yppasswdd(8): Fix some warnings and raise WARNS to 5.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 23 Mar 2012 20:40:36 +0000 (13:40 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Improve NFS server error responses when an inode goes away
Matthew Dillon [Fri, 23 Mar 2012 20:38:29 +0000 (13:38 -0700)]
kernel - Improve NFS server error responses when an inode goes away

* When an inode goes away and FHTOVP fails return ESTALE instead of
  what the VFS returned.

* Greatly improves the re-acquisition of files on NFS clients which have
  been ripped out by the server or other clients.

12 years agokernel - Fix improper unlock/relock sequence in HAMMER
Matthew Dillon [Fri, 23 Mar 2012 20:36:27 +0000 (13:36 -0700)]
kernel - Fix improper unlock/relock sequence in HAMMER

* VOP_FSYNC() can be called during a vnode inactivation or reclaim.
  In this case the vnode lock absolutely cannot be released or it
  can create a window of opportunity for another thread that results
  in a panic.

* Fixes a NFS server crash when multiple clients are trying to
  delete/create/write the same file at the same time.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 23 Mar 2012 16:07:48 +0000 (09:07 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix bug in SILI, remove debugging in AHCI
Matthew Dillon [Fri, 23 Mar 2012 16:06:57 +0000 (09:06 -0700)]
kernel - Fix bug in SILI, remove debugging in AHCI

* Fix the same unlock/lock sequence bug in the SILI driver that was
  fixed in the AHCI driver.

* Remove a flag that was being added to the service set in AHCI for
  debugging purposes.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 23 Mar 2012 08:52:00 +0000 (01:52 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix another AHCI bug
Matthew Dillon [Fri, 23 Mar 2012 08:47:48 +0000 (01:47 -0700)]
kernel - Fix another AHCI bug

* Remove the unlock/lock sequences around the xpt_done() calls.  These
  temporary unlocks create a gap which can allow another interrupt to
  squeeze in and interfere with the interrupt thread that is already
  running, resulting in corruption.

  This bug occurs under very heavy loads, and typically required multiple
  concurrent ops to a SSD to trigger.

* Add additional assertions to catch issues and reorder one of the
  chiploads.

* This is a bit non-optimal, be on the lookout for deadlocks in case it
  turns out that holding the lock is a bad idea.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 23 Mar 2012 08:40:00 +0000 (01:40 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agotcp/sack: Add comment about the implemented TCP/SACK related RFCs
Sepherosa Ziehau [Fri, 23 Mar 2012 06:48:26 +0000 (14:48 +0800)]
tcp/sack: Add comment about the implemented TCP/SACK related RFCs

12 years agokernel - Fix mount refs interactions and umount races
Matthew Dillon [Fri, 23 Mar 2012 04:37:25 +0000 (21:37 -0700)]
kernel - Fix mount refs interactions and umount races

* It is possible for a umount to race other operations on active mount
  point, causing one or the other to deadlock.

* vfs_busy()/vfs_unbusy() now incr/decr mp->mnt_refs.

* cache_findmount() now increments mp->mnt_refs, and add a new API
  function cache_dropmount() which decrements it.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Fri, 23 Mar 2012 04:35:07 +0000 (21:35 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix three AHCI bugs
Matthew Dillon [Fri, 23 Mar 2012 04:31:31 +0000 (21:31 -0700)]
kernel - Fix three AHCI bugs

* This fixes spurious timeouts which occur on SMP boxes with faster devices
  (such as SSDs or more recent hard drives)

* The global interrupt status register appears to be latched on some parts
  rather than wire-or.  Clearing it after signaling the port threads or
  processing the interrupt can cause interrupts to be lost.

* In cases where it is actually wire-or we may get a double-interrupt,
  but stability is more important here.

* Fix the port signaling code.  The mask was being cleared with the
  port interlock released.  It has to be cleared when the interlock is
  held.

* Reorder the per-port interrupt status register clearing code in two
  places to execute before processing the operation rather than after,
  which may fix another source of lost interrupts.

12 years agohammer2 - Implement depth limit for stack recursion, embedded data fixes
Matthew Dillon [Thu, 22 Mar 2012 23:52:11 +0000 (16:52 -0700)]
hammer2 - Implement depth limit for stack recursion, embedded data fixes

* Implement a procedure call depth limit in hammer2_chain_flush().
  Dirty elements that are too deep are placed on a deferral list and
  then executed at the top-level.  Worst case stack depth is reduced 40:1.

* Fix a bug when transitioning from embedded data to indirect data.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Thu, 22 Mar 2012 23:51:45 +0000 (16:51 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Cluster fixes + Enable clustering for HAMMER1
Matthew Dillon [Thu, 22 Mar 2012 23:45:55 +0000 (16:45 -0700)]
kernel - Cluster fixes + Enable clustering for HAMMER1

* Add cluster_awrite(), which replaces vfs_bio_awrite() and has the same
  basic semantics as bawrite().

* Remove vfs_bio_awrite(), which had an odd API that required the buffer
  to be locked but not removed from its queues.

* Make cluster operations work on disk device buffers as well as on
  regular files.

* Add a blkflags argument to getcacheblk(), allowing GETBLK_NOWAIT to
  be passed to it.

* Enhance cluster_wbuild() to support cluster_awrite() by having it take
  an optional bp to incorporate into the cluster.  The caller disposes of
  the bp by calling bawrite() if the cluster_wbuild() code could not use it.

* Certain adjustments to cluster_write() and related code in checking against
  the file EOF to not break when variable block sizes are used.

* Fix a bug in calls made to buf_checkwrite().  The caller is required to
  initiate the I/O if the function returns good (0).  HAMMER1 uses this
  save side effects and blows up if the I/O is then not initiated.

* Enable clustering in HAMMER1 for both data and meta-data.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Thu, 22 Mar 2012 19:41:29 +0000 (12:41 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Thu, 22 Mar 2012 19:22:27 +0000 (12:22 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel/kobj: Put the default kobj_method inside the kobjop_desc struct.
Sascha Wildner [Thu, 22 Mar 2012 18:35:13 +0000 (19:35 +0100)]
kernel/kobj: Put the default kobj_method inside the kobjop_desc struct.

Also, make kobj_methods constant. See FreeBSD's r227343 and r227384 for
more information.

This change reduces the size of a LINT64 kernel by 18KB and our source
by 7 lines!

Taken-from: FreeBSD

12 years agoVFS accounting: handle file truncation on open(2)
Francois Tigeot [Thu, 22 Mar 2012 16:51:47 +0000 (17:51 +0100)]
VFS accounting: handle file truncation on open(2)

* Files succesfully opened with O_TRUNC are truncated to zero length.
  This case was not previously handled, leading to a growing drift
  between VFS counters and reality.

* Fix a buildworld issue caused by the last VFS accounting commit

12 years agopstat.8: The fstat manpage is in section 1.
Sascha Wildner [Thu, 22 Mar 2012 15:50:05 +0000 (16:50 +0100)]
pstat.8: The fstat manpage is in section 1.

12 years agoVFS accounting: isolate the code to find the real mp
François Tigeot [Thu, 22 Mar 2012 12:48:33 +0000 (13:48 +0100)]
VFS accounting: isolate the code to find the real mp

* It was not specific to vop_write()

* Put it in a standalone vq_vptomp() function so that it may be easily
  used in other places

12 years agohammer2 - Bug fixes in allocator and chain_next, rename
Matthew Dillon [Thu, 22 Mar 2012 07:12:43 +0000 (00:12 -0700)]
hammer2 - Bug fixes in allocator and chain_next, rename

* The addition of a larger segment to allocate blocks out of caused
  the allocator to mishandle 64K requests, resulting in non-optimal
  I/O performance.

* Fix a bug in hammer2_chain_next() which was causing truncations to
  crash.

* Rename operations would sometimes not recursively mark the chain
  MODIFIED1 or would not mark the updated inode MOVED, causing
  data loss.

* Replace HAMMER2_CHAIN_WAS_MODIFIED with a local variable.

12 years agohammer2 - Major hammer2_chain_*() API cleanup
Matthew Dillon [Thu, 22 Mar 2012 04:10:40 +0000 (21:10 -0700)]
hammer2 - Major hammer2_chain_*() API cleanup

* Do a major rewrite of the hammer2_chain_*() API functions, primarily
  dealing with whether the caller wants data instantiated for a chain
  element or not.

  Also revamp the locking calls.  Integrate the ref count into
  hammer2_chain_lock() to simplify the operation.

* Add infrastructure to allow a minimum physical I/O size to be specified
  independently from the allocation size.  Not finished yet and currently
  disabled.

* Optimize I/O a little, but this still needs a ton of work.
  Set B_CLUSTEROK for logical buffers.

* Add some statistics gathering.

* Remove several duplicative functions.

12 years agohammer2 - small-embedded-data fixes, syncer fixes
Matthew Dillon [Wed, 21 Mar 2012 05:16:19 +0000 (22:16 -0700)]
hammer2 - small-embedded-data fixes, syncer fixes

* Add a bit of a hack to try to fix an issue where the embedded data
  would sometimes not get synchronized.  Add the DIRTYEMBED flag
  and test for it in various places.

* Remove an improper call to hammer2_chain_modify() on the inode
  (the previous handling of embedded data, which was broken).

* Detect and dispose of unlinked files from vop_inactive.

* Fix some inefficiencies in the flush code.  When modifying a chain
  in order to update its blockref array hammer2_chain_modify() was
  recursively setting SUBMODIFIED upward, messing up the flush code's
  sequencing and causing it to not completely flush the topology.

* Remove some debugging.

12 years agohammer2 - cleanup, stabilization pass
Matthew Dillon [Wed, 21 Mar 2012 02:13:56 +0000 (19:13 -0700)]
hammer2 - cleanup, stabilization pass

* MOVED -> SUBMODIFIED was not being set in the parent chain under some
  circumstances.

* Optimize I/O a bit more, there's no point dirtying a chain for a blockref
  update until all sub-chains are clean (at least for now).

* Additional chain locking around certain tests and propagations.

* Numerous fixes to hammer_chain_flush(), sync, and unmount

* Properly destroy the chains for disconnected inodes when the inodes are
  reclaimed.

* Code cleanup.

12 years agohammer2 - Avoid unnecessary IO
Matthew Dillon [Tue, 20 Mar 2012 22:35:07 +0000 (15:35 -0700)]
hammer2 - Avoid unnecessary IO

* With the new strategy we no longer have to build smaller blocksizes into
  larger buffers.

  When flushing embedded data we can now getblk() the block instead of
  bread() it.

* DELETED nodes have to be explicitly flushed to remove references
  associated with MODIFY1 and MOVE.

* There's no need to flush meta-data associated with a deleted node.

12 years agohammer2 - Reformulate strategy code and direct I/O
Matthew Dillon [Tue, 20 Mar 2012 22:12:02 +0000 (15:12 -0700)]
hammer2 - Reformulate strategy code and direct I/O

* Use variable block sizes for both logical and physical buffers such
  that the logical buffer matches the physical buffer.

* Change the file data layout to use 64K blocks for all bulk data fully
  enclosed in the block, with a single variable-length block straddling
  the file EOF sized 1K - 64K in powers of 2.  The inode's 512 bytes of
  embedded data is still implemented for file sizes <= 512 bytes.

* Implement direct IO for both reading and writing.

* Reformulate the strategy write code such that bio2.bio_offset is always
  pre-calculated, allowing the strategy code to issue the I/O without
  requiring any further filesystem interactions.

* Fixes numerous deadlocks.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 20 Mar 2012 22:11:27 +0000 (15:11 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Add argument to nvtruncbuf()
Matthew Dillon [Tue, 20 Mar 2012 22:10:02 +0000 (15:10 -0700)]
kernel - Add argument to nvtruncbuf()

* Add a 'trivial' arg to nvtruncbuf() that works similarly to
  nvextendbuf().

  This will allow hammer2 to tell nvtruncbuf() not to mess with the
  buffer that overlaps EOF, so hammer2 can mess with it atomically.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 20 Mar 2012 22:04:52 +0000 (15:04 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agompt(4): Fix an issue that caused the driver to attach to mfi(4) cards.
Sascha Wildner [Tue, 20 Mar 2012 20:19:25 +0000 (21:19 +0100)]
mpt(4): Fix an issue that caused the driver to attach to mfi(4) cards.

FreeBSD's commit message (r232411) explains it:

Fix a problem that was causing the mpt(4) driver to attach to MegaRAID
cards that should be handled by the mfi(4) driver.

The root of the problem is that the mpt(4) driver was masking off the
bottom bit of the PCI device ID when deciding which cards to attach to.

It appears that a number of the mpt(4) Fibre Channel cards had a LAN
variant whose PCI device ID was just one bit off from the FC card's device
ID.  The FC cards were even and the LAN cards were odd.

The problem was that this pattern wasn't carried over on the SAS and
parallel SCSI mpt(4) cards.  Luckily the SAS and parallel SCSI PCI device
IDs were either even numbers, or they would get masked to a supported
adjacent PCI device ID, and everything worked well.

Now LSI is using some of the odd-numbered PCI device IDs between the 3Gb
SAS device IDs for their new MegaRAID cards.  This is causing the mpt(4)
driver to attach to the RAID cards instead of the mfi(4) driver.

The solution is to stop masking off the bottom bit of the device ID, and
explicitly list the PCI device IDs of all supported cards.

This change should be a no-op for mpt(4) hardware.  The only intended
functional change is that for the 929X, the is_fc variable gets set.  It
wasn't being set previously, but needs to be because the 929X is a Fibre
Channel card.

12 years agoaesni(4): Move some unused variables into the #if 0'd parts.
Sascha Wildner [Tue, 20 Mar 2012 15:32:45 +0000 (16:32 +0100)]
aesni(4): Move some unused variables into the #if 0'd parts.

12 years agondis(4): Use the device_t for getting the softc.
Sascha Wildner [Tue, 20 Mar 2012 12:25:43 +0000 (13:25 +0100)]
ndis(4): Use the device_t for getting the softc.

12 years agohammer2 - Flush sequencing
Matthew Dillon [Tue, 20 Mar 2012 04:23:37 +0000 (21:23 -0700)]
hammer2 - Flush sequencing

* Add a flag HAMMER2_CHAIN_DIRTYBP to differentiate between clean and
  dirty buffers, separate from HAMMER2_CHAIN_MODIFIED1.  We needed a
  new flag because a buffer can be dirtied and then written out by the
  OS (becoming clean) before the chain hierarchy itself is flushed.

  This fixes an issue where a small percentage of buffers were being
  written out several times without any new changes.

* Clean up HAMMER2_CHAIN_IOFLUSH and implement to reduce double buffering
  overheads, at least for the buffer cache.  The VM backing store might
  still have double-buffered data.

  This reduces the load on the buffer management code in the kernel and
  helps avoid potential deadlocks.

* Unlock the inode when stalling in bwillwrite().  This solves a problem
  where a program stuck in flstik can also stall out the buffer daemons.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 20 Mar 2012 04:18:57 +0000 (21:18 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix buffer cache deadlock due to multiple buffer cache sizes
Matthew Dillon [Tue, 20 Mar 2012 04:14:13 +0000 (21:14 -0700)]
kernel - Fix buffer cache deadlock due to multiple buffer cache sizes

* The buffer daemon was triggering off of dirtybufspace[hw], comparing
  it against bufspace.  However, bufspace is an aggregation of the
  total buffer kva reserved, not the dirty count based on b_bufsize.

* Add dirtykvasize to track the dirty space in terms of the kva reservation
  and change the buffer daemons to use that instead.

* systat and other displays still use the bufsize, which is a more
  accurate indicator for human consumption.

12 years agohammer2 - Implement variable-sized indirect blocks, clustered reads
Matthew Dillon [Tue, 20 Mar 2012 01:34:45 +0000 (18:34 -0700)]
hammer2 - Implement variable-sized indirect blocks, clustered reads

* Implement 4K indirect blocks as well as 64K indirect blocks

* Do not flush the chains for VOP_FSYNC() calls issued from 'sync' or
  from the syncer, only flush the chains when called from fsync().

  This solves a fairly nasty repeated copy-on-write ops on the same block
  in the topology.

* Issue appropriate cluster_read() calls instead of bread().

* Implement forward-looking bmap across multiple blocks instead of just one.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 20 Mar 2012 00:56:18 +0000 (17:56 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix clustered read bug (2)
Matthew Dillon [Tue, 20 Mar 2012 00:52:48 +0000 (17:52 -0700)]
kernel - Fix clustered read bug (2)

* Fix an edge case that can cause hammer1 to panic.  The read-ahead
  must not go past the filesize limit.  HAMMER1 uses this to
  implement two different logical buffer sizes for regular files.

12 years agoMerge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository...
Matthew Dillon [Tue, 20 Mar 2012 00:12:31 +0000 (17:12 -0700)]
Merge branches 'hammer2' and 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into hammer2

12 years agokernel - Fix clustered read bug
Matthew Dillon [Tue, 20 Mar 2012 00:11:09 +0000 (17:11 -0700)]
kernel - Fix clustered read bug

* cluster_read() was improperly reducing the 'maxra' variable when
  handling the read-ahead mark, creating a degenerate situation which
  would cause only the first few burst reads from a file to cluster,
  and the remainder to read-ahead but not cluster.