Use SYSREF to reference count struct vnode. v_usecount is now
v_sysref(.refcnt). v_holdcnt is now v_auxrefs. SYSREF's termination state
(using a negative reference count from -0x40000000+) now places the vnode in
a VCACHED or VFREE state and deactivates it. The vnode is now assigned a
64 bit unique id via SYSREF.
vhold() (which manipulates v_auxrefs) no longer reactivates a vnode and
is explicitly used only to track references from auxillary structures
and references to prevent premature destruction of the vnode. vdrop()
will now only move a vnode from VCACHED to VFREE on the 1->0 transition
of v_auxrefs if the vnode is in a termination state.
vref() will now panic if used on a vnode in a termination state. vget()
must now be used to explicitly reactivate a vnode. These requirements
existed before but are now explicitly asserted.
vlrureclaim() and allocvnode() should now interact a bit better. In
particular, vlrureclaim() will do a better job of finding vnodes to flush
and transition from VCACHED to VFREE, and allocvnode() will do a better
job finding vnodes to reuse without getting blocked by a flush.
allocvnode now uses a real VX lock to sequence vnodes into VRECLAIMED. All
vnode special state processing now uses a VX lock.
Vnodes are now able to be slowly returned to the memory pool when
kern.maxvnodes is reduced at run time.
Various initialization elements have been moved to CTOR/DTOR and are
no longer in the critical path, improving performance. However, since
SYSREF uses atomic_cmpset_int() (aka cmpxchgl), which reduces performance
somewhat, overall performance tends to be about the same.
40 files changed: