Home | History | Annotate | only in /src/sys/fs/union
History log of /src/sys/fs/union
RevisionDateAuthorComments
 1.1 16-Mar-2003  jdolecek move union filesystem code from sys/miscfs/union to sys/fs/union
 1.3 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.2 02-Mar-2010  pooka branches: 1.2.20;
Don't generate unused fs_thefs.h headers.
 1.1 16-Mar-2003  jdolecek branches: 1.1.104; 1.1.126;
move union filesystem code from sys/miscfs/union to sys/fs/union
 1.1.126.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.104.1 11-Mar-2010  yamt sync with head
 1.2.20.1 03-Dec-2017  jdolecek update from HEAD
 1.30 18-Aug-2020  hannken Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.29 17-Jul-2017  hannken branches: 1.29.2; 1.29.10;
Make union_newlower() ans union_newupper() local to union_subr.c,
expand and remove union_updatevp() and take care to transfer the
vnode lock from the union vnode to its new upper vnode without
breaking the fstrans state.

Add assertions that un_lowervp and un_uppervp never change from
non-NULL to non-NULL.
 1.28 16-Feb-2015  hannken branches: 1.28.10;
Change union to vcache. Use address of the union node as key.

It would be better to use (uppervp, lowervp) as key, but either
may be NULL and may change any time.
 1.27 16-Feb-2015  hannken Add reference count to union node.
 1.26 14-Feb-2014  hannken branches: 1.26.6;
Member un_flags is unused now -- remove.
 1.25 13-Feb-2014  hannken Get rid of UN_KLOCK to keep a lock on vput(). It is not really needed
and makes the source difficult to read. Always hold references to the
union nodes until the operation is done.
 1.24 05-Nov-2012  dholland branches: 1.24.2;
Disentangle the namecache from the internals of namei.

- Move the namecache's hash computation to inside the namecache code,
instead of being spread out all over the place. Remove cn_hash from
struct componentname and delete all uses of it.

- It is no longer necessary (if it ever was) for cache_lookup and
cache_lookup_raw to clear MAKEENTRY from cnp->cn_flags for the cases
that cache_enter already checks for.

- Rearrange the interface of cache_lookup (and cache_lookup_raw) to
make it somewhat simpler, to exclude certain nonexistent error
conditions, and (most importantly) to make it not require write access
to cnp->cn_flags.

This change requires a kernel bump.
 1.23 23-Nov-2011  hannken branches: 1.23.8;
Use hashinit() / hashdone() to create the union node hash list.

Cleanup the hash lookup in union_allocvp().

Needs more work as there is still a possible deadlock between
union_allocvp() and vclean().
 1.22 21-Nov-2011  hannken Replace flag based union node locking with generic vnode lock, support
shared and nowait locks and protect un_uppervp and un_*sz with mutex.

Mark file system MPSAFE.
 1.21 23-Aug-2011  hannken branches: 1.21.2;
Stop abusing relookup() to prepare the creation of new nodes
in the upper layer.
Replace union_relookup() with union_do_lookup() that prepares
a component, calls VOP_LOOKUP() and does the EEXIST test.
 1.20 12-Aug-2011  hannken Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.

No functional changes intended.
 1.19 07-Aug-2011  hannken Change union rmdir semantics to fail directory removal for
non-empty directories like all other file systems do.

Change test accordingly.
 1.18 28-Jun-2008  rumble Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.17 02-Jan-2008  ad branches: 1.17.6; 1.17.10; 1.17.12; 1.17.14;
Merge vmlocking2 to head.
 1.16 08-Dec-2007  pooka branches: 1.16.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.15 14-May-2006  elad branches: 1.15.32; 1.15.34; 1.15.40; 1.15.44;
integrate kauth.
 1.14 27-Dec-2005  chs branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
changes for making DIAGNOSTIC not change the kernel ABI:
- for structure fields that are conditionally present,
make those fields always present.
- for functions which are conditionally inline, make them never inline.
- remove some other functions which are conditionally defined but
don't actually do anything anymore.
- make a lock-debugging function conditional on only LOCKDEBUG.

as discussed on tech-kern some time back.
 1.13 11-Dec-2005  christos merge ktrace-lwp.
 1.12 03-Dec-2005  christos - protect userland exported files against multiple inclusion.
- make sure that kernel only files don't compile in userland using #error
- XXX: some kernel only files still get installed.
- XXX: some files used in userland, don't get installed.
 1.11 30-Aug-2005  xtraeme Remove __P()
 1.10 20-May-2004  atatat branches: 1.10.12;
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.9 03-Oct-2003  yamt branches: 1.9.2;
terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 29-Jun-2003  fvdl branches: 1.7.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.6 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.5 29-Jun-2003  thorpej Fix problems with Darren's ktrace/lwp changes.
 1.4 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.3 17-Mar-2003  jdolecek no need to export union_vfsops here
 1.2 17-Mar-2003  jdolecek make it possible for UNION fs to be loaded via LKM - instead of
having some #ifdef UNION code in vfs_vnops.c, introduce variable
'vn_union_readdir_hook' which is set to address of appropriate
vn_readdir() hook by union filesystem when it's loaded & mounted
 1.1 16-Mar-2003  jdolecek move union filesystem code from sys/miscfs/union to sys/fs/union
 1.7.2.7 11-Dec-2005  christos Sync with head.
 1.7.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 03-Jul-2003  wrstuden LWP-ify union fs.

Note: These changes suffer from the same cnp->cn_lwp issue noted for
ufs. They will need to get fixed at the same time as ufs. The fix is to
add struct lwp * as a parameter to some VOPs.

Note also that most of the cn_lwp references used to be cn_proc references,
so if cnp->cn_lwp is bad to use, unionfs's been naughty for quite some
time.
 1.9.2.1 23-May-2004  tron Pull up revision 1.10 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.10.12.2 21-Jan-2008  yamt sync with head
 1.10.12.1 21-Jun-2006  yamt sync with head.
 1.14.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.10.2 06-May-2006  christos Move _KERNEL decl lower. Some KNF.
 1.14.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.14.8.1 24-May-2006  yamt sync with head.
 1.14.6.1 01-Jun-2006  kardel Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.44.2 26-Dec-2007  ad Sync with head.
 1.15.44.1 10-Dec-2007  ad - Don't drain the vnode lock in vclean(); reference counting and XLOCK
should be enough.
- LK_SETRECURSE is gone.
 1.15.40.1 18-Feb-2008  mjf Sync with HEAD.
 1.15.34.1 09-Jan-2008  matt sync with HEAD
 1.15.32.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.14.1 03-Jul-2008  simonb Sync with head.
 1.17.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.10.1 04-May-2009  yamt sync with head.
 1.17.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.21.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.21.2.1 17-Apr-2012  yamt sync with head
 1.23.8.3 03-Dec-2017  jdolecek update from HEAD
 1.23.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.24.2.1 18-May-2014  rmind sync with head
 1.26.6.2 28-Aug-2017  skrll Sync with HEAD
 1.26.6.1 06-Apr-2015  skrll Sync with HEAD
 1.28.10.1 25-Jul-2017  snj Pull up following revision(s) (requested by hannken in ticket #145):
sys/fs/union/union.h: revision 1.29
sys/fs/union/union_subr.c: revision 1.76
Make union_newlower() ans union_newupper() local to union_subr.c,
expand and remove union_updatevp() and take care to transfer the
vnode lock from the union vnode to its new upper vnode without
breaking the fstrans state.
Add assertions that un_lowervp and un_uppervp never change from
non-NULL to non-NULL.
 1.29.10.1 27-Aug-2020  martin Pull up following revision(s) (requested by hannken in ticket #1062):

sys/fs/union/union.h: revision 1.30
sys/fs/union/union_subr.c: revision 1.79
sys/fs/union/union_vnops.c: revision 1.74

Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.29.2.2 17-Jul-2017  hannken 3095096
 1.29.2.1 17-Jul-2017  hannken file union.h was added on branch perseant-stdc-iso10646 on 2017-07-17 09:22:37 +0000
 1.82 18-Jul-2022  thorpej Make kqueue event status for vnodes shareable, and for stacked file systems
like nullfs, make the upper vnode share that status with the lower vnode.

And, lo, NetBSD 9.99.99.

Fixes PR kern/56713.
 1.81 19-Mar-2022  hannken Remove now unused VV_LOCKSWORK, all file systems support locking.

Remove unused predicates vn_locked() and vn_anylocked().

Welcome to 9.99.95
 1.80 19-Mar-2022  hannken As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check()
from union_lock() is no longer needed.

Adapt union_lock() to the recent addition of upgrade or downgrade.

VV_LOCKSWORK now.
 1.79 18-Aug-2020  hannken Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.78 23-Feb-2020  ad UVM locking changes, proposed on tech-kern:

- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart. v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap. Others to follow later.
 1.77 28-Jan-2018  christos branches: 1.77.4; 1.77.8; 1.77.10;
CID-1428639: make sure we always initialiaze hash, because if ultimately
the file is not found and we end up looping we need them.
 1.76 17-Jul-2017  hannken branches: 1.76.2;
Make union_newlower() ans union_newupper() local to union_subr.c,
expand and remove union_updatevp() and take care to transfer the
vnode lock from the union vnode to its new upper vnode without
breaking the fstrans state.

Add assertions that un_lowervp and un_uppervp never change from
non-NULL to non-NULL.
 1.75 01-Jun-2017  chs branches: 1.75.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.74 20-Aug-2016  hannken Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.73 20-Apr-2015  riastradh Cull unused vnode v_iflags: VI_LAYER, VI_LOCKSHARE.
 1.72 20-Apr-2015  riastradh Make vget always return vnode unlocked.

Convert callers who want locks to use vn_lock afterward.

Add extra argument so the compiler will report stragglers.
 1.71 24-Feb-2015  hannken A union node may be reactivated while it is being reclaimed so
change union_freevp() to detach the vnode from the union node
by clearing the vnode backpointer and the lower node sizes.
 1.70 16-Feb-2015  hannken Change union to vcache. Use address of the union node as key.

It would be better to use (uppervp, lowervp) as key, but either
may be NULL and may change any time.
 1.69 16-Feb-2015  hannken Add reference count to union node.
 1.68 16-Feb-2015  hannken Remove a superfluous vref(), VOP_CREATE() was changed to
keep dvp referenced and locked some time ago.
 1.67 05-Sep-2014  matt branches: 1.67.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.66 17-Jun-2014  hannken branches: 1.66.2;
Unlock directory vnode after VOP_CREATE.
 1.65 17-May-2014  dholland Also set or assert that *vpp is null before calling VOP_MKDIR.
 1.64 17-May-2014  dholland Set *vpp to NULL before calling VOP_CREATE. This always happens when
calling using nameidata, and if not something went wrong, so we'd like
to be able to assert about it.
 1.63 16-Feb-2014  hannken branches: 1.63.2;
Change union_allocvp() to take an unlocked uppervp and to return the
union node unlocked. Another VI_XLOCK hack is gone.
 1.62 14-Feb-2014  hannken Member un_flags is unused now -- remove.
 1.61 13-Feb-2014  hannken Get rid of UN_KLOCK to keep a lock on vput(). It is not really needed
and makes the source difficult to read. Always hold references to the
union nodes until the operation is done.
 1.60 07-Feb-2014  hannken Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
 1.59 23-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
 1.58 17-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
 1.57 17-Oct-2013  christos remove unused code
 1.56 05-Nov-2012  dholland branches: 1.56.2;
Disentangle the namecache from the internals of namei.

- Move the namecache's hash computation to inside the namecache code,
instead of being spread out all over the place. Remove cn_hash from
struct componentname and delete all uses of it.

- It is no longer necessary (if it ever was) for cache_lookup and
cache_lookup_raw to clear MAKEENTRY from cnp->cn_flags for the cases
that cache_enter already checks for.

- Rearrange the interface of cache_lookup (and cache_lookup_raw) to
make it somewhat simpler, to exclude certain nonexistent error
conditions, and (most importantly) to make it not require write access
to cnp->cn_flags.

This change requires a kernel bump.
 1.55 25-Nov-2011  hannken branches: 1.55.8;
When union_allocvp() finds a node being cleaned out and the caller holds
a lock, ignore the node and continue. To allow the cleaning to succeed
the current threadmust make progress.
For a brief time the cache may contain more than one vnode referring to
a lower node.

Don't unlock the hash mutex if getnewvnode fails -- we don't hold it.
 1.54 23-Nov-2011  hannken Use hashinit() / hashdone() to create the union node hash list.

Cleanup the hash lookup in union_allocvp().

Needs more work as there is still a possible deadlock between
union_allocvp() and vclean().
 1.53 21-Nov-2011  hannken Replace flag based union node locking with generic vnode lock, support
shared and nowait locks and protect un_uppervp and un_*sz with mutex.

Mark file system MPSAFE.
 1.52 14-Nov-2011  hannken Remove a needless vnode lock/unlock dance. This is a leftover from the
removal of VOP_LEASE().

Function union_removed_upper() always works on unlocked upper vnodes so
remove the test-and-unlock and add an assertion.
 1.51 18-Oct-2011  hannken branches: 1.51.2;
VOP_GETATTR() needs a shared lock at least.
 1.50 23-Aug-2011  hannken Stop abusing relookup() to prepare the creation of new nodes
in the upper layer.
Replace union_relookup() with union_do_lookup() that prepares
a component, calls VOP_LOOKUP() and does the EEXIST test.
 1.49 13-Aug-2011  hannken Use mutexes to protect the hash lists instead of tsleep/wakeup.
 1.48 12-Aug-2011  hannken Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.

No functional changes intended.
 1.47 12-Aug-2011  hannken When creating a union node representing a device initialize
the spec_node to make vrele() happy.
 1.46 10-Aug-2011  hannken Update the (shared) v_interlock if the upper node changes.
 1.45 10-Aug-2011  hannken Use LK_SHARED, it is sufficient for VOP_GETATTR() and VOP_READDIR().
 1.44 07-Aug-2011  hannken Change union rmdir semantics to fail directory removal for
non-empty directories like all other file systems do.

Change test accordingly.
 1.43 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.42 02-Jan-2011  dholland branches: 1.42.6;
Remove the special refcount behavior (adding an extra reference to the
parent dir) associated with SAVESTART in relookup().

Check all call sites to make sure that SAVESTART wasn't set while
calling relookup(); if it was, adjust the refcount behavior. Remove
related references to SAVESTART.

The only code that was reaching the extra ref was msdosfs_rename,
where the refcount behavior was already fairly broken and/or gross;
repair it.

Add a dummy 4th argument to relookup to make sure code that hasn't
been inspected won't compile. (This will go away next time the
relookup semantics change, which they will.)
 1.41 30-Nov-2010  dholland Abolish the SAVENAME and HASBUF flags. There is now always a buffer,
so the path in a struct componentname is now always valid during VOP
calls.
 1.40 30-Nov-2010  dholland Abolish struct componentname's cn_pnbuf. Use the path buffer in the
pathbuf object passed to namei as work space instead. (For now a pnbuf
pointer appears in struct nameidata, to support certain unclean things
that haven't been fixed yet, but it will be going away in the future.)

This removes the need for the SAVENAME and HASBUF namei flags.
 1.39 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.38 16-Jul-2010  hannken Always take the hash list lock before removing a node from the hash chain.

Release the hash list lock before calling getnewvnode() and check the
hash list again like other file systems do.

Take v_interlock before calling vget().
 1.37 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.36 06-Jun-2010  hannken Change layered file systems to always pass the locking VOP's down to the
leaf file system. Remove now unused member v_vnlock from struct vnode.
Welcome to 5.99.30

Discussed on tech-kern.
 1.35 08-Jan-2010  pooka branches: 1.35.2; 1.35.4;
The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase). Plenty of mix'n match upper/lowercase has creeped
into the tree since then. Nuke the macros and convert all callsites
to lowercase.

no functional change
 1.34 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.33 21-Mar-2008  ad branches: 1.33.4; 1.33.12;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.32 27-Feb-2008  matt Convert to ansi definitions from old-style definitons.
 1.31 25-Jan-2008  ad branches: 1.31.2; 1.31.6;
Remove VOP_LEASE. Discussed on tech-kern.
 1.30 08-Dec-2007  pooka Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.29 26-Nov-2007  pooka branches: 1.29.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.28 10-Oct-2007  ad branches: 1.28.4;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.27 23-Jul-2007  pooka branches: 1.27.4; 1.27.6; 1.27.8; 1.27.10;
Rearrange previous to make it work by other than chance.

noticed by xtraeme's gcc flags
 1.26 23-Jul-2007  pooka Set union vnode size when creating a vnode.

fixes kern/36679 by Geoff C. Wing
 1.25 07-Apr-2007  hannken branches: 1.25.4;
Remove calls to now obsolete vn_start_write() and vn_finished_write().
 1.24 04-Feb-2007  chs branches: 1.24.2; 1.24.6; 1.24.8;
more fixes for the new vnode locking scheme:
- don't use SAVESTART in calls to relookup() from unionfs,
just vref() the desired vnode when we need to.
- fix locking and refcounting in the unionfs EEXIST error cases.
- release any vnode locks before calling VFS_ROOT(), vfs_busy() is enough.
this allows us to simplify union_root() and fix PR 3006.
- union_lock() doesn't handle shared lock requests correctly,
so convert them to exclusive instead. fixes PR 34775.
- in relookup(), avoid reusing "dp" for different purposes,
the error handling wasn't right. (actually just get rid of dp.)
also, change relookup() to ignore LOCKLEAF and always return the
vnode locked since the callers already expect this.
 1.23 29-Jan-2007  hubertf Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.22 09-Dec-2006  chs a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
these now always return the parent vnode locked. namei() works as before.
lookup() and various other paths no longer acquire vnode locks in the
wrong order via vrele(). fixes PR 32535.
as a nice side effect, path lookup is also up to 25% faster.
- the above allows us to get rid of PDIRUNLOCK.
- also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
- remove an assumption in layer_node_find() that all file systems implement
a recursive VOP_LOCK() (unionfs doesn't).
- require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
fill in eopnotsupp() for file systems that don't support being exported
and remove the checks for NULL. (layerfs calls these without checking.)
- in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
adjust which vnode is locked. fixes PR 33374.
- apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
 1.21 16-Nov-2006  christos branches: 1.21.2;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 23-Jul-2006  ad branches: 1.19.4; 1.19.6;
Use the LWP cached credentials where sane.
 1.18 14-May-2006  elad integrate kauth.
 1.17 15-Apr-2006  christos Coverity CID 1001: Avoid NULL deref.
 1.16 01-Mar-2006  yamt branches: 1.16.2; 1.16.4; 1.16.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.15 11-Dec-2005  christos branches: 1.15.2; 1.15.4; 1.15.6;
merge ktrace-lwp.
 1.14 30-Aug-2005  xtraeme branches: 1.14.6;
Remove __P()
 1.13 29-May-2005  christos branches: 1.13.2;
- rename variables to avoid shadowing.
- add a few const.
 1.12 26-Feb-2005  perry nuke trailing whitespace
 1.11 17-Sep-2004  skrll branches: 1.11.4; 1.11.6;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.10 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.9 27-Apr-2004  jrf First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

- removed casts from unionfs, deadfs and fdesc
(there are more to hunt down still)
- changed vfs_quotactl args argumet from caddr_t to void *
- changed vfs_quotactl structures/callers to reflect the api change

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.
 1.8 15-Oct-2003  hannken Add the gating of system calls that cause modifications to the underlying
file system.
The function vfs_write_suspend stops all new write operations to a file
system, allows any file system modifying system calls already in progress
to complete, then sync's the file system to disk and returns. The
function vfs_write_resume allows the suspended write operations to
complete.

From FreeBSD with slight modifications.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 29-Jun-2003  fvdl branches: 1.6.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.5 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.4 29-Jun-2003  thorpej Fix problems with Darren's ktrace/lwp changes.
 1.3 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.2 17-Mar-2003  jdolecek make it possible for UNION fs to be loaded via LKM - instead of
having some #ifdef UNION code in vfs_vnops.c, introduce variable
'vn_union_readdir_hook' which is set to address of appropriate
vn_readdir() hook by union filesystem when it's loaded & mounted
 1.1 16-Mar-2003  jdolecek move union filesystem code from sys/miscfs/union to sys/fs/union
 1.6.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.6.2.2 03-Aug-2004  skrll Sync with HEAD
 1.6.2.1 03-Jul-2003  wrstuden LWP-ify union fs.

Note: These changes suffer from the same cnp->cn_lwp issue noted for
ufs. They will need to get fixed at the same time as ufs. The fix is to
add struct lwp * as a parameter to some VOPs.

Note also that most of the cn_lwp references used to be cn_proc references,
so if cnp->cn_lwp is bad to use, unionfs's been naughty for quite some
time.
 1.11.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.4.1 29-Apr-2005  kent sync with -current
 1.13.2.10 24-Mar-2008  yamt sync with head.
 1.13.2.9 17-Mar-2008  yamt sync with head.
 1.13.2.8 04-Feb-2008  yamt sync with head.
 1.13.2.7 21-Jan-2008  yamt sync with head
 1.13.2.6 07-Dec-2007  yamt sync with head
 1.13.2.5 27-Oct-2007  yamt sync with head.
 1.13.2.4 03-Sep-2007  yamt sync with head.
 1.13.2.3 26-Feb-2007  yamt sync with head.
 1.13.2.2 30-Dec-2006  yamt sync with head.
 1.13.2.1 21-Jun-2006  yamt sync with head.
 1.14.6.2 19-Nov-2005  yamt - finish reverting VOP_READ prototype changes.
- remove unused variables.
- fix typos.
some of them are pointed by Juan RP.
 1.14.6.1 15-Nov-2005  yamt - adapt to the new prototype of VOP_READ.
- adapt ext2fs and union.
 1.15.6.2 01-Jun-2006  kardel Sync with head.
 1.15.6.1 22-Apr-2006  simonb Sync with head.
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.15.2.1 18-Feb-2006  yamt adapt the rest of MI code.
 1.16.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.4.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.16.4.2 19-Apr-2006  elad sync with head.
 1.16.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.16.2.2 11-Aug-2006  yamt sync with head
 1.16.2.1 24-May-2006  yamt sync with head.
 1.19.6.2 10-Dec-2006  yamt sync with head.
 1.19.6.1 22-Oct-2006  yamt sync with head
 1.19.4.4 09-Feb-2007  ad Sync with HEAD.
 1.19.4.3 01-Feb-2007  ad Sync with head.
 1.19.4.2 12-Jan-2007  ad Sync with head.
 1.19.4.1 18-Nov-2006  ad Sync with head.
 1.21.2.1 17-Feb-2007  tron Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.24.8.1 11-Jul-2007  mjf Sync with head.
 1.24.6.3 20-Aug-2007  ad Sync with HEAD.
 1.24.6.2 17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.24.6.1 10-Apr-2007  ad Sync with head.
 1.24.2.1 15-Apr-2007  yamt sync with head.
 1.25.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.27.10.2 23-Jul-2007  pooka Rearrange previous to make it work by other than chance.

noticed by xtraeme's gcc flags
 1.27.10.1 23-Jul-2007  pooka file union_subr.c was added on branch matt-mips64 on 2007-07-23 08:52:48 +0000
 1.27.8.1 14-Oct-2007  yamt sync with head.
 1.27.6.3 23-Mar-2008  matt sync with HEAD
 1.27.6.2 09-Jan-2008  matt sync with HEAD
 1.27.6.1 06-Nov-2007  matt sync with HEAD
 1.27.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.27.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.27.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.28.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.28.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.28.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.29.2.1 26-Dec-2007  ad Sync with head.
 1.31.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.31.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.31.2.1 24-Mar-2008  keiichi sync with head.
 1.33.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.4.3 11-Aug-2010  yamt sync with head.
 1.33.4.2 11-Mar-2010  yamt sync with head
 1.33.4.1 04-May-2009  yamt sync with head.
 1.35.4.5 30-May-2011  rmind - Amend getnewvnode(9) to take the lock for sharing, not a vnode.
- Update tmpfs to perform vnode and UVM object lock sharing correctly.
 1.35.4.4 21-May-2011  rmind Finish v_interlock sharing bits for union/unionfs.
 1.35.4.3 19-May-2011  rmind Implement sharing of vnode_t::v_interlock amongst vnodes:
- Lock is shared amongst UVM objects using uvm_obj_setlock() or getnewvnode().
- Adjust vnode cache to handle unsharing, add VI_LOCKSHARE flag for that.
- Use sharing in tmpfs and layerfs for underlying object.
- Simplify locking in ubc_fault().
- Sprinkle some asserts.

Discussed with ad@.
 1.35.4.2 05-Mar-2011  rmind sync with head
 1.35.4.1 03-Jul-2010  rmind sync with head
 1.35.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.42.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.51.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.51.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.51.2.1 17-Apr-2012  yamt sync with head
 1.55.8.3 03-Dec-2017  jdolecek update from HEAD
 1.55.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.56.2.1 18-May-2014  rmind sync with head
 1.63.2.1 10-Aug-2014  tls Rebase.
 1.66.2.1 17-Feb-2015  martin Pull up following revision(s) (requested by hannken in ticket #529):
sys/fs/union/union_subr.c: revision 1.68
Remove a superfluous vref(), VOP_CREATE() was changed to
keep dvp referenced and locked some time ago.
 1.67.2.4 28-Aug-2017  skrll Sync with HEAD
 1.67.2.3 05-Oct-2016  skrll Sync with HEAD
 1.67.2.2 06-Jun-2015  skrll Sync with HEAD
 1.67.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.2.1 25-Jul-2017  snj Pull up following revision(s) (requested by hannken in ticket #145):
sys/fs/union/union.h: revision 1.29
sys/fs/union/union_subr.c: revision 1.76
Make union_newlower() ans union_newupper() local to union_subr.c,
expand and remove union_updatevp() and take care to transfer the
vnode lock from the union vnode to its new upper vnode without
breaking the fstrans state.
Add assertions that un_lowervp and un_uppervp never change from
non-NULL to non-NULL.
 1.76.2.2 17-Jul-2017  hannken 3095096
 1.76.2.1 17-Jul-2017  hannken file union_subr.c was added on branch perseant-stdc-iso10646 on 2017-07-17 09:22:37 +0000
 1.77.10.1 29-Feb-2020  ad Sync with head.
 1.77.8.1 27-Aug-2020  martin Pull up following revision(s) (requested by hannken in ticket #1062):

sys/fs/union/union.h: revision 1.30
sys/fs/union/union_subr.c: revision 1.79
sys/fs/union/union_vnops.c: revision 1.74

Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.77.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.88 18-May-2024  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.87 13-Feb-2023  hannken When mounting a union file system set its lower mount only on success.

Reported-by: syzbot+b81b69971581b4f4db00@syzkaller.appspotmail.com
 1.86 06-Feb-2023  hannken Set IMNT_MPSAFE only if all lower layers have it set.
 1.85 21-Nov-2022  hannken branches: 1.85.2;
When testing whiteout support on the underlying file system
union_mount() should not use a NULL componentname as not all
file systems can handle it.

Use static { LOOKUP, NOCRED } componentname instead.

Reported-by: syzbot+ecda308a1dd9652836d0@syzkaller.appspotmail.com
Reported-by: syzbot+9b687847ee5f43e94ca3@syzkaller.appspotmail.com
Reported-by: syzbot+9f9d1a841734f9f50de2@syzkaller.appspotmail.com
 1.84 04-Nov-2022  hannken Add a helper to set or clear lower mount and use it.
Always add a reference to the lower mount.

Ride 9.99.105
 1.83 12-Sep-2022  christos kmem_alloc -> kmem_zalloc, thanks Rin.
 1.82 11-Sep-2022  christos - avoid another credential leak on error from Chris J-D
(chris at accessvector dot net)
- KNF
- use kmem
 1.81 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.80 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.79 20-Feb-2019  hannken branches: 1.79.4; 1.79.6;
Set "mnt_lower" before the first file system operation on the new file system.
 1.78 01-Apr-2017  riastradh branches: 1.78.14;
KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.77 06-Mar-2017  hannken Add field "mnt_lower" to "struct mount" to track the file system
a layered file system is mounted on.

Welcome to 7.99.65
 1.76 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.75 23-Jul-2015  hannken branches: 1.75.2; 1.75.4;
union_unmount: use vfs_vnode_iterator to count attached vnodes.
 1.74 16-Feb-2015  hannken Change union to vcache. Use address of the union node as key.

It would be better to use (uppervp, lowervp) as key, but either
may be NULL and may change any time.
 1.73 18-Oct-2014  snj branches: 1.73.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.72 16-Apr-2014  maxv An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
 1.71 23-Mar-2014  hannken branches: 1.71.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.70 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.69 16-Feb-2014  hannken Change union_allocvp() to take an unlocked uppervp and to return the
union node unlocked. Another VI_XLOCK hack is gone.
 1.68 30-Apr-2012  rmind branches: 1.68.2; 1.68.4;
- Replace some malloc(9) uses with kmem(9).
- G/C M_IPMOPTS, M_IPMADDR and M_BWMETER.
 1.67 05-Dec-2011  hannken branches: 1.67.2; 1.67.6; 1.67.8;
The union file system is as stable as other layered file systems so
no longer print a warning to the console.

Gnats is waiting ...
 1.66 23-Nov-2011  hannken branches: 1.66.2;
Use hashinit() / hashdone() to create the union node hash list.

Cleanup the hash lookup in union_allocvp().

Needs more work as there is still a possible deadlock between
union_allocvp() and vclean().
 1.65 21-Nov-2011  hannken Replace flag based union node locking with generic vnode lock, support
shared and nowait locks and protect un_uppervp and un_*sz with mutex.

Mark file system MPSAFE.
 1.64 28-Aug-2011  hannken branches: 1.64.2;
Print the warning message on mount once.

Should fix PR #42795 (patch to make mounting union filesystems less obnoxious)
 1.63 05-Jul-2010  pooka union doesn't use layerfs (avoids panic in kernel bootstrap when
union is compiled in but none of the layer-using file systems are).
 1.62 30-Jun-2010  hannken The directory vnode must be locked before we call VOP_WHITEOUT().

Should fix PR #23986 "problem mounting directories".
 1.61 08-Jan-2010  pooka branches: 1.61.2; 1.61.4;
The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase). Plenty of mix'n match upper/lowercase has creeped
into the tree since then. Nuke the macros and convert all callsites
to lowercase.

no functional change
 1.60 29-Jun-2009  dholland Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.59 04-Apr-2009  ad Turn up the volume on the warning message a bit and note that unionfs can
corrupt the underlying file system. This is an old problem but is now
much easier to trigger because VFS has gone fully multithreaded.
 1.58 05-Dec-2008  ad branches: 1.58.4;
PR kern/40110: null, overlay and umap modules loading -> panic (layerfs symbols not there)

Add a layerfs module.
 1.57 28-Jun-2008  rumble branches: 1.57.2; 1.57.4; 1.57.6;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.56 18-May-2008  ad branches: 1.56.2;
Until these get fixed or replaced:

WARNING: the foo file system is experimental and may be unstable
 1.55 13-May-2008  simonb mnt_data is a pointer, set it to NULL not 0 when we're finished with it.
 1.54 10-May-2008  rumble Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

As a consequence, most of the file systems can now be loaded as new style
modules.

Quick sanity check by ad@.
 1.53 29-Apr-2008  ad branches: 1.53.2;
PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.
 1.52 27-Feb-2008  matt branches: 1.52.2; 1.52.4;
Convert to ansi definitions from old-style definitons.
 1.51 28-Jan-2008  dholland branches: 1.51.2; 1.51.6;
Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.
 1.50 08-Dec-2007  pooka Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.49 26-Nov-2007  pooka branches: 1.49.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.48 31-Jul-2007  pooka branches: 1.48.2; 1.48.4; 1.48.10; 1.48.12;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods
 1.47 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.46 17-Jul-2007  pooka branches: 1.46.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok
 1.45 12-Jul-2007  dsl Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.
 1.44 08-Apr-2007  hannken Remove now obsolete vn_start_write() and vn_finished_write() and
corresponding flags.

Revert softdep_trackbufs() to its state before vn_start_write() was added.

Remove from struct mount now unneeded flags IMNT_SUSPEND* and
members mnt_writeopcountupper, mnt_writeopcountlower and mnt_leaf.

Welcome to 4.99.17
 1.43 04-Feb-2007  chs branches: 1.43.2; 1.43.6; 1.43.8;
more fixes for the new vnode locking scheme:
- don't use SAVESTART in calls to relookup() from unionfs,
just vref() the desired vnode when we need to.
- fix locking and refcounting in the unionfs EEXIST error cases.
- release any vnode locks before calling VFS_ROOT(), vfs_busy() is enough.
this allows us to simplify union_root() and fix PR 3006.
- union_lock() doesn't handle shared lock requests correctly,
so convert them to exclusive instead. fixes PR 34775.
- in relookup(), avoid reusing "dp" for different purposes,
the error handling wasn't right. (actually just get rid of dp.)
also, change relookup() to ignore LOCKLEAF and always return the
vnode locked since the callers already expect this.
 1.42 19-Jan-2007  hannken New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).
 1.41 09-Dec-2006  chs a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
these now always return the parent vnode locked. namei() works as before.
lookup() and various other paths no longer acquire vnode locks in the
wrong order via vrele(). fixes PR 32535.
as a nice side effect, path lookup is also up to 25% faster.
- the above allows us to get rid of PDIRUNLOCK.
- also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
- remove an assumption in layer_node_find() that all file systems implement
a recursive VOP_LOCK() (unionfs doesn't).
- require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
fill in eopnotsupp() for file systems that don't support being exported
and remove the checks for NULL. (layerfs calls these without checking.)
- in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
adjust which vnode is locked. fixes PR 33374.
- apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
 1.40 16-Nov-2006  christos branches: 1.40.2;
__unused removal on arguments; approved by core.
 1.39 20-Oct-2006  reinoud Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

An extra benefit is the removal of the ugly hack from the Berkly days on
LFS.

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.
 1.38 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.37 03-Sep-2006  christos branches: 1.37.2; 1.37.4;
add missing initializers
 1.36 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.35 14-May-2006  elad integrate kauth.
 1.34 14-Apr-2006  christos Coverity CID 715: Remove dead code.
 1.33 20-Mar-2006  christos PR/32986: Kouichirou Hiratsuka: Don't proceed with unmounting the filesystem
if vflush failed. Thank to Jeff Ito for adopting a similar fix from FreeBSD.
 1.32 05-Jan-2006  wrstuden branches: 1.32.2; 1.32.4; 1.32.6; 1.32.8; 1.32.10;
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.

This addresses PR: kern/31382
 1.31 11-Dec-2005  christos branches: 1.31.2;
merge ktrace-lwp.
 1.30 23-Sep-2005  jmmv Apply the NFS exports list rototill patch:

- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
 1.29 30-Aug-2005  xtraeme Remove __P()
 1.28 24-Aug-2005  nakayama statvfs(2) returns bogus result from union mounted file systems with
`-r' option, since it uses uninitialized buffer in the case of no
lower-layer file system.

So, add M_ZERO to malloc(9) flags to initialize the buffer.
 1.27 29-May-2005  christos branches: 1.27.2;
- rename variables to avoid shadowing.
- add a few const.
 1.26 29-Mar-2005  thorpej - Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].
 1.25 26-Feb-2005  perry branches: 1.25.2;
nuke trailing whitespace
 1.24 02-Jan-2005  thorpej branches: 1.24.2; 1.24.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.23 01-Jul-2004  hannken Keep a pointer to the leaf mount. Needed for write gating where a
file system gets suspended and has layered mounts above it.

Welcome to 2.0G

Reviewed by: Bill Studenmund <wrstuden@netbsd.org>
 1.22 31-May-2004  wrstuden Revert last two changes. Since union vnode private data do not follow
layerfs guidelines, whenever layerfs_snapshot() does something, it
won't be correct for unionfs.
 1.21 30-May-2004  tron Include "miscfs/genfs/layer_extern.h" to get prototype for
layerfs_snapshot().
 1.20 29-May-2004  wrstuden unionfs can use layerfs_snapshot() too.
 1.19 25-May-2004  hannken Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
Snapshots may not be opened for writing and the attributes are read-only.
Use the mtime as the time this snapshot was taken.
Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
 1.18 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.17 24-May-2004  christos Can't do the trick with using sbp as temporary storage; allocate memory
instead.
 1.16 22-May-2004  christos declare the correct variable; thanks Juan RP.
 1.15 22-May-2004  christos simplify stats taking and avoid the extra copy on the stack.
 1.14 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.13 27-Apr-2004  jrf First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

- removed casts from unionfs, deadfs and fdesc
(there are more to hunt down still)
- changed vfs_quotactl args argumet from caddr_t to void *
- changed vfs_quotactl structures/callers to reflect the api change

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.
 1.12 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.11 24-Mar-2004  atatat branches: 1.11.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.10 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 29-Jun-2003  fvdl branches: 1.8.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.6 29-Jun-2003  thorpej Fix problems with Darren's ktrace/lwp changes.
 1.5 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.4 16-Apr-2003  christos PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.
 1.3 17-Mar-2003  jdolecek add comment for one NULL union_vfsops member
 1.2 17-Mar-2003  jdolecek make it possible for UNION fs to be loaded via LKM - instead of
having some #ifdef UNION code in vfs_vnops.c, introduce variable
'vn_union_readdir_hook' which is set to address of appropriate
vn_readdir() hook by union filesystem when it's loaded & mounted
 1.1 16-Mar-2003  jdolecek move union filesystem code from sys/miscfs/union to sys/fs/union
 1.8.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.8 01-Apr-2005  skrll Sync with HEAD.
 1.8.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.8.2.2 03-Aug-2004  skrll Sync with HEAD
 1.8.2.1 03-Jul-2003  wrstuden LWP-ify union fs.

Note: These changes suffer from the same cnp->cn_lwp issue noted for
ufs. They will need to get fixed at the same time as ufs. The fix is to
add struct lwp * as a parameter to some VOPs.

Note also that most of the cn_lwp references used to be cn_proc references,
so if cnp->cn_lwp is bad to use, unionfs's been naughty for quite some
time.
 1.11.2.2 06-Jan-2006  riz Pull up following revision(s) (requested by wrstuden in ticket #10213):
sys/fs/union/union_vfsops.c: revision 1.32 via patch
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.
This addresses PR: kern/31382
 1.11.2.1 29-May-2004  tron branches: 1.11.2.1.2; 1.11.2.1.4;
Pull up revision 1.18 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.11.2.1.4.1 06-Jan-2006  riz Pull up following revision(s) (requested by wrstuden in ticket #10213):
sys/fs/union/union_vfsops.c: revision 1.32 via patch
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.
This addresses PR: kern/31382
 1.11.2.1.2.1 06-Jan-2006  riz Pull up following revision(s) (requested by wrstuden in ticket #10213):
sys/fs/union/union_vfsops.c: revision 1.32 via patch
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.
This addresses PR: kern/31382
 1.24.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.24.2.1 29-Apr-2005  kent sync with -current
 1.25.2.2 08-Jan-2006  riz Pull up following revision(s) (requested by wrstuden in ticket #1091):
sys/fs/union/union_vfsops.c: revision 1.32
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.
This addresses PR: kern/31382
 1.25.2.1 28-Aug-2005  tron branches: 1.25.2.1.2;
Pull up following revision(s) (requested by nakayama in ticket #708):
sys/fs/union/union_vfsops.c: revision 1.28
statvfs(2) returns bogus result from union mounted file systems with
`-r' option, since it uses uninitialized buffer in the case of no
lower-layer file system.
So, add M_ZERO to malloc(9) flags to initialize the buffer.
 1.25.2.1.2.1 08-Jan-2006  riz Pull up following revision(s) (requested by wrstuden in ticket #1091):
sys/fs/union/union_vfsops.c: revision 1.32
Change union_unmount() to not play with the fs root vnode explicitly.
Let it get recycled along with all of the others. This is important
as if the root vnode has already been reclaimed, then we get a panic
when we try to vget it.
This addresses PR: kern/31382
 1.27.2.8 17-Mar-2008  yamt sync with head.
 1.27.2.7 04-Feb-2008  yamt sync with head.
 1.27.2.6 21-Jan-2008  yamt sync with head
 1.27.2.5 07-Dec-2007  yamt sync with head
 1.27.2.4 03-Sep-2007  yamt sync with head.
 1.27.2.3 26-Feb-2007  yamt sync with head.
 1.27.2.2 30-Dec-2006  yamt sync with head.
 1.27.2.1 21-Jun-2006  yamt sync with head.
 1.31.2.1 15-Jan-2006  yamt sync with head.
 1.32.10.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.32.10.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.32.8.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.32.8.2 19-Apr-2006  elad sync with head.
 1.32.8.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.32.6.4 14-Sep-2006  yamt sync with head.
 1.32.6.3 11-Aug-2006  yamt sync with head
 1.32.6.2 24-May-2006  yamt sync with head.
 1.32.6.1 01-Apr-2006  yamt sync with head.
 1.32.4.2 01-Jun-2006  kardel Sync with head.
 1.32.4.1 22-Apr-2006  simonb Sync with head.
 1.32.2.1 09-Sep-2006  rpaulo sync with head
 1.37.4.2 10-Dec-2006  yamt sync with head.
 1.37.4.1 22-Oct-2006  yamt sync with head
 1.37.2.4 09-Feb-2007  ad Sync with HEAD.
 1.37.2.3 01-Feb-2007  ad Sync with head.
 1.37.2.2 12-Jan-2007  ad Sync with head.
 1.37.2.1 18-Nov-2006  ad Sync with head.
 1.40.2.1 17-Feb-2007  tron Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.43.8.1 11-Jul-2007  mjf Sync with head.
 1.43.6.3 20-Aug-2007  ad Sync with HEAD.
 1.43.6.2 15-Jul-2007  ad Sync with head.
 1.43.6.1 10-Apr-2007  ad Sync with head.
 1.43.2.1 15-Apr-2007  yamt sync with head.
 1.46.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.48.12.2 31-Jul-2007  pooka * nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods
 1.48.12.1 31-Jul-2007  pooka file union_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:20 +0000
 1.48.10.3 18-Feb-2008  mjf Sync with HEAD.
 1.48.10.2 27-Dec-2007  mjf Sync with HEAD.
 1.48.10.1 08-Dec-2007  mjf Sync with HEAD.
 1.48.4.2 23-Mar-2008  matt sync with HEAD
 1.48.4.1 09-Jan-2008  matt sync with HEAD
 1.48.2.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.48.2.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.49.2.1 26-Dec-2007  ad Sync with head.
 1.51.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.51.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.51.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.51.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.51.2.1 24-Mar-2008  keiichi sync with head.
 1.52.4.5 11-Aug-2010  yamt sync with head.
 1.52.4.4 11-Mar-2010  yamt sync with head
 1.52.4.3 18-Jul-2009  yamt sync with head.
 1.52.4.2 04-May-2009  yamt sync with head.
 1.52.4.1 16-May-2008  yamt sync with head.
 1.52.2.2 04-Jun-2008  yamt sync with head
 1.52.2.1 18-May-2008  yamt sync with head.
 1.53.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.53.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.56.2.1 03-Jul-2008  simonb Sync with head.
 1.57.6.3 25-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.57.6.2 17-Sep-2011  bouyer branches: 1.57.6.2.2;
Pull up following revision(s) (requested by hannken in ticket #1667):
sys/fs/union/union_vfsops.c: revision 1.64
Print the warning message on mount once.
=20
Should fix PR #42795 (patch to make mounting union filesystems less =
obnoxious)
=20
=20
 1.57.6.1 04-Apr-2009  snj branches: 1.57.6.1.6;
Pull up following revision(s) (requested by ad in ticket #663):
sys/fs/union/union_vfsops.c: revision 1.59
Turn up the volume on the warning message a bit and note that unionfs can
corrupt the underlying file system. This is an old problem but is now
much easier to trigger because VFS has gone fully multithreaded.
 1.57.6.2.2.1 28-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.57.6.1.6.1 28-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.57.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.57.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.57.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.58.4.2 23-Jul-2009  jym Sync with HEAD.
 1.58.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.61.4.2 05-Mar-2011  rmind sync with head
 1.61.4.1 03-Jul-2010  rmind sync with head
 1.61.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.64.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.64.2.2 23-May-2012  yamt sync with head.
 1.64.2.1 17-Apr-2012  yamt sync with head
 1.66.2.2 02-Jun-2012  mrg sync to latest -current.
 1.66.2.1 18-Feb-2012  mrg merge to -current.
 1.67.8.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.67.6.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.67.2.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.68.4.1 18-May-2014  rmind sync with head
 1.68.2.2 03-Dec-2017  jdolecek update from HEAD
 1.68.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.2.1 10-Aug-2014  tls Rebase.
 1.73.2.3 28-Aug-2017  skrll Sync with HEAD
 1.73.2.2 22-Sep-2015  skrll Sync with HEAD
 1.73.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.75.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.75.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.78.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.78.14.1 10-Jun-2019  christos Sync with HEAD
 1.79.6.1 17-Jan-2020  ad Sync with head.
 1.79.4.1 06-Feb-2023  martin Pull up following revision(s) (requested by hannken in ticket #1587):

sys/fs/union/union_vfsops.c: revision 1.86
sys/miscfs/nullfs/null_vfsops.c: revision 1.101 (via patch)

Set IMNT_MPSAFE only if all lower layers have it set.
 1.85.2.2 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #873):

sys/fs/union/union_vfsops.c: revision 1.87

When mounting a union file system set its lower mount only on success.
 1.85.2.1 06-Feb-2023  martin Pull up following revision(s) (requested by hannken in ticket #68):

sys/fs/union/union_vfsops.c: revision 1.86
sys/miscfs/nullfs/null_vfsops.c: revision 1.101

Set IMNT_MPSAFE only if all lower layers have it set.
 1.84 02-Sep-2025  dholland onionfs: Fix deadlock in link

Don't relookup the destination name with the source vnode locked.
This is both an ordering inversion and can lead to finding and locking
another reference to the same vnode if another process does the same
link operation.

See tech-kern posting of 20250902 for further analysis.
 1.83 19-Mar-2022  hannken As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check()
from union_lock() is no longer needed.

Adapt union_lock() to the recent addition of upgrade or downgrade.

VV_LOCKSWORK now.
 1.82 10-Dec-2021  andvar s/unaccessible/inaccessible/
 1.81 10-Dec-2021  hannken Fix previous, don't copy up if the underlying node is unreadable.
 1.80 05-Dec-2021  hannken In union_access() copy up regular files before checking permissions.

Unionfs is meant to provide a writable layer above a read-only layer
and should not fail here just because the lower layer is mounted
read-only.
 1.79 20-Oct-2021  thorpej Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
forcing each individual file system to deal with it (except VOP_RENAME(),
because VOP_RENAME() is a mess and we currently have 2 different ways
of handling it; at least it's reasonably well-centralized in the "new"
way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
to avoid doing work for events no one cares about (avoiding, e.g.
taking locks and traversing the klist to send a NOTE_WRITE when
someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
to be invoked before and after vop_pre() and vop_post(), respectively.
Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
vop_*_args structures. These context fields are used to convey information
between the file system VOP function and the VOP wrapper, but do not
occupy an argument slot in the VOP_*() call itself. These context fields
are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
back the resulting link count of the target vnode. Return this in tmpfs,
udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.
 1.78 04-Jul-2021  hannken Fix union_parsepath(), either the upper or the lower dvp may be NULL.
 1.77 29-Jun-2021  dholland Now remove cn_consume from struct componentname.

This change requires a kernel bump.

Note though that I'm not going to version the VOP_LOOKUP args
structure (or any other args structure) as code that doesn't touch
cn_consume doesn't need attention and code that does will fail on it
without further intervention.
 1.76 29-Jun-2021  dholland Onionfs needs to know about parsepath too, in case it has one of the
other cases underneath it.

The solution here is not really very good (take the longer
path-to-consume if they're different) but it will serve for the cases
that exist.

(If we were to add a fs that really uses different naming semantics,
we'd have to take additional steps; probably it doesn't make sense to
allow unionfs to union such a thing with a normal fs and attempting it
should fail at mount time.)

Update fs/unionfs as well to avoid increasing the current set of
compile failures there. Though maybe it's time to just remove
fs/unionfs.
 1.75 29-Jun-2021  dholland - Add a new vnode op: VOP_PARSEPATH.
- Move namei_getcomponent to genfs_vnops.c and call it genfs_parsepath.
- Add a parsepath entry to every vnode ops table.

VOP_PARSEPATH takes a directory vnode to be searched and a complete
following path and chooses how much of that path to consume. To begin
with, all parsepath calls are genfs_parsepath, which locates the first
'/' as always.

Note that the call doesn't take the whole struct componentname, only
the string. The other bits of struct componentname should not be
needed and there's no reason to cause potential complications by
exposing them.
 1.74 18-Aug-2020  hannken branches: 1.74.6;
Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.73 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.72 23-Feb-2020  ad UVM locking changes, proposed on tech-kern:

- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart. v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap. Others to follow later.
 1.71 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.70 26-May-2017  riastradh branches: 1.70.10; 1.70.14; 1.70.16;
Make VOP_RECLAIM do the last unlock of the vnode.

VOP_RECLAIM naturally has exclusive access to the vnode, so having it
locked on entry is not strictly necessary -- but it means if there
are any final operations that must be done on the vnode, such as
ffs_update, requiring exclusive access to it, we can now kassert that
the vnode is locked in those operations.

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.
 1.69 24-May-2017  hannken Use VCALL() to lock or unlock the lower node.
 1.68 07-May-2017  hannken Move v_writecount adjustment from revoke to reclaim.
 1.67 26-Apr-2017  riastradh branches: 1.67.2;
Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.

No change to vp -- the plan is to replace the node by the
componentname in the vop parameters, and let all directory vops do
lookups internally.

Proposed on tech-kern with no objections:
https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html
 1.66 17-Apr-2017  hannken Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.65 11-Apr-2017  riastradh Make VOP_INACTIVE preserve vnode lock on return.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2017/04/01/msg021751.html

Ride 7.99.68, a bumpy bus of incremental vfs improvements!
 1.64 06-Mar-2017  hannken Handle v_writecount from union_open(), union_close() and union_revoke()
so lower file system vnodes get marked as open for writing.
 1.63 20-Apr-2015  riastradh branches: 1.63.2; 1.63.4;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.62 25-Jul-2014  dholland branches: 1.62.4;
Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.
 1.61 17-May-2014  dholland Also set or assert that *vpp is null before calling VOP_MKDIR.
 1.60 17-May-2014  dholland Set *vpp to NULL before calling VOP_CREATE. This always happens when
calling using nameidata, and if not something went wrong, so we'd like
to be able to assert about it.
 1.59 24-Mar-2014  hannken branches: 1.59.2;
- Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
 1.58 12-Mar-2014  hannken Restructure union_lock() to always lock before testing for dead node.
Add two little helpers to lock or unlock a node. Use "vp" for the
union node and "lockvp" for the node to be locked. Use ISSET() to
test flags, add assertions.
 1.57 27-Feb-2014  hannken The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Change deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
the vnode is locked and unlock and return ENOENT in this case.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Adresses PR kern/37706 (Forced unmount of file systems is unsafe)

Discussed on tech-kern.

Welcome to 6.99.33
 1.56 16-Feb-2014  hannken Change union_allocvp() to take an unlocked uppervp and to return the
union node unlocked. Another VI_XLOCK hack is gone.
 1.55 13-Feb-2014  martin Remove an unused variable
 1.54 13-Feb-2014  hannken Get rid of UN_KLOCK to keep a lock on vput(). It is not really needed
and makes the source difficult to read. Always hold references to the
union nodes until the operation is done.
 1.53 13-Feb-2014  hannken Fix the DOT and DOTDOT case for union_lookup1().
 1.52 07-Feb-2014  hannken Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
 1.51 23-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
 1.50 17-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
 1.49 21-Nov-2011  hannken branches: 1.49.8; 1.49.12;
Replace flag based union node locking with generic vnode lock, support
shared and nowait locks and protect un_uppervp and un_*sz with mutex.

Mark file system MPSAFE.
 1.48 14-Nov-2011  hannken VOP_ABORTOP() has no specific lock requirements so there is no need
to force locked vnodes here. It should be impossible to come here
with a nil upper node.

Relock the directory vnode after copyup. A locked union node with an
unlocked upper vnode can no longer exist so make FIXUP() an assertion.
 1.47 18-Oct-2011  hannken branches: 1.47.2;
VOP_GETATTR() needs a shared lock at least.
 1.46 23-Aug-2011  hannken Stop abusing relookup() to prepare the creation of new nodes
in the upper layer.
Replace union_relookup() with union_do_lookup() that prepares
a component, calls VOP_LOOKUP() and does the EEXIST test.
 1.45 12-Aug-2011  hannken Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.

No functional changes intended.
 1.44 12-Aug-2011  hannken Add missing parts to mount devices from a union file system:
- union_close() has to lock/unlock the lower vnode.
- union_fsync() has to call spec_fsync() for the union vnode.
- union_strategy() must allow writes to devices on the lower file system.
- union_bwrite() was completely missing.
 1.43 10-Aug-2011  hannken For devices, sockets and fifos ignore setting the file size to zero to make
open(..., O_TRUNC) happy and allow them to write through the lower layer.

Fixes PR #43560 (writing to null device in unionfs fails)
 1.42 07-Aug-2011  hannken Change union rmdir semantics to fail directory removal for
non-empty directories like all other file systems do.

Change test accordingly.
 1.41 05-Aug-2011  hannken When union_lookup() creates a shadow directory and nameiop is not LOOKUP
it has to restart the lookup to get the componentname right.

Fixes PR #44383 (an endless stream of whiteout and opaque dir problems ...)
 1.40 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.39 02-Jan-2011  dholland branches: 1.39.6;
Remove the special refcount behavior (adding an extra reference to the
parent dir) associated with SAVESTART in relookup().

Check all call sites to make sure that SAVESTART wasn't set while
calling relookup(); if it was, adjust the refcount behavior. Remove
related references to SAVESTART.

The only code that was reaching the extra ref was msdosfs_rename,
where the refcount behavior was already fairly broken and/or gross;
repair it.

Add a dummy 4th argument to relookup to make sure code that hasn't
been inspected won't compile. (This will go away next time the
relookup semantics change, which they will.)
 1.38 02-Jul-2010  hannken LK_INTERLOCK is no longer a valid flag for VOP_LOCK().
 1.37 01-Jul-2010  hannken Remove vlockmgr(). Generic vnode lock operations now use a rwlock located
in the vnode. All LK_* flags move from sys/lock.h to sys/vnode.h. Calls
to vlockmgr() in file systems get replaced with VOP_LOCK() or VOP_UNLOCK().

Welcome to 5.99.34.

Discussed on tech-kern.
 1.36 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.35 01-May-2010  pooka Return correct value from union_islocked.
(XXX: anything asserting LK_SHARED will fail because union doesn't
support shared locks)
 1.34 08-Jan-2010  pooka branches: 1.34.2; 1.34.4;
The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase). Plenty of mix'n match upper/lowercase has creeped
into the tree since then. Nuke the macros and convert all callsites
to lowercase.

no functional change
 1.33 06-May-2008  ad PR kern/38141 lookup/vfs_busy acquire rwlock recursively

Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
 1.32 30-Apr-2008  ad PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
 1.31 29-Apr-2008  ad kern/38135 vfs_busy/vfs_trybusy confusion

The symptom was that sometimes file systems would occasionally not appear
in output from 'df' or 'mount' if the system was busy. Resolution:

- Make mount locks work somewhat like vm_map locks.
- vfs_trybusy() now only fails if the mount is gone, or if someone is
unmounting the file system. Simple contention on mnt_lock doesn't
cause it to fail.
- vfs_busy() will wait even if the file system is being unmounted.
 1.30 27-Feb-2008  matt branches: 1.30.2; 1.30.4;
Convert to ansi definitions from old-style definitons.
 1.29 09-Feb-2008  dholland branches: 1.29.2; 1.29.6;
Restore a fragment of a comment that apparently got lost in a merge slipup
in 1998.
 1.28 30-Jan-2008  ad PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.
 1.27 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.26 16-Jan-2008  ad union_putpages: fix a locking botch.
 1.25 02-Jan-2008  ad Merge vmlocking2 to head.
 1.24 08-Dec-2007  pooka branches: 1.24.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.23 26-Nov-2007  pooka branches: 1.23.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.22 10-Oct-2007  ad branches: 1.22.4;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.21 29-Jul-2007  pooka branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10;
apply ketchup to vop_mmap_args comment
 1.20 16-Apr-2007  chs branches: 1.20.2;
define a pager flag PGO_RECLAIM, similar to FSYNC_RECLAIM, and use it
to skip unnecessary flushing when layered file system vnodes are recycled.
this also prevents a deadlock with the dodgy LFS putpages routine.
fixes the non-LFS part of PR 36150.
 1.19 04-Feb-2007  chs branches: 1.19.2; 1.19.6; 1.19.8;
more fixes for the new vnode locking scheme:
- don't use SAVESTART in calls to relookup() from unionfs,
just vref() the desired vnode when we need to.
- fix locking and refcounting in the unionfs EEXIST error cases.
- release any vnode locks before calling VFS_ROOT(), vfs_busy() is enough.
this allows us to simplify union_root() and fix PR 3006.
- union_lock() doesn't handle shared lock requests correctly,
so convert them to exclusive instead. fixes PR 34775.
- in relookup(), avoid reusing "dp" for different purposes,
the error handling wasn't right. (actually just get rid of dp.)
also, change relookup() to ignore LOCKLEAF and always return the
vnode locked since the callers already expect this.
 1.18 09-Dec-2006  chs a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
these now always return the parent vnode locked. namei() works as before.
lookup() and various other paths no longer acquire vnode locks in the
wrong order via vrele(). fixes PR 32535.
as a nice side effect, path lookup is also up to 25% faster.
- the above allows us to get rid of PDIRUNLOCK.
- also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
- remove an assumption in layer_node_find() that all file systems implement
a recursive VOP_LOCK() (unionfs doesn't).
- require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
fill in eopnotsupp() for file systems that don't support being exported
and remove the checks for NULL. (layerfs calls these without checking.)
- in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
adjust which vnode is locked. fixes PR 33374.
- apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
 1.17 29-Sep-2006  christos branches: 1.17.2;
Coverity CID 2960: Don't print NULL vnode (from Arnaud Lacombe)
 1.16 14-May-2006  elad branches: 1.16.8; 1.16.10;
integrate kauth.
 1.15 15-Apr-2006  christos Coverity CID 1001: Avoid NULL deref.
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
merge ktrace-lwp.
 1.13 02-Nov-2005  yamt branches: 1.13.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.12 30-Aug-2005  xtraeme branches: 1.12.2;
Remove __P()
 1.11 26-Feb-2005  perry branches: 1.11.4;
nuke trailing whitespace
 1.10 27-Apr-2004  jrf branches: 1.10.4; 1.10.6;
First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

- removed casts from unionfs, deadfs and fdesc
(there are more to hunt down still)
- changed vfs_quotactl args argumet from caddr_t to void *
- changed vfs_quotactl structures/callers to reflect the api change

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.
 1.9 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.8 25-Jan-2004  hannken Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.

VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp) Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp) Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 29-Jun-2003  fvdl branches: 1.6.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.5 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.4 29-Jun-2003  thorpej Fix problems with Darren's ktrace/lwp changes.
 1.3 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.2 17-Mar-2003  jdolecek add kqueue support
 1.1 16-Mar-2003  jdolecek move union filesystem code from sys/miscfs/union to sys/fs/union
 1.6.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.6 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.6.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.6.2.2 03-Aug-2004  skrll Sync with HEAD
 1.6.2.1 03-Jul-2003  wrstuden LWP-ify union fs.

Note: These changes suffer from the same cnp->cn_lwp issue noted for
ufs. They will need to get fixed at the same time as ufs. The fix is to
add struct lwp * as a parameter to some VOPs.

Note also that most of the cn_lwp references used to be cn_proc references,
so if cnp->cn_lwp is bad to use, unionfs's been naughty for quite some
time.
 1.10.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.11.4.10 17-Mar-2008  yamt sync with head.
 1.11.4.9 11-Feb-2008  yamt sync with head.
 1.11.4.8 04-Feb-2008  yamt sync with head.
 1.11.4.7 21-Jan-2008  yamt sync with head
 1.11.4.6 07-Dec-2007  yamt sync with head
 1.11.4.5 27-Oct-2007  yamt sync with head.
 1.11.4.4 03-Sep-2007  yamt sync with head.
 1.11.4.3 26-Feb-2007  yamt sync with head.
 1.11.4.2 30-Dec-2006  yamt sync with head.
 1.11.4.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 20-Oct-2005  yamt adapt union.
 1.13.2.2 19-Nov-2005  yamt - finish reverting VOP_READ prototype changes.
- remove unused variables.
- fix typos.
some of them are pointed by Juan RP.
 1.13.2.1 15-Nov-2005  yamt - adapt to the new prototype of VOP_READ.
- adapt ext2fs and union.
 1.14.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.10.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.14.10.2 19-Apr-2006  elad sync with head.
 1.14.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.14.8.1 24-May-2006  yamt sync with head.
 1.14.6.2 01-Jun-2006  kardel Sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.16.10.2 10-Dec-2006  yamt sync with head.
 1.16.10.1 22-Oct-2006  yamt sync with head
 1.16.8.3 09-Feb-2007  ad Sync with HEAD.
 1.16.8.2 12-Jan-2007  ad Sync with head.
 1.16.8.1 18-Nov-2006  ad Sync with head.
 1.17.2.2 16-Apr-2007  bouyer Pull up following revision(s) (requested by chs in ticket #577):
sys/kern/vfs_subr.c: revision 1.287
sys/fs/union/union_vnops.c: revision 1.20
sys/miscfs/genfs/layer_vnops.c: revision 1.30
sys/uvm/uvm_pager.h: revision 1.35
define a pager flag PGO_RECLAIM, similar to FSYNC_RECLAIM, and use it
to skip unnecessary flushing when layered file system vnodes are recycled.
this also prevents a deadlock with the dodgy LFS putpages routine.
fixes the non-LFS part of PR 36150.
 1.17.2.1 17-Feb-2007  tron Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.19.8.1 11-Jul-2007  mjf Sync with head.
 1.19.6.5 16-Sep-2007  ad Checkpoint work in progress on the vnode lifecycle and reference counting
stuff. This makes it work properly without kernel_lock and fixes a few
quite old bugs. See vfs_subr.c 1.283.2.17 for details.
 1.19.6.4 20-Aug-2007  ad Sync with HEAD.
 1.19.6.3 17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.19.6.2 08-Jun-2007  ad Sync with head.
 1.19.6.1 05-Apr-2007  ad Compile fixes.
 1.19.2.1 07-May-2007  yamt sync with head.
 1.20.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.21.10.2 29-Jul-2007  pooka apply ketchup to vop_mmap_args comment
 1.21.10.1 29-Jul-2007  pooka file union_vnops.c was added on branch matt-mips64 on 2007-07-29 13:12:43 +0000
 1.21.8.1 14-Oct-2007  yamt sync with head.
 1.21.6.3 23-Mar-2008  matt sync with HEAD
 1.21.6.2 09-Jan-2008  matt sync with HEAD
 1.21.6.1 06-Nov-2007  matt sync with HEAD
 1.21.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.21.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.21.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.22.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.22.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.23.2.3 26-Dec-2007  ad Sync with head.
 1.23.2.2 10-Dec-2007  ad - Don't drain the vnode lock in vclean(); reference counting and XLOCK
should be enough.
- LK_SETRECURSE is gone.
 1.23.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.24.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.24.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.29.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.29.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.29.2.1 24-Mar-2008  keiichi sync with head.
 1.30.4.3 11-Aug-2010  yamt sync with head.
 1.30.4.2 11-Mar-2010  yamt sync with head
 1.30.4.1 16-May-2008  yamt sync with head.
 1.30.2.1 18-May-2008  yamt sync with head.
 1.34.4.5 19-May-2011  rmind Implement sharing of vnode_t::v_interlock amongst vnodes:
- Lock is shared amongst UVM objects using uvm_obj_setlock() or getnewvnode().
- Adjust vnode cache to handle unsharing, add VI_LOCKSHARE flag for that.
- Use sharing in tmpfs and layerfs for underlying object.
- Simplify locking in ubc_fault().
- Sprinkle some asserts.

Discussed with ad@.
 1.34.4.4 05-Mar-2011  rmind sync with head
 1.34.4.3 03-Jul-2010  rmind sync with head
 1.34.4.2 30-May-2010  rmind sync with head
 1.34.4.1 16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.34.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.39.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.47.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.2.1 17-Apr-2012  yamt sync with head
 1.49.12.1 18-May-2014  rmind sync with head
 1.49.8.2 03-Dec-2017  jdolecek update from HEAD
 1.49.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.59.2.1 10-Aug-2014  tls Rebase.
 1.62.4.2 28-Aug-2017  skrll Sync with HEAD
 1.62.4.1 06-Jun-2015  skrll Sync with HEAD
 1.63.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.63.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.63.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.67.2.1 11-May-2017  pgoyette Sync with HEAD
 1.70.16.2 29-Feb-2020  ad Sync with head.
 1.70.16.1 17-Jan-2020  ad Sync with head.
 1.70.14.1 27-Aug-2020  martin Pull up following revision(s) (requested by hannken in ticket #1062):

sys/fs/union/union.h: revision 1.30
sys/fs/union/union_subr.c: revision 1.79
sys/fs/union/union_vnops.c: revision 1.74

Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/55552: panic with union mount
 1.70.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.74.6.1 01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed