Home | History | Annotate | only in /src/sys/fs
History log of /src/sys/fs
RevisionDateAuthorComments
 1.22 04-Apr-2020  jdolecek branches: 1.22.28;
remove SMBFS and nsmb(4) - kernel part

it's unmaintained and supports only obsolete SMB1
 1.21 09-Jan-2018  christos branches: 1.21.4;
Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.20 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.19 14-Jun-2010  pooka Install ptyfs userspace header into user's space.
 1.18 18-Jul-2009  reinoud branches: 1.18.2; 1.18.4;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.17 28-Jul-2008  pooka branches: 1.17.8;
Install mount argument structure header just like every other file system.
 1.16 29-Jun-2007  rumble branches: 1.16.14; 1.16.28; 1.16.32; 1.16.34; 1.16.36; 1.16.38;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.15 06-Mar-2007  dillo branches: 1.15.2; 1.15.4;
Complete rename of hfsp to hfs, requested by thorpej.
 1.14 05-Mar-2007  dillo Integrate apmlabel and HFS+ file system.
 1.13 22-Oct-2006  pooka branches: 1.13.4;
kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.12 02-Feb-2006  reinoud branches: 1.12.16; 1.12.18;
Initial import of a UDF file system implementation for NetBSD.

Finally the logic glue and the set distribution lists modifications.
 1.11 29-Dec-2005  tsutsui branches: 1.11.2; 1.11.4;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 12-Sep-2005  jmmv Remove tmpfs from here, as it doesn't have a Makefile (dunno if it is
needed, yet). Pointed out by FUKAUMI Naoki in private mail.
 1.8 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.7 16-Mar-2003  jdolecek branches: 1.7.2; 1.7.18;
move union filesystem code from sys/miscfs/union to sys/fs/union
 1.6 26-Dec-2002  jdolecek move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.5 23-Dec-2002  jdolecek move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.4 23-Dec-2002  jdolecek move NTFS code from sys/ntfs to sys/fs/ntfs
 1.3 23-Dec-2002  jdolecek move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.2 23-Dec-2002  jdolecek move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1 09-Jan-2002  deberg branches: 1.1.2; 1.1.4;
descend into smbfs
 1.1.4.3 29-Dec-2002  thorpej With with HEAD.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 09-Jan-2002  nathanw file Makefile was added on branch nathanw_sa on 2002-02-28 04:14:41 +0000
 1.1.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.1 09-Jan-2002  thorpej file Makefile was added on branch kqueue on 2002-01-10 19:59:26 +0000
 1.7.18.3 03-Sep-2007  yamt sync with head.
 1.7.18.2 30-Dec-2006  yamt sync with head.
 1.7.18.1 21-Jun-2006  yamt sync with head.
 1.7.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 18-Feb-2006  yamt sync with head.
 1.12.18.1 10-Dec-2006  yamt sync with head.
 1.12.16.1 18-Nov-2006  ad Sync with head.
 1.13.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 15-Jul-2007  ad Sync with head.
 1.16.38.1 19-Oct-2008  haad Sync with HEAD.
 1.16.36.1 28-Jul-2008  simonb Sync with head.
 1.16.34.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.16.32.3 11-Aug-2010  yamt sync with head.
 1.16.32.2 19-Aug-2009  yamt sync with head.
 1.16.32.1 04-May-2009  yamt sync with head.
 1.16.28.1 28-Sep-2008  mjf Sync with HEAD.
 1.16.14.1 19-Nov-2007  mjf Stubs for devfs. Committing this before I sync with HEAD.
 1.17.8.1 23-Jul-2009  jym Sync with HEAD.
 1.18.4.1 03-Jul-2010  rmind sync with head
 1.18.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22.28.1 29-Jun-2024  perseant Implementation of exFAT filesystem, with compilation conditional on MKEXFATFS
make variable.
 1.2 30-Aug-2008  reinoud Back out dirhash kernel module for now.
 1.1 29-Aug-2008  reinoud Add dirhash kernel module for sharing dirhashing support with other FS
other than UDF. Its FS agnostic and could be used for any FS

Note to self: manpage needs to follow.
 1.3 30-Aug-2008  reinoud Back out dirhash kernel module for now.
 1.2 29-Aug-2008  reinoud Remove spurious old header file dependency that slipped trough.
 1.1 29-Aug-2008  reinoud Add dirhash kernel module for sharing dirhashing support with other FS
other than UDF. Its FS agnostic and could be used for any FS

Note to self: manpage needs to follow.
 1.2 30-Aug-2008  reinoud Back out dirhash kernel module for now.
 1.1 29-Aug-2008  reinoud Add dirhash kernel module for sharing dirhashing support with other FS
other than UDF. Its FS agnostic and could be used for any FS

Note to self: manpage needs to follow.
 1.7 06-Apr-2014  jakllsch Use size_t instead of int for character count to avoid sign compare issues.
 1.6 28-Apr-2008  martin branches: 1.6.34; 1.6.44; 1.6.50; 1.6.60;
Remove clause 3 and 4 from TNF licenses
 1.5 26-Feb-2007  drochner branches: 1.5.38; 1.5.40; 1.5.42;
-add __unused declarations to make it possible to use only half of it
-fix a bitmask (harmless) and remove two unnecessary ones
We should find a better location for that code!
 1.4 20-May-2006  yamt branches: 1.4.12;
revive copyright notice for the code derived from libc/locale/utf2.c.
i've asked jdolecek@ about this, but got no reply.
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.12; 1.3.14;
merge ktrace-lwp.
 1.2 27-Dec-2004  jdolecek branches: 1.2.10;
change wget_utf8() to not require NUL-terminated string as input (added
'size' parameter), and adjust callers appropriately
 1.1 21-Nov-2004  jdolecek branches: 1.1.2;
routines to encode/decode Unicode in UTF-8; based on ntfs/ntfs_conv.c,
but modified to be slightly more forgiving for invalid sequencies, and
to gracefully handle end of string in middle of decoded sequence
 1.1.2.3 17-Jan-2005  skrll Sync with HEAD.
 1.1.2.2 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 21-Nov-2004  skrll file unicode.h was added on branch ktrace-lwp on 2004-11-29 07:24:50 +0000
 1.2.10.2 03-Sep-2007  yamt sync with head.
 1.2.10.1 21-Jun-2006  yamt sync with head.
 1.3.14.1 19-Jun-2006  chap Sync with head.
 1.3.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.3.8.1 24-May-2006  yamt sync with head.
 1.3.6.1 01-Jun-2006  kardel Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.12.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.5.42.1 16-May-2008  yamt sync with head.
 1.5.40.1 18-May-2008  yamt sync with head.
 1.5.38.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.60.1 10-Aug-2014  tls Rebase.
 1.6.50.1 18-May-2014  rmind sync with head
 1.6.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.34.1 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.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-12-29 19:55:24 +0000
 1.22 06-Aug-2022  andvar s/blity/bility/ in various words, mainly in comments.
 1.21 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.20 03-Sep-2018  riastradh branches: 1.20.6;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.19 07-Feb-2014  hannken branches: 1.19.28; 1.19.30;
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.18 05-Nov-2012  dholland branches: 1.18.2;
Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.17 05-Nov-2012  dholland 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.16 22-Jul-2012  rmind branches: 1.16.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.15 30-Nov-2010  dholland branches: 1.15.8; 1.15.14;
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.14 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.13 08-Jan-2010  pooka branches: 1.13.2; 1.13.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.12 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.11 26-Nov-2007  pooka branches: 1.11.18; 1.11.26; 1.11.32;
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.10 10-Oct-2007  ad branches: 1.10.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.9 09-Dec-2006  chs branches: 1.9.6; 1.9.18; 1.9.20; 1.9.22;
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.8 14-May-2006  elad branches: 1.8.8; 1.8.10; 1.8.12;
integrate kauth.
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
merge ktrace-lwp.
 1.6 26-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 24-Feb-2004  wiz branches: 1.5.8; 1.5.10;
achieved, not acheived. From Peter Postma.
 1.4 24-Feb-2004  wiz becuase -> because. From Peter Postma.
 1.3 29-Jun-2003  fvdl branches: 1.3.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file adlookup.c was added on branch nathanw_sa on 2002-12-29 19:55:25 +0000
 1.3.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.4 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.3.2.3 03-Aug-2004  skrll Sync with HEAD
 1.3.2.2 03-Jul-2003  wrstuden LWP-ify adosfs. Also remove unused variable size from adosfs_mount().

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.
 1.3.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.5.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.8.1 29-Apr-2005  kent sync with -current
 1.6.4.4 07-Dec-2007  yamt sync with head
 1.6.4.3 27-Oct-2007  yamt sync with head.
 1.6.4.2 30-Dec-2006  yamt sync with head.
 1.6.4.1 21-Jun-2006  yamt sync with head.
 1.7.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.7.8.1 24-May-2006  yamt sync with head.
 1.7.6.1 01-Jun-2006  kardel Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.12.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.8.10.1 10-Dec-2006  yamt sync with head.
 1.8.8.1 12-Jan-2007  ad Sync with head.
 1.9.22.1 14-Oct-2007  yamt sync with head.
 1.9.20.2 09-Jan-2008  matt sync with HEAD
 1.9.20.1 06-Nov-2007  matt sync with HEAD
 1.9.18.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.9.18.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.9.6.1 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.10.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.11.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.18.3 11-Aug-2010  yamt sync with head.
 1.11.18.2 11-Mar-2010  yamt sync with head
 1.11.18.1 04-May-2009  yamt sync with head.
 1.13.4.2 05-Mar-2011  rmind sync with head
 1.13.4.1 03-Jul-2010  rmind sync with head
 1.13.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.15.14.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.15.8.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.15.8.2 16-Jan-2013  yamt sync with (a bit old) head
 1.15.8.1 30-Oct-2012  yamt sync with head
 1.16.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.2.1 18-May-2014  rmind sync with head
 1.19.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.19.30.1 10-Jun-2019  christos Sync with HEAD
 1.19.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.20.6.1 17-Jan-2020  ad Sync with head.
 1.13 05-Aug-2014  hannken Change adosfs from hashlist to vcache.
- point ap->block to real file header block for hard links.
 1.12 03-Oct-2012  mlelstv branches: 1.12.10;
Use getdisksize() to find out geometry, fetch only other magic values
from disklabel.
 1.11 30-Aug-2009  phx branches: 1.11.12; 1.11.22;
Fixed fatal warnings with ADOSFS_DIAGNOSTIC.
 1.10 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 28-Jun-2008  rumble branches: 1.9.4; 1.9.10;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.8 03-Dec-2005  christos branches: 1.8.70; 1.8.74; 1.8.76; 1.8.78;
- 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.7 25-Sep-2005  jmmv Follow compat naming tradition: rename compat_export_args to export_args30.
 1.6 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.5 26-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 13-Sep-2004  jdolecek branches: 1.4.4; 1.4.6;
set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.3 20-May-2004  atatat 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.2 01-Feb-2003  thorpej branches: 1.2.2; 1.2.4;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file adosfs.h was added on branch nathanw_sa on 2002-12-29 19:55:26 +0000
 1.2.4.1 23-May-2004  tron Pull up revision 1.3 (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.2.2.8 11-Dec-2005  christos Sync with head.
 1.2.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.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.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 03-Jul-2003  wrstuden LWP-ify adosfs. Also remove unused variable size from adosfs_mount().

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.
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.8.78.1 03-Jul-2008  simonb Sync with head.
 1.8.76.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.74.2 16-Sep-2009  yamt sync with head
 1.8.74.1 04-May-2009  yamt sync with head.
 1.8.70.1 29-Jun-2008  mjf Sync with HEAD.
 1.9.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.12.1 30-Oct-2012  yamt sync with head
 1.12.10.1 10-Aug-2014  tls Rebase.
 1.17 05-Aug-2014  hannken Change adosfs from hashlist to vcache.
- point ap->block to real file header block for hard links.
 1.16 27-Feb-2014  hannken branches: 1.16.2;
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.15 12-Jun-2011  rmind branches: 1.15.2; 1.15.12; 1.15.16;
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.14 23-May-2011  rmind branches: 1.14.2;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.13 21-Jul-2010  hannken branches: 1.13.2;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.12 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.11 14-Mar-2009  dsl branches: 1.11.2; 1.11.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.10 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.9 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.8 30-Jan-2008  ad branches: 1.8.10; 1.8.18; 1.8.24;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.7 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.6 02-Jan-2008  ad Merge vmlocking2 to head.
 1.5 10-Oct-2007  ad branches: 1.5.4; 1.5.6; 1.5.10;
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.4 11-Dec-2005  christos branches: 1.4.30; 1.4.44; 1.4.46; 1.4.48;
merge ktrace-lwp.
 1.3 26-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 27-Jan-2003  lonewolf branches: 1.2.2; 1.2.10; 1.2.12;
Fix compiler warnings after 64bit daddr_t change.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file adutil.c was added on branch nathanw_sa on 2002-12-29 19:55:27 +0000
 1.2.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.10.1 29-Apr-2005  kent sync with -current
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 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.2.2.1 03-Jul-2003  wrstuden LWP-ify adosfs. Also remove unused variable size from adosfs_mount().

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.
 1.3.4.3 04-Feb-2008  yamt sync with head.
 1.3.4.2 21-Jan-2008  yamt sync with head
 1.3.4.1 27-Oct-2007  yamt sync with head.
 1.4.48.1 14-Oct-2007  yamt sync with head.
 1.4.46.3 23-Mar-2008  matt sync with HEAD
 1.4.46.2 09-Jan-2008  matt sync with HEAD
 1.4.46.1 06-Nov-2007  matt sync with HEAD
 1.4.44.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.4.30.1 20-Aug-2007  ad Sync with HEAD.
 1.5.10.2 08-Jan-2008  bouyer Sync with HEAD
 1.5.10.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.6.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.5.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.10.2 11-Aug-2010  yamt sync with head.
 1.8.10.1 04-May-2009  yamt sync with head.
 1.11.4.4 31-May-2011  rmind sync with head
 1.11.4.3 05-Mar-2011  rmind sync with head
 1.11.4.2 03-Jul-2010  rmind sync with head
 1.11.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.11.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15.16.1 18-May-2014  rmind sync with head
 1.15.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.1 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.16.2.1 10-Aug-2014  tls Rebase.
 1.80 05-Dec-2021  msaitoh s/filesytem/filesystem/ in comment.
 1.79 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.78 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.77 01-Jun-2017  chs branches: 1.77.10; 1.77.16;
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.76 17-Feb-2017  hannken branches: 1.76.4;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.75 18-Nov-2015  phx branches: 1.75.2; 1.75.4;
Patch by hannken@ to fix a bug which has been introduced with 1.71.
The kernel crashed with uvm fault when mounting an ados file system.
 1.74 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.73 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.72 02-Jan-2015  christos We have three sets of DTYPE_ constants in the kernel:
altq Drop Type
disklabel Disk Type
file Descriptor Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
 1.71 05-Aug-2014  hannken branches: 1.71.2; 1.71.4; 1.71.6;
Change adosfs from hashlist to vcache.
- point ap->block to real file header block for hard links.
 1.70 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.69 23-Mar-2014  hannken branches: 1.69.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.68 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.67 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.66 20-Dec-2012  hannken branches: 1.66.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.65 03-Oct-2012  mlelstv Use getdisksize() to find out geometry, fetch only other magic values
from disklabel.
 1.64 13-Mar-2012  elad branches: 1.64.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.63 14-Nov-2011  hannken branches: 1.63.4; 1.63.6; 1.63.10; 1.63.12;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.62 12-Jun-2011  rmind branches: 1.62.2;
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.61 23-May-2011  rmind branches: 1.61.2;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.60 24-Jun-2010  hannken branches: 1.60.2;
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.59 30-Aug-2009  phx branches: 1.59.2; 1.59.4;
Fixed fatal warnings with ADOSFS_DIAGNOSTIC.
 1.58 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.57 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.56 15-Mar-2009  cegger ansify function definitions
 1.55 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.54 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.53 28-Jun-2008  rumble branches: 1.53.4; 1.53.6; 1.53.10; 1.53.16; 1.53.20;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.52 16-May-2008  hannken branches: 1.52.2;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.51 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.50 29-Apr-2008  ad branches: 1.50.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.49 05-Feb-2008  ad branches: 1.49.6; 1.49.8; 1.49.10;
Do genfs_node_init() earlier. PR kern/36162.
 1.48 28-Jan-2008  dholland 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.47 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.46 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.45 08-Dec-2007  pooka branches: 1.45.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.44 26-Nov-2007  pooka branches: 1.44.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.43 10-Oct-2007  ad branches: 1.43.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.42 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.41 31-Jul-2007  pooka branches: 1.41.2; 1.41.4; 1.41.6; 1.41.8;
* 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.40 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.39 23-Jul-2007  pooka Initialize size and/or writesize when creating a vnode.
 1.38 17-Jul-2007  pooka branches: 1.38.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.37 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.36 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.35 13-Mar-2007  ad Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.34 04-Mar-2007  yamt branches: 1.34.2; 1.34.4;
fix fallout from caddr_t changes.
 1.33 19-Jan-2007  hannken branches: 1.33.2;
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.32 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.31 25-Nov-2006  christos fix missing initializer
 1.30 23-Jul-2006  ad branches: 1.30.4; 1.30.6;
Use the LWP cached credentials where sane.
 1.29 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.28 15-May-2006  christos branches: 1.28.4;
More kauth fallout.
 1.27 14-May-2006  elad integrate kauth.
 1.26 11-Dec-2005  christos branches: 1.26.4; 1.26.6; 1.26.8; 1.26.10; 1.26.12;
merge ktrace-lwp.
 1.25 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.24 19-Aug-2005  christos fix a printf arg.
 1.23 28-Jun-2005  yamt branches: 1.23.2;
- constify genfs_ops.
- use member designators.
 1.22 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.21 26-Feb-2005  perry branches: 1.21.2;
nuke trailing whitespace
 1.20 02-Jan-2005  thorpej branches: 1.20.2; 1.20.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.19 14-Sep-2004  skrll Fix typos/pastos.
 1.18 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.17 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.16 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.15 20-May-2004  atatat Explicitly call pool_init() (and pool_destroy()) when being built as
an _LKM.

This adds pools to the list of things that lkms must do manually
because they're set up with link sets. Not that there's anything
wrong with link sets, but that we need to try harder to remember that
lkms are second class citizens. Of a sort.
 1.14 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.13 25-Apr-2004  simonb Initialise (most) pools from a link set instead of explicit calls
to pool_init. Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

Convert struct session, ucred and lockf to pools.
 1.12 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.11 27-Mar-2004  atatat branches: 1.11.2;
Manually attach malloc types when being built as an lkm.
 1.10 24-Mar-2004  atatat Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.9 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.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 Fix problems with the ktrace/lwp changes.
 1.6 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.5 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 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 21-Mar-2003  dsl Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file advfsops.c was added on branch nathanw_sa on 2002-12-29 19:55:28 +0000
 1.8.2.13 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.12 01-Apr-2005  skrll Sync with HEAD.
 1.8.2.11 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.10 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.9 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.8 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.7 26-Aug-2004  skrll Missed these in the vget, etc changes.
 1.8.2.6 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.5 13-Aug-2004  skrll Adapt to branch.

cats GENERIC compiles.
 1.8.2.4 12-Aug-2004  skrll Sync with HEAD.
 1.8.2.3 03-Aug-2004  skrll Sync with HEAD
 1.8.2.2 03-Jul-2003  wrstuden LWP-ify adosfs. Also remove unused variable size from adosfs_mount().

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.
 1.8.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.11.2.1 29-May-2004  tron Pull up revision 1.16 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.20.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.2.1 29-Apr-2005  kent sync with -current
 1.21.2.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.23.2.9 11-Feb-2008  yamt sync with head.
 1.23.2.8 04-Feb-2008  yamt sync with head.
 1.23.2.7 21-Jan-2008  yamt sync with head
 1.23.2.6 07-Dec-2007  yamt sync with head
 1.23.2.5 27-Oct-2007  yamt sync with head.
 1.23.2.4 03-Sep-2007  yamt sync with head.
 1.23.2.3 26-Feb-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.26.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.26.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.26.8.2 11-Aug-2006  yamt sync with head
 1.26.8.1 24-May-2006  yamt sync with head.
 1.26.6.1 01-Jun-2006  kardel Sync with head.
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.28.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.30.6.1 10-Dec-2006  yamt sync with head.
 1.30.4.2 01-Feb-2007  ad Sync with head.
 1.30.4.1 12-Jan-2007  ad Sync with head.
 1.33.2.2 24-Mar-2007  yamt sync with head.
 1.33.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.4 20-Aug-2007  ad Sync with HEAD.
 1.34.2.3 15-Jul-2007  ad Sync with head.
 1.34.2.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.34.2.1 13-Mar-2007  ad Sync with head.
 1.38.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.41.8.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.41.8.1 31-Jul-2007  pooka file advfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:17 +0000
 1.41.6.1 14-Oct-2007  yamt sync with head.
 1.41.4.3 23-Mar-2008  matt sync with HEAD
 1.41.4.2 09-Jan-2008  matt sync with HEAD
 1.41.4.1 06-Nov-2007  matt sync with HEAD
 1.41.2.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.41.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.41.2.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.43.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.43.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.43.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.44.2.1 26-Dec-2007  ad Sync with head.
 1.45.4.1 08-Jan-2008  bouyer Sync with HEAD
 1.49.10.5 11-Aug-2010  yamt sync with head.
 1.49.10.4 16-Sep-2009  yamt sync with head
 1.49.10.3 18-Jul-2009  yamt sync with head.
 1.49.10.2 04-May-2009  yamt sync with head.
 1.49.10.1 16-May-2008  yamt sync with head.
 1.49.8.1 18-May-2008  yamt sync with head.
 1.49.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.49.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.50.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.50.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.2.1 03-Jul-2008  simonb Sync with head.
 1.53.20.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.53.16.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.53.10.2 23-Jul-2009  jym Sync with HEAD.
 1.53.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.6.1 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.53.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.59.4.3 31-May-2011  rmind sync with head
 1.59.4.2 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.59.4.1 03-Jul-2010  rmind sync with head
 1.59.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.61.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.62.2.4 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.62.2.3 23-Jan-2013  yamt sync with head
 1.62.2.2 30-Oct-2012  yamt sync with head
 1.62.2.1 17-Apr-2012  yamt sync with head
 1.63.12.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.63.10.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.63.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.63.4.1 05-Apr-2012  mrg sync to latest -current.
 1.64.2.4 03-Dec-2017  jdolecek update from HEAD
 1.64.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.64.2.2 25-Feb-2013  tls resync with head
 1.64.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.66.2.1 18-May-2014  rmind sync with head
 1.69.2.1 10-Aug-2014  tls Rebase.
 1.71.6.1 22-Nov-2015  bouyer Pull up following revision(s) (requested by phx in ticket #1042):
sys/fs/adosfs/advfsops.c: revision 1.75
Patch by hannken@ to fix a bug which has been introduced with 1.71.
The kernel crashed with uvm fault when mounting an ados file system.
 1.71.4.4 28-Aug-2017  skrll Sync with HEAD
 1.71.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.71.4.2 06-Jun-2015  skrll Sync with HEAD
 1.71.4.1 06-Apr-2015  skrll Sync with HEAD
 1.71.2.1 22-Nov-2015  bouyer Pull up following revision(s) (requested by phx in ticket #1042):
sys/fs/adosfs/advfsops.c: revision 1.75
Patch by hannken@ to fix a bug which has been introduced with 1.71.
The kernel crashed with uvm fault when mounting an ados file system.
 1.75.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.75.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.75.2.3 21-Jul-2016  pgoyette Add missing semicolon
 1.75.2.2 21-Jul-2016  pgoyette Call bdevsw_release() in the normal-exit path.
 1.75.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.76.4.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.77.16.1 17-Jan-2020  ad Sync with head.
 1.77.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.60 13-May-2024  msaitoh s/contigous/contiguous/ in comment.
 1.59 04-Apr-2022  andvar fix various typos, mainly in comments.
 1.58 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.57 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.56 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.55 27-Jun-2020  christos branches: 1.55.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.54 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.53 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.52 23-Apr-2020  jdolecek fix obvious typo in error handling - buf error should go to b_error
 1.51 17-Jan-2020  ad branches: 1.51.4;
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.50 26-May-2017  riastradh branches: 1.50.10; 1.50.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.49 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.48 20-Aug-2016  hannken branches: 1.48.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.47 20-Apr-2015  riastradh branches: 1.47.2;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.46 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.45 05-Aug-2014  hannken branches: 1.45.4;
Change adosfs from hashlist to vcache.
- point ap->block to real file header block for hard links.
 1.44 25-Jul-2014  dholland 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.43 23-Jan-2014  hannken branches: 1.43.2;
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.42 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.41 18-Mar-2013  plunky branches: 1.41.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.40 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.39 13-Mar-2012  elad branches: 1.39.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.38 19-May-2011  rmind branches: 1.38.4; 1.38.8;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.37 24-Jun-2010  hannken branches: 1.37.2;
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 30-Aug-2009  phx branches: 1.36.2; 1.36.4;
Fixed fatal warnings with ADOSFS_DIAGNOSTIC.
 1.35 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.34 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.33 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.32 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.31 16-Dec-2008  pooka branches: 1.31.2;
The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.30 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.29 16-May-2008  hannken branches: 1.29.4; 1.29.6;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.28 25-Jan-2008  ad branches: 1.28.6; 1.28.8; 1.28.10; 1.28.12;
Remove VOP_LEASE. Discussed on tech-kern.
 1.27 02-Jan-2008  ad Merge vmlocking2 to head.
 1.26 26-Nov-2007  pooka branches: 1.26.2; 1.26.6;
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.25 08-Oct-2007  ad branches: 1.25.4;
Merge brelse() changes from the vmlocking branch.
 1.24 29-Jul-2007  ad branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.23 04-Mar-2007  yamt branches: 1.23.2; 1.23.10;
fix fallout from caddr_t changes.
 1.22 20-Feb-2007  ad Call genfs_node_destroy() where appropriate.
 1.21 23-Sep-2006  aymeric branches: 1.21.4;
fix adosfs_readdir() so that we can list directories on AmigaOS filesystems.
. get rid of struct adirent which didn't match struct dirent anymore
. fix cookies, move all the code handling them to the end of the function

Includes many minor changes to the code of this function.
 1.20 15-May-2006  christos branches: 1.20.8; 1.20.10;
More kauth fallout.
 1.19 14-May-2006  elad integrate kauth.
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10; 1.18.12;
merge ktrace-lwp.
 1.17 29-Nov-2005  yamt merge yamt-readahead branch.
 1.16 02-Nov-2005  yamt branches: 1.16.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.15 26-Feb-2005  perry branches: 1.15.4; 1.15.6;
nuke trailing whitespace
 1.14 09-Jan-2005  chs branches: 1.14.2; 1.14.4;
adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway. there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
 1.13 14-Sep-2004  jdolecek rename 'sp' variable to 'ap' in adosfs_pathconf(), so that it matches other
filesystems and avoid silly pastos
 1.12 14-Sep-2004  skrll Fix typos/pastos.
 1.11 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.10 04-May-2004  jrf Remove caddr_t inlines. Approved by christos@NetBSD.org.
 1.9 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.8 26-Jan-2004  hannken Fix xxx_strategy() to use the vnode arg instead of bp->b_vp.
 1.7 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.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 Fix problems with the ktrace/lwp changes.
 1.4 27-Jan-2003  lonewolf Fix compiler warnings after 64bit daddr_t change.
 1.3 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.2 09-Jan-2003  lonewolf Don't scale file block numbers. Fixes mmap() and UBCified read() problems.
Reviewed by Ignatios.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.2.3 15-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file advnops.c was added on branch nathanw_sa on 2002-12-29 19:55:29 +0000
 1.6.2.10 11-Dec-2005  christos Sync with head.
 1.6.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.7 17-Jan-2005  skrll Sync with HEAD.
 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 adosfs. Also remove unused variable size from adosfs_mount().

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.
 1.14.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.2.1 29-Apr-2005  kent sync with -current
 1.15.6.1 20-Oct-2005  yamt adapt adosfs.
 1.15.4.8 04-Feb-2008  yamt sync with head.
 1.15.4.7 21-Jan-2008  yamt sync with head
 1.15.4.6 07-Dec-2007  yamt sync with head
 1.15.4.5 27-Oct-2007  yamt sync with head.
 1.15.4.4 03-Sep-2007  yamt sync with head.
 1.15.4.3 26-Feb-2007  yamt sync with head.
 1.15.4.2 30-Dec-2006  yamt sync with head.
 1.15.4.1 21-Jun-2006  yamt sync with head.
 1.16.2.3 19-Nov-2005  yamt - as read-ahead context is per-vnode now,
there are less reasons to make VOP_READ call uvm_ra_request explicitly.
move it to pager (uvn_get) so that it can handle accesses via mmap as well.
- pass advice to pager via ubc.
- tweak DPRINTF.

XXX can be disturbed by PGO_LOCKED.

XXX it's controversial where it should be done.
(uvm_fault, uvn_get or genfs_getpages.)
 1.16.2.2 18-Nov-2005  yamt - associate read-ahead context to vnode, rather than file.
- revert VOP_READ prototype.
 1.16.2.1 15-Nov-2005  yamt adapt the rest of filesystems which use genfs_getpages.
 1.18.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.18.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.18.8.1 24-May-2006  yamt sync with head.
 1.18.6.1 01-Jun-2006  kardel Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.20.10.1 22-Oct-2006  yamt sync with head
 1.20.8.1 18-Nov-2006  ad Sync with head.
 1.21.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.21.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.23.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.23.2.3 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.23.2.2 20-Aug-2007  ad Sync with HEAD.
 1.23.2.1 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.24.10.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.24.10.1 29-Jul-2007  ad file advnops.c was added on branch matt-mips64 on 2007-07-29 12:15:46 +0000
 1.24.8.1 14-Oct-2007  yamt sync with head.
 1.24.6.3 23-Mar-2008  matt sync with HEAD
 1.24.6.2 09-Jan-2008  matt sync with HEAD
 1.24.6.1 06-Nov-2007  matt sync with HEAD
 1.24.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.24.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.25.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.25.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.26.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.26.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.28.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.10.4 11-Aug-2010  yamt sync with head.
 1.28.10.3 16-Sep-2009  yamt sync with head
 1.28.10.2 18-Jul-2009  yamt sync with head.
 1.28.10.1 04-May-2009  yamt sync with head.
 1.28.8.1 18-May-2008  yamt sync with head.
 1.28.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.28.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.29.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.29.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.31.2.2 23-Jul-2009  jym Sync with HEAD.
 1.31.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.4.2 31-May-2011  rmind sync with head
 1.36.4.1 03-Jul-2010  rmind sync with head
 1.36.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.37.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.8.1 05-Apr-2012  mrg sync to latest -current.
 1.38.4.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.38.4.2 23-Jan-2013  yamt sync with head
 1.38.4.1 17-Apr-2012  yamt sync with head
 1.39.2.4 03-Dec-2017  jdolecek update from HEAD
 1.39.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.2.2 23-Jun-2013  tls resync from head
 1.39.2.1 25-Feb-2013  tls resync with head
 1.41.6.1 18-May-2014  rmind sync with head
 1.43.2.1 10-Aug-2014  tls Rebase.
 1.45.4.4 28-Aug-2017  skrll Sync with HEAD
 1.45.4.3 05-Oct-2016  skrll Sync with HEAD
 1.45.4.2 06-Jun-2015  skrll Sync with HEAD
 1.45.4.1 06-Apr-2015  skrll Sync with HEAD
 1.47.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.48.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.50.16.1 17-Jan-2020  ad Sync with head.
 1.50.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.51.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.55.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.152;
move adosfs files from sys/adosfs to sys/fs/adosfs
 1.1.152.1 03-Dec-2017  jdolecek update from HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file files.adosfs was added on branch nathanw_sa on 2002-12-29 19:55:29 +0000
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.6 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.5 28-Mar-2020  tkusumi autofs: Make autofs(5) timeout messages include affected process name and PID

Sync warning message with FreeBSD and DragonFlyBSD.
taken-from: FreeBSD
 1.4 14-Dec-2019  tkusumi autofs: Make /dev/autofs cdevsw functions static

Also less confusing since autofs vnops also has autofs_{open,close} in NetBSD.
 1.3 09-Jan-2018  christos branches: 1.3.4;
fix module attachment and cdevsw
 1.2 09-Jan-2018  martin Include <sys/atomic.h> for the atomic funtions used in here.
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.3.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5 17-May-2023  tkusumi sys/fs/autofs: Remove unused APRINTF macro

Remove a debug print macro (originates from DragonFly autofs)
I had intentionally kept at the time.
 1.4 23-Nov-2019  tkusumi autofs: Remove unused autofs_node::an_vnode_lock

Unlike FreeBSD and DragonFlyBSD, this is unused in NetBSD.
 1.3 23-Nov-2019  tkusumi autofs: u_int -> unsigned int
 1.2 23-Nov-2019  tkusumi autofs: Drop unused autofs_mount field which originates from FreeBSD

Taken-from: DragonFlyBSD
 1.1 09-Jan-2018  christos branches: 1.1.4;
Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.1.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.3 23-Nov-2019  tkusumi autofs: Fix a comment on autofs_args

mount_autofs(8) also uses this.
mount_autofs(8) was added by NetBSD as an optional command (not needed to use autofs).
 1.2 14-Jan-2018  christos branches: 1.2.4;
support getargs, fix flush, fix mutex_destroy
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.2.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12 28-Mar-2022  riastradh driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this. (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back. To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
 1.11 26-Apr-2020  tkusumi autofs: Silence down a warning which should really be a debug message

taken-from: FreeBSD
 1.10 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.9 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.8 26-Nov-2019  tkusumi branches: 1.8.2;
autofs: Use NULLVP for NULL vnode

I originally used NULL for NetBSD autofs, but it got mixed up with
NULLVP when merged with NetBSD.
 1.7 23-Nov-2019  tkusumi autofs: Don't calculate dirent reclen twice

Taken-from: DragonFlyBSD
 1.6 16-Nov-2019  tkusumi autofs: Fix change by r1.3 "prevent assert on unmount."

Must delete all nodes on unmount, otherwise automounts with >1 level of directories can't be deleted.
taken-from: FreeBSD and DragonFlyBSD
 1.5 14-Nov-2019  tkusumi autofs: Whitespace fix
 1.4 14-Jan-2018  christos branches: 1.4.4;
support getargs, fix flush, fix mutex_destroy
 1.3 13-Jan-2018  christos prevent assert on unmount.
 1.2 09-Jan-2018  christos fix module attachment and cdevsw
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.4.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8.2.1 17-Jan-2020  ad Sync with head.
 1.10 15-Dec-2024  andvar s/partcular/particular/ in comment.
 1.9 20-Oct-2024  mlelstv Handle seek operations on autofs mountpoints.
 1.8 11-Dec-2022  mlelstv branches: 1.8.8;
Use genfs_pathconf for VOP_PATHCONF.
Fixes bin/57103.
 1.7 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.6 16-May-2020  christos branches: 1.6.6;
Add ACL support for FFS. From FreeBSD.
 1.5 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.4 26-Nov-2019  tkusumi branches: 1.4.2;
autofs: Use NULLVP for NULL vnode

I originally used NULL for NetBSD autofs, but it got mixed up with
NULLVP when merged with NetBSD.
 1.3 23-Nov-2019  tkusumi autofs: Remove unused autofs_node::an_vnode_lock

Unlike FreeBSD and DragonFlyBSD, this is unused in NetBSD.
 1.2 23-Nov-2019  tkusumi autofs: Don't calculate dirent reclen twice

Taken-from: DragonFlyBSD
 1.1 09-Jan-2018  christos branches: 1.1.4;
Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.1.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.2.1 17-Jan-2020  ad Sync with head.
 1.6.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.8.8.1 02-Aug-2025  perseant Sync with HEAD
 1.1 09-Jan-2018  christos Merge autofs support from: Tomohiro Kusumi
XXX: Does not work yet
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-12-29 19:55:30 +0000
 1.4 17-May-2015  pooka update: runs as a userspace process now.
 1.3 11-Dec-2005  christos branches: 1.3.120; 1.3.140;
merge ktrace-lwp.
 1.2 26-Feb-2005  perry nuke trailing whitespace
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.14.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.12.1 29-Apr-2005  kent sync with -current
 1.1.4.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file TODO was added on branch nathanw_sa on 2002-12-29 19:55:31 +0000
 1.3.140.1 06-Jun-2015  skrll Sync with HEAD
 1.3.120.1 03-Dec-2017  jdolecek update from HEAD
 1.3 17-May-2015  pooka Remove. For example, vfs_cluster hasn't existed since early UBC days
(which were 10+ years ago).
 1.2 06-Jan-2003  wiz branches: 1.2.150; 1.2.170;
through, not throught.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.3 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file TODO.hibler was added on branch nathanw_sa on 2002-12-29 19:55:32 +0000
 1.2.170.1 06-Jun-2015  skrll Sync with HEAD
 1.2.150.1 03-Dec-2017  jdolecek update from HEAD
 1.5 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.4 27-Feb-2008  matt branches: 1.4.48; 1.4.64;
Convert to ansi definitions from old-style definitons.
 1.3 11-Dec-2005  christos branches: 1.3.46; 1.3.66; 1.3.70;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_bmap.c was added on branch nathanw_sa on 2002-12-29 19:55:33 +0000
 1.2.16.1 17-Mar-2008  yamt sync with head.
 1.3.70.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.66.1 24-Mar-2008  keiichi sync with head.
 1.3.46.1 23-Mar-2008  matt sync with HEAD
 1.4.64.1 10-Aug-2014  tls Rebase.
 1.4.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29 19-May-2024  tsutsui Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.
 1.28 02-Feb-2024  christos PR/57897: Ricardo Branco: Add support for mount options mask,dirmask,uid,gid
 1.27 22-Aug-2018  msaitoh branches: 1.27.30;
- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.26 23-Jun-2013  dholland branches: 1.26.32; 1.26.34;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.25 19-Jun-2013  dholland blkoff() -> cd9660_blkoff()
blksize() -> cd9660_blksize()
 1.24 28-Jun-2008  rumble branches: 1.24.30; 1.24.40;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.23 27-Feb-2008  matt branches: 1.23.4; 1.23.6; 1.23.8;
Convert to ansi definitions from old-style definitons.
 1.22 31-Jul-2007  pooka branches: 1.22.4; 1.22.20; 1.22.24; 1.22.26;
* 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.21 12-Jul-2007  dsl branches: 1.21.2;
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.20 13-Jul-2006  martin branches: 1.20.14;
Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.19 14-May-2006  elad branches: 1.19.4;
integrate kauth.
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10; 1.18.12;
merge ktrace-lwp.
 1.17 03-Dec-2005  christos protect against multiple inclusion instead of forbidding their access from
userland, and #ifdef _KERNEL all their kernel functions.
 1.16 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.15 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.14 30-Aug-2005  xtraeme Remove __P()
 1.13 26-Feb-2005  perry branches: 1.13.4;
nuke trailing whitespace
 1.12 28-Dec-2004  jdolecek branches: 1.12.2; 1.12.4;
size_t police

pointed out by Jesse Off on source-changes@
 1.11 21-Nov-2004  jdolecek when Joliet extension is in use, encode the Joliet Unicode file names
into UTF-8, rather than filtering them to ISO-8859-1 subset

provide vfs.cd9660.utf8_joliet sysctl to switch to the former
iso-8859-1-only handling, default is to UTF-8 encode
 1.10 20-May-2004  atatat 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 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 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.7 04-Dec-2003  atatat branches: 1.7.2;
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.6 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.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 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.3 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_extern.h was added on branch nathanw_sa on 2002-12-29 19:55:35 +0000
 1.5.2.10 11-Dec-2005  christos Sync with head.
 1.5.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.6 29-Nov-2004  skrll Sync with HEAD.
 1.5.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.5.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.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.7.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.12.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.2.1 29-Apr-2005  kent sync with -current
 1.13.4.4 17-Mar-2008  yamt sync with head.
 1.13.4.3 03-Sep-2007  yamt sync with head.
 1.13.4.2 30-Dec-2006  yamt sync with head.
 1.13.4.1 21-Jun-2006  yamt sync with head.
 1.18.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.18.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.18.8.2 11-Aug-2006  yamt sync with head
 1.18.8.1 24-May-2006  yamt sync with head.
 1.18.6.1 01-Jun-2006  kardel Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.19.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.20.14.2 20-Aug-2007  ad Sync with HEAD.
 1.20.14.1 15-Jul-2007  ad Sync with head.
 1.21.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.22.26.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.22.26.1 31-Jul-2007  pooka file cd9660_extern.h was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.22.24.2 29-Jun-2008  mjf Sync with HEAD.
 1.22.24.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.20.1 24-Mar-2008  keiichi sync with head.
 1.22.4.1 23-Mar-2008  matt sync with HEAD
 1.23.8.1 03-Jul-2008  simonb Sync with head.
 1.23.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.23.4.1 04-May-2009  yamt sync with head.
 1.24.40.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.40.1 23-Jun-2013  tls resync from head
 1.24.30.1 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.26.34.1 10-Jun-2019  christos Sync with HEAD
 1.26.32.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.27.30.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.33 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.32 06-Aug-2022  andvar branches: 1.32.10;
s/blity/bility/ in various words, mainly in comments.
 1.31 04-Apr-2020  ad Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.30 28-Mar-2015  maxv branches: 1.30.18; 1.30.24;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.29 16-Jun-2014  hannken branches: 1.29.4;
Change cd9660 from hashlist to vcache.
 1.28 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.27 03-Jun-2014  joerg Introduce two helper functions to centralise the namecache statistics
in vfs_cache.c. Use consistent locking around the per-cpu data.
 1.26 07-Feb-2014  hannken branches: 1.26.2;
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.25 23-Jun-2013  dholland branches: 1.25.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.24 19-Jun-2013  dholland blkoff() -> cd9660_blkoff()
blksize() -> cd9660_blksize()
 1.23 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.22 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.21 05-Nov-2012  dholland 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.20 22-Jul-2012  rmind branches: 1.20.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.19 27-Sep-2011  christos branches: 1.19.2; 1.19.8;
use ISO_MAXNAMLEN instead of NAME_MAX
 1.18 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.17 08-Jan-2010  pooka branches: 1.17.2; 1.17.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.16 16-May-2008  hannken Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.15 27-Feb-2008  matt branches: 1.15.2; 1.15.4; 1.15.6;
Convert to ansi definitions from old-style definitons.
 1.14 26-Nov-2007  pooka branches: 1.14.10; 1.14.14;
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.13 08-Oct-2007  ad branches: 1.13.4;
Merge brelse() changes from the vmlocking branch.
 1.12 09-Dec-2006  chs branches: 1.12.6; 1.12.18; 1.12.20; 1.12.22;
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.11 14-May-2006  elad branches: 1.11.8; 1.11.10; 1.11.12;
integrate kauth.
 1.10 15-Apr-2006  christos Coverity CID 1135: Add KASSERT before deref.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
merge ktrace-lwp.
 1.8 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.7 26-Feb-2005  perry branches: 1.7.4; 1.7.6;
nuke trailing whitespace
 1.6 07-Aug-2003  agc branches: 1.6.8; 1.6.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 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.3 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.2 20-Jan-2003  simonb Remove variable that is only assigned too but not referenced.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_lookup.c was added on branch nathanw_sa on 2002-12-29 19:55:35 +0000
 1.5.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.5.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.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.6.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.7.6.1 20-Oct-2005  yamt adapt cd9660.
 1.7.4.5 17-Mar-2008  yamt sync with head.
 1.7.4.4 07-Dec-2007  yamt sync with head
 1.7.4.3 27-Oct-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.9.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.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.9.10.2 19-Apr-2006  elad sync with head.
 1.9.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.9.8.1 24-May-2006  yamt sync with head.
 1.9.6.2 01-Jun-2006  kardel Sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.11.12.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.11.10.1 10-Dec-2006  yamt sync with head.
 1.11.8.1 12-Jan-2007  ad Sync with head.
 1.12.22.1 14-Oct-2007  yamt sync with head.
 1.12.20.3 23-Mar-2008  matt sync with HEAD
 1.12.20.2 09-Jan-2008  matt sync with HEAD
 1.12.20.1 06-Nov-2007  matt sync with HEAD
 1.12.18.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12.18.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.12.6.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.13.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.14.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.10.1 24-Mar-2008  keiichi sync with head.
 1.15.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.4.3 11-Aug-2010  yamt sync with head.
 1.15.4.2 11-Mar-2010  yamt sync with head
 1.15.4.1 04-May-2009  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.17.4.1 03-Jul-2010  rmind sync with head
 1.17.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.19.8.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.19.2.4 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.19.2.3 23-Jan-2013  yamt sync with head
 1.19.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.19.2.1 30-Oct-2012  yamt sync with head
 1.20.2.5 03-Dec-2017  jdolecek update from HEAD
 1.20.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.2.3 23-Jun-2013  tls resync from head
 1.20.2.2 25-Feb-2013  tls resync with head
 1.20.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.25.2.1 18-May-2014  rmind sync with head
 1.26.2.1 10-Aug-2014  tls Rebase.
 1.29.4.1 06-Apr-2015  skrll Sync with HEAD
 1.30.24.1 19-Jan-2020  ad Set IMNT_SHRLOOKUP and use it for the in-cache case. Need to check what
more can be done with tmpfs though, it can probably do the whole lookup.
 1.30.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.10.1 02-Aug-2025  perseant Sync with HEAD
 1.7 02-Feb-2024  christos PR/57897: Ricardo Branco: Add support for mount options mask,dirmask,uid,gid
 1.6 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.5 25-Sep-2005  jmmv Follow compat naming tradition: rename compat_export_args to export_args30.
 1.4 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.3 03-Oct-2003  yamt branches: 1.3.16;
terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_mount.h was added on branch nathanw_sa on 2002-12-29 19:55:36 +0000
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.38 26-May-2017  riastradh Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.37 26-May-2017  riastradh 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.36 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.35 20-Aug-2016  hannken branches: 1.35.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.34 10-Nov-2014  maxv branches: 1.34.2; 1.34.4;
Do not uselessly include <sys/malloc.h>.
 1.33 16-Jun-2014  hannken branches: 1.33.2;
Change cd9660 from hashlist to vcache.
 1.32 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.31 10-May-2014  martin PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.30 27-Feb-2014  hannken branches: 1.30.2;
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.29 12-Jun-2011  rmind branches: 1.29.2; 1.29.8; 1.29.12; 1.29.14; 1.29.16; 1.29.22;
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.28 19-May-2011  rmind branches: 1.28.2;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.27 21-Jul-2010  hannken branches: 1.27.2;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.26 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.25 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.24 05-May-2008  ad branches: 1.24.10; 1.24.20; 1.24.22; 1.24.24; 1.24.28;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.23 27-Feb-2008  matt branches: 1.23.2; 1.23.4;
Convert to ansi definitions from old-style definitons.
 1.22 30-Jan-2008  ad branches: 1.22.2; 1.22.6;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.21 17-Jan-2008  ad Fix dodgy tests of v_usecount.
 1.20 02-Jan-2008  ad Merge vmlocking2 to head.
 1.19 08-Dec-2007  ad branches: 1.19.4;
Merge locking changes + fixes from the vmlocking branch.
 1.18 26-Nov-2007  pooka branches: 1.18.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.17 08-Oct-2007  ad branches: 1.17.4;
Merge brelse() changes from the vmlocking branch.
 1.16 30-Jun-2007  pooka branches: 1.16.6; 1.16.8; 1.16.10;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.15 12-Mar-2007  ad branches: 1.15.2; 1.15.4;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.14 20-Feb-2007  ad branches: 1.14.4;
Call genfs_node_destroy() where appropriate.
 1.13 11-Dec-2005  christos branches: 1.13.26;
merge ktrace-lwp.
 1.12 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.11 30-Aug-2005  xtraeme branches: 1.11.2;
Remove __P()
 1.10 29-May-2005  christos branches: 1.10.2;
- rename variables to avoid shadowing.
- add a few const.
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 20-May-2004  atatat branches: 1.8.4; 1.8.6;
Explicitly call pool_init() (and pool_destroy()) when being built as
an _LKM.

This adds pools to the list of things that lkms must do manually
because they're set up with link sets. Not that there's anything
wrong with link sets, but that we need to try harder to remember that
lkms are second class citizens. Of a sort.
 1.7 25-Apr-2004  simonb Initialise (most) pools from a link set instead of explicit calls
to pool_init. Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

Convert struct session, ucred and lockf to pools.
 1.6 27-Mar-2004  atatat Manually attach malloc types when being built as an lkm.
 1.5 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.4 29-Jun-2003  fvdl branches: 1.4.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.3 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.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_node.c was added on branch nathanw_sa on 2002-12-29 19:55:37 +0000
 1.4.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.6 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.4.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.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.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.2.8 17-Mar-2008  yamt sync with head.
 1.10.2.7 04-Feb-2008  yamt sync with head.
 1.10.2.6 21-Jan-2008  yamt sync with head
 1.10.2.5 07-Dec-2007  yamt sync with head
 1.10.2.4 27-Oct-2007  yamt sync with head.
 1.10.2.3 03-Sep-2007  yamt sync with head.
 1.10.2.2 26-Feb-2007  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.11.2.1 20-Oct-2005  yamt adapt cd9660.
 1.13.26.2 24-Mar-2007  yamt sync with head.
 1.13.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.14.4.8 24-Oct-2007  ad cd9660_done: destroy locks.
 1.14.4.7 24-Oct-2007  ad - Kill ISODEVMAP.
- Mark cd9660 MPSAFE.
 1.14.4.6 24-Oct-2007  ad - Fix a race in cd9660_vget().
- simplelock -> mutex.
 1.14.4.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.14.4.4 15-Jul-2007  ad Sync with head.
 1.14.4.3 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.14.4.2 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.14.4.1 13-Mar-2007  ad Sync with head.
 1.15.4.1 09-Dec-2007  reinoud Pullup to HEAD
 1.15.2.1 11-Jul-2007  mjf Sync with head.
 1.16.10.1 14-Oct-2007  yamt sync with head.
 1.16.8.3 23-Mar-2008  matt sync with HEAD
 1.16.8.2 09-Jan-2008  matt sync with HEAD
 1.16.8.1 06-Nov-2007  matt sync with HEAD
 1.16.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.16.6.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.17.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.17.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.17.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.18.2.2 08-Dec-2007  ad Sync with head.
 1.18.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.19.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.19.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.22.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.22.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.2.1 24-Mar-2008  keiichi sync with head.
 1.23.4.2 11-Aug-2010  yamt sync with head.
 1.23.4.1 16-May-2008  yamt sync with head.
 1.23.2.1 18-May-2008  yamt sync with head.
 1.24.28.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1904):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.24.24.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1904):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.24.22.4 31-May-2011  rmind sync with head
 1.24.22.3 05-Mar-2011  rmind sync with head
 1.24.22.2 03-Jul-2010  rmind sync with head
 1.24.22.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.24.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.24.10.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1904):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.29.22.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1062):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.29.16.1 18-May-2014  rmind sync with head
 1.29.14.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1062):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.29.12.2 03-Dec-2017  jdolecek update from HEAD
 1.29.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.8.1 21-May-2014  bouyer Pull up following revision(s) (requested by martin in ticket #1062):
sys/fs/cd9660/cd9660_node.c: revision 1.31
PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
 1.29.2.1 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.30.2.1 10-Aug-2014  tls Rebase.
 1.33.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.34.4.1 26-Apr-2017  pgoyette Sync with HEAD
 1.34.2.2 28-Aug-2017  skrll Sync with HEAD
 1.34.2.1 05-Oct-2016  skrll Sync with HEAD
 1.35.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.18 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.17 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.16 16-Jun-2014  hannken branches: 1.16.44;
Change cd9660 from hashlist to vcache.
 1.15 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.14 27-Feb-2008  matt branches: 1.14.48; 1.14.64;
Convert to ansi definitions from old-style definitons.
 1.13 08-Dec-2007  ad branches: 1.13.8; 1.13.12;
Merge locking changes + fixes from the vmlocking branch.
 1.12 03-Dec-2005  christos branches: 1.12.30; 1.12.34; 1.12.44; 1.12.46; 1.12.56;
protect against multiple inclusion instead of forbidding their access from
userland, and #ifdef _KERNEL all their kernel functions.
 1.11 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.10 11-Nov-2005  yamt - ignore truncation for VCHR/VBLK/VFIFO as it used to be
before yamt-vop merge. PR/32049 from Atsushi Onoe.
- reject setattr which attempts to change size of VLNK/VSOCK.
 1.9 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.8 30-Aug-2005  xtraeme branches: 1.8.2;
Remove an extra ')'
 1.7 30-Aug-2005  xtraeme Remove __P()
 1.6 20-Jun-2004  dillo branches: 1.6.12;
Use unsigned long for file size and location; avoids sign extension
for files >2GB. Okayed by Martin Husemann.
 1.5 07-Aug-2003  agc branches: 1.5.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 29-Jun-2003  fvdl branches: 1.4.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.3 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.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_node.h was added on branch nathanw_sa on 2002-12-29 19:55:37 +0000
 1.4.2.7 11-Dec-2005  christos Sync with head.
 1.4.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.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.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.5.2.1 22-Jun-2004  tron Pull up revision 1.6 (requested by dillo in ticket #525):
Use unsigned long for file size and location; avoids sign extension
for files >2GB. Okayed by Martin Husemann.
 1.6.12.3 17-Mar-2008  yamt sync with head.
 1.6.12.2 21-Jan-2008  yamt sync with head
 1.6.12.1 21-Jun-2006  yamt sync with head.
 1.8.2.2 29-Oct-2005  yamt cd9660_setattr: remove extra checks. return EOPNOTSUPP immediately.
suggested by Chuck Silvers.
 1.8.2.1 20-Oct-2005  yamt adapt cd9660.
 1.12.56.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.12.46.2 23-Mar-2008  matt sync with HEAD
 1.12.46.1 09-Jan-2008  matt sync with HEAD
 1.12.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.12.34.1 09-Dec-2007  reinoud Pullup to HEAD
 1.12.30.2 24-Oct-2007  ad - Kill ISODEVMAP.
- Mark cd9660 MPSAFE.
 1.12.30.1 24-Oct-2007  ad - Fix a race in cd9660_vget().
- simplelock -> mutex.
 1.13.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.8.1 24-Mar-2008  keiichi sync with head.
 1.14.64.1 10-Aug-2014  tls Rebase.
 1.14.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.44.1 01-Aug-2021  thorpej Sync with HEAD.
 1.18 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.17 27-Sep-2011  christos branches: 1.17.12; 1.17.30;
use ISO_MAXNAMLEN instead of NAME_MAX
 1.16 16-May-2008  hannken Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.15 27-Feb-2008  matt branches: 1.15.2; 1.15.4; 1.15.6;
Convert to ansi definitions from old-style definitons.
 1.14 08-Oct-2007  ad branches: 1.14.14; 1.14.18;
Merge brelse() changes from the vmlocking branch.
 1.13 04-Mar-2007  christos branches: 1.13.2; 1.13.14; 1.13.16; 1.13.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 16-Nov-2006  christos branches: 1.12.4;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 14-May-2006  elad branches: 1.10.8; 1.10.10;
integrate kauth.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
merge ktrace-lwp.
 1.8 30-Aug-2005  xtraeme Remove __P()
 1.7 29-May-2005  christos branches: 1.7.2;
- rename variables to avoid shadowing.
- add a few const.
 1.6 26-Feb-2005  perry nuke trailing whitespace
 1.5 21-Nov-2004  jdolecek branches: 1.5.4; 1.5.6;
when Joliet extension is in use, encode the Joliet Unicode file names
into UTF-8, rather than filtering them to ISO-8859-1 subset

provide vfs.cd9660.utf8_joliet sysctl to switch to the former
iso-8859-1-only handling, default is to UTF-8 encode
 1.4 20-Nov-2004  jdolecek whitespace cleanup
 1.3 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.2 16-May-2003  itojun branches: 1.2.2;
use strlcpy. check size if we are to use namei buffer.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_rrip.c was added on branch nathanw_sa on 2002-12-29 19:55:38 +0000
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.7.2.5 17-Mar-2008  yamt sync with head.
 1.7.2.4 27-Oct-2007  yamt sync with head.
 1.7.2.3 03-Sep-2007  yamt sync with head.
 1.7.2.2 30-Dec-2006  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.9.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.10.1 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.9.8.1 24-May-2006  yamt sync with head.
 1.9.6.1 01-Jun-2006  kardel Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.10.2 10-Dec-2006  yamt sync with head.
 1.10.10.1 22-Oct-2006  yamt sync with head
 1.10.8.1 18-Nov-2006  ad Sync with head.
 1.12.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.18.1 14-Oct-2007  yamt sync with head.
 1.13.16.2 23-Mar-2008  matt sync with HEAD
 1.13.16.1 06-Nov-2007  matt sync with HEAD
 1.13.14.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.13.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.14.18.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.18.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.14.1 24-Mar-2008  keiichi sync with head.
 1.15.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.4.1 04-May-2009  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.17.30.1 06-Apr-2015  skrll Sync with HEAD
 1.17.12.1 03-Dec-2017  jdolecek update from HEAD
 1.3 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.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.4 11-Dec-2005  christos Sync with head.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_rrip.h was added on branch nathanw_sa on 2002-12-29 19:55:39 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.16 25-May-2024  tsutsui Appease warnings on building tools/installboot on Cygwin.
 1.15 19-May-2024  tsutsui Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.
 1.14 09-Mar-2016  christos branches: 1.14.48;
remove installboot.h; it is not needed
 1.13 09-Mar-2016  christos Make it usable from userland.
 1.12 10-Nov-2014  maxv branches: 1.12.2;
Do not uselessly include <sys/malloc.h>.
 1.11 01-Jun-2014  martin branches: 1.11.2;
PR kern/48815: do not skip ';' twice when comparing file versions.
Patch from Thomas Schmitt.
 1.10 27-Sep-2011  christos branches: 1.10.8; 1.10.12; 1.10.26;
define and use ISO_MAXNAMLEN instead of MAXNAMLEN
 1.9 27-Feb-2008  matt Convert to ansi definitions from old-style definitons.
 1.8 08-Dec-2006  enami branches: 1.8.20; 1.8.36; 1.8.40;
The function wget() is always responsible to maintain length of component
not yet compared. Otherwise pathname lookup fails on certain condition.
 1.7 28-Aug-2006  christos branches: 1.7.2; 1.7.4;
correct bogus loop test; used to be always true.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8;
merge ktrace-lwp.
 1.5 28-Dec-2004  jdolecek branches: 1.5.10;
size_t police

pointed out by Jesse Off on source-changes@
 1.4 27-Dec-2004  jdolecek change wget_utf8() to not require NUL-terminated string as input,
and adjust callers appropriately. cn_nameptr isn't NUL-terminated
for non-leaf components, so it's incorrect to assume it is always
NUL-terminated.

This fixes previous utf8-ization changes to not panic for cases
like 'echo */*/*.ps' in case the intermediate path components
are not in cache (yet).
 1.3 21-Nov-2004  jdolecek when Joliet extension is in use, encode the Joliet Unicode file names
into UTF-8, rather than filtering them to ISO-8859-1 subset

provide vfs.cd9660.utf8_joliet sysctl to switch to the former
iso-8859-1-only handling, default is to UTF-8 encode
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.5 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.4 29-Nov-2004  skrll Sync with HEAD.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_util.c was added on branch nathanw_sa on 2002-12-29 19:55:40 +0000
 1.5.10.2 17-Mar-2008  yamt sync with head.
 1.5.10.1 30-Dec-2006  yamt sync with head.
 1.6.8.1 03-Sep-2006  yamt sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.4.1 10-Dec-2006  yamt sync with head.
 1.7.2.1 12-Jan-2007  ad Sync with head.
 1.8.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.36.1 24-Mar-2008  keiichi sync with head.
 1.8.20.1 23-Mar-2008  matt sync with HEAD
 1.10.26.1 10-Aug-2014  tls Rebase.
 1.10.12.2 03-Dec-2017  jdolecek update from HEAD
 1.10.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.8.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by martin in ticket #1073):
sys/fs/cd9660/cd9660_util.c: revision 1.11
PR kern/48815: do not skip ';' twice when comparing file versions.
Patch from Thomas Schmitt.
 1.11.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.12.2.1 19-Mar-2016  skrll Sync with HEAD
 1.14.48.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.105 16-Feb-2025  joe remove unecessary branches
 1.104 15-May-2024  reinoud branches: 1.104.2;
Fixing potential, though unlikely overflow as detected by coverity scan
 1.103 03-Feb-2024  christos add checks for id and mask in the update case (thanks hannken)
 1.102 03-Feb-2024  christos need the new args pointer...
 1.101 03-Feb-2024  christos fix MNT_UPDATE (thanks hannken)
 1.100 03-Feb-2024  christos Provide backwards compatibility (pointed out by hannken)
 1.99 03-Feb-2024  hannken cd9660_mountroot: must initialize new args "fmask" and "dmask".
 1.98 02-Feb-2024  christos PR/57897: Ricardo Branco: Add support for mount options mask,dirmask,uid,gid
 1.97 03-May-2022  hannken Lock devvp for vinvalbuf().
 1.96 04-Apr-2020  ad Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.95 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.94 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.93 17-Apr-2017  hannken branches: 1.93.2; 1.93.12; 1.93.18;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.92 17-Apr-2017  hannken Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.91 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.90 28-Mar-2015  maxv branches: 1.90.2; 1.90.4;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.89 09-Jul-2014  maxv branches: 1.89.4;
Remove ROOTNAME (unused).
 1.88 22-Jun-2014  hannken CID 1223346: No need to check bp against NULL. It is always valid here.
 1.87 16-Jun-2014  hannken Change cd9660 from hashlist to vcache.
 1.86 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.85 13-May-2014  martin PR kern/48799: make filehandles properly use 64bit inodes on CD9660 file
systems. Patch from Thomas Schmitt, with slight modifications.
 1.84 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.83 24-Mar-2014  dholland branches: 1.83.2;
Tidy up locking in cd9660_mount; thrash the lock less, and make it
clear that the lock is only dropped when calling iso_mountfs().

While here, don't use the vnode pointer's value after vrele().
 1.82 23-Mar-2014  hannken Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.81 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.80 23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.79 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.78 23-Jun-2013  dholland branches: 1.78.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.77 19-Jun-2013  dholland blkoff() -> cd9660_blkoff()
blksize() -> cd9660_blksize()
 1.76 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.75 13-Mar-2012  elad branches: 1.75.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.74 14-Nov-2011  hannken branches: 1.74.4; 1.74.6; 1.74.10; 1.74.12;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.73 27-Sep-2011  christos branches: 1.73.2;
define and use ISO_MAXNAMLEN instead of MAXNAMLEN
 1.72 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.71 24-Jun-2010  hannken branches: 1.71.6;
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.70 26-Jan-2010  mlelstv branches: 1.70.2; 1.70.4;
Drop two uses of disk label data.

msdosfs and cd9660 are the only filesystems that verify the filesystem
type in the label. This is the wrong place, sanity checks should only
rely on the inner structure of the filesystem (like signatures or
magic numbers).

msdosfs also used the device type information from the label to
deduce a filesystem parameter heuristically for the gemdos variant.
If there is no information inside the filesystem data itself, this
should be an explicit mount option.
 1.69 08-Jan-2010  pooka 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.68 19-Oct-2009  tsutsui Apply a similar fix for mount function from ffs_vfsops.c rev 1.186:
Change cd9660_mount, in MNT_UPDATE case, to check dev_t's for equality
instead of just vnode pointers. Fixes erroneous "Invalid argument"
errors from mount(8) with -u against cd9660 root in the presence of
mfs or tmpfs /dev prepared after initial mountroot.

Tested on QEMU running cobalt Restore CD.
 1.67 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.66 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.65 22-Jan-2009  cegger branches: 1.65.2;
buildfix: re-adapt for major/minor returning 32bit value again.
 1.64 11-Jan-2009  cegger make this compile
 1.63 28-Jun-2008  rumble branches: 1.63.4; 1.63.6; 1.63.12;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.62 16-May-2008  hannken branches: 1.62.2;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.61 06-May-2008  ad branches: 1.61.2;
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.60 03-May-2008  ad Convert cd9660 to attach as a module.
 1.59 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.58 29-Apr-2008  ad 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.57 27-Feb-2008  matt branches: 1.57.2; 1.57.4;
Convert to ansi definitions from old-style definitons.
 1.56 30-Jan-2008  ad branches: 1.56.2; 1.56.6;
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.55 28-Jan-2008  dholland 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.54 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.53 02-Jan-2008  ad Merge vmlocking2 to head.
 1.52 08-Dec-2007  pooka branches: 1.52.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.51 08-Dec-2007  ad Merge locking changes + fixes from the vmlocking branch.
 1.50 26-Nov-2007  pooka branches: 1.50.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.49 10-Oct-2007  ad branches: 1.49.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.48 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.47 31-Jul-2007  pooka branches: 1.47.2; 1.47.4; 1.47.6; 1.47.8;
* 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.46 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.45 23-Jul-2007  pooka Initialize size and/or writesize when creating a vnode.
 1.44 17-Jul-2007  pooka branches: 1.44.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.43 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.42 09-Jul-2007  pooka mntflushbuf() cargo cult comment mania cleanup. there is no mntflushbuf().
 1.41 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.40 04-Mar-2007  christos branches: 1.40.2; 1.40.4; 1.40.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.39 19-Jan-2007  hannken branches: 1.39.2;
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.38 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.37 24-Oct-2006  drochner minor fix to error handling (from OpenBSD, rev.1.40):
only set devvp->v_specmountpoint on successful mounts
 1.36 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.35 28-Aug-2006  christos branches: 1.35.2; 1.35.4;
add missing initializers
 1.34 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.33 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.32 14-May-2006  elad branches: 1.32.4;
integrate kauth.
 1.31 21-Feb-2006  thorpej branches: 1.31.2; 1.31.4; 1.31.6;
Use device_class() instead of accessing dv_class directly.
 1.30 11-Dec-2005  christos branches: 1.30.2; 1.30.4; 1.30.6;
merge ktrace-lwp.
 1.29 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.28 30-Sep-2005  dyoung branches: 1.28.2;
In cd9660_mount, initialize imp to VFSTOISOFS(mp) instead of NULL.
Remove redundant assignments to imp. This fixes the page fault
panic when the kernel mounts an ISO9660 filesystem, introduced at
revision 1.27.
 1.27 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.26 30-Aug-2005  xtraeme Remove __P()
 1.25 05-Aug-2005  jmmv Fix comment regarding sbp->f_favail (which was a duplicate due to a pasto).
 1.24 28-Jun-2005  yamt branches: 1.24.2;
- constify genfs_ops.
- use member designators.
 1.23 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.22 26-Feb-2005  perry branches: 1.22.2;
nuke trailing whitespace
 1.21 09-Jan-2005  mycroft branches: 1.21.2; 1.21.4;
Rework the mountroot interface so that vfs_mountroot() opens the root device
and just passes it on to the file system functions. This avoids opening and
closing the device several times.

Mentioned on tech-kern some time ago, IIRC. I've been running this for a
long time.
 1.20 02-Jan-2005  thorpej Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.19 21-Nov-2004  jdolecek when Joliet extension is in use, encode the Joliet Unicode file names
into UTF-8, rather than filtering them to ISO-8859-1 subset

provide vfs.cd9660.utf8_joliet sysctl to switch to the former
iso-8859-1-only handling, default is to UTF-8 encode
 1.18 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.17 15-Aug-2004  mycroft Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
FS-specific checks littered throughout the code. This may be used later to
make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
 1.16 05-Jul-2004  pk Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().
 1.15 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.14 25-May-2004  atatat Sysctl descriptions under vfs subtree
 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 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.5 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.4 03-Apr-2003  christos Avoid stupid printfs during mountroot attempt.
 1.3 21-Mar-2003  dsl Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_vfsops.c was added on branch nathanw_sa on 2002-12-29 19:55:40 +0000
 1.8.2.11 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.10 01-Apr-2005  skrll Sync with HEAD.
 1.8.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.8 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.7 29-Nov-2004  skrll Sync with HEAD.
 1.8.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.4 25-Aug-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 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.11.2.1 29-May-2004  tron Pull up revision 1.14 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.21.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.2.1 29-Apr-2005  kent sync with -current
 1.22.2.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.24.2.9 17-Mar-2008  yamt sync with head.
 1.24.2.8 04-Feb-2008  yamt sync with head.
 1.24.2.7 21-Jan-2008  yamt sync with head
 1.24.2.6 07-Dec-2007  yamt sync with head
 1.24.2.5 27-Oct-2007  yamt sync with head.
 1.24.2.4 03-Sep-2007  yamt sync with head.
 1.24.2.3 26-Feb-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.28.2.1 20-Oct-2005  yamt adapt cd9660.
 1.30.6.2 01-Jun-2006  kardel Sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.30.2.1 01-Mar-2006  yamt sync with head.
 1.31.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.31.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.31.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.31.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.31.2.3 03-Sep-2006  yamt sync with head.
 1.31.2.2 11-Aug-2006  yamt sync with head
 1.31.2.1 24-May-2006  yamt sync with head.
 1.32.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.35.4.2 10-Dec-2006  yamt sync with head.
 1.35.4.1 22-Oct-2006  yamt sync with head
 1.35.2.2 01-Feb-2007  ad Sync with head.
 1.35.2.1 18-Nov-2006  ad Sync with head.
 1.39.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.40.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.40.4.1 11-Jul-2007  mjf Sync with head.
 1.40.2.10 24-Oct-2007  ad - Kill ISODEVMAP.
- Mark cd9660 MPSAFE.
 1.40.2.9 24-Oct-2007  ad - Fix a race in cd9660_vget().
- simplelock -> mutex.
 1.40.2.8 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.40.2.7 24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.40.2.6 20-Aug-2007  ad Sync with HEAD.
 1.40.2.5 29-Jul-2007  ad Add vfs_destroy() to free mount structures. The specificdata_ref was being
leaked.
 1.40.2.4 15-Jul-2007  ad Sync with head.
 1.40.2.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.40.2.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.40.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.44.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.47.8.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.47.8.1 31-Jul-2007  pooka file cd9660_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.47.6.1 14-Oct-2007  yamt sync with head.
 1.47.4.3 23-Mar-2008  matt sync with HEAD
 1.47.4.2 09-Jan-2008  matt sync with HEAD
 1.47.4.1 06-Nov-2007  matt sync with HEAD
 1.47.2.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.47.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.47.2.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.49.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.49.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.49.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.50.2.3 26-Dec-2007  ad Sync with head.
 1.50.2.2 08-Dec-2007  ad Sync with head.
 1.50.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.52.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.56.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.56.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.56.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.56.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.56.2.1 24-Mar-2008  keiichi sync with head.
 1.57.4.5 11-Aug-2010  yamt sync with head.
 1.57.4.4 11-Mar-2010  yamt sync with head
 1.57.4.3 18-Jul-2009  yamt sync with head.
 1.57.4.2 04-May-2009  yamt sync with head.
 1.57.4.1 16-May-2008  yamt sync with head.
 1.57.2.1 18-May-2008  yamt sync with head.
 1.61.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.61.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.62.2.1 03-Jul-2008  simonb Sync with head.
 1.63.12.1 21-Apr-2010  matt sync to netbsd-5
 1.63.6.2 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.63.6.1 27-Oct-2009  bouyer branches: 1.63.6.1.2; 1.63.6.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #1115):
sys/fs/cd9660/cd9660_vfsops.c: revision 1.68
Apply a similar fix for mount function from ffs_vfsops.c rev 1.186:
Change cd9660_mount, in MNT_UPDATE case, to check dev_t's for equality
instead of just vnode pointers. Fixes erroneous "Invalid argument"
errors from mount(8) with -u against cd9660 root in the presence of
mfs or tmpfs /dev prepared after initial mountroot.
Tested on QEMU running cobalt Restore CD.
 1.63.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.63.6.1.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.63.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.63.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.63.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.65.2.2 23-Jul-2009  jym Sync with HEAD.
 1.65.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.70.4.2 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.70.4.1 03-Jul-2010  rmind sync with head
 1.70.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.71.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.73.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.73.2.2 23-Jan-2013  yamt sync with head
 1.73.2.1 17-Apr-2012  yamt sync with head
 1.74.12.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.74.10.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.74.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.74.4.1 05-Apr-2012  mrg sync to latest -current.
 1.75.2.4 03-Dec-2017  jdolecek update from HEAD
 1.75.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.75.2.2 23-Jun-2013  tls resync from head
 1.75.2.1 25-Feb-2013  tls resync with head
 1.78.2.1 18-May-2014  rmind sync with head
 1.83.2.1 10-Aug-2014  tls Rebase.
 1.89.4.2 28-Aug-2017  skrll Sync with HEAD
 1.89.4.1 06-Apr-2015  skrll Sync with HEAD
 1.90.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.90.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.90.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.90.2.2 23-Jul-2016  pgoyette Be consistent in the ordering of operations.
 1.90.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.93.18.2 19-Jan-2020  ad Set IMNT_SHRLOOKUP and use it for the in-cache case. Need to check what
more can be done with tmpfs though, it can probably do the whole lookup.
 1.93.18.1 17-Jan-2020  ad Sync with head.
 1.93.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.93.2.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.104.2.1 02-Aug-2025  perseant Sync with HEAD
 1.63 02-Feb-2024  christos PR/57897: Ricardo Branco: Add support for mount options mask,dirmask,uid,gid
 1.62 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.61 19-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 2; cvs randomly didn't commit these changes before, and then hid
them from me until I touched the files to force it to rethink. Dunno
what happened.

There's probably more of these, going to have to scan the tree the
hard way.
 1.60 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.59 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.58 27-Jun-2020  christos branches: 1.58.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.57 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.56 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.55 12-Jul-2019  maxv branches: 1.55.8;
Fix info leak: zero out the buffer, because it is not entirely filled, and
the uninitialized bytes get copied to userland in sys___getdens30(). Remove
unneeded cast while here.
 1.54 12-Mar-2016  christos branches: 1.54.10; 1.54.18;
PR/50951: Unmess this up.
 1.53 11-Mar-2016  christos PR/50951: David Binderman: Fix misplaced parens
 1.52 20-Apr-2015  riastradh Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.51 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.50 28-Mar-2015  maxv Remove the 'cred' argument from breadn(), and update the man page
accordingly.

ok hannken@
 1.49 25-Jul-2014  dholland branches: 1.49.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.48 14-Jun-2014  hannken Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber. For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency. Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads. No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
 1.47 23-Jan-2014  hannken branches: 1.47.2;
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.46 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.45 23-Jun-2013  dholland branches: 1.45.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.44 19-Jun-2013  dholland blkoff() -> cd9660_blkoff()
blksize() -> cd9660_blksize()
 1.43 18-Mar-2013  plunky C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.42 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.41 13-Mar-2012  elad branches: 1.41.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.40 27-Sep-2011  christos branches: 1.40.2; 1.40.6;
use ISO_MAXNAMLEN instead of NAME_MAX
 1.39 29-Mar-2010  pooka Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.38 03-Jul-2009  elad branches: 1.38.2; 1.38.4;
Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.37 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.36 17-Dec-2008  cegger branches: 1.36.2;
kill MALLOC and FREE macros.
 1.35 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.34 16-May-2008  hannken branches: 1.34.4; 1.34.6;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.33 27-Feb-2008  matt branches: 1.33.2; 1.33.4; 1.33.6;
Convert to ansi definitions from old-style definitons.
 1.32 25-Jan-2008  ad branches: 1.32.2; 1.32.6;
Remove VOP_LEASE. Discussed on tech-kern.
 1.31 08-Dec-2007  ad Merge locking changes + fixes from the vmlocking branch.
 1.30 26-Nov-2007  pooka branches: 1.30.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.29 08-Oct-2007  ad branches: 1.29.4;
Merge brelse() changes from the vmlocking branch.
 1.28 29-Jul-2007  rumble branches: 1.28.4; 1.28.6; 1.28.8; 1.28.10;
Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.27 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.26 04-Mar-2007  christos branches: 1.26.2; 1.26.6; 1.26.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.24 16-Nov-2006  christos branches: 1.24.4;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 14-May-2006  elad branches: 1.22.8; 1.22.10;
integrate kauth.
 1.21 15-Apr-2006  christos Coverity CID 1197: Add KASSERT before deref.
 1.20 01-Mar-2006  yamt branches: 1.20.2; 1.20.4; 1.20.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.19 11-Dec-2005  christos branches: 1.19.2; 1.19.4; 1.19.6;
merge ktrace-lwp.
 1.18 29-Nov-2005  yamt merge yamt-readahead branch.
 1.17 11-Nov-2005  yamt branches: 1.17.2;
- ignore truncation for VCHR/VBLK/VFIFO as it used to be
before yamt-vop merge. PR/32049 from Atsushi Onoe.
- reject setattr which attempts to change size of VLNK/VSOCK.
 1.16 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.15 30-Aug-2005  xtraeme branches: 1.15.2;
Remove __P()
 1.14 19-Aug-2005  christos 64 bit inode changes.
 1.13 23-Jun-2005  thorpej branches: 1.13.2;
Remove the last references to M_NAMEI; everything should be using PNBUF_*()
now (for a long time now). Remove M_NAMEI, and bump the kernel version to
3.99.7 to reflect its removal.
 1.12 26-Feb-2005  perry nuke trailing whitespace
 1.11 09-Jan-2005  chs branches: 1.11.2; 1.11.4;
adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway. there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
 1.10 17-Sep-2004  skrll 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.9 04-May-2004  jrf Remove caddr_t inlines. Approved by christos@NetBSD.org.
 1.8 26-Jan-2004  hannken Fix xxx_strategy() to use the vnode arg instead of bp->b_vp.
 1.7 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.6 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.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.3 07-Jun-2003  reinoud Fix a botch in a boolean expression. Thanks to Martim Husemann for the fix
:)

PR kern/21816: Big DVD's with cd9660 fs (can) crash Alpha can be closed
allready :)
 1.2 16-May-2003  itojun use strlcpy. check size if we are to use namei buffer.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file cd9660_vnops.c was added on branch nathanw_sa on 2002-12-29 19:55:42 +0000
 1.5.2.8 11-Dec-2005  christos Sync with head.
 1.5.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.11.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.2.1 29-Apr-2005  kent sync with -current
 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.15.2.2 29-Oct-2005  yamt cd9660_setattr: remove extra checks. return EOPNOTSUPP immediately.
suggested by Chuck Silvers.
 1.15.2.1 20-Oct-2005  yamt adapt cd9660.
 1.17.2.4 19-Nov-2005  yamt - as read-ahead context is per-vnode now,
there are less reasons to make VOP_READ call uvm_ra_request explicitly.
move it to pager (uvn_get) so that it can handle accesses via mmap as well.
- pass advice to pager via ubc.
- tweak DPRINTF.

XXX can be disturbed by PGO_LOCKED.

XXX it's controversial where it should be done.
(uvm_fault, uvn_get or genfs_getpages.)
 1.17.2.3 19-Nov-2005  yamt - finish reverting VOP_READ prototype changes.
- remove unused variables.
- fix typos.
some of them are pointed by Juan RP.
 1.17.2.2 18-Nov-2005  yamt - associate read-ahead context to vnode, rather than file.
- revert VOP_READ prototype.
 1.17.2.1 15-Nov-2005  yamt adapt the rest of filesystems which use genfs_getpages.
 1.19.6.2 01-Jun-2006  kardel Sync with head.
 1.19.6.1 22-Apr-2006  simonb Sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.19.2.1 05-Feb-2006  yamt adapt cd9660.
 1.20.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.20.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.20.4.2 19-Apr-2006  elad sync with head.
 1.20.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.20.2.1 24-May-2006  yamt sync with head.
 1.22.10.2 10-Dec-2006  yamt sync with head.
 1.22.10.1 22-Oct-2006  yamt sync with head
 1.22.8.1 18-Nov-2006  ad Sync with head.
 1.24.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.24.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.26.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.26.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.26.2.5 24-Oct-2007  ad - Kill ISODEVMAP.
- Mark cd9660 MPSAFE.
 1.26.2.4 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.26.2.3 20-Aug-2007  ad Sync with HEAD.
 1.26.2.2 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.26.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.28.10.2 29-Jul-2007  rumble Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.28.10.1 29-Jul-2007  rumble file cd9660_vnops.c was added on branch matt-mips64 on 2007-07-29 21:17:42 +0000
 1.28.8.1 14-Oct-2007  yamt sync with head.
 1.28.6.3 23-Mar-2008  matt sync with HEAD
 1.28.6.2 09-Jan-2008  matt sync with HEAD
 1.28.6.1 06-Nov-2007  matt sync with HEAD
 1.28.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.28.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.28.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.29.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.29.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.29.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.30.2.2 08-Dec-2007  ad Sync with head.
 1.30.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.32.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.32.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.32.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.2.1 24-Mar-2008  keiichi sync with head.
 1.33.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.4.3 11-Aug-2010  yamt sync with head.
 1.33.4.2 18-Jul-2009  yamt sync with head.
 1.33.4.1 04-May-2009  yamt sync with head.
 1.33.2.1 18-May-2008  yamt sync with head.
 1.34.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.36.2.1 23-Jul-2009  jym Sync with HEAD.
 1.38.4.1 30-May-2010  rmind sync with head
 1.38.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.40.6.1 05-Apr-2012  mrg sync to latest -current.
 1.40.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.40.2.2 23-Jan-2013  yamt sync with head
 1.40.2.1 17-Apr-2012  yamt sync with head
 1.41.2.4 03-Dec-2017  jdolecek update from HEAD
 1.41.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.2.2 23-Jun-2013  tls resync from head
 1.41.2.1 25-Feb-2013  tls resync with head
 1.45.2.1 18-May-2014  rmind sync with head
 1.47.2.1 10-Aug-2014  tls Rebase.
 1.49.4.3 19-Mar-2016  skrll Sync with HEAD
 1.49.4.2 06-Jun-2015  skrll Sync with HEAD
 1.49.4.1 06-Apr-2015  skrll Sync with HEAD
 1.54.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.54.10.1 04-Aug-2019  martin Pull up following revision(s) (requested by maxv in ticket #1322):

sys/fs/cd9660/cd9660_vnops.c: revision 1.55

Fix info leak: zero out the buffer, because it is not entirely filled, and
the uninitialized bytes get copied to userland in sys___getdens30(). Remove
unneeded cast while here.
 1.55.8.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.58.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.152;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.152.1 03-Dec-2017  jdolecek update from HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file files.cd9660 was added on branch nathanw_sa on 2002-12-29 19:55:42 +0000
 1.10 27-Sep-2011  christos define and use ISO_MAXNAMLEN instead of MAXNAMLEN
 1.9 27-Jan-2007  cbiere * Added missing cast in isonum_712().
* Added const-qualifiers.
* Removed unnecessary duplicate prototypes.
* Use the endian conversion functions from <sys/endian.h>.
 1.8 16-Feb-2006  perry branches: 1.8.14;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.7 24-Dec-2005  perry branches: 1.7.2; 1.7.4; 1.7.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 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.5 22-Jun-2005  junyoung branches: 1.5.2;
ANSIfy and de-__P.
 1.4 26-Feb-2005  perry nuke trailing whitespace
 1.3 30-Nov-2004  martin branches: 1.3.4; 1.3.6;
Declare functions with the proper type they return. While there, replace
some strange type names with their C99 equivalent.
This avoids sign extension of 32bit fields (like the file size) on 64bit
archs.
Based on a patch supplied by Olaf 'Rhialto' Seibert in PR kern/28471;
should fix that PR.
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.7 11-Dec-2005  christos Sync with head.
 1.1.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.4 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file iso.h was added on branch nathanw_sa on 2002-12-29 19:55:43 +0000
 1.3.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.4.1 29-Apr-2005  kent sync with -current
 1.5.2.2 26-Feb-2007  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.7.2.1 18-Feb-2006  yamt sync with head.
 1.8.14.1 01-Feb-2007  ad Sync with head.
 1.4 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.3 30-Aug-2005  xtraeme Remove __P()
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move cd9660 filesystem code from sys/isofs/cd9660 to sys/fs/cd9660
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file iso_rrip.h was added on branch nathanw_sa on 2002-12-29 19:55:45 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2007-09-03 14:40:08 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file Makefile was added on branch vmlocking on 2007-07-15 16:15:17 +0000
 1.2 30-Jun-2007  rumble branches: 1.2.2; 1.2.12;
Additional documentation on extents and some artificial limitations SGI
has introduced (and changed in backwards-incompatible ways) over the years.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.2.12.2 03-Sep-2007  yamt sync with head.
 1.2.12.1 30-Jun-2007  yamt file efs.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:08 +0000
 1.2.2.2 15-Jul-2007  ad Sync with head.
 1.2.2.1 30-Jun-2007  ad file efs.h was added on branch vmlocking on 2007-07-15 16:15:20 +0000
 1.3 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.2 30-Jun-2007  rumble branches: 1.2.2; 1.2.12; 1.2.82; 1.2.102;
Additional documentation on extents and some artificial limitations SGI
has introduced (and changed in backwards-incompatible ways) over the years.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.2.102.1 09-Jul-2016  skrll Sync with HEAD
 1.2.82.1 03-Dec-2017  jdolecek update from HEAD
 1.2.12.2 03-Sep-2007  yamt sync with head.
 1.2.12.1 30-Jun-2007  yamt file efs_dinode.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:08 +0000
 1.2.2.2 15-Jul-2007  ad Sync with head.
 1.2.2.1 30-Jun-2007  ad file efs_dinode.h was added on branch vmlocking on 2007-07-15 16:15:21 +0000
 1.2 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12; 1.1.82; 1.1.102;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.102.1 09-Jul-2016  skrll Sync with HEAD
 1.1.82.1 03-Dec-2017  jdolecek update from HEAD
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_dir.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:09 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_dir.h was added on branch vmlocking on 2007-07-15 16:15:21 +0000
 1.3 04-Jul-2007  rumble branches: 1.3.2; 1.3.12;
Additional fixes/enhancements:
1) Comply with the way buffercache(9) is intended to be used. Now we
read in single blocks of EFS_BB_SIZE, never taking in variable
length extents with a single bread() call.

2) Handle symlinks with more than one extent. There's no reason for
this to ever happen, but it's handled now.

3) Finally, add a hint to our iteration initialiser so we can start
from the desired offset, rather than naively looping through from
the beginning each time. Since we can binary search the correct
location quickly, this improves large sequential reads by about
40% with 128MB files. Improvement should increase with file size.
 1.2 30-Jun-2007  rumble Additional documentation on extents and some artificial limitations SGI
has introduced (and changed in backwards-incompatible ways) over the years.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.3.12.2 03-Sep-2007  yamt sync with head.
 1.3.12.1 04-Jul-2007  yamt file efs_extent.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:09 +0000
 1.3.2.2 15-Jul-2007  ad Sync with head.
 1.3.2.1 04-Jul-2007  ad file efs_extent.h was added on branch vmlocking on 2007-07-15 16:15:22 +0000
 1.2 28-May-2018  chs add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12; 1.1.124;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.124.1 25-Jun-2018  pgoyette Sync with HEAD
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_genfs.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:10 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_genfs.c was added on branch vmlocking on 2007-07-15 16:15:22 +0000
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_genfs.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:10 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_genfs.h was added on branch vmlocking on 2007-07-15 16:15:23 +0000
 1.11 07-Aug-2014  hannken Change efs from hashlist to vcache.
 1.10 27-Feb-2014  hannken branches: 1.10.2;
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.9 29-Apr-2012  dsl branches: 1.9.2; 1.9.4;
Remove everything to do with 'struct malloc_type' and the malloc link_set.
To make code in 'external' (etc) still compile, MALLOC_DECLARE() still
has to generate something of type 'struct malloc_type *', with
normal optimisation gcc generates a compile-time 0.
MALLOC_DEFINE() and friends have no effect.
Fix one or two places where the code would no longer compile.
 1.8 27-Jan-2012  para extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.7 12-Jun-2011  rmind branches: 1.7.2; 1.7.6;
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.6 21-Jul-2010  hannken branches: 1.6.6;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.5 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.4 05-May-2008  ad branches: 1.4.20; 1.4.22;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.3 30-Jan-2008  ad branches: 1.3.6; 1.3.8; 1.3.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.2 02-Jan-2008  ad Merge vmlocking2 to head.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.10; 1.1.12; 1.1.18; 1.1.20; 1.1.24;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.24.1 02-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.1.18.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.12.4 04-Feb-2008  yamt sync with head.
 1.1.12.3 21-Jan-2008  yamt sync with head
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_ihash.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:11 +0000
 1.1.10.2 23-Mar-2008  matt sync with HEAD
 1.1.10.1 09-Jan-2008  matt sync with HEAD
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_ihash.c was added on branch vmlocking on 2007-07-15 16:15:24 +0000
 1.3.10.2 11-Aug-2010  yamt sync with head.
 1.3.10.1 16-May-2008  yamt sync with head.
 1.3.8.1 18-May-2008  yamt sync with head.
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.22.3 05-Mar-2011  rmind sync with head
 1.4.22.2 03-Jul-2010  rmind sync with head
 1.4.22.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.4.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.6.2 02-Jun-2012  mrg sync to latest -current.
 1.7.6.1 18-Feb-2012  mrg merge to -current.
 1.7.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.7.2.2 23-May-2012  yamt sync with head.
 1.7.2.1 17-Apr-2012  yamt sync with head
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.2.1 10-Aug-2014  tls Rebase.
 1.2 07-Aug-2014  hannken Change efs from hashlist to vcache.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12; 1.1.82; 1.1.98;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.98.1 10-Aug-2014  tls Rebase.
 1.1.82.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_ihash.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:11 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_ihash.h was added on branch vmlocking on 2007-07-15 16:15:25 +0000
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_inode.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:12 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_inode.h was added on branch vmlocking on 2007-07-15 16:15:27 +0000
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_mount.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:13 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_mount.h was added on branch vmlocking on 2007-07-15 16:15:28 +0000
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file efs_sb.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:14 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file efs_sb.h was added on branch vmlocking on 2007-07-15 16:15:28 +0000
 1.14 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.13 07-Sep-2020  christos fix unaligned access
 1.12 26-Sep-2015  maxv Curious typo. Harmless. Found by Brainy
 1.11 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.10 30-Oct-2013  mrg branches: 1.10.6;
use __diagused where appropriate.
 1.9 20-Oct-2013  christos Now that KASSERT will always consume its arguments, move a KASSERT inside
a DIAGNOSTIC, because the function used is only defined with DIAGNOSTIC.
 1.8 20-Dec-2012  hannken branches: 1.8.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.7 16-May-2008  hannken branches: 1.7.32; 1.7.42;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.6 08-Oct-2007  ad branches: 1.6.18; 1.6.20; 1.6.22; 1.6.24;
Merge brelse() changes from the vmlocking branch.
 1.5 06-Aug-2007  rumble branches: 1.5.2; 1.5.4; 1.5.6; 1.5.8;
Fix a parenthesis bug that would nearly always make the superblock magic
check evaluate to true.
 1.4 29-Jul-2007  rumble branches: 1.4.4;
When computing the superblock checksum, use an unsigned short to avoid an
undesired sign-extension. Now EFS works on big endian machines, too.
 1.3 04-Jul-2007  rumble branches: 1.3.2; 1.3.4;
Clamp down tigher on the bound around 'numextents'. Add a few comments
to make it clearer what we're tracking.
 1.2 04-Jul-2007  rumble Additional fixes/enhancements:
1) Comply with the way buffercache(9) is intended to be used. Now we
read in single blocks of EFS_BB_SIZE, never taking in variable
length extents with a single bread() call.

2) Handle symlinks with more than one extent. There's no reason for
this to ever happen, but it's handled now.

3) Finally, add a hint to our iteration initialiser so we can start
from the desired offset, rather than naively looping through from
the beginning each time. Since we can binary search the correct
location quickly, this improves large sequential reads by about
40% with 128MB files. Improvement should increase with file size.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.3.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.3.2.3 20-Aug-2007  ad Sync with HEAD.
 1.3.2.2 15-Jul-2007  ad Sync with head.
 1.3.2.1 04-Jul-2007  ad file efs_subr.c was added on branch vmlocking on 2007-07-15 16:15:29 +0000
 1.4.4.2 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.4.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.5.8.2 06-Aug-2007  rumble Fix a parenthesis bug that would nearly always make the superblock magic
check evaluate to true.
 1.5.8.1 06-Aug-2007  rumble file efs_subr.c was added on branch matt-mips64 on 2007-08-06 23:25:28 +0000
 1.5.6.1 14-Oct-2007  yamt sync with head.
 1.5.4.3 27-Oct-2007  yamt sync with head.
 1.5.4.2 03-Sep-2007  yamt sync with head.
 1.5.4.1 06-Aug-2007  yamt file efs_subr.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:14 +0000
 1.5.2.1 06-Nov-2007  matt sync with HEAD
 1.6.24.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.6.22.1 04-May-2009  yamt sync with head.
 1.6.20.1 18-May-2008  yamt sync with head.
 1.6.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.42.3 03-Dec-2017  jdolecek update from HEAD
 1.7.42.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.42.1 25-Feb-2013  tls resync with head
 1.7.32.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.7.32.1 23-Jan-2013  yamt sync with head
 1.8.2.1 18-May-2014  rmind sync with head
 1.10.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.10.6.1 06-Apr-2015  skrll Sync with HEAD
 1.2 04-Jul-2007  rumble branches: 1.2.2; 1.2.12;
Additional fixes/enhancements:
1) Comply with the way buffercache(9) is intended to be used. Now we
read in single blocks of EFS_BB_SIZE, never taking in variable
length extents with a single bread() call.

2) Handle symlinks with more than one extent. There's no reason for
this to ever happen, but it's handled now.

3) Finally, add a hint to our iteration initialiser so we can start
from the desired offset, rather than naively looping through from
the beginning each time. Since we can binary search the correct
location quickly, this improves large sequential reads by about
40% with 128MB files. Improvement should increase with file size.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.2.12.2 03-Sep-2007  yamt sync with head.
 1.2.12.1 04-Jul-2007  yamt file efs_subr.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:15 +0000
 1.2.2.2 15-Jul-2007  ad Sync with head.
 1.2.2.1 04-Jul-2007  ad file efs_subr.h was added on branch vmlocking on 2007-07-15 16:15:29 +0000
 1.30 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.29 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.28 17-Feb-2017  hannken branches: 1.28.14; 1.28.20;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.27 07-Jul-2016  msaitoh branches: 1.27.2; 1.27.4;
KNF. Remove extra spaces. No functional change.
 1.26 07-Aug-2014  hannken branches: 1.26.4;
Change efs from hashlist to vcache.
 1.25 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.24 20-Dec-2012  hannken branches: 1.24.2; 1.24.10;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.23 13-Mar-2012  elad branches: 1.23.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.22 12-Jun-2011  rmind branches: 1.22.2; 1.22.6; 1.22.8; 1.22.12; 1.22.14;
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.21 19-Nov-2010  dholland branches: 1.21.6;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.20 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.19 25-Apr-2009  elad branches: 1.19.2; 1.19.4;
Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.18 20-Apr-2009  elad Pass VREAD instead of FREAD to VOP_ACCESS().

Okay christos@.
 1.17 01-Dec-2008  pooka branches: 1.17.4;
Add specfs/fifofs support. Not really fully tested, but at least
vfs routines don't crash now.
(didn't have an image with matching device node numbers)

fixes PR kern/40055 by myself
 1.16 24-Sep-2008  ad branches: 1.16.2; 1.16.4;
Don't assign vnode::v_mount. getnewvnode() does it.
 1.15 10-May-2008  rumble branches: 1.15.4;
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.14 08-Dec-2007  pooka branches: 1.14.12; 1.14.14; 1.14.16; 1.14.18;
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.13 26-Nov-2007  pooka branches: 1.13.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.12 10-Oct-2007  ad branches: 1.12.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.11 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.10 08-Sep-2007  rumble branches: 1.10.2;
Don't explicitly set vp->v_size and then call uvm_vnp_setsize(). This is
not only unnecessary, but trips a kernel assertion introduced in r1.85 of
uvm/uvm_vnode.c.
 1.9 06-Aug-2007  pooka branches: 1.9.2; 1.9.4; 1.9.6;
Make VFS_SYNC always succeed instead of always fail.
Fixes non-forced unmount.
 1.8 31-Jul-2007  pooka branches: 1.8.2;
* 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.7 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.6 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.5 17-Jul-2007  pooka branches: 1.5.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.4 12-Jul-2007  dsl branches: 1.4.2;
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.3 04-Jul-2007  rumble Additional fixes/enhancements:
1) Comply with the way buffercache(9) is intended to be used. Now we
read in single blocks of EFS_BB_SIZE, never taking in variable
length extents with a single bread() call.

2) Handle symlinks with more than one extent. There's no reason for
this to ever happen, but it's handled now.

3) Finally, add a hint to our iteration initialiser so we can start
from the desired offset, rather than naively looping through from
the beginning each time. Since we can binary search the correct
location quickly, this improves large sequential reads by about
40% with 128MB files. Improvement should increase with file size.
 1.2 01-Jul-2007  rumble Remove a superfluous pasted structure definition, permitting ALL to
build again.

Caught by Hisashi T Fujinaka.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.4.2.5 23-Oct-2007  ad Sync with head.
 1.4.2.4 09-Oct-2007  ad Sync with head.
 1.4.2.3 20-Aug-2007  ad Sync with HEAD.
 1.4.2.2 15-Jul-2007  ad Sync with head.
 1.4.2.1 12-Jul-2007  ad file efs_vfsops.c was added on branch vmlocking on 2007-07-15 16:15:30 +0000
 1.5.2.2 10-Sep-2007  skrll Sync with HEAD.
 1.5.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.8.2.5 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.2.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.8.2.3 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.8.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.8.2.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.9.6.2 06-Aug-2007  pooka Make VFS_SYNC always succeed instead of always fail.
Fixes non-forced unmount.
 1.9.6.1 06-Aug-2007  pooka file efs_vfsops.c was added on branch matt-mips64 on 2007-08-06 21:10:25 +0000
 1.9.4.5 21-Jan-2008  yamt sync with head
 1.9.4.4 07-Dec-2007  yamt sync with head
 1.9.4.3 27-Oct-2007  yamt sync with head.
 1.9.4.2 03-Sep-2007  yamt sync with head.
 1.9.4.1 06-Aug-2007  yamt file efs_vfsops.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:15 +0000
 1.9.2.2 09-Jan-2008  matt sync with HEAD
 1.9.2.1 06-Nov-2007  matt sync with HEAD
 1.10.2.1 14-Oct-2007  yamt sync with head.
 1.12.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.12.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.2.1 26-Dec-2007  ad Sync with head.
 1.14.18.2 10-Oct-2008  skrll Sync with HEAD.
 1.14.18.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.16.3 11-Aug-2010  yamt sync with head.
 1.14.16.2 04-May-2009  yamt sync with head.
 1.14.16.1 16-May-2008  yamt sync with head.
 1.14.14.1 18-May-2008  yamt sync with head.
 1.14.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.14.12.2 28-Sep-2008  mjf Sync with HEAD.
 1.14.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.4.1 19-Oct-2008  haad Sync with HEAD.
 1.16.4.2 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.16.4.1 06-Jan-2009  snj branches: 1.16.4.1.6; 1.16.4.1.10;
Pull up following revision(s) (requested by rumble in ticket #216):
sys/fs/efs/efs_vfsops.c: revision 1.17
sys/fs/efs/efs_vnops.c: revision 1.17
Add specfs/fifofs support. Not really fully tested, but at least
vfs routines don't crash now.
(didn't have an image with matching device node numbers)
fixes PR kern/40055 by myself
 1.16.4.1.10.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.16.4.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.16.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.16.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.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.19.4.2 05-Mar-2011  rmind sync with head
 1.19.4.1 03-Jul-2010  rmind sync with head
 1.19.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.14.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.22.12.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.22.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.22.6.1 05-Apr-2012  mrg sync to latest -current.
 1.22.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.22.2.2 23-Jan-2013  yamt sync with head
 1.22.2.1 17-Apr-2012  yamt sync with head
 1.23.2.3 03-Dec-2017  jdolecek update from HEAD
 1.23.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.2.1 25-Feb-2013  tls resync with head
 1.24.10.1 10-Aug-2014  tls Rebase.
 1.24.2.1 18-May-2014  rmind sync with head
 1.26.4.2 28-Aug-2017  skrll Sync with HEAD
 1.26.4.1 09-Jul-2016  skrll Sync with HEAD
 1.27.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.27.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.28.20.1 17-Jan-2020  ad Sync with head.
 1.28.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.44 06-Aug-2022  andvar s/blity/bility/ in various words, mainly in comments.
 1.43 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.42 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.41 27-Jun-2020  christos branches: 1.41.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.40 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.39 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.38 26-May-2017  riastradh branches: 1.38.20;
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.37 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.36 20-Aug-2016  hannken branches: 1.36.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.35 07-Jul-2016  msaitoh branches: 1.35.2;
KNF. Remove extra spaces. No functional change.
 1.34 02-Mar-2016  christos PR/50883: David Binderman: Remove redundant code.
 1.33 07-Aug-2014  hannken branches: 1.33.4;
Change efs from hashlist to vcache.
 1.32 25-Jul-2014  dholland 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.31 07-Feb-2014  hannken branches: 1.31.2;
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.30 18-Mar-2013  plunky branches: 1.30.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.29 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.28 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.27 05-Nov-2012  dholland 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.26 22-Jul-2012  rmind branches: 1.26.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.25 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.24 19-May-2011  rmind branches: 1.24.4; 1.24.8; 1.24.10;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.23 30-Nov-2010  dholland branches: 1.23.2;
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.22 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.21 29-Mar-2010  pooka Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.20 03-Jul-2009  pooka branches: 1.20.2; 1.20.4;
Fix utterly botched previous commit. efs compiles now and apprears
to work, but the person doing the original change should verify
that it actually works like before the change.

(hi, elad!)
 1.19 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.18 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.17 01-Dec-2008  pooka branches: 1.17.4;
Add specfs/fifofs support. Not really fully tested, but at least
vfs routines don't crash now.
(didn't have an image with matching device node numbers)

fixes PR kern/40055 by myself
 1.16 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.15 16-Nov-2008  pooka more <sys/buf.h> police
 1.14 25-Jan-2008  ad branches: 1.14.6; 1.14.10; 1.14.16; 1.14.18; 1.14.20;
Remove VOP_LEASE. Discussed on tech-kern.
 1.13 02-Jan-2008  ad Merge vmlocking2 to head.
 1.12 26-Nov-2007  pooka branches: 1.12.2; 1.12.6;
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.11 10-Oct-2007  ad branches: 1.11.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.10 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.9 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.8 08-Sep-2007  rumble branches: 1.8.2;
In efs_readdir don't foolishly allocate and free dirents for each entry
before copying them out, rather just use a single one. Further, follow
the example of tmpfs and others by simply allocating on the stack.

This should have the side-effect of silencing false Coverity reports like
CID 4559 and 4554.
 1.7 08-Sep-2007  rumble CID 4553:

In efs_lookup, when checking whether a CREATE or RENAME operation would
succeed, be sure to pass the appropriate vnode pointer to VOP_ACCESS.
 1.6 29-Jul-2007  rumble branches: 1.6.4; 1.6.6; 1.6.8; 1.6.10;
Only set *ap->a_cookies when we're returning success. Also, do not hard-
code 16, but rather use _DIRENT_MINSIZE as the divisor when determining
the number of cookies to allocate.

Noticed by pooka@.
 1.5 29-Jul-2007  rumble Support NFS cookies and the eofflag in efs_readdir. Also, be sure to
update uio->uio_offset as not doing so would cause large directory reads
to misbehave.

EFS is now properly NFS-exportable.
 1.4 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.3 04-Jul-2007  rumble branches: 1.3.2; 1.3.4;
Additional fixes/enhancements:
1) Comply with the way buffercache(9) is intended to be used. Now we
read in single blocks of EFS_BB_SIZE, never taking in variable
length extents with a single bread() call.

2) Handle symlinks with more than one extent. There's no reason for
this to ever happen, but it's handled now.

3) Finally, add a hint to our iteration initialiser so we can start
from the desired offset, rather than naively looping through from
the beginning each time. Since we can binary search the correct
location quickly, this improves large sequential reads by about
40% with 128MB files. Improvement should increase with file size.
 1.2 04-Jul-2007  rumble Fix a significant performance bug in efs_read:

When reading a file, we would erroneously iterate to the next extent
before having filled the entire uio request. This lead to unnecessary
extent iteration and excessive calls to efs_read.

Sequential read performance has doubled in the uncached case and
quadrupled when data is buffered.
 1.1 29-Jun-2007  rumble Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.3.4.2 10-Sep-2007  skrll Sync with HEAD.
 1.3.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.3.2.7 09-Oct-2007  ad Sync with head.
 1.3.2.6 09-Oct-2007  ad Sync with head.
 1.3.2.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.3.2.4 20-Aug-2007  ad Sync with HEAD.
 1.3.2.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.3.2.2 15-Jul-2007  ad Sync with head.
 1.3.2.1 04-Jul-2007  ad file efs_vnops.c was added on branch vmlocking on 2007-07-15 16:15:30 +0000
 1.6.10.2 29-Jul-2007  rumble Only set *ap->a_cookies when we're returning success. Also, do not hard-
code 16, but rather use _DIRENT_MINSIZE as the divisor when determining
the number of cookies to allocate.

Noticed by pooka@.
 1.6.10.1 29-Jul-2007  rumble file efs_vnops.c was added on branch matt-mips64 on 2007-07-29 20:58:11 +0000
 1.6.8.6 04-Feb-2008  yamt sync with head.
 1.6.8.5 21-Jan-2008  yamt sync with head
 1.6.8.4 07-Dec-2007  yamt sync with head
 1.6.8.3 27-Oct-2007  yamt sync with head.
 1.6.8.2 03-Sep-2007  yamt sync with head.
 1.6.8.1 29-Jul-2007  yamt file efs_vnops.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:16 +0000
 1.6.6.3 23-Mar-2008  matt sync with HEAD
 1.6.6.2 09-Jan-2008  matt sync with HEAD
 1.6.6.1 06-Nov-2007  matt sync with HEAD
 1.6.4.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.6.4.2 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.6.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.8.2.2 14-Oct-2007  yamt sync with head.
 1.8.2.1 06-Oct-2007  yamt sync with head.
 1.11.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.11.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.14.20.4 06-Jan-2009  snj Apply patch (requested by rumble in ticket #216):
Adjust for the netbsd-5 branch by defining UBC_UNMAP_FLAG.
 1.14.20.3 06-Jan-2009  snj Pull up following revision(s) (requested by rumble in ticket #216):
sys/fs/efs/efs_vfsops.c: revision 1.17
sys/fs/efs/efs_vnops.c: revision 1.17
Add specfs/fifofs support. Not really fully tested, but at least
vfs routines don't crash now.
(didn't have an image with matching device node numbers)
fixes PR kern/40055 by myself
 1.14.20.2 06-Jan-2009  snj Pull up following revision(s) (requested by rumble in ticket #216):
sys/fs/efs/efs_vnops.c: revision 1.16
Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.14.20.1 06-Jan-2009  snj Pull up following revision(s) (requested by rumble in ticket #216):
sys/fs/efs/efs_vnops.c: revision 1.15
more <sys/buf.h> police
 1.14.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.10.3 11-Aug-2010  yamt sync with head.
 1.14.10.2 18-Jul-2009  yamt sync with head.
 1.14.10.1 04-May-2009  yamt sync with head.
 1.14.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.17.4.1 23-Jul-2009  jym Sync with HEAD.
 1.20.4.4 31-May-2011  rmind sync with head
 1.20.4.3 05-Mar-2011  rmind sync with head
 1.20.4.2 03-Jul-2010  rmind sync with head
 1.20.4.1 30-May-2010  rmind sync with head
 1.20.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.20.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.10.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.24.8.1 05-Apr-2012  mrg sync to latest -current.
 1.24.4.5 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.24.4.4 23-Jan-2013  yamt sync with head
 1.24.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.24.4.2 30-Oct-2012  yamt sync with head
 1.24.4.1 17-Apr-2012  yamt sync with head
 1.26.2.5 03-Dec-2017  jdolecek update from HEAD
 1.26.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.3 23-Jun-2013  tls resync from head
 1.26.2.2 25-Feb-2013  tls resync with head
 1.26.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.30.6.1 18-May-2014  rmind sync with head
 1.31.2.1 10-Aug-2014  tls Rebase.
 1.33.4.4 28-Aug-2017  skrll Sync with HEAD
 1.33.4.3 05-Oct-2016  skrll Sync with HEAD
 1.33.4.2 09-Jul-2016  skrll Sync with HEAD
 1.33.4.1 19-Mar-2016  skrll Sync with HEAD
 1.35.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.36.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.38.20.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.41.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.3 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.2 07-Aug-2014  hannken Change efs from hashlist to vcache.
 1.1 29-Jun-2007  rumble branches: 1.1.2; 1.1.12; 1.1.82; 1.1.98;
Add read-only support for SGI's Extent File System.

Reviewed by pooka@.
 1.1.98.1 10-Aug-2014  tls Rebase.
 1.1.82.2 03-Dec-2017  jdolecek update from HEAD
 1.1.82.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.12.2 03-Sep-2007  yamt sync with head.
 1.1.12.1 29-Jun-2007  yamt file files.efs was added on branch yamt-lazymbuf on 2007-09-03 14:40:16 +0000
 1.1.2.2 15-Jul-2007  ad Sync with head.
 1.1.2.1 29-Jun-2007  ad file files.efs was added on branch vmlocking on 2007-07-15 16:15:31 +0000
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-12-29 19:55:45 +0000
 1.5 25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.4 03-Dec-2005  christos branches: 1.4.46; 1.4.52; 1.4.56; 1.4.60;
- 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.3 06-Sep-2003  jdolecek branches: 1.3.16;
sprinkle __attribute__((__packed__)) to structures representing on-disk data

this hopefully fixes problem with reading filecore FS under i386, reported
on current-users@ (thread 'acorn32 disk on i386')
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.4 11-Dec-2005  christos Sync with head.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore.h was added on branch nathanw_sa on 2002-12-29 19:55:46 +0000
 1.3.16.2 21-Jan-2008  yamt sync with head
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.4.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.56.1 26-Dec-2007  ad Sync with head.
 1.4.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.46.1 09-Jan-2008  matt sync with HEAD
 1.11 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.10 20-Dec-2012  hannken branches: 1.10.14;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.9 14-Mar-2009  dsl branches: 1.9.12; 1.9.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 16-May-2008  hannken branches: 1.8.6; 1.8.12;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.7 30-Apr-2008  ad branches: 1.7.2;
Make various bits of debug code compile again.
 1.6 08-Oct-2007  ad branches: 1.6.18; 1.6.20; 1.6.22;
Merge brelse() changes from the vmlocking branch.
 1.5 15-May-2006  christos branches: 1.5.18; 1.5.32; 1.5.34; 1.5.36;
More kauth fallout.
 1.4 14-May-2006  elad integrate kauth.
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.10; 1.3.12;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_bmap.c was added on branch nathanw_sa on 2002-12-29 19:55:47 +0000
 1.2.16.2 27-Oct-2007  yamt sync with head.
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.3.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.3.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.3.8.1 24-May-2006  yamt sync with head.
 1.3.6.1 01-Jun-2006  kardel Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.5.36.1 14-Oct-2007  yamt sync with head.
 1.5.34.1 06-Nov-2007  matt sync with HEAD
 1.5.32.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.5.18.1 20-Aug-2007  ad Sync with HEAD.
 1.6.22.2 04-May-2009  yamt sync with head.
 1.6.22.1 16-May-2008  yamt sync with head.
 1.6.20.1 18-May-2008  yamt sync with head.
 1.6.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.22.2 03-Dec-2017  jdolecek update from HEAD
 1.9.22.1 25-Feb-2013  tls resync with head
 1.9.12.1 23-Jan-2013  yamt sync with head
 1.10.14.1 06-Apr-2015  skrll Sync with HEAD
 1.22 23-Jun-2013  dholland Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.21 19-Jun-2013  dholland blkoff() -> filecore_blkoff()
blksize() -> filecore_blksize()
 1.20 23-May-2011  rmind branches: 1.20.4; 1.20.14;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.19 14-Mar-2009  dsl branches: 1.19.4; 1.19.6;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 28-Jun-2008  rumble branches: 1.18.4; 1.18.10;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.17 24-Sep-2007  rumble branches: 1.17.18; 1.17.22; 1.17.24; 1.17.26;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.16 31-Jul-2007  pooka branches: 1.16.2; 1.16.4; 1.16.6; 1.16.8;
* 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.15 12-Jul-2007  dsl branches: 1.15.2;
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.14 13-Jul-2006  martin branches: 1.14.14;
Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.13 14-May-2006  elad branches: 1.13.4;
integrate kauth.
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 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.10 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.9 20-May-2004  atatat branches: 1.9.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.8 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.7 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.6 04-Dec-2003  atatat branches: 1.6.2;
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.5 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.4 29-Jun-2003  fvdl branches: 1.4.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.3 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_extern.h was added on branch nathanw_sa on 2002-12-29 19:55:48 +0000
 1.4.2.9 11-Dec-2005  christos Sync with head.
 1.4.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.7 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.6 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.5 26-Aug-2004  skrll Missed these in the vget, etc changes.
 1.4.2.4 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.4.2.3 03-Aug-2004  skrll Sync with HEAD
 1.4.2.2 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.4.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.6.2.1 23-May-2004  tron Pull up revision 1.9 (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.9.12.4 27-Oct-2007  yamt sync with head.
 1.9.12.3 03-Sep-2007  yamt sync with head.
 1.9.12.2 30-Dec-2006  yamt sync with head.
 1.9.12.1 21-Jun-2006  yamt sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.2 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.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.2 11-Aug-2006  yamt sync with head
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.1 01-Jun-2006  kardel Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.14.14.3 09-Oct-2007  ad Sync with head.
 1.14.14.2 20-Aug-2007  ad Sync with HEAD.
 1.14.14.1 15-Jul-2007  ad Sync with head.
 1.15.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.16.8.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.16.8.1 31-Jul-2007  pooka file filecore_extern.h was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.16.6.1 06-Oct-2007  yamt sync with head.
 1.16.4.1 06-Nov-2007  matt sync with HEAD
 1.16.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.17.26.1 03-Jul-2008  simonb Sync with head.
 1.17.24.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.22.1 04-May-2009  yamt sync with head.
 1.17.18.1 29-Jun-2008  mjf Sync with HEAD.
 1.18.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.1 31-May-2011  rmind sync with head
 1.20.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.14.1 23-Jun-2013  tls resync from head
 1.20.4.1 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.23 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.22 06-Aug-2022  andvar branches: 1.22.10;
s/blity/bility/ in various words, mainly in comments.
 1.21 04-Oct-2014  hannken Change filecore to vcache.

Compile-tested only, was not able to get my hands on a readable fs image.
 1.20 03-Jun-2014  joerg Introduce two helper functions to centralise the namecache statistics
in vfs_cache.c. Use consistent locking around the per-cpu data.
 1.19 07-Feb-2014  hannken branches: 1.19.2;
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.18 20-Oct-2013  christos remove unused
 1.17 20-Dec-2012  hannken branches: 1.17.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.16 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.15 05-Nov-2012  dholland 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.14 22-Jul-2012  rmind branches: 1.14.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.13 24-Jun-2010  hannken branches: 1.13.8; 1.13.14;
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.12 08-Jan-2010  pooka branches: 1.12.2; 1.12.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.11 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.10 26-Nov-2007  pooka branches: 1.10.18; 1.10.26; 1.10.32;
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.9 08-Oct-2007  ad branches: 1.9.4;
Merge brelse() changes from the vmlocking branch.
 1.8 09-Dec-2006  chs branches: 1.8.6; 1.8.18; 1.8.20; 1.8.22;
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.7 14-May-2006  elad branches: 1.7.8; 1.7.10; 1.7.12;
integrate kauth.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8; 1.6.10; 1.6.12;
merge ktrace-lwp.
 1.5 26-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 07-Aug-2003  agc branches: 1.4.8; 1.4.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 29-Jun-2003  fvdl branches: 1.3.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_lookup.c was added on branch nathanw_sa on 2002-12-29 19:55:48 +0000
 1.3.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.4 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.3.2.3 03-Aug-2004  skrll Sync with HEAD
 1.3.2.2 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.3.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.4.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.8.1 29-Apr-2005  kent sync with -current
 1.5.4.4 07-Dec-2007  yamt sync with head
 1.5.4.3 27-Oct-2007  yamt sync with head.
 1.5.4.2 30-Dec-2006  yamt sync with head.
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.6.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.6.8.1 24-May-2006  yamt sync with head.
 1.6.6.1 01-Jun-2006  kardel Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.12.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.7.10.1 10-Dec-2006  yamt sync with head.
 1.7.8.1 12-Jan-2007  ad Sync with head.
 1.8.22.1 14-Oct-2007  yamt sync with head.
 1.8.20.2 09-Jan-2008  matt sync with HEAD
 1.8.20.1 06-Nov-2007  matt sync with HEAD
 1.8.18.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.8.18.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.8.6.1 20-Aug-2007  ad Sync with HEAD.
 1.9.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.18.3 11-Aug-2010  yamt sync with head.
 1.10.18.2 11-Mar-2010  yamt sync with head
 1.10.18.1 04-May-2009  yamt sync with head.
 1.12.4.1 03-Jul-2010  rmind sync with head
 1.12.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.14.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.13.8.4 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.13.8.3 23-Jan-2013  yamt sync with head
 1.13.8.2 16-Jan-2013  yamt sync with (a bit old) head
 1.13.8.1 30-Oct-2012  yamt sync with head
 1.14.2.4 03-Dec-2017  jdolecek update from HEAD
 1.14.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.2 25-Feb-2013  tls resync with head
 1.14.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.2.1 18-May-2014  rmind sync with head
 1.19.2.1 10-Aug-2014  tls Rebase.
 1.22.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 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.5 25-Sep-2005  jmmv Follow compat naming tradition: rename compat_export_args to export_args30.
 1.4 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.3 03-Oct-2003  yamt branches: 1.3.16;
terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_mount.h was added on branch nathanw_sa on 2002-12-29 19:55:50 +0000
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.31 26-May-2017  riastradh Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.30 26-May-2017  riastradh 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.29 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.28 20-Aug-2016  hannken branches: 1.28.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.27 04-Oct-2014  hannken branches: 1.27.2; 1.27.4;
Change filecore to vcache.

Compile-tested only, was not able to get my hands on a readable fs image.
 1.26 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.25 12-Jun-2011  rmind branches: 1.25.2; 1.25.12; 1.25.16;
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.24 23-May-2011  rmind branches: 1.24.2;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.23 19-May-2011  rmind Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.22 21-Jul-2010  hannken branches: 1.22.2;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.21 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.20 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.19 15-Mar-2009  cegger branches: 1.19.2; 1.19.4;
ansify function definitions
 1.18 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.17 05-May-2008  ad branches: 1.17.8; 1.17.14;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.16 30-Jan-2008  ad branches: 1.16.6; 1.16.8; 1.16.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.15 17-Jan-2008  ad Fix dodgy tests of v_usecount.
 1.14 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.13 02-Jan-2008  ad Merge vmlocking2 to head.
 1.12 26-Nov-2007  pooka branches: 1.12.2; 1.12.6;
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.11 24-Sep-2007  rumble branches: 1.11.4;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.10 30-Jun-2007  pooka branches: 1.10.6; 1.10.8; 1.10.10;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.9 13-Mar-2007  ad Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.8 20-Feb-2007  ad branches: 1.8.4; 1.8.6;
Call genfs_node_destroy() where appropriate.
 1.7 11-Dec-2005  christos branches: 1.7.26;
merge ktrace-lwp.
 1.6 26-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 20-May-2004  atatat branches: 1.5.4; 1.5.6;
Explicitly call pool_init() (and pool_destroy()) when being built as
an _LKM.

This adds pools to the list of things that lkms must do manually
because they're set up with link sets. Not that there's anything
wrong with link sets, but that we need to try harder to remember that
lkms are second class citizens. Of a sort.
 1.4 25-Apr-2004  simonb Initialise (most) pools from a link set instead of explicit calls
to pool_init. Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

Convert struct session, ucred and lockf to pools.
 1.3 27-Mar-2004  atatat Manually attach malloc types when being built as an lkm.
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.6 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.1.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.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.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_node.c was added on branch nathanw_sa on 2002-12-29 19:55:51 +0000
 1.5.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.6.4.7 04-Feb-2008  yamt sync with head.
 1.6.4.6 21-Jan-2008  yamt sync with head
 1.6.4.5 07-Dec-2007  yamt sync with head
 1.6.4.4 27-Oct-2007  yamt sync with head.
 1.6.4.3 03-Sep-2007  yamt sync with head.
 1.6.4.2 26-Feb-2007  yamt sync with head.
 1.6.4.1 21-Jun-2006  yamt sync with head.
 1.7.26.2 24-Mar-2007  yamt sync with head.
 1.7.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.6.1 11-Jul-2007  mjf Sync with head.
 1.8.4.5 09-Oct-2007  ad Sync with head.
 1.8.4.4 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.8.4.3 20-Aug-2007  ad Sync with HEAD.
 1.8.4.2 15-Jul-2007  ad Sync with head.
 1.8.4.1 13-Mar-2007  ad Sync with head.
 1.10.10.1 06-Oct-2007  yamt sync with head.
 1.10.8.3 23-Mar-2008  matt sync with HEAD
 1.10.8.2 09-Jan-2008  matt sync with HEAD
 1.10.8.1 06-Nov-2007  matt sync with HEAD
 1.10.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.11.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.11.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.12.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.12.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.16.10.3 11-Aug-2010  yamt sync with head.
 1.16.10.2 04-May-2009  yamt sync with head.
 1.16.10.1 16-May-2008  yamt sync with head.
 1.16.8.1 18-May-2008  yamt sync with head.
 1.16.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.4.4 31-May-2011  rmind sync with head
 1.19.4.3 05-Mar-2011  rmind sync with head
 1.19.4.2 03-Jul-2010  rmind sync with head
 1.19.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.19.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.22.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.25.16.1 18-May-2014  rmind sync with head
 1.25.12.2 03-Dec-2017  jdolecek update from HEAD
 1.25.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.2.1 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.27.4.1 26-Apr-2017  pgoyette Sync with HEAD
 1.27.2.2 28-Aug-2017  skrll Sync with HEAD
 1.27.2.1 05-Oct-2016  skrll Sync with HEAD
 1.28.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.8 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.7 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.6 04-Oct-2014  hannken branches: 1.6.36;
Change filecore to vcache.

Compile-tested only, was not able to get my hands on a readable fs image.
 1.5 14-Mar-2009  dsl branches: 1.5.22;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.4 03-Dec-2005  christos branches: 1.4.74; 1.4.84; 1.4.90;
- 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.3 19-Aug-2005  christos namlen is u_int16_t now.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.7 11-Dec-2005  christos Sync with head.
 1.1.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.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.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_node.h was added on branch nathanw_sa on 2002-12-29 19:55:52 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.4.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.84.1 28-Apr-2009  skrll Sync with HEAD.
 1.4.74.1 04-May-2009  yamt sync with head.
 1.5.22.1 03-Dec-2017  jdolecek update from HEAD
 1.6.36.1 01-Aug-2021  thorpej Sync with HEAD.
 1.12 29-Sep-2020  msaitoh s/occurence/occurrence/
 1.11 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.10 14-Mar-2009  dsl branches: 1.10.12; 1.10.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.9 30-Apr-2008  ad branches: 1.9.8; 1.9.14;
Make various bits of debug code compile again.
 1.8 08-Oct-2007  ad branches: 1.8.18; 1.8.20; 1.8.22;
Merge brelse() changes from the vmlocking branch.
 1.7 15-May-2006  christos branches: 1.7.18; 1.7.32; 1.7.34; 1.7.36;
More kauth fallout.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8; 1.6.12;
merge ktrace-lwp.
 1.5 19-Aug-2005  christos namlen is u_int16_t now.
 1.4 17-May-2005  christos branches: 1.4.2;
Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.3 26-Feb-2005  perry nuke trailing whitespace
 1.2 07-Aug-2003  agc branches: 1.2.8; 1.2.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_utils.c was added on branch nathanw_sa on 2002-12-29 19:55:52 +0000
 1.2.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.4.2.2 27-Oct-2007  yamt sync with head.
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.6.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.8.1 24-May-2006  yamt sync with head.
 1.6.6.1 01-Jun-2006  kardel Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.36.1 14-Oct-2007  yamt sync with head.
 1.7.34.1 06-Nov-2007  matt sync with HEAD
 1.7.32.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.7.18.1 20-Aug-2007  ad Sync with HEAD.
 1.8.22.2 04-May-2009  yamt sync with head.
 1.8.22.1 16-May-2008  yamt sync with head.
 1.8.20.1 18-May-2008  yamt sync with head.
 1.8.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.22.1 25-Feb-2013  tls resync with head
 1.10.12.1 23-Jan-2013  yamt sync with head
 1.83 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.82 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.81 17-Apr-2017  hannken branches: 1.81.2; 1.81.12; 1.81.18;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.80 17-Apr-2017  hannken Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.79 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.78 28-Mar-2015  maxv branches: 1.78.2; 1.78.4;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.77 04-Oct-2014  hannken branches: 1.77.2;
Change filecore to vcache.

Compile-tested only, was not able to get my hands on a readable fs image.
 1.76 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.75 23-Mar-2014  hannken branches: 1.75.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.74 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.73 25-Dec-2013  mlelstv At least fetch the mount data pointer before using it.
Coverity CID 274525
 1.72 23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.71 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.70 20-Dec-2012  hannken branches: 1.70.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.69 13-Mar-2012  elad branches: 1.69.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.68 14-Nov-2011  hannken branches: 1.68.4; 1.68.6; 1.68.10; 1.68.12;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.67 12-Jun-2011  rmind branches: 1.67.2;
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.66 09-Jun-2011  rmind Remove few references to simple_lock.
 1.65 23-May-2011  rmind branches: 1.65.2;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.64 24-Jun-2010  hannken branches: 1.64.2;
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.63 11-Apr-2010  mlelstv The *_modcmd functions use the module name as prefix.
 1.62 11-Apr-2010  pooka Make module name match MOUNT_NAME. Inspired by PR kern/43110.
 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 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.58 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.57 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.56 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.55 28-Jun-2008  rumble branches: 1.55.4; 1.55.6; 1.55.10; 1.55.16; 1.55.20;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.54 16-May-2008  hannken branches: 1.54.2;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.53 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.52 06-May-2008  ad branches: 1.52.2;
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.51 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.50 29-Apr-2008  ad 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.49 05-Feb-2008  ad branches: 1.49.6; 1.49.8; 1.49.10;
Do genfs_node_init() earlier. PR kern/36162.
 1.48 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.47 28-Jan-2008  dholland 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.46 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.45 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.44 26-Nov-2007  pooka branches: 1.44.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.43 10-Oct-2007  ad branches: 1.43.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.42 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.41 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.40 31-Jul-2007  pooka branches: 1.40.2; 1.40.4; 1.40.6; 1.40.8;
* 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.39 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.38 23-Jul-2007  pooka Initialize size and/or writesize when creating a vnode.
 1.37 17-Jul-2007  pooka branches: 1.37.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.36 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.35 09-Jul-2007  pooka mntflushbuf() cargo cult comment mania cleanup. there is no mntflushbuf().
 1.34 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.33 04-Apr-2007  rmind filecore_mountfs: Remove the dead code - fcmp cannot be non-zero here.
CID: 714
 1.32 04-Mar-2007  jnemeth branches: 1.32.2; 1.32.4;
more caddr_t -> void * fallout
 1.31 19-Jan-2007  hannken branches: 1.31.2;
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.30 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.29 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.28 29-Sep-2006  christos branches: 1.28.2;
Coverity CID 2435: Add KASSERT before NULL deref (from Arnaud Lacombe)
 1.27 23-Jul-2006  ad branches: 1.27.4; 1.27.6;
Use the LWP cached credentials where sane.
 1.26 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.25 15-May-2006  christos branches: 1.25.4;
More kauth fallout.
 1.24 14-May-2006  elad integrate kauth.
 1.23 21-Feb-2006  thorpej branches: 1.23.2; 1.23.4; 1.23.6;
Use device_class() instead of accessing dv_class directly.
 1.22 11-Dec-2005  christos branches: 1.22.2; 1.22.4; 1.22.6;
merge ktrace-lwp.
 1.21 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.20 28-Jun-2005  yamt branches: 1.20.2;
- constify genfs_ops.
- use member designators.
 1.19 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.18 26-Feb-2005  perry branches: 1.18.2;
nuke trailing whitespace
 1.17 02-Jan-2005  thorpej branches: 1.17.2; 1.17.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.16 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.15 15-Aug-2004  mycroft Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
FS-specific checks littered throughout the code. This may be used later to
make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
 1.14 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.13 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.12 04-May-2004  jrf Remove caddr_t inlines. Approved by christos@NetBSD.org.
 1.11 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.10 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.9 24-Mar-2004  atatat branches: 1.9.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.8 05-Dec-2003  bjh21 Include <sys/sysctl.h> for sysctl stuff.
Also, create the vfs.filecore subtree, rather than vfs.union.
 1.7 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.6 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.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.3 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.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_vfsops.c was added on branch nathanw_sa on 2002-12-29 19:55:53 +0000
 1.5.2.12 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.11 01-Apr-2005  skrll Sync with HEAD.
 1.5.2.10 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.9 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.8 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.7 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.6 26-Aug-2004  skrll Missed these in the vget, etc changes.
 1.5.2.5 25-Aug-2004  skrll Sync with HEAD.
 1.5.2.4 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.5.2.3 03-Aug-2004  skrll Sync with HEAD
 1.5.2.2 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.9.2.1 29-May-2004  tron Pull up revision 1.13 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.17.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.2.1 29-Apr-2005  kent sync with -current
 1.18.2.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.20.2.9 11-Feb-2008  yamt sync with head.
 1.20.2.8 04-Feb-2008  yamt sync with head.
 1.20.2.7 21-Jan-2008  yamt sync with head
 1.20.2.6 07-Dec-2007  yamt sync with head
 1.20.2.5 27-Oct-2007  yamt sync with head.
 1.20.2.4 03-Sep-2007  yamt sync with head.
 1.20.2.3 26-Feb-2007  yamt sync with head.
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.22.6.2 01-Jun-2006  kardel Sync with head.
 1.22.6.1 22-Apr-2006  simonb Sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.22.2.1 01-Mar-2006  yamt sync with head.
 1.23.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.23.4.2 19-Apr-2006  elad adapt to kauth...
 1.23.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.23.2.2 11-Aug-2006  yamt sync with head
 1.23.2.1 24-May-2006  yamt sync with head.
 1.25.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.27.6.2 10-Dec-2006  yamt sync with head.
 1.27.6.1 22-Oct-2006  yamt sync with head
 1.27.4.3 01-Feb-2007  ad Sync with head.
 1.27.4.2 12-Jan-2007  ad Sync with head.
 1.27.4.1 18-Nov-2006  ad Sync with head.
 1.28.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.31.2.2 15-Apr-2007  yamt sync with head.
 1.31.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.32.4.1 11-Jul-2007  mjf Sync with head.
 1.32.2.7 09-Oct-2007  ad Sync with head.
 1.32.2.6 24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.32.2.5 20-Aug-2007  ad Sync with HEAD.
 1.32.2.4 29-Jul-2007  ad Add vfs_destroy() to free mount structures. The specificdata_ref was being
leaked.
 1.32.2.3 15-Jul-2007  ad Sync with head.
 1.32.2.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.32.2.1 10-Apr-2007  ad Sync with head.
 1.37.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.40.8.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.40.8.1 31-Jul-2007  pooka file filecore_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.40.6.2 14-Oct-2007  yamt sync with head.
 1.40.6.1 06-Oct-2007  yamt sync with head.
 1.40.4.3 23-Mar-2008  matt sync with HEAD
 1.40.4.2 09-Jan-2008  matt sync with HEAD
 1.40.4.1 06-Nov-2007  matt sync with HEAD
 1.40.2.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.40.2.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.40.2.2 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.40.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.43.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.43.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.43.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.44.2.1 26-Dec-2007  ad Sync with head.
 1.49.10.5 11-Aug-2010  yamt sync with head.
 1.49.10.4 11-Mar-2010  yamt sync with head
 1.49.10.3 18-Jul-2009  yamt sync with head.
 1.49.10.2 04-May-2009  yamt sync with head.
 1.49.10.1 16-May-2008  yamt sync with head.
 1.49.8.1 18-May-2008  yamt sync with head.
 1.49.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.49.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.52.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.52.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.54.2.1 03-Jul-2008  simonb Sync with head.
 1.55.20.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.55.16.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.55.10.2 23-Jul-2009  jym Sync with HEAD.
 1.55.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.55.6.1 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.55.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.61.4.5 12-Jun-2011  rmind sync with head
 1.61.4.4 31-May-2011  rmind sync with head
 1.61.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.61.4.2 03-Jul-2010  rmind sync with head
 1.61.4.1 30-May-2010  rmind sync with head
 1.61.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.61.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.64.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.65.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.67.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.67.2.2 23-Jan-2013  yamt sync with head
 1.67.2.1 17-Apr-2012  yamt sync with head
 1.68.12.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.10.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.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.68.4.1 05-Apr-2012  mrg sync to latest -current.
 1.69.2.3 03-Dec-2017  jdolecek update from HEAD
 1.69.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.2.1 25-Feb-2013  tls resync with head
 1.70.2.1 18-May-2014  rmind sync with head
 1.75.2.1 10-Aug-2014  tls Rebase.
 1.77.2.2 28-Aug-2017  skrll Sync with HEAD
 1.77.2.1 06-Apr-2015  skrll Sync with HEAD
 1.78.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.78.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.78.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.78.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.81.18.1 17-Jan-2020  ad Sync with head.
 1.81.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.81.2.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.50 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.49 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.48 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.47 27-Jun-2020  christos branches: 1.47.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.46 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.45 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.44 20-Apr-2015  riastradh branches: 1.44.28;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.43 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.42 25-Jul-2014  dholland branches: 1.42.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.41 23-Jan-2014  hannken branches: 1.41.2;
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.40 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.39 20-Oct-2013  christos remove unused
 1.38 23-Jun-2013  dholland branches: 1.38.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.37 19-Jun-2013  dholland blkoff() -> filecore_blkoff()
blksize() -> filecore_blksize()
 1.36 18-Mar-2013  plunky C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.35 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.34 13-Mar-2012  elad branches: 1.34.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.33 23-May-2011  rmind branches: 1.33.4; 1.33.8;
Convert some simple_lock(9) uses to mutex(9) and malloc(9) to kmem(9).
 1.32 03-Jul-2009  elad branches: 1.32.4; 1.32.6;
Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.31 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.30 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.29 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.28 26-Nov-2008  pooka branches: 1.28.4;
Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.27 16-May-2008  hannken branches: 1.27.4; 1.27.6;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.26 30-Apr-2008  ad branches: 1.26.2;
Make various bits of debug code compile again.
 1.25 25-Jan-2008  ad branches: 1.25.6; 1.25.8; 1.25.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.24 26-Nov-2007  pooka 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.23 08-Oct-2007  ad branches: 1.23.4;
Merge brelse() changes from the vmlocking branch.
 1.22 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.21 29-Jul-2007  rumble branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10;
Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.20 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.19 04-Mar-2007  jnemeth branches: 1.19.2; 1.19.10;
yet more caddr_t -> void * fallout
 1.18 15-May-2006  christos branches: 1.18.14;
More kauth fallout.
 1.17 14-May-2006  elad integrate kauth.
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
merge ktrace-lwp.
 1.15 29-Nov-2005  yamt merge yamt-readahead branch.
 1.14 02-Nov-2005  yamt branches: 1.14.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.13 19-Aug-2005  christos branches: 1.13.2;
namlen is u_int16_t now.
 1.12 19-Aug-2005  christos Add an _ to DIRENT_SIZE
 1.11 09-Jan-2005  chs branches: 1.11.10;
adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway. there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
 1.10 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.9 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.8 26-Jan-2004  hannken Fix xxx_strategy() to use the vnode arg instead of bp->b_vp.
 1.7 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.6 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.5 06-Jul-2003  rearnsha Fix a build failure when NFSSERVER. Unconditionally define
filecore_lease_check to genfs_lease_check (was previously lease_check
which isn't defined anywhere). No need to include opt_nfsserver.h
any more.
 1.4 26-Jun-2003  itojun branches: 1.4.2;
strlcpy
 1.3 23-Jun-2003  martin #ifdef _KERNEL_OPT police
 1.2 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file filecore_vnops.c was added on branch nathanw_sa on 2002-12-29 19:55:53 +0000
 1.4.2.9 11-Dec-2005  christos Sync with head.
 1.4.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.4.2.6 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.4.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 03-Jul-2003  wrstuden LWP-ify filecore 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.

Also, some how or another, this code missed out on the changes to use
genfs_lease_check, and had a dangling reference to lease_check().
Given that genfs_lease_check has been around since 1998, I'm puzzled as
to what's been going on. Noticed in a compild of acorn32/GENERIC.
 1.11.10.5 04-Feb-2008  yamt sync with head.
 1.11.10.4 07-Dec-2007  yamt sync with head
 1.11.10.3 27-Oct-2007  yamt sync with head.
 1.11.10.2 03-Sep-2007  yamt sync with head.
 1.11.10.1 21-Jun-2006  yamt sync with head.
 1.13.2.1 20-Oct-2005  yamt adapt filecore.
 1.14.2.3 19-Nov-2005  yamt - as read-ahead context is per-vnode now,
there are less reasons to make VOP_READ call uvm_ra_request explicitly.
move it to pager (uvn_get) so that it can handle accesses via mmap as well.
- pass advice to pager via ubc.
- tweak DPRINTF.

XXX can be disturbed by PGO_LOCKED.

XXX it's controversial where it should be done.
(uvm_fault, uvn_get or genfs_getpages.)
 1.14.2.2 18-Nov-2005  yamt - associate read-ahead context to vnode, rather than file.
- revert VOP_READ prototype.
 1.14.2.1 15-Nov-2005  yamt adapt the rest of filesystems which use genfs_getpages.
 1.16.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.16.8.1 24-May-2006  yamt sync with head.
 1.16.6.1 01-Jun-2006  kardel Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.18.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.19.2.3 09-Oct-2007  ad Sync with head.
 1.19.2.2 20-Aug-2007  ad Sync with HEAD.
 1.19.2.1 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.21.10.2 29-Jul-2007  rumble Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.21.10.1 29-Jul-2007  rumble file filecore_vnops.c was added on branch matt-mips64 on 2007-07-29 21:17:42 +0000
 1.21.8.2 14-Oct-2007  yamt sync with head.
 1.21.8.1 06-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 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.21.4.2 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.21.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.23.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.23.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.10.3 18-Jul-2009  yamt sync with head.
 1.25.10.2 04-May-2009  yamt sync with head.
 1.25.10.1 16-May-2008  yamt sync with head.
 1.25.8.1 18-May-2008  yamt sync with head.
 1.25.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.25.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.27.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.4.2 23-Jul-2009  jym Sync with HEAD.
 1.28.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.4.1 31-May-2011  rmind sync with head
 1.33.8.1 05-Apr-2012  mrg sync to latest -current.
 1.33.4.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.33.4.2 23-Jan-2013  yamt sync with head
 1.33.4.1 17-Apr-2012  yamt sync with head
 1.34.2.4 03-Dec-2017  jdolecek update from HEAD
 1.34.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.2.2 23-Jun-2013  tls resync from head
 1.34.2.1 25-Feb-2013  tls resync with head
 1.38.2.1 18-May-2014  rmind sync with head
 1.41.2.1 10-Aug-2014  tls Rebase.
 1.42.4.2 06-Jun-2015  skrll Sync with HEAD
 1.42.4.1 06-Apr-2015  skrll Sync with HEAD
 1.44.28.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.47.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.4 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.3 11-Dec-2005  christos branches: 1.3.120;
merge ktrace-lwp.
 1.2 26-Feb-2005  perry nuke trailing whitespace
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14;
move filecorefs code from sys/filecorefs to sys/fs/filecorefs
 1.1.14.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.12.1 29-Apr-2005  kent sync with -current
 1.1.4.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file files.filecorefs was added on branch nathanw_sa on 2002-12-29 19:55:53 +0000
 1.3.120.1 03-Dec-2017  jdolecek update from HEAD
 1.2 06-Mar-2007  dillo branches: 1.2.4; 1.2.20;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2.20.2 03-Sep-2007  yamt sync with head.
 1.2.20.1 06-Mar-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2007-09-03 14:40:18 +0000
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file Makefile was added on branch yamt-idlelwp on 2007-03-12 06:14:51 +0000
 1.3 22-Mar-2007  dillo branches: 1.3.12;
Add a few.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file TODO was added on branch yamt-idlelwp on 2007-03-12 06:14:51 +0000
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.3.12.2 03-Sep-2007  yamt sync with head.
 1.3.12.1 22-Mar-2007  yamt file TODO was added on branch yamt-lazymbuf on 2007-09-03 14:40:18 +0000
 1.4 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.3 10-Aug-2014  hannken Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
 1.2 06-Mar-2007  dillo branches: 1.2.4; 1.2.20; 1.2.90;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.90.2 03-Dec-2017  jdolecek update from HEAD
 1.2.90.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.20.2 03-Sep-2007  yamt sync with head.
 1.2.20.1 06-Mar-2007  yamt file files.hfs was added on branch yamt-lazymbuf on 2007-09-03 14:40:19 +0000
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file files.hfs was added on branch yamt-idlelwp on 2007-03-12 06:14:52 +0000
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.12 24-Jul-2020  skrll Replace the */ I accidentally removed in the last commit
 1.11 23-Jul-2020  skrll unifdef -U_LKM
 1.10 23-Jul-2020  skrll Trailing whitespace
 1.9 10-Aug-2014  hannken Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
 1.8 28-Jan-2012  joerg branches: 1.8.6;
Include sys/malloc.h for MALLOC_DECLARE.
 1.7 03-Sep-2008  gmcgarry branches: 1.7.28; 1.7.32;
Don't use unnamed structures.
 1.6 08-Aug-2007  pooka branches: 1.6.4; 1.6.24; 1.6.28; 1.6.30; 1.6.34;
sprinkle #ifdef _KERNEL
 1.5 31-Jul-2007  pooka branches: 1.5.2; 1.5.4;
* 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.4 12-Jul-2007  dsl branches: 1.4.2;
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.3 22-Mar-2007  dillo Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file hfs.h was added on branch yamt-idlelwp on 2007-03-12 06:14:52 +0000
 1.2.2.3 20-Aug-2007  ad Sync with HEAD.
 1.2.2.2 15-Jul-2007  ad Sync with head.
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.4.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.4.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.5.4.1 31-Jul-2007  pooka file hfs.h was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.5.2.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.6.34.1 19-Oct-2008  haad Sync with HEAD.
 1.6.30.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.28.1 04-May-2009  yamt sync with head.
 1.6.24.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.4.2 03-Sep-2007  yamt sync with head.
 1.6.4.1 08-Aug-2007  yamt file hfs.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:19 +0000
 1.7.32.1 18-Feb-2012  mrg merge to -current.
 1.7.28.1 17-Apr-2012  yamt sync with head
 1.8.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14 10-Aug-2014  hannken Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
 1.13 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.12 12-Jun-2011  rmind branches: 1.12.2; 1.12.12; 1.12.16;
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.11 21-Jul-2010  hannken branches: 1.11.6;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.10 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.9 03-Sep-2008  gmcgarry branches: 1.9.14; 1.9.16;
Don't use unnamed structures.
 1.8 05-May-2008  ad branches: 1.8.2; 1.8.6;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.7 30-Jan-2008  ad branches: 1.7.6; 1.7.8; 1.7.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.6 25-Jan-2008  ad - Fix probelms with inode hash: make MPSAFE, don't allocate with held locks.
- Replace use of lockmgr().
 1.5 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.4 02-Jan-2008  ad Merge vmlocking2 to head.
 1.3 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.18; 1.2.20; 1.2.26; 1.2.28; 1.2.30; 1.2.32;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.32.3 08-Jan-2008  bouyer Sync with HEAD
 1.2.32.2 02-Jan-2008  bouyer Sync with HEAD
 1.2.32.1 13-Dec-2007  bouyer Sync with HEAD
 1.2.30.1 11-Dec-2007  yamt sync with head.
 1.2.28.2 26-Dec-2007  ad Sync with head.
 1.2.28.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.2.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.20.4 04-Feb-2008  yamt sync with head.
 1.2.20.3 21-Jan-2008  yamt sync with head
 1.2.20.2 03-Sep-2007  yamt sync with head.
 1.2.20.1 06-Mar-2007  yamt file hfs_nhash.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:20 +0000
 1.2.18.2 23-Mar-2008  matt sync with HEAD
 1.2.18.1 09-Jan-2008  matt sync with HEAD
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file hfs_nhash.c was added on branch yamt-idlelwp on 2007-03-12 06:14:52 +0000
 1.2.2.1 05-Apr-2007  ad Compile fixes.
 1.7.10.3 11-Aug-2010  yamt sync with head.
 1.7.10.2 04-May-2009  yamt sync with head.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.6.1 19-Oct-2008  haad Sync with HEAD.
 1.8.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.16.3 05-Mar-2011  rmind sync with head
 1.9.16.2 03-Jul-2010  rmind sync with head
 1.9.16.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.9.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.16.1 18-May-2014  rmind sync with head
 1.12.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.1 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.19 21-Jun-2015  maxv KNF
 1.18 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.17 14-Nov-2011  hannken branches: 1.17.10; 1.17.28;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.16 13-Nov-2011  christos use getdisksize()
 1.15 24-Feb-2011  christos branches: 1.15.4;
simplify and handle unaligned pointer access.
 1.14 24-Jun-2010  hannken branches: 1.14.2; 1.14.4;
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.13 27-Nov-2009  pooka branches: 1.13.2; 1.13.4;
Yes, you need a VOP_UNLOCK() there.
 1.12 26-Mar-2009  pooka pretend to do some sort of cleanup in error branches
 1.11 16-Nov-2008  pooka branches: 1.11.4;
more <sys/buf.h> police
 1.10 03-Sep-2008  gmcgarry branches: 1.10.2;
Don't use unnamed structures.
 1.9 16-May-2008  hannken branches: 1.9.4;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.8 24-Jan-2008  ad branches: 1.8.6; 1.8.8; 1.8.10; 1.8.12;
specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.7 02-Jan-2008  ad Merge vmlocking2 to head.
 1.6 26-Nov-2007  pooka branches: 1.6.2; 1.6.6;
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.5 10-Oct-2007  ad branches: 1.5.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.4 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.3 22-Mar-2007  dillo branches: 1.3.8; 1.3.10; 1.3.12; 1.3.14;
Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.

Based on work from and test image provided by Pelle Johansson.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file hfs_subr.c was added on branch yamt-idlelwp on 2007-03-12 06:14:52 +0000
 1.2.2.5 23-Oct-2007  ad Sync with head.
 1.2.2.4 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.2.2.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.2.2.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.3.14.1 14-Oct-2007  yamt sync with head.
 1.3.12.6 04-Feb-2008  yamt sync with head.
 1.3.12.5 21-Jan-2008  yamt sync with head
 1.3.12.4 07-Dec-2007  yamt sync with head
 1.3.12.3 27-Oct-2007  yamt sync with head.
 1.3.12.2 03-Sep-2007  yamt sync with head.
 1.3.12.1 22-Mar-2007  yamt file hfs_subr.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:20 +0000
 1.3.10.3 23-Mar-2008  matt sync with HEAD
 1.3.10.2 09-Jan-2008  matt sync with HEAD
 1.3.10.1 06-Nov-2007  matt sync with HEAD
 1.3.8.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.3.8.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.5.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.5.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.8.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.10.3 11-Aug-2010  yamt sync with head.
 1.8.10.2 11-Mar-2010  yamt sync with head
 1.8.10.1 04-May-2009  yamt sync with head.
 1.8.8.1 18-May-2008  yamt sync with head.
 1.8.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.8.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.8.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.9.4.1 19-Oct-2008  haad Sync with HEAD.
 1.10.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.10.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.4.2 05-Mar-2011  rmind sync with head
 1.13.4.1 03-Jul-2010  rmind sync with head
 1.13.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.14.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.4.1 17-Apr-2012  yamt sync with head
 1.17.28.2 22-Sep-2015  skrll Sync with HEAD
 1.17.28.1 06-Apr-2015  skrll Sync with HEAD
 1.17.10.1 03-Dec-2017  jdolecek update from HEAD
 1.38 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.37 28-Feb-2020  kamil Avoid undefined behavior in left shift semantics

hfs_vfsops.c:477:19, left shift of 1 by 31 places cannot be represented in type 'int'
 1.36 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.35 10-Dec-2018  maxv branches: 1.35.6;
Remove unused mbuf.h includes.
 1.34 17-Feb-2017  hannken branches: 1.34.4; 1.34.12; 1.34.14;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.33 29-Dec-2014  maxv branches: 1.33.2; 1.33.4;
Small cleanup:
- KNF
- malloc + memset -> malloc(|M_ZERO)
- no need to check data == NULL
 1.32 10-Aug-2014  hannken branches: 1.32.4;
Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
 1.31 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.30 23-Mar-2014  hannken branches: 1.30.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.29 13-Jun-2012  joerg branches: 1.29.2; 1.29.4;
Ensure that error is initialized in all code paths.
 1.28 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.27 12-Jun-2011  rmind branches: 1.27.2; 1.27.6; 1.27.8;
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.26 24-Jun-2010  hannken branches: 1.26.6;
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.25 08-Jan-2010  pooka branches: 1.25.2; 1.25.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.24 03-Dec-2009  pooka vrele, not vput for unlocked devvp
 1.23 27-Nov-2009  pooka Fix another fine example of "if you make the kernel panic, it's
more secure".
 1.22 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.21 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.20 17-Dec-2008  cegger branches: 1.20.2;
kill MALLOC and FREE macros.
 1.19 03-Sep-2008  gmcgarry branches: 1.19.2; 1.19.4; 1.19.12; 1.19.16;
Don't use unnamed structures.
 1.18 10-May-2008  rumble branches: 1.18.4;
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.17 29-Apr-2008  ad branches: 1.17.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.16 28-Jan-2008  dholland branches: 1.16.6; 1.16.8; 1.16.10;
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.15 25-Jan-2008  ad - Fix probelms with inode hash: make MPSAFE, don't allocate with held locks.
- Replace use of lockmgr().
 1.14 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.13 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.12 26-Nov-2007  pooka branches: 1.12.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.11 25-Nov-2007  pooka * Use vfs_stdextattrctl instead of a homegrown version. Also fixes
a bug: the homegrown version neglected to unlock vp
* don't reimplement eopnotsupp()
* init genfs_node earlier vget, protects against error paths in vget
from attempting to destroy a non-inited node
 1.10 10-Oct-2007  ad branches: 1.10.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.9 31-Jul-2007  pooka branches: 1.9.2; 1.9.4; 1.9.6; 1.9.8; 1.9.10;
* 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.8 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.7 17-Jul-2007  pooka branches: 1.7.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.6 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.5 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.4 22-Mar-2007  dillo Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.

Based on work from and test image provided by Pelle Johansson.
 1.3 19-Mar-2007  dillo args.path is in UIO_USERSPACE too.
Fixes statvfs on macppc and PR kern/36012.
Thanks to Magnus Henoch for testing.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file hfs_vfsops.c was added on branch yamt-idlelwp on 2007-03-12 06:14:52 +0000
 1.2.2.5 23-Oct-2007  ad Sync with head.
 1.2.2.4 20-Aug-2007  ad Sync with HEAD.
 1.2.2.3 15-Jul-2007  ad Sync with head.
 1.2.2.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.2.2.1 10-Apr-2007  ad Sync with head.
 1.7.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.9.10.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.9.10.1 31-Jul-2007  pooka file hfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.9.8.1 14-Oct-2007  yamt sync with head.
 1.9.6.6 04-Feb-2008  yamt sync with head.
 1.9.6.5 21-Jan-2008  yamt sync with head
 1.9.6.4 07-Dec-2007  yamt sync with head
 1.9.6.3 27-Oct-2007  yamt sync with head.
 1.9.6.2 03-Sep-2007  yamt sync with head.
 1.9.6.1 31-Jul-2007  yamt file hfs_vfsops.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:21 +0000
 1.9.4.3 23-Mar-2008  matt sync with HEAD
 1.9.4.2 09-Jan-2008  matt sync with HEAD
 1.9.4.1 06-Nov-2007  matt sync with HEAD
 1.9.2.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.9.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.9.2.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.10.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.10.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.10.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.2.1 26-Dec-2007  ad Sync with head.
 1.16.10.5 11-Aug-2010  yamt sync with head.
 1.16.10.4 11-Mar-2010  yamt sync with head
 1.16.10.3 18-Jul-2009  yamt sync with head.
 1.16.10.2 04-May-2009  yamt sync with head.
 1.16.10.1 16-May-2008  yamt sync with head.
 1.16.8.1 18-May-2008  yamt sync with head.
 1.16.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.16.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.16.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.4.1 19-Oct-2008  haad Sync with HEAD.
 1.19.16.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.19.12.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.19.4.1 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.19.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.19.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.2.2 23-Jul-2009  jym Sync with HEAD.
 1.20.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.4.3 21-May-2011  rmind Fix the build.
 1.25.4.2 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.25.4.1 03-Jul-2010  rmind sync with head
 1.25.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.26.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.27.8.2 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.27.8.1 24-Jun-2012  jdc branches: 1.27.8.1.4; 1.27.8.1.6;
Pull up revisions:
src/sys/fs/hfs/hfs_vfsops.c revision 1.29
src/sys/fs/sysvbfs/sysvbfs_vfsops.c revision 1.40
src/sys/fs/v7fs/v7fs_vfsops.c revision 1.7
(requested by joerg in ticket #344).
 1.27.8.1.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.27.8.1.4.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.27.6.1 05-Apr-2012  mrg sync to latest -current.
 1.27.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.27.2.2 30-Oct-2012  yamt sync with head
 1.27.2.1 17-Apr-2012  yamt sync with head
 1.29.4.1 18-May-2014  rmind sync with head
 1.29.2.2 03-Dec-2017  jdolecek update from HEAD
 1.29.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.2.1 10-Aug-2014  tls Rebase.
 1.32.4.2 28-Aug-2017  skrll Sync with HEAD
 1.32.4.1 06-Apr-2015  skrll Sync with HEAD
 1.33.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.33.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.34.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.14.1 10-Jun-2019  christos Sync with HEAD
 1.34.12.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.34.4.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.35.6.2 29-Feb-2020  ad Sync with head.
 1.35.6.1 17-Jan-2020  ad Sync with head.
 1.40 06-Aug-2022  andvar s/blity/bility/ in various words, mainly in comments.
 1.39 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.38 29-Jun-2021  dholland Implement VOP_PARSEPATH() for hfs.

This checks for a following "/rsrc" at the end of the pathname (to
indicate the resource fork of a file) and assimilates it into the
component name to be looked up. Then cn_namelen will already include
this text in lookup, and it's no longer necessary to muck with
cn_consume.

Invalid uses of "/rsrc" are ignored rather than rejected, which
appears to be the same as the old behavior. It is possible that the
parsepath logic should only consume the "/rsrc" if the name names a
file and not a directory, which would require looking it up in
parsepath and be a general nuisance; I hope not. It's also possible
that the whole thing doesn't work at all now, or it didn't before, as
I don't have any way to test it.
 1.37 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.36 16-May-2020  christos branches: 1.36.6;
Add ACL support for FFS. From FreeBSD.
 1.35 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.34 26-May-2017  riastradh branches: 1.34.20;
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.33 20-Aug-2016  hannken Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.32 21-Jun-2015  maxv KNF
 1.31 10-Aug-2014  hannken branches: 1.31.4;
Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
 1.30 25-Jul-2014  dholland 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.29 07-Feb-2014  hannken branches: 1.29.2;
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.28 18-Oct-2013  christos remove unused variables
 1.27 18-Mar-2013  plunky branches: 1.27.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.26 22-Jul-2012  rmind branches: 1.26.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.25 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.24 27-Sep-2011  christos branches: 1.24.2; 1.24.6; 1.24.8;
use NAME_MAX instead of MAXNAMLEN
 1.23 19-May-2011  rmind Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.22 10-Feb-2011  christos remove comments about needing to encode : since the on disk format does
not allow them. Also fix reversed encoding in lookup. From Taylor R Campbell.
 1.21 10-Feb-2011  christos PR/44523: Taylor R Campbell: mount_hfs badly handles file names with slashes
in them, encode them as colons. XXX: Should encode : as :: too?
 1.20 07-Feb-2011  jakllsch Make this build.

Also, the previous commit contanined "unintended" functional changes I'm
going to ignore.
 1.19 07-Feb-2011  christos KNF, no functional changes intended.
 1.18 24-Jun-2010  hannken branches: 1.18.2; 1.18.4;
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.17 29-Mar-2010  pooka Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.16 08-Jan-2010  pooka branches: 1.16.2; 1.16.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.15 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.14 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.13 17-Dec-2008  cegger branches: 1.13.2;
kill MALLOC and FREE macros.
 1.12 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.11 03-Sep-2008  gmcgarry branches: 1.11.2; 1.11.4;
Don't use unnamed structures.
 1.10 29-Apr-2008  ad branches: 1.10.2; 1.10.6;
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.9 30-Jan-2008  ad branches: 1.9.6; 1.9.8; 1.9.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.8 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.7 03-Jan-2008  pooka struct vop_foo_args comment police: a_l has ceased to be
 1.6 08-Dec-2007  pooka branches: 1.6.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.5 26-Nov-2007  pooka branches: 1.5.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.4 17-Aug-2007  pooka branches: 1.4.2; 1.4.4; 1.4.10;
In the new world order (a.k.a. the human-understandable world order)
VOP_LOOKUP ignores LOCKPARENT completely, so make this ignore it also.

XXX: tested only with rump, but I can't really see how this worked
at all before
 1.3 22-Mar-2007  dillo branches: 1.3.4; 1.3.8;
Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.

Based on work from and test image provided by Pelle Johansson.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file hfs_vnops.c was added on branch yamt-idlelwp on 2007-03-12 06:14:55 +0000
 1.2.2.2 20-Aug-2007  ad Sync with HEAD.
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.3.8.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.8.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.3.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.3.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.4.10.3 18-Feb-2008  mjf Sync with HEAD.
 1.4.10.2 27-Dec-2007  mjf Sync with HEAD.
 1.4.10.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.4.5 04-Feb-2008  yamt sync with head.
 1.4.4.4 21-Jan-2008  yamt sync with head
 1.4.4.3 07-Dec-2007  yamt sync with head
 1.4.4.2 03-Sep-2007  yamt sync with head.
 1.4.4.1 17-Aug-2007  yamt file hfs_vnops.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:21 +0000
 1.4.2.2 23-Mar-2008  matt sync with HEAD
 1.4.2.1 09-Jan-2008  matt sync with HEAD
 1.5.2.1 26-Dec-2007  ad Sync with head.
 1.6.4.1 08-Jan-2008  bouyer Sync with HEAD
 1.9.10.5 11-Aug-2010  yamt sync with head.
 1.9.10.4 11-Mar-2010  yamt sync with head
 1.9.10.3 18-Jul-2009  yamt sync with head.
 1.9.10.2 04-May-2009  yamt sync with head.
 1.9.10.1 16-May-2008  yamt sync with head.
 1.9.8.1 18-May-2008  yamt sync with head.
 1.9.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.9.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.9.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.10.6.1 19-Oct-2008  haad Sync with HEAD.
 1.10.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.4.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by dholland in ticket #1554):
sys/fs/hfs/hfs_vnops.c: revision 1.21, 1.22 via patch
PR/44523: Taylor R Campbell: mount_hfs badly handles file names with slashes
in them, encode them as colons. XXX: Should encode : as :: too?
remove comments about needing to encode : since the on disk format does
not allow them. Also fix reversed encoding in lookup. From Taylor R Campbell.
 1.11.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.2.1 23-Jul-2009  jym Sync with HEAD.
 1.16.4.4 31-May-2011  rmind sync with head
 1.16.4.3 05-Mar-2011  rmind sync with head
 1.16.4.2 03-Jul-2010  rmind sync with head
 1.16.4.1 30-May-2010  rmind sync with head
 1.16.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.18.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.8.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.24.6.1 05-Apr-2012  mrg sync to latest -current.
 1.24.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.24.2.2 30-Oct-2012  yamt sync with head
 1.24.2.1 17-Apr-2012  yamt sync with head
 1.26.2.3 03-Dec-2017  jdolecek update from HEAD
 1.26.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.1 23-Jun-2013  tls resync from head
 1.27.6.1 18-May-2014  rmind sync with head
 1.29.2.1 10-Aug-2014  tls Rebase.
 1.31.4.3 28-Aug-2017  skrll Sync with HEAD
 1.31.4.2 05-Oct-2016  skrll Sync with HEAD
 1.31.4.1 22-Sep-2015  skrll Sync with HEAD
 1.34.20.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.36.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.19 11-Aug-2023  mrg avoid uninitialised variable usage in early error paths.

found by GCC 12.
 1.18 19-Jun-2023  msaitoh Fix typo. unknwon -> unknown
 1.17 01-Mar-2023  riastradh fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.16 01-Mar-2023  riastradh fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.15 30-Dec-2018  sevan branches: 1.15.4; 1.15.30;
Fix support for case sensitive HFS.
Without this change, the wrong file is returned, if 2 file names contain a
subset of each other.


Code submitted in PR bin/52993 by Harold Gutch
 1.14 21-Jun-2015  maxv branches: 1.14.10; 1.14.16; 1.14.18;
KNF
 1.13 29-Dec-2014  maxv I started to KNF this file but quickly ended up figuring out I was not
courageous enough for such ugliness. So I only KNF'ed the first 300
lines.

I'll come back later.
 1.12 28-Jul-2012  matt branches: 1.12.2; 1.12.16;
Fix -fno-common found by building i386/conf/ALL
 1.11 15-Jun-2012  joerg Assert that out_hr is not NULL in hfslib_read_header_node
 1.10 24-Feb-2011  christos branches: 1.10.4;
simplify and avoid pointer gymnastics
 1.9 27-Nov-2009  pooka branches: 1.9.4; 1.9.6; 1.9.8;
Don't spam if mount fails due to invalid file system.
 1.8 14-Jul-2009  apb Initialise the "fork" local variable in hfslib_get_file_extents().
This variable was not actually used uninitialised, but some compilers
(e.g. gcc-4.3.3) warned that the variable might be used uninitialised.
Inspired by PR 41255 from Kurt Lidl.
 1.7 27-Mar-2009  pooka fix botch in previous
 1.6 26-Mar-2009  pooka pretend to do some sort of cleanup in error branches
 1.5 11-Dec-2007  lukem branches: 1.5.12; 1.5.20; 1.5.26;
use __KERNEL_RCSID()
 1.4 22-Mar-2007  dillo branches: 1.4.10; 1.4.12; 1.4.20; 1.4.22; 1.4.24;
Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.

Based on work from and test image provided by Pelle Johansson.
 1.3 09-Mar-2007  dillo branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
Fix PR kern/35953 by mange at freemail dot hu (panic on mount):
(hfslib_open_volume) We are only interested in the catalgo and
extents header, so read the first 512 bytes, not the whole first
extent. Also makes mounting a lot faster.
 1.2 06-Mar-2007  dillo Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.3.8.1 29-Mar-2007  reinoud Pullup to -current
 1.3.6.1 11-Jul-2007  mjf Sync with head.
 1.3.4.3 24-Mar-2007  yamt sync with head.
 1.3.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.3.4.1 09-Mar-2007  rmind file libhfs.c was added on branch yamt-idlelwp on 2007-03-12 06:14:55 +0000
 1.3.2.1 10-Apr-2007  ad Sync with head.
 1.4.24.1 13-Dec-2007  bouyer Sync with HEAD
 1.4.22.1 11-Dec-2007  yamt sync with head.
 1.4.20.1 26-Dec-2007  ad Sync with head.
 1.4.12.3 21-Jan-2008  yamt sync with head
 1.4.12.2 03-Sep-2007  yamt sync with head.
 1.4.12.1 22-Mar-2007  yamt file libhfs.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:22 +0000
 1.4.10.1 09-Jan-2008  matt sync with HEAD
 1.5.26.2 23-Jul-2009  jym Sync with HEAD.
 1.5.26.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.20.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.12.3 11-Mar-2010  yamt sync with head
 1.5.12.2 18-Jul-2009  yamt sync with head.
 1.5.12.1 04-May-2009  yamt sync with head.
 1.9.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.9.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.10.4.1 30-Oct-2012  yamt sync with head
 1.12.16.2 22-Sep-2015  skrll Sync with HEAD
 1.12.16.1 06-Apr-2015  skrll Sync with HEAD
 1.12.2.1 03-Dec-2017  jdolecek update from HEAD
 1.14.18.1 10-Jun-2019  christos Sync with HEAD
 1.14.16.1 18-Jan-2019  pgoyette Synch with HEAD
 1.14.10.2 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1865):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.14.10.1 01-Apr-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1817):

sys/fs/hfs/libhfs.c: revision 1.15

Fix support for case sensitive HFS.

Without this change, the wrong file is returned, if 2 file names contain a
subset of each other.

Code submitted in PR bin/52993 by Harold Gutch
 1.15.30.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #271):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.15.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1682):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.9 01-Mar-2023  riastradh fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.8 05-Jan-2019  maya branches: 1.8.4; 1.8.30;
Remove bogus code to workaround PCC limitations.

This would print stack garbage, which isn't desirable.
 1.7 21-Jun-2015  maxv branches: 1.7.10; 1.7.16; 1.7.18;
KNF
 1.6 28-Jul-2012  matt branches: 1.6.2; 1.6.16;
Fix -fno-common found by building i386/conf/ALL
 1.5 17-Jul-2011  joerg branches: 1.5.2;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.4 03-Sep-2008  gmcgarry Hack around zero vararg macro list on PCC.
 1.3 22-Mar-2007  dillo branches: 1.3.12; 1.3.32; 1.3.36; 1.3.38; 1.3.42;
Add support for HFS Wrapper (HFS+ volume inside an HFS volume).
Remove offset argument, we should now find an HFS+ volume in any
of its standard places.

Based on work from and test image provided by Pelle Johansson.
 1.2 06-Mar-2007  dillo branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Complete rename of hfsp to hfs, requested by thorpej.
 1.1 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.2.8.1 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 11-Jul-2007  mjf Sync with head.
 1.2.4.3 24-Mar-2007  yamt sync with head.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 06-Mar-2007  rmind file libhfs.h was added on branch yamt-idlelwp on 2007-03-12 06:14:55 +0000
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.3.42.1 19-Oct-2008  haad Sync with HEAD.
 1.3.38.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.36.1 04-May-2009  yamt sync with head.
 1.3.32.1 28-Sep-2008  mjf Sync with HEAD.
 1.3.12.2 03-Sep-2007  yamt sync with head.
 1.3.12.1 22-Mar-2007  yamt file libhfs.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:23 +0000
 1.5.2.1 30-Oct-2012  yamt sync with head
 1.6.16.1 22-Sep-2015  skrll Sync with HEAD
 1.6.2.1 03-Dec-2017  jdolecek update from HEAD
 1.7.18.1 10-Jun-2019  christos Sync with HEAD
 1.7.16.1 18-Jan-2019  pgoyette Synch with HEAD
 1.7.10.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1865):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.8.30.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #271):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.8.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1682):

sys/fs/hfs/libhfs.h: revision 1.9
sys/fs/hfs/libhfs.c: revision 1.16
sys/fs/hfs/libhfs.c: revision 1.17

fs/hfs: Avoid buffer overrun in hfslib_reada_node_offsets.

fs/hfs: Avoid undefined pointer arith in hfslib_reada_node_offsets.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.2 06-Mar-2007  dillo Rename files from hfsp to hfs.
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.3 21-Jun-2015  maxv KNF
 1.2 11-Dec-2007  lukem branches: 1.2.56; 1.2.76;
use __KERNEL_RCSID()
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo branches: 1.1.1.1.4; 1.1.1.1.18; 1.1.1.1.20; 1.1.1.1.28; 1.1.1.1.30; 1.1.1.1.32;
nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.1.1.1.32.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.1.1.30.1 11-Dec-2007  yamt sync with head.
 1.1.1.1.28.1 26-Dec-2007  ad Sync with head.
 1.1.1.1.20.3 21-Jan-2008  yamt sync with head
 1.1.1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.1.1.20.1 06-Mar-2007  yamt file unicode.c was added on branch yamt-lazymbuf on 2007-09-03 14:40:23 +0000
 1.1.1.1.18.1 09-Jan-2008  matt sync with HEAD
 1.1.1.1.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.1.1.1.4.1 06-Mar-2007  rmind file unicode.c was added on branch yamt-idlelwp on 2007-03-12 06:14:56 +0000
 1.2.76.1 22-Sep-2015  skrll Sync with HEAD
 1.2.56.1 03-Dec-2017  jdolecek update from HEAD
 1.1 06-Mar-2007  dillo branches: 1.1.1;
Initial revision
 1.1.1.1 06-Mar-2007  dillo branches: 1.1.1.1.4; 1.1.1.1.20;
nitial import of (experimental read-only) implementation of Apple
HFS+ file system.

Originally developed for Google Summer of Code 2005 by Yevgeny Binder,
updated and enhanced by me.
 1.1.1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.1.1.20.1 06-Mar-2007  yamt file unicode.h was added on branch yamt-lazymbuf on 2007-09-03 14:40:24 +0000
 1.1.1.1.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.1.1.1.4.1 06-Mar-2007  rmind file unicode.h was added on branch yamt-idlelwp on 2007-03-12 06:14:56 +0000
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-12-29 19:55:54 +0000
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file TODO was added on branch nathanw_sa on 2002-12-29 19:55:55 +0000
 1.7 09-Aug-2021  andvar s/fist/first/
 1.6 22-Jan-2016  dholland u_int8_t -> uint8_t
 1.5 04-Nov-2012  jakllsch branches: 1.5.14;
Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.4 14-Aug-2006  gdt branches: 1.4.92; 1.4.102;
When mounting an MSDOS fileysystem, do not require that bytes 252 and
253 of the superblock be zero. Searching the net failed to find any
justification for checking these bytes; all available references say
that they are part of the boot code and not BOOTSIG2 and BOOTSIG3.

Modify the MSDOS 7.1 bootsector definition to have 420 bytes of boot
code and no BOOTSIG[23], rather than 418 bytes of boot code, to follow
available references and apparent Windows practice. A test build
showed that these defines are not used other than in the check removed
by this commit.

Patch tested on netbsd-3, and enabled mounting of a 4 GB CF formatted
under Windows XP and then in a digital camera. The CF was previously
unmountable.

Concept approved on tech-kern by christos@ and martin@.
 1.3 03-Dec-2005  christos branches: 1.3.4; 1.3.8;
- 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.2 06-Oct-2003  lukem branches: 1.2.16;
Consistently use "bsBPB" as the struct member for the BIOS parameter block.
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.4.4 11-Dec-2005  christos Sync with head.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file bootsect.h was added on branch nathanw_sa on 2002-12-29 19:55:56 +0000
 1.2.16.2 30-Dec-2006  yamt sync with head.
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.3.8.1 03-Sep-2006  yamt sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.102.2 03-Dec-2017  jdolecek update from HEAD
 1.4.102.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.92.1 16-Jan-2013  yamt sync with (a bit old) head
 1.5.14.1 19-Mar-2016  skrll Sync with HEAD
 1.8 22-Jan-2016  dholland u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and
u_char -> unsigned char.
 1.7 04-Nov-2012  jakllsch branches: 1.7.14;
Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.6 27-Jan-2007  cbiere branches: 1.6.80; 1.6.90;
Use the endian conversion functions from sys/endian.h.
 1.5 30-Nov-2006  christos PR/35151: Christian Groessler: file size reported incorrectly for files > 2GB
on a FAT32 file system on a 64bit host
 1.4 03-Dec-2005  christos branches: 1.4.20; 1.4.22;
- 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.3 30-Jun-2004  christos branches: 1.3.12;
cleanup casts in get/set u short/long so that we don't have const castaways.
 1.2 08-Oct-2003  lukem add bpbReserved fields
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.4.4 11-Dec-2005  christos Sync with head.
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file bpb.h was added on branch nathanw_sa on 2002-12-29 19:55:56 +0000
 1.3.12.3 26-Feb-2007  yamt sync with head.
 1.3.12.2 30-Dec-2006  yamt sync with head.
 1.3.12.1 21-Jun-2006  yamt sync with head.
 1.4.22.1 10-Dec-2006  yamt sync with head.
 1.4.20.2 01-Feb-2007  ad Sync with head.
 1.4.20.1 12-Jan-2007  ad Sync with head.
 1.6.90.2 03-Dec-2017  jdolecek update from HEAD
 1.6.90.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.6.80.1 16-Jan-2013  yamt sync with (a bit old) head
 1.7.14.1 19-Mar-2016  skrll Sync with HEAD
 1.29 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.28 23-Oct-2021  hannken Convert msdosfs_rename() to use genfs_sane_rename().

Based on work by Taylor R Campbell.
 1.27 23-Oct-2021  hannken Factor out the lookup results from struct denode.

No functional change.
 1.26 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.25 14-Jan-2017  maya branches: 1.25.32;
Be explicit about how we're placing part of the on-disk name into
the extension, so it doesn't appear like we are overrunning an array.
Appeases coverity, NFC.

ok riastradh
 1.24 08-Jul-2014  hannken branches: 1.24.4; 1.24.8;
Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.23 26-Jan-2013  christos branches: 1.23.10;
fix fstat build.
 1.22 26-Jan-2013  christos more cross-compile friendly.
 1.21 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.20 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.19 04-Apr-2011  hannken branches: 1.19.4; 1.19.14;
Msdosfs on-disk meta data is not sufficient to create or validate file handles.

Maintain a tree of file handles, create nodes from msdosfs_vptofh() and keep
them until either the file gets unlinked or the file system gets unmounted.

Fixes the msdosfs part of PR #43745 (fhopen of an unlinked file causes problems
on multiple file systems)
 1.18 08-Apr-2010  pooka branches: 1.18.2;
In genfs where available.

The only functional change is mknod now returning EOPNOTSUPP instead
of EINVAL. I make this sacrifice willingly and with a clean conscience.
 1.17 08-Apr-2010  pooka Use genfs instead of homegrown stuff where possible.
 1.16 26-Nov-2007  pooka branches: 1.16.18; 1.16.38; 1.16.40;
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.15 09-Apr-2007  pooka branches: 1.15.8; 1.15.10; 1.15.16;
fix comment: struct fid is in fstypes.h now
 1.14 22-Sep-2006  xtraeme branches: 1.14.4; 1.14.8; 1.14.10;
Apply patch from PR kern/34583 sent by Rhialto, quoting him:

"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."

And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".

Also remove a 2 if-statements testing the same condition, combine them.

All that from Rhialto, thank you very much.
 1.13 14-May-2006  elad branches: 1.13.6; 1.13.8; 1.13.10;
integrate kauth.
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 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.10 04-Nov-2005  christos PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.9 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.8 12-Sep-2005  christos branches: 1.8.2;
Use nanotime() to update the time fields in filesystems. Convert the code
from macros to real functions. Original patch and review from chuq.
Note: ext2fs only keeps seconds in the on-disk inode, and msdosfs does not
have enough precision for all fields, so this is not very useful for those
two.
 1.7 29-Aug-2005  xtraeme Remove __P()
 1.6 29-Aug-2005  xtraeme The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.

From OpenBSD.

This closes my PR kern/30864: "panic when copying files of >4GB on msdosfs"
 1.5 23-Jul-2005  yamt update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.
 1.4 07-Sep-2003  itojun branches: 1.4.2; 1.4.6; 1.4.14; 1.4.16;
add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.3 29-Jun-2003  fvdl branches: 1.3.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file denode.h was added on branch nathanw_sa on 2002-12-29 19:55:57 +0000
 1.3.2.6 11-Dec-2005  christos Sync with head.
 1.3.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Aug-2004  skrll Sync with HEAD
 1.3.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.4.16.4 07-Dec-2007  yamt sync with head
 1.4.16.3 03-Sep-2007  yamt sync with head.
 1.4.16.2 30-Dec-2006  yamt sync with head.
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.4.14.4 06-Oct-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1525):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.4.14.3 06-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #937):
sys/fs/msdosfs/denode.h: revision 1.10
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.22
PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.4.14.2 02-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #722):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.4.14.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.4.6.2 06-Nov-2005  riz Pull up following revision(s) (requested by christos in ticket #5972):
sys/fs/msdosfs/denode.h: revision 1.10
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.22
PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.4.6.1 06-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #5627):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.4.2.1 06-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #5627):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.8.2.1 20-Oct-2005  yamt adapt msdosfs.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.1 01-Jun-2006  kardel Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.10.1 22-Oct-2006  yamt sync with head
 1.13.8.1 18-Nov-2006  ad Sync with head.
 1.13.6.1 23-Sep-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #206):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.14.10.1 11-Jul-2007  mjf Sync with head.
 1.14.8.1 10-Apr-2007  ad Sync with head.
 1.14.4.1 15-Apr-2007  yamt sync with head.
 1.15.16.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.10.1 09-Jan-2008  matt sync with HEAD
 1.15.8.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.16.40.2 21-Apr-2011  rmind sync with head
 1.16.40.1 30-May-2010  rmind sync with head
 1.16.38.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.18.1 11-Aug-2010  yamt sync with head.
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.14.4 03-Dec-2017  jdolecek update from HEAD
 1.19.14.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.14.2 25-Feb-2013  tls resync with head
 1.19.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.4.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.19.4.1 16-Jan-2013  yamt sync with (a bit old) head
 1.23.10.1 10-Aug-2014  tls Rebase.
 1.24.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.24.4.1 05-Feb-2017  skrll Sync with HEAD
 1.25.32.1 01-Aug-2021  thorpej Sync with HEAD.
 1.12 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.11 01-Feb-2016  christos We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).
 1.10 30-Jan-2016  mlelstv Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
 1.9 23-Jan-2016  dholland Apparently a recent round of vandalism by the C++ standards committee
includes disallowing the standard and historic type name "unsigned". Add
a gratuitous "int" to recent changes.

C++ is really a blight on the world.
 1.8 22-Jan-2016  dholland u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and
u_char -> unsigned char.
 1.7 20-Oct-2013  christos branches: 1.7.6;
provide a function to access the name and extension as a single array as
opposed depend on array index overflow.
 1.6 26-Jan-2013  christos branches: 1.6.2;
expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.5 03-Dec-2005  christos branches: 1.5.110; 1.5.120;
- 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.4 12-Sep-2005  christos Use nanotime() to update the time fields in filesystems. Convert the code
from macros to real functions. Original patch and review from chuq.
Note: ext2fs only keeps seconds in the on-disk inode, and msdosfs does not
have enough precision for all fields, so this is not very useful for those
two.
 1.3 29-Aug-2005  xtraeme Remove __P()
 1.2 07-Sep-2003  itojun branches: 1.2.16;
add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file direntry.h was added on branch nathanw_sa on 2002-12-29 19:55:58 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.5.120.3 03-Dec-2017  jdolecek update from HEAD
 1.5.120.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.120.1 25-Feb-2013  tls resync with head
 1.5.110.1 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.6.2.1 18-May-2014  rmind sync with head
 1.7.6.1 19-Mar-2016  skrll Sync with HEAD
 1.10 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.9 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.8 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.7 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.6 04-Nov-2012  jakllsch And correct a typo that wasn't corrected in previous.
 1.5 04-Nov-2012  jakllsch Correct constant in comment to match the expression it is derived from.
 1.4 03-Dec-2005  christos branches: 1.4.110; 1.4.120;
- 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.3 29-Aug-2005  xtraeme Remove __P()
 1.2 26-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.14.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.12.1 29-Apr-2005  kent sync with -current
 1.1.4.3 11-Dec-2005  christos Sync with head.
 1.1.4.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file fat.h was added on branch nathanw_sa on 2002-12-29 19:55:59 +0000
 1.2.4.1 21-Jun-2006  yamt sync with head.
 1.4.120.3 03-Dec-2017  jdolecek update from HEAD
 1.4.120.2 25-Feb-2013  tls resync with head
 1.4.120.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.110.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.4.110.1 16-Jan-2013  yamt sync with (a bit old) head
 1.4 23-Oct-2021  hannken Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.
 1.3 06-Feb-2016  mlelstv Split case folding table into separate source file and add full
copyright and permission notice from http://www.unicode.org/copyright.html
 1.2 11-Oct-2014  uebayasi branches: 1.2.2;
Define filesystem attributes with vfs dependency.
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.152;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.152.1 03-Dec-2017  jdolecek update from HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file files.msdosfs was added on branch nathanw_sa on 2002-12-29 19:55:59 +0000
 1.2.2.1 19-Mar-2016  skrll Sync with HEAD
 1.20 02-Jun-2023  andvar follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.
 1.19 13-Feb-2023  andvar s/chacters/characters/ in comments.
 1.18 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.17 30-Jun-2016  nonaka Fix false positives when comparing long file names that have the
same first 13 (or some multiple thereof) characters.
 1.16 06-Mar-2016  mlelstv Use KASSERT for conditions that cannot be met with current parameters.
 1.15 06-Feb-2016  mlelstv Split case folding table into separate source file and add full
copyright and permission notice from http://www.unicode.org/copyright.html
 1.14 01-Feb-2016  christos - split a long line.
- remove extra test.
- move d_namlen setting to msdosfs_vnops.c to avoid the ifdef.
 1.13 01-Feb-2016  martin Avoid unsigned/signed comparision warning to fix the build.
 1.12 01-Feb-2016  christos We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).
 1.11 30-Jan-2016  mlelstv Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
 1.10 01-Sep-2014  martin branches: 1.10.2;
Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
 1.9 26-Jan-2013  christos branches: 1.9.12;
more cross-compile friendly.
 1.8 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.7 15-Mar-2009  cegger branches: 1.7.12; 1.7.22;
ansify function definitions
 1.6 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.84; 1.5.90;
merge ktrace-lwp.
 1.4 12-Sep-2005  christos Use nanotime() to update the time fields in filesystems. Convert the code
from macros to real functions. Original patch and review from chuq.
Note: ext2fs only keeps seconds in the on-disk inode, and msdosfs does not
have enough precision for all fields, so this is not very useful for those
two.
 1.3 26-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 07-Sep-2003  itojun branches: 1.2.8; 1.2.10;
add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_conv.c was added on branch nathanw_sa on 2002-12-29 19:56:00 +0000
 1.2.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.3.4.1 21-Jun-2006  yamt sync with head.
 1.5.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.84.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.74.1 04-May-2009  yamt sync with head.
 1.7.22.2 03-Dec-2017  jdolecek update from HEAD
 1.7.22.1 25-Feb-2013  tls resync with head
 1.7.12.1 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.9.12.1 12-Nov-2014  snj Pull up following revision(s) (requested by martin in ticket #216):
share/man/man9/todr.9: revision 1.17
sys/arch/sh3/dev/rtc.c: revision 1.9
sys/dev/clock_subr.c: revision 1.17-1.22
sys/dev/clock_subr.h: revision 1.22
sys/fs/msdosfs/msdosfs_conv.c: revision 1.10
tools/compat/compat_defs.h: revision 1.98
tools/compat/dev/clock_subr.h: revision 1.1-1.2
usr.sbin/makefs/msdos/Makefile.inc: revision 1.6
clock_secs_to_ymdhms(9) takes seconds as a time_t, not int.
--
Make this compile- and usable from userland as well.
--
Add a slightly stripped down version of sys/dev/clock/clock_subr.h to make
this code available for tools.
--
Reformulate an overflow test so it can be used in tool builds (i.e. does
not depend on netbsd specific macros).
--
Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
--
Copy definitions of __type_min(t), __type_max(t), and some related macros,
from <sys/cdefs.h>, for use when building tools.
--
Revert previous; test secs > __type_max(time_t) again, now
that __type_max is available in tools/compat/compat_defs.h.
--
If HAVE_NBTOOL_CONFIG_H is set, then include "nbtool_config.h",
because this file is compiled as part of tools/makefs.
--
Counting leap years was fine while we had 32bit time_t - but now it
is not a good idea for dates far away in the future.
For dates in the year 2000 or later, use arithmetic instead (since the
repeating periods are well aligned). Should fix PR 49144.
--
Avoid overflowing the "year" value by making the field uint64_t. Adapt
arguments and local variables accordingly.
This now fixes PR 49144 for real.
--
Adapt formats for debug printfs to clock_subr type changes.
 1.10.2.2 09-Jul-2016  skrll Sync with HEAD
 1.10.2.1 19-Mar-2016  skrll Sync with HEAD
 1.60 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.59 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.58 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.57 28-May-2018  chs branches: 1.57.2; 1.57.12;
add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.56 26-May-2017  riastradh branches: 1.56.8;
Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.55 26-May-2017  riastradh 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.54 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.53 01-Mar-2017  hannken Remove now redundant calls to fstrans_start()/fstrans_done().
 1.52 20-Aug-2016  hannken branches: 1.52.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.51 28-Mar-2015  maxv branches: 1.51.2;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.50 08-Jul-2014  hannken branches: 1.50.4;
Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.49 30-May-2014  hannken msdosfs_reclaim(): add missing fstrans and protect change
of v_data with v_interlock as msdosfs_sync() now needs it.
 1.48 20-Dec-2012  hannken branches: 1.48.10;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.47 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.46 16-Jun-2011  hannken branches: 1.46.2; 1.46.12;
Rename uvm_vnp_zerorange(struct vnode *, off_t, size_t) to
ubc_zerorange(struct uvm_object *, off_t, size_t, int) changing
the first argument to an uvm_object and adding a flags argument.

Modify tmpfs_reg_resize() to zero the backing store (aobj) instead
of the vnode. Ubc_purge() no longer panics when unmounting tmpfs.

Keep uvm_vnp_zerorange() until the next kernel version bump.
 1.45 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.44 19-May-2011  rmind branches: 1.44.2;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.43 04-Apr-2011  hannken Msdosfs on-disk meta data is not sufficient to create or validate file handles.

Maintain a tree of file handles, create nodes from msdosfs_vptofh() and keep
them until either the file gets unlinked or the file system gets unmounted.

Fixes the msdosfs part of PR #43745 (fhopen of an unlinked file causes problems
on multiple file systems)
 1.42 22-Mar-2011  hannken When truncating a file purge the fat cache after setting the new size
and after all io but before actually updating the cluster chain.

Both uvm_vnp_zerorange() and vtruncbuf() call get/putpages -> bmap -> pcbmap
and here the fat cache gets updated with information no longer valid after
truncation.
 1.41 20-Mar-2011  hannken When extending a file, either by truncating or by writing past EOF make
sure the unallocated remainder of the last page gets zeroed.

Detected by fsx.
 1.40 21-Jul-2010  hannken branches: 1.40.2;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.39 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.38 09-Apr-2010  hannken Add file system suspension support (vfs_suspend(9)) to msdosfs.

Reviewed by: Antti Kantee <pooka@netbsd.org>
 1.37 08-Jan-2010  pooka branches: 1.37.2; 1.37.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.36 15-Mar-2009  cegger ansify function definitions
 1.35 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.34 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.33 16-May-2008  hannken branches: 1.33.6; 1.33.12;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.32 05-May-2008  ad branches: 1.32.2;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.31 17-Jan-2008  ad branches: 1.31.6; 1.31.8; 1.31.10;
Fix dodgy tests of v_usecount.
 1.30 02-Jan-2008  ad Merge vmlocking2 to head.
 1.29 28-Dec-2007  reinoud Use uvm_vnp_setwritesize() on file extending to instruct UVM to NOT read-in
the newly added space first. This significantly speeds up write speed for
msdosfs and making it at par with ffs wich already had this patched.

Speed increase measured on my IDE disc from 2Mb/sec to 32 Mb/sec
 1.28 08-Dec-2007  ad branches: 1.28.4;
Merge ihash locking changes from the vmlocking branch.
 1.27 26-Nov-2007  pooka branches: 1.27.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.26 10-Oct-2007  ad branches: 1.26.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.25 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.24 28-Sep-2007  pooka Release vnode being created in error branch instead of leaving it
locked. Ideally the function should be rewritten to do things in
a different order, but this tries to keep changes minimal aiming
for a possible netbsd-4 pullup.

fixes PR kern/37034
 1.23 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.22 23-Jul-2007  pooka branches: 1.22.4; 1.22.6; 1.22.8; 1.22.10;
Also set writesize when creating node.

noticed by Markus W Kilbinger
 1.21 30-Jun-2007  pooka branches: 1.21.2;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.20 12-Mar-2007  ad branches: 1.20.2; 1.20.4;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.19 04-Mar-2007  christos branches: 1.19.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 20-Feb-2007  ad Call genfs_node_destroy() where appropriate.
 1.17 25-Nov-2006  scw branches: 1.17.2; 1.17.4; 1.17.6;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.16 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 14-May-2006  elad branches: 1.14.8; 1.14.10;
integrate kauth.
 1.13 15-Apr-2006  christos Coverity CID 2508: Initialize variable
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.10 29-Aug-2005  xtraeme branches: 1.10.2;
Remove __P()
 1.9 23-Jul-2005  yamt update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.
 1.8 28-Jun-2005  yamt branches: 1.8.2;
- constify genfs_ops.
- use member designators.
 1.7 20-May-2004  atatat branches: 1.7.10;
Explicitly call pool_init() (and pool_destroy()) when being built as
an _LKM.

This adds pools to the list of things that lkms must do manually
because they're set up with link sets. Not that there's anything
wrong with link sets, but that we need to try harder to remember that
lkms are second class citizens. Of a sort.
 1.6 25-Apr-2004  simonb Initialise (most) pools from a link set instead of explicit calls
to pool_init. Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

Convert struct session, ucred and lockf to pools.
 1.5 27-Mar-2004  atatat Manually attach malloc types when being built as an lkm.
 1.4 29-Jun-2003  fvdl branches: 1.4.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.3 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.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_denode.c was added on branch nathanw_sa on 2002-12-29 19:56:01 +0000
 1.4.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.6 31-Oct-2004  skrll Fix comment that describe the argument structures.
 1.4.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.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.4.2.2 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.7.10.2 04-Oct-2007  bouyer Pull up following revision(s) (requested by pooka in ticket #1849):
sys/fs/msdosfs/msdosfs_denode.c: revision 1.24
Release vnode being created in error branch instead of leaving it
locked. Ideally the function should be rewritten to do things in
a different order, but this tries to keep changes minimal aiming
for a possible netbsd-4 pullup.
fixes PR kern/37034
 1.7.10.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.8.2.7 21-Jan-2008  yamt sync with head
 1.8.2.6 07-Dec-2007  yamt sync with head
 1.8.2.5 27-Oct-2007  yamt sync with head.
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 20-Oct-2005  yamt adapt msdosfs.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.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.12.10.2 19-Apr-2006  elad sync with head.
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.2 01-Jun-2006  kardel Sync with head.
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.14.10.2 10-Dec-2006  yamt sync with head.
 1.14.10.1 22-Oct-2006  yamt sync with head
 1.14.8.2 12-Jan-2007  ad Sync with head.
 1.14.8.1 18-Nov-2006  ad Sync with head.
 1.17.6.1 30-Sep-2007  wrstuden Catch up w/ last night's netbsd-4
 1.17.4.3 24-Mar-2007  yamt sync with head.
 1.17.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.17.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.17.2.1 29-Sep-2007  xtraeme Pull up following revision(s) (requested by pooka in ticket #909):
sys/fs/msdosfs/msdosfs_denode.c: revision 1.24

Release vnode being created in error branch instead of leaving it
locked. Ideally the function should be rewritten to do things in
a different order, but this tries to keep changes minimal aiming
for a possible netbsd-4 pullup.
fixes PR kern/37034
 1.19.2.10 25-Oct-2007  ad Fix up mnt_vnodelist handling.
 1.19.2.9 09-Oct-2007  ad Sync with head.
 1.19.2.8 09-Oct-2007  ad Sync with head.
 1.19.2.7 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.2.6 20-Aug-2007  ad Sync with HEAD.
 1.19.2.5 15-Jul-2007  ad Sync with head.
 1.19.2.4 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.2.3 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.19.2.2 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.19.2.1 13-Mar-2007  ad Sync with head.
 1.20.4.1 09-Dec-2007  reinoud Pullup to HEAD
 1.20.2.1 11-Jul-2007  mjf Sync with head.
 1.21.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.22.10.2 23-Jul-2007  pooka Also set writesize when creating node.

noticed by Markus W Kilbinger
 1.22.10.1 23-Jul-2007  pooka file msdosfs_denode.c was added on branch matt-mips64 on 2007-07-23 11:05:48 +0000
 1.22.8.2 14-Oct-2007  yamt sync with head.
 1.22.8.1 06-Oct-2007  yamt sync with head.
 1.22.6.3 23-Mar-2008  matt sync with HEAD
 1.22.6.2 09-Jan-2008  matt sync with HEAD
 1.22.6.1 06-Nov-2007  matt sync with HEAD
 1.22.4.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.22.4.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.22.4.2 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.1 02-Oct-2007  joerg Sync with HEAD.
 1.26.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.26.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.26.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.2.2 08-Dec-2007  ad Sync with head.
 1.27.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.28.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.28.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.31.10.4 11-Aug-2010  yamt sync with head.
 1.31.10.3 11-Mar-2010  yamt sync with head
 1.31.10.2 04-May-2009  yamt sync with head.
 1.31.10.1 16-May-2008  yamt sync with head.
 1.31.8.1 18-May-2008  yamt sync with head.
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.37.4.7 31-May-2011  rmind sync with head
 1.37.4.6 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.37.4.5 21-Apr-2011  rmind sync with head
 1.37.4.4 05-Mar-2011  rmind sync with head
 1.37.4.3 03-Jul-2010  rmind sync with head
 1.37.4.2 30-May-2010  rmind sync with head
 1.37.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.37.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.37.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.40.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.44.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.46.12.4 03-Dec-2017  jdolecek update from HEAD
 1.46.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.12.2 25-Feb-2013  tls resync with head
 1.46.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.2.2 23-Jan-2013  yamt sync with head
 1.46.2.1 16-Jan-2013  yamt sync with (a bit old) head
 1.48.10.1 10-Aug-2014  tls Rebase.
 1.50.4.3 28-Aug-2017  skrll Sync with HEAD
 1.50.4.2 05-Oct-2016  skrll Sync with HEAD
 1.50.4.1 06-Apr-2015  skrll Sync with HEAD
 1.51.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.51.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.52.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.56.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.57.12.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.57.12.1 20-Apr-2020  bouyer Sync with HEAD
 1.57.2.1 21-Apr-2020  martin Sync with HEAD
 1.37 13-May-2024  msaitoh s/contigous/contiguous/ in comment.
 1.36 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.35 07-Sep-2020  mrg avoid an uninit warning with GCC 9.
 1.34 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.33 25-Jul-2018  kamil Avoid undefined behavior semantics in msdosfs_fat.c

Do not change signedness bit with left shift.
While there avoid signed integer overflow.
Address both issues with using unsigned type.

msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]'
msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]'

Detected with micro-UBSan in the user mode.
 1.32 27-Jan-2018  sevan branches: 1.32.2; 1.32.4;
Need strings.h for ffs()
Resolves implict declaration warning of ffs() when building tools via build.sh
 1.31 07-May-2016  mlelstv branches: 1.31.10;
fix DEBUG build
 1.30 03-May-2016  mlelstv Validate FAT entries to avoid some panics caused by a corrupted FAT.

Also print FAT write errors when mount is synchronous (-o sync). This
reveals problems caused by a write protected disklabel on sector 1.
 1.29 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.28 28-Jan-2013  christos branches: 1.28.12; 1.28.14;
A little more debugging.
 1.27 27-Jan-2013  christos don't need sys/mount.h in userland.
 1.26 27-Jan-2013  christos tidy up debugging printfs; no functional change.
 1.25 26-Jan-2013  christos more cross-compile friendly.
 1.24 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.23 20-Dec-2012  hannken Revert rev. 1.20 now that bread() has been fixed.

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.22 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.21 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.20 09-Apr-2012  hannken branches: 1.20.2;
pcbmap(): We cannot use bread() here as for the pagedaemon getblk()
may fail leading to a panic in bread().
Replace bread() with getblk() / VOP_STRATEGY() and return
an error if getblk() fails.

Fixes PR#46282: 6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread

This is an interim solution for easy pullup. The final solution
is be to change bread() to not return a buffer on error. As
we have to change all callers of bread() this will not qualify
for a pullup.
 1.19 26-Jan-2010  joerg branches: 1.19.12; 1.19.16; 1.19.18;
On broken filesystems the fillinmap inner loop may have never read a
block, so don't try to release it if bp==NULL.
 1.18 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.17 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.16 16-May-2008  hannken branches: 1.16.6; 1.16.12;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.15 08-Oct-2007  ad branches: 1.15.18; 1.15.20; 1.15.22; 1.15.24;
Merge brelse() changes from the vmlocking branch.
 1.14 29-Apr-2007  msaitoh branches: 1.14.6; 1.14.8; 1.14.10;
fix typos
 1.13 04-Mar-2007  christos branches: 1.13.2; 1.13.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 25-Nov-2006  scw branches: 1.12.4;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.11 22-Sep-2006  xtraeme Apply patch from PR kern/34583 sent by Rhialto, quoting him:

"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."

And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".

Also remove a 2 if-statements testing the same condition, combine them.

All that from Rhialto, thank you very much.
 1.10 14-May-2006  elad branches: 1.10.6; 1.10.8; 1.10.10;
integrate kauth.
 1.9 15-Apr-2006  christos Coverity CID 839: Add KASSERT before deref.
 1.8 15-Apr-2006  christos Coverity CID 838: Add KASSERT before deref.
 1.7 24-Dec-2005  perry branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 29-Aug-2005  xtraeme Remove __P()
 1.4 26-Feb-2005  perry branches: 1.4.2; 1.4.4;
nuke trailing whitespace
 1.3 21-Apr-2004  christos branches: 1.3.4; 1.3.6;
Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.2 22-Oct-2003  briggs Fix a panic that occurred when trying to traverse a corrupt msdosfs
filesystem. With this particular corruption, the code in pcbmap()
would compute an offset into an array that was way out of bounds,
so check the bounds before trying to access and return an error if
the offset would be out of bounds.
 1.1 26-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_fat.c was added on branch nathanw_sa on 2002-12-29 19:56:02 +0000
 1.3.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.4.1 29-Apr-2005  kent sync with -current
 1.4.4.4 27-Oct-2007  yamt sync with head.
 1.4.4.3 03-Sep-2007  yamt sync with head.
 1.4.4.2 30-Dec-2006  yamt sync with head.
 1.4.4.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 06-Oct-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1525):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.7.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.10.2 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.7.10.1 19-Apr-2006  elad sync with head.
 1.7.8.1 24-May-2006  yamt sync with head.
 1.7.6.2 01-Jun-2006  kardel Sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.10.10.2 10-Dec-2006  yamt sync with head.
 1.10.10.1 22-Oct-2006  yamt sync with head
 1.10.8.2 12-Jan-2007  ad Sync with head.
 1.10.8.1 18-Nov-2006  ad Sync with head.
 1.10.6.1 23-Sep-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #206):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.12.4.2 07-May-2007  yamt sync with head.
 1.12.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.4.1 11-Jul-2007  mjf Sync with head.
 1.13.2.2 08-Jun-2007  ad Sync with head.
 1.13.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.14.10.1 14-Oct-2007  yamt sync with head.
 1.14.8.1 06-Nov-2007  matt sync with HEAD
 1.14.6.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.15.24.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.22.2 11-Mar-2010  yamt sync with head
 1.15.22.1 04-May-2009  yamt sync with head.
 1.15.20.1 18-May-2008  yamt sync with head.
 1.15.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.18.1 16-Apr-2012  riz Pull up following revision(s) (requested by hannken in ticket #183):
sys/fs/msdosfs/msdosfs_fat.c: revision 1.20
pcbmap(): We cannot use bread() here as for the pagedaemon getblk()
may fail leading to a panic in bread().
Replace bread() with getblk() / VOP_STRATEGY() and return
an error if getblk() fails.

Fixes PR#46282: 6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread ->
bio_doread

This is an interim solution for easy pullup. The final solution
is be to change bread() to not return a buffer on error. As
we have to change all callers of bread() this will not qualify
for a pullup.
 1.19.16.1 29-Apr-2012  mrg sync to latest -current.
 1.19.12.4 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.19.12.3 23-Jan-2013  yamt sync with head
 1.19.12.2 16-Jan-2013  yamt sync with (a bit old) head
 1.19.12.1 17-Apr-2012  yamt sync with head
 1.20.2.3 03-Dec-2017  jdolecek update from HEAD
 1.20.2.2 25-Feb-2013  tls resync with head
 1.20.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.28.14.2 29-May-2016  skrll Sync with HEAD
 1.28.14.1 06-Apr-2015  skrll Sync with HEAD
 1.28.12.1 19-Feb-2018  snj Pull up following revision(s) (requested by sevan in ticket #1558):
sys/fs/msdosfs/msdosfs_fat.c: 1.32
usr.sbin/makefs/msdos/msdosfs_vfsops.c: 1.11
Need strings.h for ffs()
--
Need strings.h for ffs()
Resolves implict declaration warning of ffs() when building tools via
build.sh
 1.31.10.1 04-Feb-2018  martin Pull up following revision(s) (requested by sevan in ticket #518):
sys/fs/msdosfs/msdosfs_fat.c: revision 1.32
usr.sbin/makefs/msdos/msdosfs_vfsops.c: revision 1.11
Need strings.h for ffs()
Need strings.h for ffs()
Resolves implict declaration warning of ffs() when building tools via
build.sh
 1.32.4.1 10-Jun-2019  christos Sync with HEAD
 1.32.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.32.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.41 06-Aug-2022  andvar s/blity/bility/ in various words, mainly in comments.
 1.40 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.39 23-Oct-2021  hannken Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.
 1.38 23-Oct-2021  hannken Factor out the lookup results from struct denode.

No functional change.
 1.37 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.36 04-Apr-2020  ad branches: 1.36.8;
Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.35 30-Jan-2016  mlelstv branches: 1.35.18; 1.35.24;
Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
 1.34 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.33 08-Jul-2014  hannken branches: 1.33.4;
Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.32 07-Feb-2014  hannken branches: 1.32.2;
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.31 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.30 24-Dec-2013  mlelstv don't treat adjacent members as a larger array
Coverity CID 977367
 1.29 26-Jan-2013  christos branches: 1.29.2;
more cross-compile friendly.
 1.28 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.27 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.26 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.25 05-Nov-2012  dholland 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.24 22-Jul-2012  rmind branches: 1.24.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.23 30-Nov-2010  dholland branches: 1.23.8; 1.23.14;
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.22 30-Jul-2010  mlelstv Return EINVAL for rename and delete operations to the
root directory instead of the erroneous EROFS.
 1.21 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.20 08-Jan-2010  pooka branches: 1.20.2; 1.20.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.19 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.18 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.17 23-Jan-2009  jmcneill branches: 1.17.2;
From FreeBSD, 10 years ago;

Now empty DOS filesystems default to long file names. Non-empty filesystems
without traces of Win95 default to short file names, as before.
 1.16 16-May-2008  hannken branches: 1.16.6; 1.16.8;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.15 26-Nov-2007  pooka branches: 1.15.14; 1.15.16; 1.15.18; 1.15.20;
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.14 10-Oct-2007  ad branches: 1.14.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.13 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.14; 1.12.16; 1.12.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 09-Dec-2006  chs branches: 1.11.2;
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.10 25-Nov-2006  scw branches: 1.10.2;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.9 14-May-2006  elad branches: 1.9.8; 1.9.10;
integrate kauth.
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
merge ktrace-lwp.
 1.7 14-Sep-2005  soda mention what is the failure case, from FreeBSD revision 1.46 cvs log
 1.6 14-Sep-2005  christos PR/31312: Juan RP: Don't use negative cacheing on msdosfs, because of the
evil case preserving and case sensitive semantics. From FreeBSD.
 1.5 29-May-2005  christos branches: 1.5.2;
- rename variables to avoid shadowing.
- add a few const.
 1.4 26-Feb-2005  perry nuke trailing whitespace
 1.3 29-Jun-2003  fvdl branches: 1.3.2; 1.3.10; 1.3.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_lookup.c was added on branch nathanw_sa on 2002-12-29 19:56:03 +0000
 1.3.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.10.1 29-Apr-2005  kent sync with -current
 1.3.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.5.2.5 07-Dec-2007  yamt sync with head
 1.5.2.4 27-Oct-2007  yamt sync with head.
 1.5.2.3 03-Sep-2007  yamt sync with head.
 1.5.2.2 30-Dec-2006  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 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.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 01-Jun-2006  kardel Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.10.1 10-Dec-2006  yamt sync with head.
 1.9.8.1 12-Jan-2007  ad Sync with head.
 1.10.2.2 04-Aug-2010  bouyer Pull up following revision(s) (requested by mlelstv in ticket #1402):
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.22
Return EINVAL for rename and delete operations to the
root directory instead of the erroneous EROFS.
 1.10.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.11.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.18.1 14-Oct-2007  yamt sync with head.
 1.12.16.2 09-Jan-2008  matt sync with HEAD
 1.12.16.1 06-Nov-2007  matt sync with HEAD
 1.12.14.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12.14.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.12.2.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.12.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.14.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.18.3 11-Aug-2010  yamt sync with head.
 1.15.18.2 11-Mar-2010  yamt sync with head
 1.15.18.1 04-May-2009  yamt sync with head.
 1.15.16.1 18-May-2008  yamt sync with head.
 1.15.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.8.2 21-Nov-2010  riz Pull up following revision(s) (requested by mlelstv in ticket #1434):
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.22
Return EINVAL for rename and delete operations to the
root directory instead of the erroneous EROFS.
 1.16.8.1 02-Feb-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #383):
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.17
From FreeBSD, 10 years ago;
Now empty DOS filesystems default to long file names. Non-empty filesystems
without traces of Win95 default to short file names, as before.
 1.16.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.16.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.4.2 05-Mar-2011  rmind sync with head
 1.20.4.1 03-Jul-2010  rmind sync with head
 1.20.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.23.14.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.23.8.4 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.23.8.3 23-Jan-2013  yamt sync with head
 1.23.8.2 16-Jan-2013  yamt sync with (a bit old) head
 1.23.8.1 30-Oct-2012  yamt sync with head
 1.24.2.4 03-Dec-2017  jdolecek update from HEAD
 1.24.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.2 25-Feb-2013  tls resync with head
 1.24.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.2.1 18-May-2014  rmind sync with head
 1.32.2.1 10-Aug-2014  tls Rebase.
 1.33.4.2 19-Mar-2016  skrll Sync with HEAD
 1.33.4.1 06-Apr-2015  skrll Sync with HEAD
 1.35.24.1 19-Jan-2020  ad Set IMNT_SHRLOOKUP and use it for the in-cache case. Need to check what
more can be done with tmpfs though, it can probably do the whole lookup.
 1.35.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.36.8.1 01-Aug-2021  thorpej Sync with HEAD.
 1.4 04-May-2024  mlelstv From genfs_rename.c:

* XXX Want a better equality test. `tcnp->cn_cred == cred'
* hoses p2k because puffs transmits the creds separately and
* allocates distinct but equivalent structures for them.

Fixes rename crash in rump_msdos.
 1.3 23-Oct-2021  thorpej branches: 1.3.4;
Sanitize the symbol namespace. NFC.
 1.2 23-Oct-2021  hannken Convert msdosfs_rename() to use genfs_sane_rename().

Based on work by Taylor R Campbell.
 1.1 23-Oct-2021  hannken Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.
 1.3.4.1 20-Jun-2024  martin Pull up following revision(s) (requested by rhialto in ticket #706):

sys/fs/msdosfs/msdosfs_rename.c: revision 1.4

From genfs_rename.c:
* XXX Want a better equality test. `tcnp->cn_cred == cred'
* hoses p2k because puffs transmits the creds separately and
* allocates distinct but equivalent structures for them.

Fixes rename crash in rump_msdos.
 1.2 06-Feb-2016  joerg branches: 1.2.2; 1.2.18;
Toolify.
 1.1 06-Feb-2016  mlelstv Split case folding table into separate source file and add full
copyright and permission notice from http://www.unicode.org/copyright.html
 1.2.18.2 03-Dec-2017  jdolecek update from HEAD
 1.2.18.1 06-Feb-2016  jdolecek file msdosfs_unicode.c was added on branch tls-maxphys on 2017-12-03 11:38:41 +0000
 1.2.2.2 19-Mar-2016  skrll Sync with HEAD
 1.2.2.1 06-Feb-2016  skrll file msdosfs_unicode.c was added on branch nick-nhusb on 2016-03-19 11:30:31 +0000
 1.138 16-Apr-2022  hannken Lock vnode for vinvalbuf().
 1.137 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.136 11-Feb-2021  ryoon Enable to mount Raspberry Pi Pico's USB mass storage partition

Fix PR kern/55985.
O.k. by thorpej@.

Pull-up to netbsd-8 and netbsd-9.
 1.135 13-Apr-2020  ad branches: 1.135.2;
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.134 04-Apr-2020  ad branches: 1.134.2;
Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.133 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.132 27-Feb-2020  ad Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.
 1.131 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.130 03-Sep-2018  riastradh branches: 1.130.4; 1.130.6;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.129 27-Nov-2017  mlelstv branches: 1.129.2; 1.129.4;
relax sanity check. It's ok to have more FAT sectors than needed.
 1.128 20-Aug-2017  mlelstv Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.

Does fix PR 52485.
 1.127 17-Apr-2017  hannken branches: 1.127.2; 1.127.4;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.126 17-Apr-2017  hannken Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.125 01-Apr-2017  riastradh KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.124 01-Mar-2017  hannken Remove now redundant calls to fstrans_start()/fstrans_done().
 1.123 22-Feb-2017  hannken Enable fstrans on all file systems.

Welcome to 7.99.61
 1.122 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.121 17-Feb-2017  hannken Untangle VFS_SYNC() from VFS_SUSPENDCTL().
 1.120 17-Feb-2017  hannken Take vnode lock for VOP_FSYNC().
 1.119 14-Dec-2016  hannken branches: 1.119.2;
Move vnode members "v_freelisthd" and "v_freelist" from "struct vnode"
to "struct vnode_impl" and rename to "vi_lrulisthd" and "vi_lrulist".

No functional change intended.

Welcome to 7.99.48
 1.118 28-Mar-2015  maxv branches: 1.118.2;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.117 23-Jan-2015  christos catch up with DPRINTF change
 1.116 23-Jan-2015  christos add some more paranoid checks about secsize and struct use.
 1.115 18-Jul-2014  maxv branches: 1.115.2; 1.115.4;
Make DPRINTF more understandable, and replace my previous #ifdef DIAGNOSTIC...
 1.114 16-Jul-2014  maxv Limit the minimum size of a disk sector to 512 bytes, to prevent memory
overflow on extremely low secsize. This normally conforms to the old standard
(for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced
Format standardizes it to 4k, so this change won't cause any trouble on
new devices.

Put the printf under DIAGNOSTIC temporarily to see if someone complains.

after a quick discussion on tech-kern
 1.113 15-Jul-2014  christos Correct the bread size of struct fsinfo from Gerald Lee at DELL dot com
 1.112 09-Jul-2014  maxv Minor changes:
- malloc()+memset() -> malloc(|M_ZERO)
- rename 'vers' to 'FSVers'
- declare 'ExtFlags' instead of calling getushort() two times
 1.111 09-Jul-2014  maxv Remove ROOTNAME (unused).
 1.110 08-Jul-2014  maxv - Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.

From me, FreeBSD, OpenBSD and the FAT specification.

ok christos@
 1.109 08-Jul-2014  hannken Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.108 24-May-2014  christos Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.
 1.107 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.106 23-Mar-2014  hannken branches: 1.106.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.105 17-Mar-2014  hannken Change msdosfs_sync() to use vfs_vnode_iterator.
 1.104 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.103 23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.102 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.101 15-Apr-2013  jakllsch branches: 1.101.4;
Don't attempt to mount file system with clusters larger than MAXBSIZE.
 1.100 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.99 04-Nov-2012  jakllsch Check that the FSInfo block's next free cluster suggestion is actually
a cluster within the bounds of the volume too.
 1.98 04-Nov-2012  jakllsch ((u_long)-1) will not always be 0xffffffff, which is what we actually
want to test against to determine if the FSInfo block's next free
cluster suggestion is valid
 1.97 03-Oct-2012  jakllsch We don't actually want to round the number of elements in the bitmap
down. Fixes a self-inflicted buffer overrun.

(This was detected by chance that the top of the bitmap coincided with
a page boundary.)
 1.96 07-Jul-2012  tsutsui branches: 1.96.2;
Revert rev 1.95 since getdisksize() no longer returns secsize=0.
 1.95 30-Jun-2012  tsutsui Add a sanity check if secsize returned from getdisksize() isn't bogus.
This prevent possible panic "panic: buf mem pool index 23" later in
vfs_bio.c:buf_mempoolidx().
(I'm not sure if it's okay for getdisksize() to assume that
partinfo taken from DIOCGPART is properly initialized
on all disk(9) devices or not)

See also:
http://mail-index.NetBSD.org/source-changes/2012/06/30/msg035298.html
 1.94 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.93 14-Nov-2011  hannken branches: 1.93.4; 1.93.6;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.92 07-Oct-2011  hannken branches: 1.92.2;
As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.
 1.91 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.90 04-Apr-2011  hannken branches: 1.90.2;
Msdosfs on-disk meta data is not sufficient to create or validate file handles.

Maintain a tree of file handles, create nodes from msdosfs_vptofh() and keep
them until either the file gets unlinked or the file system gets unmounted.

Fixes the msdosfs part of PR #43745 (fhopen of an unlinked file causes problems
on multiple file systems)
 1.89 27-Dec-2010  hannken branches: 1.89.2;
Extend the range of fstrans transactions to a sequence of vnode operations
on a locked vnode. This leaves a suspended file system and therefore a
snapshot with either all or no operations of such a sequence done.
 1.88 14-Dec-2010  hannken msdosfs_sync: check for dead vnode (denode == NULL) before testing denode flags.
 1.87 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.86 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.85 13-Apr-2010  pooka polish previous
 1.84 13-Apr-2010  pooka If getdisksize() fails (happens e.g. on fss block devices), don't
give up if we don't really need the information provided by it.
 1.83 11-Apr-2010  mlelstv The *_modcmd functions use the module name as prefix.
 1.82 11-Apr-2010  pooka Make module name match MOUNT_NAME. Inspired by PR kern/43110.
 1.81 09-Apr-2010  hannken Add file system suspension support (vfs_suspend(9)) to msdosfs.

Reviewed by: Antti Kantee <pooka@netbsd.org>
 1.80 07-Apr-2010  pooka * Don't care about VOP_CLOSE() error in unmount. In the extremely
unlike event it did fail, the kernel would double lutz to doom
(in failure devvp now remains unmountable until reboot. fans
of complicated & untested error branches may attempt to gunk this
up. i'm not one of them).
* cosmetic surgery: cut extra ;
 1.79 31-Jan-2010  mlelstv branches: 1.79.2; 1.79.4;
Replace individual queries for partition information with
new helper function.
 1.78 26-Jan-2010  mlelstv Drop two uses of disk label data.

msdosfs and cd9660 are the only filesystems that verify the filesystem
type in the label. This is the wrong place, sanity checks should only
rely on the inner structure of the filesystem (like signatures or
magic numbers).

msdosfs also used the device type information from the label to
deduce a filesystem parameter heuristically for the gemdos variant.
If there is no information inside the filesystem data itself, this
should be an explicit mount option.
 1.77 25-Jan-2010  mlelstv Fetch sector size also from wedges.
 1.76 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.75 25-Apr-2009  elad Wrap some long lines in a comment, pointed out by ad@ - thanks!

While here, wrap two more long lines.
 1.74 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.73 15-Mar-2009  cegger ansify function definitions
 1.72 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.71 05-Feb-2009  abs branches: 1.71.2;
Remove additional GEMDOS only check on fstype, and update comment
 1.70 26-Dec-2008  jmcneill Remove pm_Heads check in msdosfs_mountfs; this value isn't really used,
FreeBSD and OpenBSD both removed this check years ago, and this makes an
8GB Memory Stick Pro Duo formatted with a PSP work.
 1.69 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.68 28-Jun-2008  rumble branches: 1.68.4; 1.68.6;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.67 16-May-2008  hannken branches: 1.67.2;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.66 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.65 06-May-2008  ad branches: 1.65.2;
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.64 30-Apr-2008  ad Make various bits of debug code compile again.
 1.63 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.62 29-Apr-2008  ad 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.61 30-Jan-2008  ad branches: 1.61.6; 1.61.8; 1.61.10;
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.60 28-Jan-2008  dholland 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.59 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.58 04-Jan-2008  pooka Politely refuse to mount a file system which says its FAT size is
zero - our implementation can't handle it (how sensible handling
a case like that would be is a whole other debate).

fixes panic reported by Jukka Salmi on current-users
 1.57 03-Jan-2008  pooka valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok
 1.56 02-Jan-2008  ad Merge vmlocking2 to head.
 1.55 08-Dec-2007  pooka branches: 1.55.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.54 26-Nov-2007  pooka branches: 1.54.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.53 10-Oct-2007  ad branches: 1.53.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.52 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.51 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.50 31-Jul-2007  pooka branches: 1.50.2; 1.50.4; 1.50.6; 1.50.8;
* 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.49 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.48 20-Jul-2007  pooka In sync, skip over vnodes based on if they are clean rather than
if they have pages.
 1.47 17-Jul-2007  pooka branches: 1.47.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.46 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.45 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.44 17-Feb-2007  kochi branches: 1.44.4; 1.44.6;
fix the problem reported in kern/35457, "cant mount msdosfs on floppy".

Since 1.40, which introduced support for non-DEV_BSIZE media,
mounting msdos floppy returned ENOTTY.

This is because floppy driver does not support DIOCGPART or DIOCWEDGEINFO
ioctl.

Those ioctls should not be a requirement for mounting msdosfs.

This patch is made by Christian Biere.
 1.43 22-Jan-2007  reinoud branches: 1.43.2;
Fix typo
- * assoicated with this mount point, start over.
+ * associated with this mount point, start over.
 1.42 20-Jan-2007  christos - If the filesystem lives on a wedge, then we try to get wedge information
since DIOCGPART is going to fail. Unfortunately there is no way to get the
geometry information we need from the wedge; it would be nice for wedges
to support a geometry ioctl. The values we cannot retrieve are marked with
XXX.
- Add a lot more debugging.
 1.41 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.40 25-Nov-2006  scw branches: 1.40.2;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.39 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.38 25-Oct-2006  reinoud Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.
 1.37 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.36 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.35 02-Sep-2006  christos branches: 1.35.2; 1.35.4;
add missing initializers
 1.34 14-Aug-2006  gdt When mounting an MSDOS fileysystem, do not require that bytes 252 and
253 of the superblock be zero. Searching the net failed to find any
justification for checking these bytes; all available references say
that they are part of the boot code and not BOOTSIG2 and BOOTSIG3.

Modify the MSDOS 7.1 bootsector definition to have 420 bytes of boot
code and no BOOTSIG[23], rather than 418 bytes of boot code, to follow
available references and apparent Windows practice. A test build
showed that these defines are not used other than in the check removed
by this commit.

Patch tested on netbsd-3, and enabled mounting of a 4 GB CF formatted
under Windows XP and then in a digital camera. The CF was previously
unmountable.

Concept approved on tech-kern by christos@ and martin@.
 1.33 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.32 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.31 14-May-2006  elad branches: 1.31.4;
integrate kauth.
 1.30 21-Feb-2006  thorpej branches: 1.30.2; 1.30.4; 1.30.6;
Use device_class() instead of accessing dv_class directly.
 1.29 11-Dec-2005  christos branches: 1.29.2; 1.29.4; 1.29.6;
merge ktrace-lwp.
 1.28 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.27 10-Sep-2005  christos PR/23773: Tero Kivinen: Cannot mount msdos filesystems if filesystem size >
128GB
PR/31287: Fabien Devaux: msdosfs now can mount >128MB filesystems
 1.26 29-Aug-2005  xtraeme Remove __P()
 1.25 05-Aug-2005  jmmv Let this build when MSDOSFS_DEBUG is defined (v_id disappeared a long time
ago but it was still used here).
 1.24 29-May-2005  christos branches: 1.24.2;
- rename variables to avoid shadowing.
- add a few const.
 1.23 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.22 09-Jan-2005  mycroft branches: 1.22.2;
Rework the mountroot interface so that vfs_mountroot() opens the root device
and just passes it on to the file system functions. This avoids opening and
closing the device several times.

Mentioned on tech-kern some time ago, IIRC. I've been running this for a
long time.
 1.21 02-Jan-2005  thorpej Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.20 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.19 27-Jun-2004  jdolecek set gmtoff in the structure returned by MNT_GETARGS call
 1.18 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.17 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.16 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.15 27-Apr-2004  jdolecek initialize gmtoff in mount structure if mount version is < 3
 1.14 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.13 24-Mar-2004  atatat branches: 1.13.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.12 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.11 14-Oct-2003  dbj add mnt_iflag field to struct mount for internal flags
mv MNT_GONE, MNT_UNMOUNT and MNT_WANTRDWR to this field
additonally add mnt_writeopcountupper and mnt_writeopcountlower fields
in preparation for pending write suspension support work
bump kernel version to 1.6ZD
 1.10 06-Oct-2003  lukem Consistently use "bsBPB" as the struct member for the BIOS parameter block.
 1.9 07-Sep-2003  itojun add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.8 02-Aug-2003  jdolecek Allow separate masks for files and directories. Useful e.g. to turn
the execute bit off for files, but keep search permission for directories.
Change contributed in PR kern/21538 by Pavel Arnost, based on some FreeBSD
patches.
Further manpage changes, and backward-compatibility adjustments done by me.

Also fixes PR kern/16778 by Johan Danielsson, and PR kern/3400 by Rick Byers
 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 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 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 21-Mar-2003  dsl Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_vfsops.c was added on branch nathanw_sa on 2002-12-29 19:56:05 +0000
 1.7.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.7.2.6 17-Jan-2005  skrll Sync with HEAD.
 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 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.13.2.2 27-Jun-2004  he Pull up revision 1.19 (requested by jdolecek in ticket #562):
Set gmtoff in the structure returned by the MNT_GETARGS call.
 1.13.2.1 29-May-2004  tron Pull up revision 1.17 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.22.2.1 29-Apr-2005  kent sync with -current
 1.24.2.8 04-Feb-2008  yamt sync with head.
 1.24.2.7 21-Jan-2008  yamt sync with head
 1.24.2.6 07-Dec-2007  yamt sync with head
 1.24.2.5 27-Oct-2007  yamt sync with head.
 1.24.2.4 03-Sep-2007  yamt sync with head.
 1.24.2.3 26-Feb-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.29.6.2 01-Jun-2006  kardel Sync with head.
 1.29.6.1 22-Apr-2006  simonb Sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.29.2.1 01-Mar-2006  yamt sync with head.
 1.30.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.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.30.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.30.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.30.2.3 03-Sep-2006  yamt sync with head.
 1.30.2.2 11-Aug-2006  yamt sync with head
 1.30.2.1 24-May-2006  yamt sync with head.
 1.31.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.35.4.2 10-Dec-2006  yamt sync with head.
 1.35.4.1 22-Oct-2006  yamt sync with head
 1.35.2.3 01-Feb-2007  ad Sync with head.
 1.35.2.2 12-Jan-2007  ad Sync with head.
 1.35.2.1 18-Nov-2006  ad Sync with head.
 1.40.2.1 27-Feb-2007  riz Pull up following revision(s) (requested by kochi in ticket #453):
sys/fs/msdosfs/msdosfs_vfsops.c: revisions 1.41-1.44 via patch
fix the problem reported in kern/35457, "cant mount msdosfs on floppy".

Since 1.40, which introduced support for non-DEV_BSIZE media,
mounting msdos floppy returned ENOTTY.

This is because floppy driver does not support DIOCGPART or DIOCWEDGEINFO
ioctl.

Those ioctls should not be a requirement for mounting msdosfs.

This patch is made by Christian Biere.
 1.43.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.44.6.1 11-Jul-2007  mjf Sync with head.
 1.44.4.10 25-Oct-2007  ad Fix up mnt_vnodelist handling.
 1.44.4.9 09-Oct-2007  ad Sync with head.
 1.44.4.8 09-Oct-2007  ad Sync with head.
 1.44.4.7 24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.44.4.6 20-Aug-2007  ad Sync with HEAD.
 1.44.4.5 29-Jul-2007  ad Add vfs_destroy() to free mount structures. The specificdata_ref was being
leaked.
 1.44.4.4 15-Jul-2007  ad Sync with head.
 1.44.4.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.44.4.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.44.4.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.47.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.50.8.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.50.8.1 31-Jul-2007  pooka file msdosfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:18 +0000
 1.50.6.2 14-Oct-2007  yamt sync with head.
 1.50.6.1 06-Oct-2007  yamt sync with head.
 1.50.4.3 23-Mar-2008  matt sync with HEAD
 1.50.4.2 09-Jan-2008  matt sync with HEAD
 1.50.4.1 06-Nov-2007  matt sync with HEAD
 1.50.2.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.50.2.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.50.2.2 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.50.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.53.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.53.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.53.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.54.2.2 26-Dec-2007  ad Sync with head.
 1.54.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.55.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.55.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.61.10.5 11-Aug-2010  yamt sync with head.
 1.61.10.4 11-Mar-2010  yamt sync with head
 1.61.10.3 18-Jul-2009  yamt sync with head.
 1.61.10.2 04-May-2009  yamt sync with head.
 1.61.10.1 16-May-2008  yamt sync with head.
 1.61.8.1 18-May-2008  yamt sync with head.
 1.61.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.61.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.61.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.65.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.65.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.67.2.1 03-Jul-2008  simonb Sync with head.
 1.68.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.68.6.2 08-Feb-2009  snj branches: 1.68.6.2.6; 1.68.6.2.10;
Pull up following revision(s) (requested by abs in ticket #420):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.71
Remove additional GEMDOS only check on fstype, and update comment
 1.68.6.1 02-Jan-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #209):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.70
Remove pm_Heads check in msdosfs_mountfs; this value isn't really used,
FreeBSD and OpenBSD both removed this check years ago, and this makes an
8GB Memory Stick Pro Duo formatted with a PSP work.
 1.68.6.2.10.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.68.6.2.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.68.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.68.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.68.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.71.2.2 23-Jul-2009  jym Sync with HEAD.
 1.71.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.79.4.5 21-Apr-2011  rmind sync with head
 1.79.4.4 05-Mar-2011  rmind sync with head
 1.79.4.3 03-Jul-2010  rmind sync with head
 1.79.4.2 30-May-2010  rmind sync with head
 1.79.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.79.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.79.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.89.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.90.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.92.2.4 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.92.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.92.2.2 30-Oct-2012  yamt sync with head
 1.92.2.1 17-Apr-2012  yamt sync with head
 1.93.6.5 17-Oct-2017  martin Apply patch form mlelstv to fix the build after pullup #1506
 1.93.6.4 13-Oct-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #1506):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.128
Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.
Does fix PR 52485.
 1.93.6.3 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1171):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.110 via patch
- From me, FreeBSD, OpenBSD and the FAT specification. Ok christos@
- Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.
- Remove 'secsize==0' and added 'secsize<DEV_BSIZE'
 1.93.6.2 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.93.6.1 05-Jul-2012  riz branches: 1.93.6.1.4; 1.93.6.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #395):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.95
sys/arch/atari/atari/autoconf.c: revision 1.62
sys/dev/md.c: revision 1.67
Add a dirty hack for atari's ancient installation ramdisk:
Forcibly configure md0, md1, and md2 devices before setroot()
for atari's traditional "auto-load from floppy on open" md_root device
which loads installation ramdisk image from floppy.
md(4) has been changed dynamically configured at first open after 5.0
and md devices won't appear in "root device:" prompt without this hack.
Tested on TT030.
Should be pulled up to netbsd-6.
Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().
Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.
Should be pulled up to netbsd-6 (at least for atari).
Add a sanity check if secsize returned from getdisksize() isn't bogus.
This prevent possible panic "panic: buf mem pool index 23" later in
vfs_bio.c:buf_mempoolidx().
(I'm not sure if it's okay for getdisksize() to assume that
partinfo taken from DIOCGPART is properly initialized
on all disk(9) devices or not)
See also:
http://mail-index.NetBSD.org/source-changes/2012/06/30/msg035298.html
 1.93.6.1.6.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1171):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.110 via patch
- From me, FreeBSD, OpenBSD and the FAT specification. Ok christos@
- Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.
- Remove 'secsize==0' and added 'secsize<DEV_BSIZE'
 1.93.6.1.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.93.6.1.4.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1171):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.110 via patch
- From me, FreeBSD, OpenBSD and the FAT specification. Ok christos@
- Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.
- Remove 'secsize==0' and added 'secsize<DEV_BSIZE'
 1.93.6.1.4.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.93.4.1 05-Apr-2012  mrg sync to latest -current.
 1.96.2.4 03-Dec-2017  jdolecek update from HEAD
 1.96.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.96.2.2 23-Jun-2013  tls resync from head
 1.96.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.101.4.1 18-May-2014  rmind sync with head
 1.106.2.1 10-Aug-2014  tls Rebase.
 1.115.4.3 28-Aug-2017  skrll Sync with HEAD
 1.115.4.2 05-Feb-2017  skrll Sync with HEAD
 1.115.4.1 06-Apr-2015  skrll Sync with HEAD
 1.115.2.2 25-Feb-2018  snj Pull up following revision(s) (requested by mlelstv in ticket #1574):
sys/fs/msdosfs/msdosfs_vfsops.c: 1.129
relax sanity check. It's ok to have more FAT sectors than needed.
 1.115.2.1 23-Oct-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #1514):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.128
Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.
Does fix PR 52485.
 1.118.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.118.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.118.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.118.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.119.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.127.4.3 11-Feb-2021  martin Pull up following revision(s) (requested by ryoon in ticket #1653):

sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.136

Enable to mount Raspberry Pi Pico's USB mass storage partition
Fix PR kern/55985.

O.k. by thorpej@.
Pull-up to netbsd-8 and netbsd-9.
 1.127.4.2 22-Jan-2018  martin Pull up following revision(s) (requested by mlelstv in ticket #508):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.129
relax sanity check. It's ok to have more FAT sectors than needed.
 1.127.4.1 23-Sep-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #292):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.128
Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.
Does fix PR 52485.
 1.127.2.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.129.4.3 21-Apr-2020  martin Sync with HEAD
 1.129.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.129.4.1 10-Jun-2019  christos Sync with HEAD
 1.129.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.130.6.3 29-Feb-2020  ad Sync with head.
 1.130.6.2 19-Jan-2020  ad Set IMNT_SHRLOOKUP and use it for the in-cache case. Need to check what
more can be done with tmpfs though, it can probably do the whole lookup.
 1.130.6.1 17-Jan-2020  ad Sync with head.
 1.130.4.1 11-Feb-2021  martin Pull up following revision(s) (requested by ryoon in ticket #1204):

sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.136

Enable to mount Raspberry Pi Pico's USB mass storage partition
Fix PR kern/55985.

O.k. by thorpej@.
Pull-up to netbsd-8 and netbsd-9.
 1.134.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.135.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.113 11-Sep-2024  perseant Move the comment intended to introduce msdosfs_fsync back above
msdosfs_fsync (it has been above the wrong function since 1996).
No functional change.
 1.112 18-Aug-2023  mrg branches: 1.112.6;
fix the previous to not fail to include the extension in lookups.

copy deExtension into the final 3 bytes. previously, this was found
by having them next to each other in the containing structure, but as
separate strings.

thanks to miod for pointing this out.
 1.111 14-Aug-2023  mrg when calling a function that needs more bytes than we have, create a
stack variable long enough and use that instead.

found by GCC 12.
 1.110 23-Oct-2021  thorpej Sanitize the symbol namespace. NFC.
 1.109 23-Oct-2021  hannken Move msdosfs_rename() and doscheckpath() to new file msdosfs_rename.c.

No functional change.
 1.108 23-Oct-2021  hannken Factor out the lookup results from struct denode.

No functional change.
 1.107 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.106 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.105 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.104 27-Jun-2020  christos branches: 1.104.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.103 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.102 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.101 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.100 23-Feb-2020  ad branches: 1.100.4;
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.99 18-Sep-2019  christos branches: 1.99.2;
Add newly created vnodes to the namei cache. The rest of the filesystems
already did that (or they don't support writing). Discussed in tech-kern.
 1.98 26-Apr-2017  riastradh branches: 1.98.12;
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.97 01-Mar-2017  hannken Remove now redundant calls to fstrans_start()/fstrans_done().
 1.96 01-Feb-2016  christos branches: 1.96.2; 1.96.4;
- split a long line.
- remove extra test.
- move d_namlen setting to msdosfs_vnops.c to avoid the ifdef.
 1.95 01-Feb-2016  christos We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).
 1.94 30-Jan-2016  mlelstv Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
 1.93 04-Apr-2015  riastradh Fix remaining read(fd, NULL, 1) cases.
 1.92 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.91 25-Jul-2014  dholland branches: 1.91.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.90 08-Jul-2014  hannken Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.89 23-Jan-2014  hannken branches: 1.89.2;
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.88 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.87 02-Nov-2013  hannken Stop using v_mount of an unreferenced vnode -- save the mount while
the vnode has a reference.
 1.86 18-Mar-2013  plunky branches: 1.86.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.85 28-Dec-2012  hannken Move the initialization of n to after the error branch.

From Taylor R Campbell <riastradh@netbsd.org>
 1.84 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.83 29-Apr-2012  chs branches: 1.83.2;
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.82 03-Apr-2012  njoly Add missing braces in previous commit.
 1.81 02-Apr-2012  njoly Report the SF_ARCHIVED file flag if set.
 1.80 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.79 21-Nov-2011  hannken branches: 1.79.2; 1.79.4;
Add missing fstrans_done().

Should fix PR #45635 (KASSERT "fli->fli_trans_cnt == 0" failed)
 1.78 20-Jul-2011  hannken branches: 1.78.2;
Even though msdosfs never truncates file names it advertises _PC_NO_TRUNC
as zero. Make it advertise one (no_trunc == true).

Names longer than NAME_MAX (255) will never pass namei() btw.

Fixes PR #43670 (msdosfs claims support for filenames longer than {NAME_MAX},
but fails)
 1.77 16-Jun-2011  hannken Rename uvm_vnp_zerorange(struct vnode *, off_t, size_t) to
ubc_zerorange(struct uvm_object *, off_t, size_t, int) changing
the first argument to an uvm_object and adding a flags argument.

Modify tmpfs_reg_resize() to zero the backing store (aobj) instead
of the vnode. Ubc_purge() no longer panics when unmounting tmpfs.

Keep uvm_vnp_zerorange() until the next kernel version bump.
 1.76 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.75 26-Apr-2011  hannken branches: 1.75.2;
Change vflushbuf() to return an error if a synchronous write fails.

Welcome to 5.99.51.
 1.74 20-Mar-2011  hannken When extending a file, either by truncating or by writing past EOF make
sure the unallocated remainder of the last page gets zeroed.

Detected by fsx.
 1.73 19-Mar-2011  hannken Remove a vnode reference leak from msdosfs_rename. Release tdvp if either
doscheckpath() or relookup() fails.

Adjust test fs/vfs/t_vnops.c and remove the link count test for msdos.

Fixes PR #44661
 1.72 03-Mar-2011  pooka In rename, use char[12]�for new names instead of [11]. At least
one routine called from here (unix2dosfn) expects and uses all of
a [12].

This may fix the "stack size exceeded" problem which has been
triggering in gson's test runs. (i'm not entirely sure why it
doesn't trigger in anyone else's env)
 1.71 02-Jan-2011  dholland branches: 1.71.2; 1.71.4;
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.70 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.69 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.68 22-Jul-2010  njoly Remove bad cast, fix compilation with MSDOSFS_DEBUG.
 1.67 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.66 25-May-2010  pooka Don't double unlock fvp if source file disappears during rename.
Problem found by njoly's awesome stresstester.
 1.65 23-Apr-2010  pooka Enforce RLIMIT_FSIZE before VOP_WRITE. This adds support to file
system drivers where it was missing from and fixes one buggy
implementation. The arguably weird semantics of the check are
maintained (v_size vs. va_bytes, overwrite).
 1.64 09-Apr-2010  hannken Add file system suspension support (vfs_suspend(9)) to msdosfs.

Reviewed by: Antti Kantee <pooka@netbsd.org>
 1.63 08-Apr-2010  pooka In genfs where available.

The only functional change is mknod now returning EOPNOTSUPP instead
of EINVAL. I make this sacrifice willingly and with a clean conscience.
 1.62 08-Apr-2010  pooka Use genfs instead of homegrown stuff where possible.
 1.61 03-Jul-2009  elad branches: 1.61.2; 1.61.4;
Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.60 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.59 07-May-2009  elad Extract the open-coded authorization logic for chtimes() from various
file-systems and put it in a single function, genfs_can_chtimes().

This also makes UDF follow the same policy as all other file-systems.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004951.html
 1.58 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.57 11-Jan-2009  cegger branches: 1.57.2;
make this compile
 1.56 11-Jan-2009  christos merge christos-time_t
 1.55 28-Nov-2008  pooka Tyop: v -> vp. Spotted by Tom's ARM builds.
 1.54 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.53 14-Nov-2008  pooka In case writing past EOF, fail if extending the file fails (most
likely due to the file system being full).

Otherwise we'd fail in VOP_PUTPAGES(), which might not happen during
VOP_WRITE(), thus giving the caller the wrong impression that
writing was succesful.
 1.52 16-May-2008  hannken branches: 1.52.4; 1.52.6; 1.52.10;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.51 30-Apr-2008  ad branches: 1.51.2;
Make various bits of debug code compile again.
 1.50 24-Apr-2008  ad branches: 1.50.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.49 30-Jan-2008  ad branches: 1.49.6; 1.49.8;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.48 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.47 05-Jan-2008  christos PR/37696: Paul Ripke: add large read / readahead support (Introduce run-length
detection to msdosfs_bmap(), from FreeBSD)
 1.46 02-Jan-2008  ad Merge vmlocking2 to head.
 1.45 28-Dec-2007  reinoud Use uvm_vnp_setwritesize() on file extending to instruct UVM to NOT read-in
the newly added space first. This significantly speeds up write speed for
msdosfs and making it at par with ffs wich already had this patched.

Speed increase measured on my IDE disc from 2Mb/sec to 32 Mb/sec
 1.44 26-Nov-2007  pooka branches: 1.44.2; 1.44.6;
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.43 14-Nov-2007  pooka Fix a problem noticed by Reinoud: the fs would try to release an
unlocked vnode when trying to rename a directory. The fix was to
shuffle some bits around and #pray.

The rename routine actually needs a very very major wide-angle whopping:
* it takes locks out-of-order
* it deals with references from SAVESTART lookups in interesting ways
* I doubt there is any guarantee for correct operation if there
are multiple concurrent accesses
* the error branches might just as well call panic() directly
 1.42 08-Oct-2007  ad branches: 1.42.2; 1.42.4;
Merge brelse() changes from the vmlocking branch.
 1.41 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.40 29-Jul-2007  rumble branches: 1.40.4; 1.40.6; 1.40.8; 1.40.10;
Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.39 19-Apr-2007  yamt branches: 1.39.2;
hold proclist_mutex when calling psignal().
 1.38 04-Mar-2007  christos branches: 1.38.2; 1.38.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.37 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.36 04-Jan-2007  elad branches: 1.36.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.35 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.34 25-Nov-2006  scw branches: 1.34.2;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.33 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.32 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.31 22-Sep-2006  xtraeme Apply patch from PR kern/34583 sent by Rhialto, quoting him:

"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."

And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".

Also remove a 2 if-statements testing the same condition, combine them.

All that from Rhialto, thank you very much.
 1.30 23-Jul-2006  ad branches: 1.30.2; 1.30.4; 1.30.6;
Use the LWP cached credentials where sane.
 1.29 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.28 14-May-2006  elad branches: 1.28.2;
integrate kauth.
 1.27 14-Apr-2006  christos Coveriry CID 733: Remove dead code.
 1.26 01-Mar-2006  yamt branches: 1.26.2; 1.26.4; 1.26.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.25 14-Jan-2006  christos branches: 1.25.2; 1.25.4;
Protect against uio_lwp being NULL from Pavel Cahyna
 1.24 11-Dec-2005  christos branches: 1.24.2;
merge ktrace-lwp.
 1.23 29-Nov-2005  yamt merge yamt-readahead branch.
 1.22 04-Nov-2005  christos branches: 1.22.2;
PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.21 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.20 12-Sep-2005  christos branches: 1.20.2;
Use nanotime() to update the time fields in filesystems. Convert the code
from macros to real functions. Original patch and review from chuq.
Note: ext2fs only keeps seconds in the on-disk inode, and msdosfs does not
have enough precision for all fields, so this is not very useful for those
two.
 1.19 10-Sep-2005  christos Make fileno calculations use ino_t variables.
 1.18 29-Aug-2005  xtraeme Remove __P()
 1.17 29-Aug-2005  xtraeme The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.

From OpenBSD.

This closes my PR kern/30864: "panic when copying files of >4GB on msdosfs"
 1.16 19-Aug-2005  christos fileid is now a quad.
 1.15 19-Aug-2005  christos 64 bit inode changes.
 1.14 26-Feb-2005  perry branches: 1.14.2; 1.14.4;
nuke trailing whitespace
 1.13 09-Jan-2005  chs branches: 1.13.2; 1.13.4;
adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway. there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
 1.12 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.11 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.10 04-May-2004  jrf Remove caddr_t inlines. Approved by christos@NetBSD.org.
 1.9 26-Jan-2004  hannken branches: 1.9.2; 1.9.4;
Fix xxx_strategy() to use the vnode arg instead of bp->b_vp.
 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-Sep-2003  itojun add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.6 02-Aug-2003  jdolecek Allow separate masks for files and directories. Useful e.g. to turn
the execute bit off for files, but keep search permission for directories.
Change contributed in PR kern/21538 by Pavel Arnost, based on some FreeBSD
patches.
Further manpage changes, and backward-compatibility adjustments done by me.

Also fixes PR kern/16778 by Johan Danielsson, and PR kern/3400 by Rick Byers
 1.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.3 26-Jun-2003  itojun strlcpy
 1.2 25-Feb-2003  jdolecek make 'dosdirtemplate' static const
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfs_vnops.c was added on branch nathanw_sa on 2002-12-29 19:56:06 +0000
 1.5.2.8 11-Dec-2005  christos Sync with head.
 1.5.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.9.4.2 06-Nov-2005  riz Pull up following revision(s) (requested by christos in ticket #5972):
sys/fs/msdosfs/denode.h: revision 1.10
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.22
PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.9.4.1 06-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #5627):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.9.2.1 06-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #5627):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.13.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.2.1 29-Apr-2005  kent sync with -current
 1.14.4.9 04-Feb-2008  yamt sync with head.
 1.14.4.8 21-Jan-2008  yamt sync with head
 1.14.4.7 07-Dec-2007  yamt sync with head
 1.14.4.6 15-Nov-2007  yamt sync with head.
 1.14.4.5 27-Oct-2007  yamt sync with head.
 1.14.4.4 03-Sep-2007  yamt sync with head.
 1.14.4.3 26-Feb-2007  yamt sync with head.
 1.14.4.2 30-Dec-2006  yamt sync with head.
 1.14.4.1 21-Jun-2006  yamt sync with head.
 1.14.2.3 06-Oct-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1525):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.14.2.2 06-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #937):
sys/fs/msdosfs/denode.h: revision 1.10
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.22
PR/32003: Brian Buhrow: msdosfs doesn't properly zero out high cluster data
on non-FAT32 msdos filesystems.
 1.14.2.1 02-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #722):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.17
sys/fs/msdosfs/denode.h: revision 1.6
The maximum file size on MS-DOS filesystems is 4 GB - 1 byte, so
don't bother trying to write files bigger than this. Just return
EFBIG to caller, rather than panic()ing later.
From OpenBSD.
This closes my PR kern/30864: "panic when copying files of >4GB on
msdosfs"
 1.20.2.1 20-Oct-2005  yamt adapt msdosfs.
 1.22.2.3 19-Nov-2005  yamt - as read-ahead context is per-vnode now,
there are less reasons to make VOP_READ call uvm_ra_request explicitly.
move it to pager (uvn_get) so that it can handle accesses via mmap as well.
- pass advice to pager via ubc.
- tweak DPRINTF.

XXX can be disturbed by PGO_LOCKED.

XXX it's controversial where it should be done.
(uvm_fault, uvn_get or genfs_getpages.)
 1.22.2.2 18-Nov-2005  yamt - associate read-ahead context to vnode, rather than file.
- revert VOP_READ prototype.
 1.22.2.1 15-Nov-2005  yamt adapt the rest of filesystems which use genfs_getpages.
 1.24.2.2 18-Feb-2006  yamt adapt the rest of MI code.
 1.24.2.1 15-Jan-2006  yamt sync with head.
 1.25.4.3 01-Jun-2006  kardel Sync with head.
 1.25.4.2 22-Apr-2006  simonb Sync with head.
 1.25.4.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.25.2.1 09-Sep-2006  rpaulo sync with head
 1.26.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.26.4.4 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.26.4.3 19-Apr-2006  elad sync with head.
 1.26.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.26.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.26.2.3 11-Aug-2006  yamt sync with head
 1.26.2.2 26-Jun-2006  yamt sync with head.
 1.26.2.1 24-May-2006  yamt sync with head.
 1.28.2.1 19-Jun-2006  chap Sync with head.
 1.30.6.2 10-Dec-2006  yamt sync with head.
 1.30.6.1 22-Oct-2006  yamt sync with head
 1.30.4.2 12-Jan-2007  ad Sync with head.
 1.30.4.1 18-Nov-2006  ad Sync with head.
 1.30.2.1 23-Sep-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #206):
sys/fs/msdosfs/denode.h: revision 1.14
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.31
sys/fs/msdosfs/msdosfs_fat.c: revision 1.11
Apply patch from PR kern/34583 sent by Rhialto, quoting him:
"Add a 3rd entry in the cache, which keeps the end position
from just before extending a file.
This has the desired effect of keeping the write speed constant."
And yes, that helps a lot copying large files... always at full speed
now. This closes my PR kern/30868 "Poor performance copying large files
on msdosfs".
Also remove a 2 if-statements testing the same condition, combine them.
All that from Rhialto, thank you very much.
 1.34.2.2 01-Feb-2008  riz Pull up following revision(s) (requested by pooka in ticket #1007):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.43
Fix a problem noticed by Reinoud: the fs would try to release an
unlocked vnode when trying to rename a directory. The fix was to
shuffle some bits around and #pray.
The rename routine actually needs a very very major wide-angle whopping:
* it takes locks out-of-order
* it deals with references from SAVESTART lookups in interesting ways
* I doubt there is any guarantee for correct operation if there
are multiple concurrent accesses
* the error branches might just as well call panic() directly
 1.34.2.1 17-Feb-2007  tron branches: 1.34.2.1.2;
Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.34.2.1.2.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.36.2.3 07-May-2007  yamt sync with head.
 1.36.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.36.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.38.4.1 11-Jul-2007  mjf Sync with head.
 1.38.2.6 09-Oct-2007  ad Sync with head.
 1.38.2.5 20-Aug-2007  ad Sync with HEAD.
 1.38.2.4 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.38.2.3 08-Jun-2007  ad Sync with head.
 1.38.2.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.38.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.39.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.40.10.2 29-Jul-2007  rumble Use _DIRENT_MINSIZE when determining the number of NFS cookies to allocate,
rather than hard-coding 16.
 1.40.10.1 29-Jul-2007  rumble file msdosfs_vnops.c was added on branch matt-mips64 on 2007-07-29 21:17:42 +0000
 1.40.8.2 14-Oct-2007  yamt sync with head.
 1.40.8.1 06-Oct-2007  yamt sync with head.
 1.40.6.3 23-Mar-2008  matt sync with HEAD
 1.40.6.2 09-Jan-2008  matt sync with HEAD
 1.40.6.1 06-Nov-2007  matt sync with HEAD
 1.40.4.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.40.4.3 21-Nov-2007  joerg Sync with HEAD.
 1.40.4.2 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.40.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.42.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.42.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.42.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.42.2.1 18-Nov-2007  bouyer Sync with HEAD
 1.44.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.44.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.44.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.49.8.1 18-May-2008  yamt sync with head.
 1.49.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.49.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.50.2.5 11-Aug-2010  yamt sync with head.
 1.50.2.4 18-Jul-2009  yamt sync with head.
 1.50.2.3 16-May-2009  yamt sync with head
 1.50.2.2 04-May-2009  yamt sync with head.
 1.50.2.1 16-May-2008  yamt sync with head.
 1.51.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.10.4 27-Dec-2008  christos merge with head.
 1.52.10.3 20-Nov-2008  christos merge with head.
 1.52.10.2 09-Nov-2008  christos account for major and minor being unsigned long long
 1.52.10.1 16-May-2008  christos file msdosfs_vnops.c was added on branch christos-time_t on 2008-11-09 02:05:20 +0000
 1.52.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.52.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.52.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.57.2.2 23-Jul-2009  jym Sync with HEAD.
 1.57.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.61.4.6 31-May-2011  rmind sync with head
 1.61.4.5 21-Apr-2011  rmind sync with head
 1.61.4.4 05-Mar-2011  rmind sync with head
 1.61.4.3 03-Jul-2010  rmind sync with head
 1.61.4.2 30-May-2010  rmind sync with head
 1.61.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.61.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.61.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.71.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.71.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.75.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.78.2.4 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.78.2.3 23-Jan-2013  yamt sync with head
 1.78.2.2 23-May-2012  yamt sync with head.
 1.78.2.1 17-Apr-2012  yamt sync with head
 1.79.4.2 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.79.4.1 06-Apr-2012  riz Pull up following revision(s) (requested by njoly in ticket #161):
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.81
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.82
Report the SF_ARCHIVED file flag if set.
Add missing braces in previous commit.
 1.79.2.2 02-Jun-2012  mrg sync to latest -current.
 1.79.2.1 05-Apr-2012  mrg sync to latest -current.
 1.83.2.4 03-Dec-2017  jdolecek update from HEAD
 1.83.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.83.2.2 23-Jun-2013  tls resync from head
 1.83.2.1 25-Feb-2013  tls resync with head
 1.86.6.1 18-May-2014  rmind sync with head
 1.89.2.1 10-Aug-2014  tls Rebase.
 1.91.4.3 28-Aug-2017  skrll Sync with HEAD
 1.91.4.2 19-Mar-2016  skrll Sync with HEAD
 1.91.4.1 06-Apr-2015  skrll Sync with HEAD
 1.96.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.96.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.98.12.3 21-Apr-2020  martin Sync with HEAD
 1.98.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.98.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.99.2.1 29-Feb-2020  ad Sync with head.
 1.100.4.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.100.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.104.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.112.6.1 02-Aug-2025  perseant Sync with HEAD
 1.21 30-Jan-2016  mlelstv Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
 1.20 08-Jul-2014  hannken branches: 1.20.4;
Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
referenced but unlocked denode.
 1.19 26-Jan-2013  christos branches: 1.19.10;
more cross-compile friendly.
 1.18 26-Jan-2013  christos expose more stuff if MAKEFS is defined for the headers, and arrange for
the source file to be compilable from userland.
 1.17 04-Nov-2012  jakllsch Stylistic changes in comments/strings:
"FAT" and "fat" are different things, use the appropriate case.
"GEMDOS" is all caps.
 1.16 03-Feb-2012  joerg branches: 1.16.6;
Only use MALLOC_DECLARE if it exists. Helps with the dirty _KERNEL
tricks fstat is using.
 1.15 28-Jun-2008  rumble branches: 1.15.30; 1.15.34;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.14 24-Sep-2007  rumble branches: 1.14.18; 1.14.22; 1.14.24; 1.14.26;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.13 04-Mar-2007  christos branches: 1.13.2; 1.13.14; 1.13.16; 1.13.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 25-Nov-2006  scw branches: 1.12.4;
Support FAT filesystems on non-DEV_BSIZE media.

Based on the patches provided in PR kern/17398 by Trevin Beattie.
 1.11 03-Dec-2005  christos branches: 1.11.20; 1.11.22;
- 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.10 25-Sep-2005  jmmv Follow compat naming tradition: rename compat_export_args to export_args30.
 1.9 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.8 30-Aug-2005  xtraeme Remove __P()
 1.7 20-May-2004  atatat branches: 1.7.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.6 19-Apr-2004  jdolecek properly version the msdosfs mount structure after addition
of gmt time offset support (Hi Itojun!); adresses most important
part of PR kern/25226 by Todd Whitesel
 1.5 03-Oct-2003  yamt branches: 1.5.2;
terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.4 07-Sep-2003  itojun add -t option for gmt time offset (normally MS-DOS filesystem has timestamp
in localtime, not GMT). PR kern/22717
 1.3 02-Aug-2003  jdolecek Allow separate masks for files and directories. Useful e.g. to turn
the execute bit off for files, but keep search permission for directories.
Change contributed in PR kern/21538 by Pavel Arnost, based on some FreeBSD
patches.
Further manpage changes, and backward-compatibility adjustments done by me.

Also fixes PR kern/16778 by Johan Danielsson, and PR kern/3400 by Rick Byers
 1.2 01-Feb-2003  thorpej branches: 1.2.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 26-Dec-2002  jdolecek branches: 1.1.2;
move msdosfs code from sys/msdosfs to sys/fs/msdosfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 26-Dec-2002  thorpej file msdosfsmount.h was added on branch nathanw_sa on 2002-12-29 19:56:07 +0000
 1.2.2.5 11-Dec-2005  christos Sync with head.
 1.2.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.2.2 23-May-2004  tron Pull up revision 1.7 (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.5.2.1 21-Apr-2004  jmc Pullup rev 1.6 (requested by jdolecek in ticket #160)

Properly version the msdosfs mount structure after addition
of gmt time offset support. PR#25226
 1.7.12.4 27-Oct-2007  yamt sync with head.
 1.7.12.3 03-Sep-2007  yamt sync with head.
 1.7.12.2 30-Dec-2006  yamt sync with head.
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.11.22.1 10-Dec-2006  yamt sync with head.
 1.11.20.1 12-Jan-2007  ad Sync with head.
 1.12.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.18.1 06-Oct-2007  yamt sync with head.
 1.13.16.1 06-Nov-2007  matt sync with HEAD
 1.13.14.1 02-Oct-2007  joerg Sync with HEAD.
 1.13.2.1 09-Oct-2007  ad Sync with head.
 1.14.26.1 03-Jul-2008  simonb Sync with head.
 1.14.24.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.22.1 04-May-2009  yamt sync with head.
 1.14.18.1 29-Jun-2008  mjf Sync with HEAD.
 1.15.34.1 18-Feb-2012  mrg merge to -current.
 1.15.30.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.15.30.2 16-Jan-2013  yamt sync with (a bit old) head
 1.15.30.1 17-Apr-2012  yamt sync with head
 1.16.6.4 03-Dec-2017  jdolecek update from HEAD
 1.16.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.2 25-Feb-2013  tls resync with head
 1.16.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.10.1 10-Aug-2014  tls Rebase.
 1.20.4.1 19-Mar-2016  skrll Sync with HEAD
 1.1 30-Sep-2013  dholland branches: 1.1.4; 1.1.6; 1.1.10;
Explain what's here.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 30-Sep-2013  tls file README.newnfs was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.6.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.1.6.1 30-Sep-2013  yamt file README.newnfs was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 30-Sep-2013  rmind file README.newnfs was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.7 13-Dec-2016  pgoyette One more option for the opt_ file.
 1.6 18-Nov-2016  pgoyette Add the initial module(9) infrastructure
 1.5 18-Nov-2016  pgoyette Clean up after the import auto-generate.

At least now it doesn't cause config(1) any problems.
 1.4 18-Nov-2016  pgoyette Resolve conflicts
 1.3 22-Sep-2016  christos add missing attribute
 1.2 11-Oct-2014  uebayasi branches: 1.2.2; 1.2.4;
Define filesystem attributes with vfs dependency.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file files.newnfs was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file files.newnfs was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file files.newnfs was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.2.2.3 05-Feb-2017  skrll Sync with HEAD
 1.2.2.2 05-Dec-2016  skrll Sync with HEAD
 1.2.2.1 05-Oct-2016  skrll Sync with HEAD
 1.1 30-Sep-2013  dholland branches: 1.1.1; 1.1.4; 1.1.6; 1.1.10;
The script for preparing an import of this nfs code.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 30-Sep-2013  tls file nfs2netbsd.sh was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.6.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.1.6.1 30-Sep-2013  yamt file nfs2netbsd.sh was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 30-Sep-2013  rmind file nfs2netbsd.sh was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1.1.1 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.2 13-Dec-2016  pgoyette More changes for creds, mutex, etc.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs.h was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.7 29-Mar-2021  simonb Don't use legacy VM types.
 1.6 29-Sep-2020  msaitoh branches: 1.6.2; 1.6.4;
s/implicitely/implicitly/
 1.5 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.4 18-Nov-2016  pgoyette branches: 1.4.14; 1.4.16;
More clean-up of #includes
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 09-Dec-2013  wiz branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
Fix typo ("then" instead of "than")
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 09-Dec-2013  tls file nfs_clbio.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.2.6.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.2.6.1 09-Dec-2013  yamt file nfs_clbio.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 09-Dec-2013  rmind file nfs_clbio.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.4.16.1 10-Jun-2019  christos Sync with HEAD
 1.4.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 09-Feb-2022  andvar s/ony/only/
 1.3 10-Nov-2021  msaitoh s/derefernce/dereference/ in comment.
 1.2 18-Nov-2016  pgoyette More clean-up of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clcomsubs.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clcomsubs.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clcomsubs.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 18-Nov-2016  pgoyette branches: 1.2.2; 1.2.4; 1.2.18;
More clean-up of #includes
 1.1 18-Nov-2016  pgoyette branches: 1.1.1;
Initial revision
 1.1.1.1 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.2.18.2 03-Dec-2017  jdolecek update from HEAD
 1.2.18.1 18-Nov-2016  jdolecek file nfs_clkdtrace.c was added on branch tls-maxphys on 2017-12-03 11:38:42 +0000
 1.2.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.4.1 18-Nov-2016  pgoyette file nfs_clkdtrace.c was added on branch pgoyette-localcount on 2017-01-07 08:56:48 +0000
 1.2.2.2 05-Dec-2016  skrll Sync with HEAD
 1.2.2.1 18-Nov-2016  skrll file nfs_clkdtrace.c was added on branch nick-nhusb on 2016-12-05 10:55:25 +0000
 1.3 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.2 13-Dec-2016  pgoyette branches: 1.2.52;
Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clkrpc.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clkrpc.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clkrpc.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.52.1 02-Aug-2025  perseant Sync with HEAD
 1.1 18-Nov-2016  pgoyette branches: 1.1.2; 1.1.4; 1.1.18;
Add the initial module(9) infrastructure
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 18-Nov-2016  jdolecek file nfs_clmodule.c was added on branch tls-maxphys on 2017-12-03 11:38:42 +0000
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 18-Nov-2016  pgoyette file nfs_clmodule.c was added on branch pgoyette-localcount on 2017-01-07 08:56:48 +0000
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 18-Nov-2016  skrll file nfs_clmodule.c was added on branch nick-nhusb on 2016-12-05 10:55:25 +0000
 1.2 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clnfsiod.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clnfsiod.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clnfsiod.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.2 18-Nov-2016  pgoyette More clean-up of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clnode.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clnode.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clnode.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clport.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clport.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clport.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.5 27-Feb-2025  andvar Fix various typos in comments.
 1.4 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.3 08-Feb-2024  andvar branches: 1.3.2;
fix misplaced or missing "e" in words with "ment" ending (argument, implement,
increment, decrement, alignment), in comments, documentation, log messages.
 1.2 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clrpcops.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clrpcops.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clrpcops.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 18-Oct-2014  snj branches: 1.2.2; 1.2.4;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clstate.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clstate.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clstate.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.2 05-Feb-2017  skrll Sync with HEAD
 1.2.2.1 05-Dec-2016  skrll Sync with HEAD
 1.2 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clsubs.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clsubs.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clsubs.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.2 13-Dec-2016  pgoyette branches: 1.2.14; 1.2.16;
Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_clvfsops.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_clvfsops.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_clvfsops.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.16.1 10-Jun-2019  christos Sync with HEAD
 1.2.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 25-Mar-2014  christos branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
kill sprintf.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.2 05-Feb-2017  skrll Sync with HEAD
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 25-Mar-2014  tls file nfs_clvnops.c was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.2.6.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.2.6.1 25-Mar-2014  yamt file nfs_clvnops.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 25-Mar-2014  rmind file nfs_clvnops.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_kdtrace.h was added on branch tls-maxphys on 2014-08-20 00:04:26 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_kdtrace.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_kdtrace.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.2 18-Nov-2016  pgoyette More clean-up of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsmount.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsmount.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsmount.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 13-Dec-2016  pgoyette Adapt code for our location of the nfs headers, and some updates for
differences in kernel options(4) handling
 1.2 18-Nov-2016  pgoyette More clean-up of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsnode.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsnode.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsnode.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlminfo.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlminfo.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlminfo.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.2 18-Nov-2016  pgoyette Clean up some #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file bootp_subr.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file bootp_subr.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file bootp_subr.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file krpc.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file krpc.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file krpc.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.7 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.6 18-Nov-2016  pgoyette branches: 1.6.52;
Clean up some #includes
 1.5 18-Nov-2016  pgoyette Resolve conflicts
 1.4 10-Jun-2016  ozaki-r branches: 1.4.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.3 07-Feb-2015  mlelstv invalidate input mbuf as soon as it is consumed by the mbuf chain
to avoid a double free later.
 1.2 07-Feb-2015  christos fix mbuf leak; this is not being compiled yet.
Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.8; 1.1.1.1.10; 1.1.1.1.12;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.12.3 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.12.2 09-Jul-2016  skrll Sync with HEAD
 1.1.1.1.12.1 06-Apr-2015  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file krpc_subr.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.8.1 16-Feb-2015  martin Pull up following revision(s) (requested by maxv in ticket #520):
sys/ufs/chfs/ebh.c: revision 1.6
sys/dev/sdmmc/sdmmc_mem.c: revision 1.33
sys/dev/ic/aic7xxx.c: revision 1.132
sys/fs/nfs/common/krpc_subr.c: revision 1.2
sys/modules/lua/lua.c: revision 1.16
sys/fs/udf/udf_subr.c: revision 1.128
sys/ufs/chfs/chfs_scan.c: revision 1.6
sys/dev/ic/an.c: revision 1.62

Fix six memory leaks and two inconsistencies.
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file krpc_subr.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file krpc_subr.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.4.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.52.1 02-Aug-2025  perseant Sync with HEAD
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_common.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_common.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_common.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_commonacl.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_commonacl.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_commonacl.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 16-Jun-2023  andvar s/curent/current/ in comment.
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_commonkrpc.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_commonkrpc.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_commonkrpc.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_commonport.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_commonport.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_commonport.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.7 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.6 05-Feb-2024  andvar branches: 1.6.2;
fix various typos in comments.
 1.5 07-Oct-2022  andvar s/alpahbetics/alphabetics/ in comment.
 1.4 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.3 26-Apr-2018  maxv branches: 1.3.2;
Fix inverted arguments in MGET().
 1.2 13-Dec-2016  pgoyette branches: 1.2.14;
More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_commonsubs.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_commonsubs.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_commonsubs.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.14.1 02-May-2018  pgoyette Synch with HEAD
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_diskless.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_diskless.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_diskless.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_fha.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_fha.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_fha.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 07-Jul-2016  msaitoh branches: 1.2.2;
KNF. Remove extra spaces. No functional change.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.12.2 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.12.1 09-Jul-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_fha.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_fha.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_fha.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_kdtrace.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_kdtrace.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_kdtrace.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 02-Jan-2020  thorpej - Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.2 13-Dec-2016  pgoyette branches: 1.2.16;
More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_lock.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_lock.c was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_lock.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_lock.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_lock.h was added on branch yamt-pagecache on 2014-05-22 11:41:00 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_lock.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 18-Nov-2016  pgoyette branches: 1.1.2; 1.1.4; 1.1.18;
Add the initial module(9) infrastructure
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 18-Nov-2016  jdolecek file nfs_module.c was added on branch tls-maxphys on 2017-12-03 11:38:42 +0000
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 18-Nov-2016  pgoyette file nfs_module.c was added on branch pgoyette-localcount on 2017-01-07 08:56:48 +0000
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 18-Nov-2016  skrll file nfs_module.c was added on branch nick-nhusb on 2016-12-05 10:55:25 +0000
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_mountcommon.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_mountcommon.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_mountcommon.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette More cleanup of #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_nfssvc.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_nfssvc.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_nfssvc.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_var.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_var.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_var.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfscl.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfscl.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfscl.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsclstate.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsclstate.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsclstate.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsdiskless.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsdiskless.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsdiskless.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsdport.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsdport.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsdport.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Disable duplicate typedef
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfskpiport.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfskpiport.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfskpiport.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.4 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 07-Jul-2016  msaitoh branches: 1.2.2;
KNF. Remove extra spaces. No functional change.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.12.3 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.2 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.12.1 09-Jul-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsm_subs.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsm_subs.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsm_subs.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4 01-Feb-2018  maxv Remove unused (and a reference to ovbcopy along the way).
 1.3 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.2 18-Nov-2016  pgoyette Clean up some #includes
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsport.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsport.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsport.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsproto.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsproto.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsproto.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsrvcache.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsrvcache.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsrvcache.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.3 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.2 13-Dec-2016  pgoyette branches: 1.2.52;
Mostly mechanical updates for caddr_t, thread, mutex, and credentials
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsrvstate.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsrvstate.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsrvstate.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.52.1 02-Aug-2025  perseant Sync with HEAD
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfssvc.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfssvc.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfssvc.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfsv4_errstr.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfsv4_errstr.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfsv4_errstr.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file old_xdr_subs.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file old_xdr_subs.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file old_xdr_subs.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file oldnfsproto.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file oldnfsproto.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file oldnfsproto.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file rpcv2.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file rpcv2.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file rpcv2.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file xdr_subs.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file xdr_subs.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file xdr_subs.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.12.1 09-Jul-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_advlock.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_advlock.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_advlock.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot_clnt.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot_clnt.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot_clnt.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.5 28-Apr-2023  andvar fix few typos and grammar in comments.
 1.4 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 13-Dec-2015  christos branches: 1.2.2;
PR/50535: David Binderman: Fix nonsense strcmp
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.12.3 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.2 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.12.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot_impl.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot_impl.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot_impl.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot_server.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot_server.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot_server.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot_svc.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot_svc.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot_svc.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nlm_prot_xdr.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nlm_prot_xdr.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nlm_prot_xdr.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file sm_inter.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file sm_inter.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file sm_inter.h was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update for location of newnfs headers, clean up some other #include
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.1 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file sm_inter_xdr.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file sm_inter_xdr.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file sm_inter_xdr.c was added on branch rmind-smpnet on 2014-05-18 17:46:05 +0000
 1.2 13-Dec-2016  pgoyette Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_fha_new.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_fha_new.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_fha_new.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_fha_new.h was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_fha_new.h was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_fha_new.h was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.5 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.4 13-Dec-2016  pgoyette branches: 1.4.52;
Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 27-Nov-2013  christos branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.2 05-Feb-2017  skrll Sync with HEAD
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 27-Nov-2013  tls file nfs_nfsdcache.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.2.6.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.2.6.1 27-Nov-2013  yamt file nfs_nfsdcache.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 27-Nov-2013  rmind file nfs_nfsdcache.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.4.52.1 02-Aug-2025  perseant Sync with HEAD
 1.5 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.4 13-Dec-2016  pgoyette branches: 1.4.52;
Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 25-Mar-2014  christos branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
kill sprintf.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.2 05-Feb-2017  skrll Sync with HEAD
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 25-Mar-2014  tls file nfs_nfsdkrpc.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.2.6.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.2.6.1 25-Mar-2014  yamt file nfs_nfsdkrpc.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 25-Mar-2014  rmind file nfs_nfsdkrpc.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.4.52.1 02-Aug-2025  perseant Sync with HEAD
 1.1 18-Nov-2016  pgoyette branches: 1.1.2; 1.1.4; 1.1.18;
Add the initial module(9) infrastructure
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 18-Nov-2016  jdolecek file nfs_nfsdmodule.c was added on branch tls-maxphys on 2017-12-03 11:38:42 +0000
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 18-Nov-2016  pgoyette file nfs_nfsdmodule.c was added on branch pgoyette-localcount on 2017-01-07 08:56:48 +0000
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 18-Nov-2016  skrll file nfs_nfsdmodule.c was added on branch nick-nhusb on 2016-12-05 10:55:26 +0000
 1.4 29-Mar-2021  simonb Don't use legacy VM types.
 1.3 03-Sep-2018  riastradh branches: 1.3.12; 1.3.14;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.2 13-Dec-2016  pgoyette branches: 1.2.14; 1.2.16;
Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_nfsdport.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_nfsdport.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_nfsdport.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.2.16.1 10-Jun-2019  christos Sync with HEAD
 1.2.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.3.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.5 05-Feb-2024  andvar branches: 1.5.2;
fix various typos in comments.
 1.4 13-Dec-2016  pgoyette Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 25-Mar-2014  christos branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
kill sprintf.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.2 05-Feb-2017  skrll Sync with HEAD
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 25-Mar-2014  tls file nfs_nfsdserv.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.2.6.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.2.6.1 25-Mar-2014  yamt file nfs_nfsdserv.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 25-Mar-2014  rmind file nfs_nfsdserv.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 13-Dec-2016  pgoyette Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10; 1.1.1.1.12; 1.1.1.1.16;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.1.1.12.2 05-Feb-2017  skrll Sync with HEAD
 1.1.1.1.12.1 05-Dec-2016  skrll Sync with HEAD
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_nfsdsocket.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_nfsdsocket.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_nfsdsocket.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.6 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.5 28-May-2023  andvar branches: 1.5.6;
s/Resture/Restore/ and s/restared/restarted/ in comments.
 1.4 13-Dec-2016  pgoyette Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 27-Nov-2013  christos branches: 1.2.4; 1.2.6; 1.2.10; 1.2.12; 1.2.16;
Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.2.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.12.2 05-Feb-2017  skrll Sync with HEAD
 1.2.12.1 05-Dec-2016  skrll Sync with HEAD
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 27-Nov-2013  tls file nfs_nfsdstate.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.2.6.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.2.6.1 27-Nov-2013  yamt file nfs_nfsdstate.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 27-Nov-2013  rmind file nfs_nfsdstate.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.5.6.1 02-Aug-2025  perseant Sync with HEAD
 1.4 13-Dec-2016  pgoyette Update locations for new nfs header files.

XXX Some #includes are just disabled (via #if 0) and will need to be
XXX resolved before further progress can be made.
 1.3 18-Nov-2016  pgoyette Resolve conflicts
 1.2 18-Oct-2014  snj branches: 1.2.2; 1.2.4;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.1 30-Sep-2013  dholland branches: 1.1.1;
Initial revision
 1.1.1.2 18-Nov-2016  pgoyette Update to FreeBSD revision 308975 ( approx 2016-11-18 07:30 UTC)

If I'm going to try to get this working, I should at least start with
the most recent code available.
 1.1.1.1 30-Sep-2013  dholland branches: 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.10;
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.
 1.1.1.1.10.3 03-Dec-2017  jdolecek update from HEAD
 1.1.1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.1.1.10.1 30-Sep-2013  tls file nfs_nfsdsubs.c was added on branch tls-maxphys on 2014-08-20 00:04:27 +0000
 1.1.1.1.6.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.1.1.1.6.1 30-Sep-2013  yamt file nfs_nfsdsubs.c was added on branch yamt-pagecache on 2014-05-22 11:41:01 +0000
 1.1.1.1.4.2 18-May-2014  rmind sync with head
 1.1.1.1.4.1 30-Sep-2013  rmind file nfs_nfsdsubs.c was added on branch rmind-smpnet on 2014-05-18 17:46:06 +0000
 1.2.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.2 05-Feb-2017  skrll Sync with HEAD
 1.2.2.1 05-Dec-2016  skrll Sync with HEAD
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file Makefile was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file Makefile was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 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 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4; 1.1.6;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.6.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.4.3 11-Mar-2010  yamt sync with head
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file files.nilfs was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file files.nilfs was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.2.20.1 03-Dec-2017  jdolecek update from HEAD
 1.6 21-Mar-2020  reinoud Compile in the DPRINTF debug macro's on DEBUG kernels
 1.5 15-Oct-2014  hannken branches: 1.5.20;
Change nilfs to vcache.
 1.4 18-Oct-2013  christos remove unused variable warnings
 1.3 28-Jul-2012  matt branches: 1.3.2; 1.3.4;
Fix -fno-common found by building i386/conf/ALL
 1.2 27-Sep-2011  christos branches: 1.2.2;
define NILFS_MAXNAMLEN and use it.
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs.h was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs.h was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.2.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.2.2.1 30-Oct-2012  yamt sync with head
 1.3.4.1 18-May-2014  rmind sync with head
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.20.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 22-Oct-2009  bouyer Remove closes 3 and 4 from my copyright.
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.4.3 11-Mar-2010  yamt sync with head
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_bswap.h was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_bswap.h was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.5 26-Dec-2024  andvar s/constrains/constraints/ in comment.
 1.4 16-Feb-2022  andvar branches: 1.4.10;
fix various typos, mainly in comments.
 1.3 01-Dec-2012  mbalmer Fix misspelling: accommodate is a long enough word to have room for two 'c's
and two 'm's.
 1.2 24-Jun-2010  reinoud branches: 1.2.8; 1.2.18;
Update NiLFS(2) on-disc structures from Linux version
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.8.1 03-Jul-2010  rmind sync with head
 1.1.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.4.3 11-Aug-2010  yamt sync with head.
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_fs.h was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_fs.h was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.2.18.1 25-Feb-2013  tls resync with head
 1.2.8.1 16-Jan-2013  yamt sync with (a bit old) head
 1.4.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 16-Oct-2019  maya Switch files copyright Reinoud Zandijk from BSD 4 clause to BSD 2 clause.

OK'd by reinoud in email (from 4 Feb 2019).
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4; 1.1.68;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.68.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_mount.h was added on branch yamt-nfs-mp on 2009-08-19 18:48:13 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_mount.h was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.16 05-Dec-2021  msaitoh s/seach/search/
 1.15 21-Mar-2020  reinoud Fix use-after-free issue!
 1.14 29-Mar-2015  riastradh branches: 1.14.18;
Complete removal of cred argument from bread in nilfs.
 1.13 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.12 15-Oct-2014  hannken branches: 1.12.2;
Change nilfs to vcache.
 1.11 15-Oct-2014  hannken Prepare nilfs for vcache:
- Calling getnewvnode() with "mp == NULL" is wrong. Stop attaching a
vnode to system file nodes and change nilfs_bread() to translate
the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
a nilfs node with locked vnode. Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.
 1.10 18-Oct-2013  christos remove unused variable warnings
 1.9 20-Dec-2012  hannken branches: 1.9.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.8 12-Jun-2011  rmind branches: 1.8.2; 1.8.12;
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.7 11-Aug-2010  pgoyette branches: 1.7.6;
Keep condvar wmesg's within 8-char limit
 1.6 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.5 24-Jun-2010  reinoud Pullup changes from the write implementation:
- remove unnessisary check that would prevent it from mounting newer nilfs
images. A field has been added in the segment summary.
- store blocks of files on their virtual block number
 1.4 29-Jul-2009  reinoud branches: 1.4.2; 1.4.4; 1.4.6;
Re-do nilfs_load_super_root() and implement crc checking of read in super root
to check for consistency.

Since a new crc-seed is chosen on each new nilfs formatting, older structures
will fail the crc check.
 1.3 29-Jul-2009  reinoud Add debugging text to indicate a super root has been found while searching for
it.
 1.2 28-Jul-2009  reinoud Enhance/fix read support for sparse files.

Extents read in wich there were no mappings at all were defined would error
out and files beginning with a sparse area were erroring out.
 1.1 18-Jul-2009  reinoud branches: 1.1.2;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_subr.c was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.4.6.4 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.4.6.3 05-Mar-2011  rmind sync with head
 1.4.6.2 03-Jul-2010  rmind sync with head
 1.4.6.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.4.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.2.4 09-Oct-2010  yamt sync with head
 1.4.2.3 11-Aug-2010  yamt sync with head.
 1.4.2.2 19-Aug-2009  yamt sync with head.
 1.4.2.1 29-Jul-2009  yamt file nilfs_subr.c was added on branch yamt-nfs-mp on 2009-08-19 18:48:14 +0000
 1.7.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.12.3 03-Dec-2017  jdolecek update from HEAD
 1.8.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.12.1 25-Feb-2013  tls resync with head
 1.8.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.8.2.1 23-Jan-2013  yamt sync with head
 1.9.2.1 18-May-2014  rmind sync with head
 1.12.2.1 06-Apr-2015  skrll Sync with HEAD
 1.14.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5 29-Jan-2023  reinoud Remove old prototypes from writing that shouldn't have been comitted at all!
 1.4 29-Mar-2015  riastradh branches: 1.4.10; 1.4.22; 1.4.48;
Complete removal of cred argument from bread in nilfs.
 1.3 15-Oct-2014  hannken branches: 1.3.2;
Change nilfs to vcache.
 1.2 15-Oct-2014  hannken Prepare nilfs for vcache:
- Calling getnewvnode() with "mp == NULL" is wrong. Stop attaching a
vnode to system file nodes and change nilfs_bread() to translate
the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
a nilfs node with locked vnode. Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4; 1.1.26;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.26.1 03-Dec-2017  jdolecek update from HEAD
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_subr.h was added on branch yamt-nfs-mp on 2009-08-19 18:48:14 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_subr.h was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.3.2.1 06-Apr-2015  skrll Sync with HEAD
 1.4.48.1 27-Jun-2023  martin Pull up following revision(s) (requested by reinoud in ticket #218):

sys/fs/nilfs/nilfs_subr.h: revision 1.5

Remove old prototypes from writing that shouldn't have been comitted at all!
 1.4.22.1 27-Jun-2023  martin Pull up following revision(s) (requested by reinoud in ticket #1657):

sys/fs/nilfs/nilfs_subr.h: revision 1.5

Remove old prototypes from writing that shouldn't have been comitted at all!
 1.4.10.1 27-Jun-2023  martin Pull up following revision(s) (requested by reinoud in ticket #1848):

sys/fs/nilfs/nilfs_subr.h: revision 1.5

Remove old prototypes from writing that shouldn't have been comitted at all!
 1.27 16-Sep-2021  andvar fix typos in word "successful".
 1.26 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.25 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.24 28-May-2018  chs branches: 1.24.2; 1.24.8;
add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.23 17-Feb-2017  hannken branches: 1.23.4; 1.23.12;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.22 07-Jul-2016  msaitoh branches: 1.22.2; 1.22.4;
KNF. Remove extra spaces. No functional change.
 1.21 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.20 07-Feb-2015  maxv Revert previous, it was a false positive.

In nilfs_mount_device() there's one branch where the node is not released:
when the device is already mounted. Not releasing it was thus intentional,
but this is something code scanners can't understand.
 1.19 07-Feb-2015  christos fix devvp leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4
 1.18 15-Oct-2014  hannken branches: 1.18.2;
Change nilfs to vcache.
 1.17 15-Oct-2014  hannken Prepare nilfs for vcache:
- Calling getnewvnode() with "mp == NULL" is wrong. Stop attaching a
vnode to system file nodes and change nilfs_bread() to translate
the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
a nilfs node with locked vnode. Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.
 1.16 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.15 23-Mar-2014  hannken branches: 1.15.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.14 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.13 01-Nov-2013  mrg apply __diagused where appropriate.
 1.12 18-Oct-2013  christos remove unused variable warnings
 1.11 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.10 20-Dec-2012  hannken branches: 1.10.2;
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.9 13-Mar-2012  elad branches: 1.9.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.8 14-Nov-2011  hannken branches: 1.8.4; 1.8.6; 1.8.10; 1.8.12;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.7 13-Nov-2011  christos use getdisksize, M_ZERO, and malloc M_WAITOK doesn't fai.
 1.6 13-Nov-2011  dholland Avoid panic on error path, from PR 45607. The error path is exercised
because this is using DIOCGPART to get the volume size, which doesn't
work on wedges. It should be calling getdisksize() instead.
 1.5 11-Aug-2010  pgoyette branches: 1.5.8;
Remove extra char - not sure where that came from (duplicated vi command?)

I really need more caffeine.

Thanks pooka@ for noticing.
 1.4 11-Aug-2010  pgoyette Keep condvar wmesg's within 8-char limit
 1.3 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.2 01-May-2010  reinoud As per change in NiLFS2 spec, select the superblocks on highest checksum
number and not on their timestamp since one of the timestamps could be wrong when the
clock was set wrong for whatever reason.
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.8.3 05-Mar-2011  rmind sync with head
 1.1.8.2 03-Jul-2010  rmind sync with head
 1.1.8.1 30-May-2010  rmind sync with head
 1.1.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.4.4 09-Oct-2010  yamt sync with head
 1.1.4.3 11-Aug-2010  yamt sync with head.
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_vfsops.c was added on branch yamt-nfs-mp on 2009-08-19 18:48:14 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_vfsops.c was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.5.8.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.5.8.2 23-Jan-2013  yamt sync with head
 1.5.8.1 17-Apr-2012  yamt sync with head
 1.8.12.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.8.10.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.8.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.8.4.1 05-Apr-2012  mrg sync to latest -current.
 1.9.2.3 03-Dec-2017  jdolecek update from HEAD
 1.9.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 25-Feb-2013  tls resync with head
 1.10.2.1 18-May-2014  rmind sync with head
 1.15.2.1 10-Aug-2014  tls Rebase.
 1.18.2.3 28-Aug-2017  skrll Sync with HEAD
 1.18.2.2 09-Jul-2016  skrll Sync with HEAD
 1.18.2.1 06-Apr-2015  skrll Sync with HEAD
 1.22.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.22.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.22.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.23.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.23.4.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.24.8.1 17-Jan-2020  ad Sync with head.
 1.24.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48 07-Oct-2022  andvar fix few typos in comments.
 1.47 28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.46 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.45 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.44 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.43 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.42 27-Jun-2020  christos branches: 1.42.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.41 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.40 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.39 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.38 27-Dec-2019  msaitoh branches: 1.38.6;
s/transfered/transferred/
 1.37 26-May-2017  riastradh branches: 1.37.10;
Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.36 26-May-2017  riastradh 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.35 26-Apr-2017  riastradh 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.34 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.33 20-Aug-2016  hannken branches: 1.33.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.32 20-Apr-2015  riastradh branches: 1.32.2;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.31 29-Mar-2015  riastradh Complete removal of cred argument from bread in nilfs.
 1.30 15-Oct-2014  hannken branches: 1.30.2;
Change nilfs to vcache.
 1.29 15-Oct-2014  hannken Prepare nilfs for vcache:
- Calling getnewvnode() with "mp == NULL" is wrong. Stop attaching a
vnode to system file nodes and change nilfs_bread() to translate
the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
a nilfs node with locked vnode. Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.
 1.28 25-Jul-2014  dholland 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.27 07-Feb-2014  hannken branches: 1.27.2;
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.26 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.25 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.24 18-Oct-2013  christos remove unused variable warnings
 1.23 08-May-2013  reinoud branches: 1.23.2;
Fix Typo
 1.22 08-May-2013  reinoud Fix serious file read problem due to not-so-clear VOP_BMAP description. Should
fix PR 45605.
 1.21 18-Mar-2013  plunky C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.20 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.19 05-Nov-2012  dholland 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.18 22-Jul-2012  rmind branches: 1.18.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.17 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.16 18-Nov-2011  christos branches: 1.16.4; 1.16.6;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.15 16-Oct-2011  hannken branches: 1.15.2;
VOP_GETATTR() needs a shared lock at least.

While here fix a typo (fvp -> tvp).
 1.14 27-Sep-2011  christos define NILFS_MAXNAMLEN and use it.
 1.13 19-Jun-2011  rmind - Fix a silly bug: remove umap from uobj in ubc_release() UBC_UNMAP case.
- Use UBC_WANT_UNMAP() consistently.

ARM (PMAP_CACHE_VIVT case) works again.
 1.12 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.11 19-May-2011  rmind branches: 1.11.2;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.10 24-Apr-2011  rmind sys_link: prevent hard links on directories (cross-mount operations are
already prevented). File systems are no longer responsible to check this.
Clean up and add asserts (note that dvp == vp cannot happen in vop_link).

OK dholland@
 1.9 30-Nov-2010  dholland branches: 1.9.2;
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.8 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.7 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.6 24-Jun-2010  reinoud Pullup changes from the write implementation:
- remove unnessisary check that would prevent it from mounting newer nilfs
images. A field has been added in the segment summary.
- store blocks of files on their virtual block number
 1.5 24-Jun-2010  hannken Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.
 1.4 08-Jan-2010  pooka branches: 1.4.2; 1.4.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.3 05-Jan-2010  mbalmer Remove extra semicolons.
 1.2 26-Aug-2009  elad Split nilfs_access() to nilfs_check_possible() and nilfs_check_permitted().
 1.1 18-Jul-2009  reinoud branches: 1.1.2; 1.1.4;
Import read-only part of the NiLFS (v2) implementation for NetBSD. It has been
tested with a DEBUG+DIAGNOSTIC+LOCKDEBUG kernel. To summerise NiLFS, i'll
repeat my posting to tech-kern here:

NiLFS stands for New implementation of Logging File System; LFS done
right they claim :) It is at version 2 now and is being developed by NTT, the
Japanese telecom company and recently put into the linux source tree. See
http://www.nilfs.org. The on-disc format is not completely frozen and i expect
at least one minor revision to come in time.

The benefits of NiLFS are build-in fine-grained checkpointing, persistent
snapshots, multiple mounts and very large file and media support. Every
checkpoint can be transformed into a snapshot and v.v. It is said to perform
very well on flash media since it is not overwriting pieces apart from a
incidental update of the superblock, but that might change. It is accompanied
by a cleaner to clean up the segments and recover lost space.

My work is not a port of the linux code; its a new implementation. Porting the
code would be more work since its very linux oriented and never written to be
ported outside linux. The goal is to be fully interchangable. The code is non
intrusive to other parts of the kernel. It is also very light-weight.

The current state of the code is read-only access to both clean and dirty
NiLFS partitions. On mounting a dirty partition it rolls forward the log to
the last checkpoint. Full read-write support is however planned!

Just as the linux code, mount_nilfs allows for the `head' to be mounted
read/write and allows multiple read-only snapshots/checkpoint mounts next to
it.

By allowing the RW mount at a different snapshot for read-write it should be
possible eventually to revert back to a previous state; i.e. try to upgrade a
system and being able to revert to the exact state prior to the upgrade.

Compared to other FS's its pretty light-weight, suitable for embedded use and
on flash media. The read-only code is currently 17kb object code on
NetBSD/i386. I doubt the read-write code will surpass the 50 or 60. Compared
this to FFS being 156kb, UDF being 84 kb and NFS being 130kb. Run-time memory
usage is most likely not very different from other uses though maybe a bit
higher than FFS.
 1.1.4.5 11-Aug-2010  yamt sync with head.
 1.1.4.4 11-Mar-2010  yamt sync with head
 1.1.4.3 16-Sep-2009  yamt sync with head
 1.1.4.2 19-Aug-2009  yamt sync with head.
 1.1.4.1 18-Jul-2009  yamt file nilfs_vnops.c was added on branch yamt-nfs-mp on 2009-08-19 18:48:14 +0000
 1.1.2.2 23-Jul-2009  jym Sync with HEAD.
 1.1.2.1 18-Jul-2009  jym file nilfs_vnops.c was added on branch jym-xensuspend on 2009-07-23 23:32:32 +0000
 1.4.4.4 31-May-2011  rmind sync with head
 1.4.4.3 05-Mar-2011  rmind sync with head
 1.4.4.2 03-Jul-2010  rmind sync with head
 1.4.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.4.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15.2.4 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.15.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.15.2.2 30-Oct-2012  yamt sync with head
 1.15.2.1 17-Apr-2012  yamt sync with head
 1.16.6.2 13-Jun-2013  msaitoh Pull up following revision(s) (requested by reinoud in ticket #894):
sys/fs/nilfs/nilfs_vnops.c: revision 1.22-1.23
Fix serious file read problem due to not-so-clear VOP_BMAP description. Should
fix PR 45605.
 1.16.6.1 12-Aug-2012  martin branches: 1.16.6.1.4; 1.16.6.1.6;
Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.16.6.1.6.1 13-Jun-2013  msaitoh Pull up following revision(s) (requested by reinoud in ticket #894):
sys/fs/nilfs/nilfs_vnops.c: revision 1.22-1.23
Fix serious file read problem due to not-so-clear VOP_BMAP description. Should
fix PR 45605.
 1.16.6.1.4.1 13-Jun-2013  msaitoh Pull up following revision(s) (requested by reinoud in ticket #894):
sys/fs/nilfs/nilfs_vnops.c: revision 1.22-1.23
Fix serious file read problem due to not-so-clear VOP_BMAP description. Should
fix PR 45605.
 1.16.4.1 05-Apr-2012  mrg sync to latest -current.
 1.18.2.4 03-Dec-2017  jdolecek update from HEAD
 1.18.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.2.2 23-Jun-2013  tls resync from head
 1.18.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.2.1 18-May-2014  rmind sync with head
 1.27.2.1 10-Aug-2014  tls Rebase.
 1.30.2.4 28-Aug-2017  skrll Sync with HEAD
 1.30.2.3 05-Oct-2016  skrll Sync with HEAD
 1.30.2.2 06-Jun-2015  skrll Sync with HEAD
 1.30.2.1 06-Apr-2015  skrll Sync with HEAD
 1.32.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.33.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.37.10.2 21-Apr-2020  martin Sync with HEAD
 1.37.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.6.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.38.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.42.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-12-29 19:56:08 +0000
 1.5 14-May-2024  andvar fix recently committed typos by msaitoh in few more places, as well as few more.
mainly s/contigous/contiguous/ and s/miliseconds/milliseconds/ in comments.
 1.4 28-Feb-2010  snj Fight the ever-increasing size of src checkouts by spelling "useful"
without an extra l.
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.96;
merge ktrace-lwp.
 1.2 02-Aug-2003  jdolecek remove all traces of non-working quota support
add quota support to TODO - makes sense only once writing support
would be implemented, and only once NTFS would support notion of file 'owner'

adresses kern/21967 by Martin Husemann
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file TODO was added on branch nathanw_sa on 2002-12-29 19:56:09 +0000
 1.3.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.74.1 11-Mar-2010  yamt sync with head
 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 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.106; 1.1.128;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.128.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.106.1 11-Mar-2010  yamt sync with head
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file files.ntfs was added on branch nathanw_sa on 2002-12-29 19:56:10 +0000
 1.2.20.1 03-Dec-2017  jdolecek update from HEAD
 1.21 28-Dec-2014  maxv Two typos:
- reserver4 -> reserved4 (in struct bootfile)
- "inducates" -> "indicates" (comment)
 1.20 13-Nov-2014  hannken branches: 1.20.2;
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.19 05-May-2008  ad branches: 1.19.44;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.18 29-Jan-2008  pooka branches: 1.18.6; 1.18.8; 1.18.10;
Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.17 10-Oct-2007  ad branches: 1.17.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.16 04-Mar-2007  christos branches: 1.16.2; 1.16.14; 1.16.16; 1.16.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.15 09-Dec-2006  chs branches: 1.15.2;
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.14 14-May-2006  he branches: 1.14.8; 1.14.10; 1.14.12;
Don't use MALLOC_DECLARE() unless _KERNEL is defined.
Fixes build problem of usr.bin/fstat/ for vax.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.12;
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 23-Oct-2005  christos make debugging code compile after 64 bit inode changes.
 1.10 23-Sep-2005  jmmv branches: 1.10.2;
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.9 30-Aug-2005  xtraeme Remove __P()
 1.8 27-Dec-2004  jdolecek branches: 1.8.10;
change wget_utf8() to not require NUL-terminated string as input (added
'size' parameter), and adjust callers appropriately
 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 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.5 24-Apr-2003  christos fix a few missing malloc attach/detach. Now this works.
 1.4 22-Apr-2003  christos forgot one malloc attach/detach
 1.3 09-Apr-2003  jdolecek #if 0 some no longer used macros; keep around for refence
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs.h was added on branch nathanw_sa on 2002-12-29 19:56:10 +0000
 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 17-Jan-2005  skrll Sync with HEAD.
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 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.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.10.5 04-Feb-2008  yamt sync with head.
 1.8.10.4 27-Oct-2007  yamt sync with head.
 1.8.10.3 03-Sep-2007  yamt sync with head.
 1.8.10.2 30-Dec-2006  yamt sync with head.
 1.8.10.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 26-Oct-2005  yamt sync with head
 1.13.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.13.8.1 24-May-2006  yamt sync with head.
 1.13.6.1 01-Jun-2006  kardel Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.12.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.14.10.1 10-Dec-2006  yamt sync with head.
 1.14.8.1 12-Jan-2007  ad Sync with head.
 1.15.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.18.1 14-Oct-2007  yamt sync with head.
 1.16.16.2 23-Mar-2008  matt sync with HEAD
 1.16.16.1 06-Nov-2007  matt sync with HEAD
 1.16.14.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.16.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.17.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.10.1 16-May-2008  yamt sync with head.
 1.18.8.1 18-May-2008  yamt sync with head.
 1.18.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.44.1 03-Dec-2017  jdolecek update from HEAD
 1.20.2.1 06-Apr-2015  skrll Sync with HEAD
 1.6 20-Feb-2015  maxv Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function
- remove unused includes
- fix some comments
- KNF

No functional change.
 1.5 18-Mar-2009  cegger branches: 1.5.22; 1.5.40;
bzero -> memset
 1.4 29-Jan-2008  pooka branches: 1.4.10; 1.4.18; 1.4.24;
Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.3 11-Dec-2005  christos branches: 1.3.46; 1.3.52;
merge ktrace-lwp.
 1.2 29-May-2005  christos branches: 1.2.2;
- rename variables to avoid shadowing.
- add a few const.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_compr.c was added on branch nathanw_sa on 2002-12-29 19:56:11 +0000
 1.2.2.1 04-Feb-2008  yamt sync with head.
 1.3.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.46.1 23-Mar-2008  matt sync with HEAD
 1.4.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.4.10.1 04-May-2009  yamt sync with head.
 1.5.40.1 06-Apr-2015  skrll Sync with HEAD
 1.5.22.1 03-Dec-2017  jdolecek update from HEAD
 1.2 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.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.20;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.20.1 21-Jun-2006  yamt sync with head.
 1.1.4.1 11-Dec-2005  christos Sync with head.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_compr.h was added on branch nathanw_sa on 2002-12-29 19:56:12 +0000
 1.10 20-Feb-2015  maxv Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function
- remove unused includes
- fix some comments
- KNF

No functional change.
 1.9 28-Apr-2008  martin branches: 1.9.44; 1.9.64;
Remove clause 3 and 4 from TNF licenses
 1.8 29-Jan-2008  pooka branches: 1.8.6; 1.8.8; 1.8.10;
Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.7 11-Dec-2005  christos branches: 1.7.46; 1.7.52;
merge ktrace-lwp.
 1.6 23-Oct-2005  christos make debugging code compile after 64 bit inode changes.
 1.5 26-Feb-2005  perry branches: 1.5.4; 1.5.6;
nuke trailing whitespace
 1.4 27-Dec-2004  jdolecek branches: 1.4.2; 1.4.4;
change wget_utf8() to not require NUL-terminated string as input (added
'size' parameter), and adjust callers appropriately
 1.3 21-Nov-2004  jdolecek switch to use new utf8 routines in <fs/unicode.h>
 1.2 15-Nov-2004  jdolecek fix comment (s,basesrc,src,)
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.1 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_conv.c was added on branch nathanw_sa on 2002-12-29 19:56:13 +0000
 1.4.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.5.6.1 26-Oct-2005  yamt sync with head
 1.5.4.2 04-Feb-2008  yamt sync with head.
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.7.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.46.1 23-Mar-2008  matt sync with HEAD
 1.8.10.1 16-May-2008  yamt sync with head.
 1.8.8.1 18-May-2008  yamt sync with head.
 1.8.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.64.1 06-Apr-2015  skrll Sync with HEAD
 1.9.44.1 03-Dec-2017  jdolecek update from HEAD
 1.11 20-Feb-2015  maxv Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function
- remove unused includes
- fix some comments
- KNF

No functional change.
 1.10 27-Jan-2012  para branches: 1.10.6; 1.10.24;
extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.9 15-Mar-2009  cegger branches: 1.9.12; 1.9.16;
ansify function definitions
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 05-May-2008  ad branches: 1.7.8; 1.7.14;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.6 30-Jun-2007  pooka branches: 1.6.28; 1.6.30; 1.6.32;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.5 27-Feb-2007  ad branches: 1.5.2; 1.5.4;
Destroy the hash locks on final unmount.
 1.4 15-Feb-2007  ad branches: 1.4.2;
Replace some uses of lockmgr() / simplelocks.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_ihash.c was added on branch nathanw_sa on 2002-12-29 19:56:13 +0000
 1.2.16.2 03-Sep-2007  yamt sync with head.
 1.2.16.1 26-Feb-2007  yamt sync with head.
 1.4.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.4.1 11-Jul-2007  mjf Sync with head.
 1.5.2.1 15-Jul-2007  ad Sync with head.
 1.6.32.2 04-May-2009  yamt sync with head.
 1.6.32.1 16-May-2008  yamt sync with head.
 1.6.30.1 18-May-2008  yamt sync with head.
 1.6.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.16.1 18-Feb-2012  mrg merge to -current.
 1.9.12.1 17-Apr-2012  yamt sync with head
 1.10.24.1 06-Apr-2015  skrll Sync with HEAD
 1.10.6.1 03-Dec-2017  jdolecek update from HEAD
 1.4 15-Feb-2007  ad Replace some uses of lockmgr() / simplelocks.
 1.3 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.2 30-Aug-2005  xtraeme Remove __P()
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.20;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.20.2 26-Feb-2007  yamt sync with head.
 1.1.20.1 21-Jun-2006  yamt sync with head.
 1.1.4.2 11-Dec-2005  christos Sync with head.
 1.1.4.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_ihash.h was added on branch nathanw_sa on 2002-12-29 19:56:14 +0000
 1.10 05-Dec-2024  andvar s/Associatied/Associated/ in comment.
 1.9 13-Nov-2014  hannken branches: 1.9.56;
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.8 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.7 29-Jan-2008  pooka branches: 1.7.54;
Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.6 27-Jan-2008  ad Replace use of lockmgr().
 1.5 02-Jan-2008  ad Merge vmlocking2 to head.
 1.4 04-Mar-2007  christos branches: 1.4.2; 1.4.16; 1.4.22; 1.4.24; 1.4.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 03-Dec-2005  christos branches: 1.3.26;
- 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.2 26-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.14.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.12.1 29-Apr-2005  kent sync with -current
 1.1.4.2 11-Dec-2005  christos Sync with head.
 1.1.4.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_inode.h was added on branch nathanw_sa on 2002-12-29 19:56:15 +0000
 1.2.4.4 04-Feb-2008  yamt sync with head.
 1.2.4.3 21-Jan-2008  yamt sync with head
 1.2.4.2 03-Sep-2007  yamt sync with head.
 1.2.4.1 21-Jun-2006  yamt sync with head.
 1.3.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.24.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.4.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.16.2 23-Mar-2008  matt sync with HEAD
 1.4.16.1 09-Jan-2008  matt sync with HEAD
 1.4.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.7.54.1 03-Dec-2017  jdolecek update from HEAD
 1.9.56.1 02-Aug-2025  perseant Sync with HEAD
 1.64 13-May-2021  hannken ntfs_loadntnode(): Use bread() when ntm_sysvn[NTFS_MFTINO] is NULL.

May happen when loading node 0 (MFT) during mount and some
attributes are stored in another ntnode.

PR kern/56160 (Mount ntfs usb disk)
 1.63 17-Jan-2020  ad branches: 1.63.10; 1.63.12;
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.62 18-Oct-2019  hannken branches: 1.62.2;
When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.

Should fix PR kern/54598: mount ntfs panic
 1.61 28-Mar-2015  maxv branches: 1.61.10; 1.61.18; 1.61.22;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.60 20-Feb-2015  maxv Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function
- remove unused includes
- fix some comments
- KNF

No functional change.
 1.59 16-Jan-2015  maxv Fix a node leak.

Sent on tech-kern@, tested by martin@
 1.58 06-Jan-2015  hannken No need to load a vnode/fnode pair to lookup attributes on a ntnode.
Use ntfs_ntlookup()/ntfs_ntput() instead.
 1.57 04-Jan-2015  christos add more debugging.
 1.56 29-Dec-2014  maxv Typos:
- "nessesary" -> "necessary" (comment)
- "UNEXISTED" -> "NON-EXISTENT" (dprintf)
- "NON-EXISTANT" -> "NON-EXISTENT" (dprintf)
- "reach" -> "reaches" (comment)
 1.55 28-Dec-2014  maxv Make this more readable (KNF).
 1.54 13-Nov-2014  hannken branches: 1.54.2;
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.53 13-Nov-2014  hannken - Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
 1.52 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.51 28-Jun-2013  matt branches: 1.51.8;
Make this compile again.
 1.50 28-Jun-2013  christos remove useless initialization, KNF
http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html
 1.49 20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.48 12-Jul-2012  dsl branches: 1.48.2;
Fix build - eg i386/ALL
 1.47 02-Jun-2012  christos - fix some mallocs not to have casts and specify sizeof(*var)
- if the index magic is 0, don't complain, just return an error.
- make dprintfs use __func__
 1.46 31-Aug-2011  plunky branches: 1.46.2;
NULL does not need a cast
 1.45 30-Jun-2011  wiz dependant -> dependent
 1.44 08-Jan-2010  pooka 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.43 01-Sep-2009  pooka Set vnode size after creation(*). Fixes cp(1) from ntfs, the
complaint in the "ntfs ubc_uiomove error" (ubc_uiomove error was
not coming from ntfs but instead the "to" file system) and PR
kern/38531 (well, I assume the submitter wanted cp(1) working on
ntfs instead of mangling ntfs the way the PR title suggests). Yes,
mmap works on ntfs like it always has.

*) well, um, and in other places too ... uuuh ... no comments.
but I guess this works as long as in-kernel ntfs doesn't grow write
support.
 1.42 18-Mar-2009  cegger bzero -> memset
 1.41 15-Mar-2009  cegger ansify function definitions
 1.40 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.39 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.38 17-Dec-2008  cegger branches: 1.38.2;
kill MALLOC and FREE macros.
 1.37 16-May-2008  hannken branches: 1.37.6; 1.37.8; 1.37.14;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.36 29-Jan-2008  pooka branches: 1.36.6; 1.36.8; 1.36.10; 1.36.12;
Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.35 27-Jan-2008  ad Replace use of lockmgr().
 1.34 02-Jan-2008  ad Merge vmlocking2 to head.
 1.33 10-Oct-2007  ad branches: 1.33.4; 1.33.6; 1.33.10;
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.32 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.31 30-Jun-2007  pooka branches: 1.31.6; 1.31.8; 1.31.10;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.30 04-Mar-2007  christos branches: 1.30.2; 1.30.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.29 15-Feb-2007  ad branches: 1.29.2;
Fix error in previous.
 1.28 15-Feb-2007  ad Replace some uses of lockmgr() / simplelocks.
 1.27 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.26 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.25 14-May-2006  elad branches: 1.25.8; 1.25.10;
integrate kauth.
 1.24 11-May-2006  mrg ntfs_runtovrun takes u_int8_t * not caddr_t
 1.23 15-Apr-2006  christos Coverity CID 1138: Add KASSERT before deref.
 1.22 17-Mar-2006  christos don't use MALLOC with a non-constant size; use malloc instead.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 23-Oct-2005  christos make debugging code compile after 64 bit inode changes.
 1.19 30-Aug-2005  xtraeme branches: 1.19.2;
Remove __P()
 1.18 19-Aug-2005  christos 64 bit inode changes.
 1.17 25-Jul-2005  christos PR/30823: Dave Huang: Panic reading files larger than 4GB on NTFS
 1.16 29-May-2005  christos branches: 1.16.2;
- rename variables to avoid shadowing.
- add a few const.
 1.15 22-May-2005  christos Don't print 0x in front of %p. From FreeBSD/OpenBSD
 1.14 26-Feb-2005  perry nuke trailing whitespace
 1.13 13-Feb-2005  jdolecek use MIN()/MAX() rather than min()/max(), to avoid possible truncation
of 64bit values to 'int'
 1.12 13-Feb-2005  jdolecek read always single cluster of data, to avoid confusing the buffer
cache; this appears to fix the random file content corruption which
happens when more than one cluster is read at the same time, i.e. for
files > 3*cluster_size

Fixes PR kern/23835

change obtained from FreeBSD ntfs_subr.c rev. 1.31
 1.11 27-Dec-2004  jdolecek branches: 1.11.2; 1.11.4;
change wget_utf8() to not require NUL-terminated string as input (added
'size' parameter), and adjust callers appropriately
 1.10 24-Jun-2004  drochner fix some questionable pointer arithmetics; gcc-3.4.x
didn't like it
 1.9 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.8 22-Mar-2004  jdolecek g/c redundant debug printf
 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 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.4 10-Apr-2003  jdolecek change some printf()s on easily-triggerable codepaths to dprintf()
 1.3 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.2 06-Jan-2003  wiz Typo and grammar fixes in comments and a printf string.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.3 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_subr.c was added on branch nathanw_sa on 2002-12-29 19:56:16 +0000
 1.7.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.7 15-Feb-2005  skrll Sync with HEAD.
 1.7.2.6 17-Jan-2005  skrll Sync with HEAD.
 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 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.11.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.2.1 29-Apr-2005  kent sync with -current
 1.16.2.7 04-Feb-2008  yamt sync with head.
 1.16.2.6 21-Jan-2008  yamt sync with head
 1.16.2.5 27-Oct-2007  yamt sync with head.
 1.16.2.4 03-Sep-2007  yamt sync with head.
 1.16.2.3 26-Feb-2007  yamt sync with head.
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.19.2.1 26-Oct-2005  yamt sync with head
 1.21.12.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.21.10.3 11-May-2006  elad sync with head
 1.21.10.2 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.21.10.1 19-Apr-2006  elad sync with head.
 1.21.8.2 24-May-2006  yamt sync with head.
 1.21.8.1 01-Apr-2006  yamt sync with head.
 1.21.6.2 01-Jun-2006  kardel Sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.25.10.2 10-Dec-2006  yamt sync with head.
 1.25.10.1 22-Oct-2006  yamt sync with head
 1.25.8.1 18-Nov-2006  ad Sync with head.
 1.29.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.4.1 11-Jul-2007  mjf Sync with head.
 1.30.2.3 15-Jul-2007  ad Sync with head.
 1.30.2.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.30.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.31.10.1 14-Oct-2007  yamt sync with head.
 1.31.8.3 23-Mar-2008  matt sync with HEAD
 1.31.8.2 09-Jan-2008  matt sync with HEAD
 1.31.8.1 06-Nov-2007  matt sync with HEAD
 1.31.6.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.33.10.1 02-Jan-2008  bouyer Sync with HEAD
 1.33.6.2 27-Dec-2007  ad lockdestroy(&ip->i_lock); XXX Why does this have inode locks?
 1.33.6.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.33.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.36.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.36.10.3 11-Mar-2010  yamt sync with head
 1.36.10.2 16-Sep-2009  yamt sync with head
 1.36.10.1 04-May-2009  yamt sync with head.
 1.36.8.1 18-May-2008  yamt sync with head.
 1.36.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.36.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.14.1 21-Apr-2010  matt sync to netbsd-5
 1.37.8.1 10-Sep-2009  snj Pull up following revision(s) (requested by pooka in ticket #942):
sys/fs/ntfs/ntfs_subr.c: revision 1.43
sys/fs/ntfs/ntfs_vfsops.c: revision 1.79
Set vnode size after creation(*). Fixes cp(1) from ntfs, the
complaint in the "ntfs ubc_uiomove error" (ubc_uiomove error was
not coming from ntfs but instead the "to" file system) and
PR kern/38531 (well, I assume the submitter wanted cp(1) working on
ntfs instead of mangling ntfs the way the PR title suggests). Yes,
mmap works on ntfs like it always has.
*) well, um, and in other places too ... uuuh ... no comments.
but I guess this works as long as in-kernel ntfs doesn't grow write
support.
 1.37.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.37.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.46.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.46.2.2 23-Jan-2013  yamt sync with head
 1.46.2.1 30-Oct-2012  yamt sync with head
 1.48.2.3 03-Dec-2017  jdolecek update from HEAD
 1.48.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.2.1 25-Feb-2013  tls resync with head
 1.51.8.1 14-Feb-2015  snj Pull up following revision(s) (requested by maxv in ticket #513):
sys/fs/ntfs/ntfs_vfsops.c: revision 1.99, 1.100
sys/fs/ntfs/ntfs_subr.c: revision 1.59
Ensure bps != 0 to prevent a division by zero. Zero byte per sector makes
no sense.
--
Prevent another division by zero in ntfs_loadntnode() by ensuring
spc != 0.
--
Fix a node leak.
Sent on tech-kern@, tested by martin@
 1.54.2.1 06-Apr-2015  skrll Sync with HEAD
 1.61.22.2 17-May-2021  martin Pull up following revision(s) (requested by hannken in ticket #1272):

sys/fs/ntfs/ntfs_subr.c: revision 1.64

ntfs_loadntnode(): Use bread() when ntm_sysvn[NTFS_MFTINO] is NULL.

May happen when loading node 0 (MFT) during mount and some
attributes are stored in another ntnode.

PR kern/56160 (Mount ntfs usb disk)
 1.61.22.1 21-Oct-2019  martin Pull up following revision(s) (requested by hannken in ticket #354):

sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
sys/fs/ntfs/ntfs_subr.c: revision 1.62

It is not possible to call vflush() from xxx_mount().
Replace with a vnode iterator and use vrecycle().

-

When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.
Should fix PR kern/54598: mount ntfs panic
 1.61.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.61.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.61.10.1 21-Oct-2019  martin Pull up following revision(s) (requested by hannken in ticket #1410):

sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
sys/fs/ntfs/ntfs_subr.c: revision 1.62

It is not possible to call vflush() from xxx_mount().
Replace with a vnode iterator and use vrecycle().

-

When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.
Should fix PR kern/54598: mount ntfs panic
 1.62.2.1 17-Jan-2020  ad Sync with head.
 1.63.12.1 31-May-2021  cjep sync with head
 1.63.10.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.9 13-Nov-2014  hannken Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.8 13-Nov-2014  hannken - Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
 1.7 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.6 04-Mar-2007  christos branches: 1.6.86;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 03-Dec-2005  christos branches: 1.5.26;
- 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.4 30-Aug-2005  xtraeme Remove __P()
 1.3 25-Jul-2005  christos PR/30823: Dave Huang: Panic reading files larger than 4GB on NTFS
 1.2 29-May-2005  christos branches: 1.2.2;
- rename variables to avoid shadowing.
- add a few const.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.2 11-Dec-2005  christos Sync with head.
 1.1.4.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_subr.h was added on branch nathanw_sa on 2002-12-29 19:56:16 +0000
 1.2.2.2 03-Sep-2007  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.5.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.86.1 03-Dec-2017  jdolecek update from HEAD
 1.111 04-Feb-2024  christos PR/57904: Ricardo Branco: Mask file permissions we get from mount_ntfs
-m option
 1.110 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.109 17-Jan-2020  ad branches: 1.109.4;
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.108 18-Oct-2019  hannken branches: 1.108.2;
It is not possible to call vflush() from xxx_mount().

Replace with a vnode iterator and use vrecycle().
 1.107 17-Apr-2017  hannken branches: 1.107.2; 1.107.4; 1.107.12; 1.107.16;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.106 17-Apr-2017  hannken Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.105 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.104 28-Mar-2015  maxv branches: 1.104.2; 1.104.4;
Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.103 20-Feb-2015  maxv Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function
- remove unused includes
- fix some comments
- KNF

No functional change.
 1.102 06-Jan-2015  hannken Adjust printf and add missing ntfs_ntput().
 1.101 04-Jan-2015  christos add more debugging.
 1.100 28-Dec-2014  maxv Prevent another division by zero in ntfs_loadntnode() by ensuring
spc != 0.
 1.99 28-Dec-2014  maxv Ensure bps != 0 to prevent a division by zero. Zero byte per sector makes
no sense.
 1.98 28-Dec-2014  maxv Make this more readable (KNF).
 1.97 13-Nov-2014  hannken branches: 1.97.2;
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.96 13-Nov-2014  hannken - Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
 1.95 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.94 16-Apr-2014  maxv branches: 1.94.2;
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.93 23-Mar-2014  hannken branches: 1.93.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.92 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.91 10-Dec-2013  christos CID 975205: Unchecked return value
 1.90 23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.89 17-Oct-2013  christos remove unused code
 1.88 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.87 14-Nov-2011  hannken branches: 1.87.6; 1.87.10; 1.87.12; 1.87.14; 1.87.20;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.86 12-Jun-2011  rmind branches: 1.86.2;
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.85 25-Jul-2010  hannken branches: 1.85.6;
It makes no sense to call vget() with LK_RETRY.
 1.84 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.83 19-Jul-2010  hannken Lock the ntnode and recheck the fnode after calling getnewvnode().

Take v_interlock while the ntnode is locked.
 1.82 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.81 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.80 08-Jan-2010  pooka branches: 1.80.2; 1.80.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.79 01-Sep-2009  pooka Set vnode size after creation(*). Fixes cp(1) from ntfs, the
complaint in the "ntfs ubc_uiomove error" (ubc_uiomove error was
not coming from ntfs but instead the "to" file system) and PR
kern/38531 (well, I assume the submitter wanted cp(1) working on
ntfs instead of mangling ntfs the way the PR title suggests). Yes,
mmap works on ntfs like it always has.

*) well, um, and in other places too ... uuuh ... no comments.
but I guess this works as long as in-kernel ntfs doesn't grow write
support.
 1.78 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.77 18-Mar-2009  cegger bcopy -> memcpy
 1.76 15-Mar-2009  cegger ansify function definitions
 1.75 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.74 19-Dec-2008  cegger branches: 1.74.2;
use M_ZERO on malloc() and remove subsequent bzero().
 1.73 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.72 28-Jun-2008  rumble branches: 1.72.4; 1.72.6; 1.72.12;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.71 16-May-2008  hannken branches: 1.71.2;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.70 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.69 06-May-2008  ad branches: 1.69.2;
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.68 05-May-2008  ad - Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.67 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.66 29-Apr-2008  ad 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.65 30-Jan-2008  ad branches: 1.65.6; 1.65.8; 1.65.10;
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.64 29-Jan-2008  pooka init genfs_node before potential vput()
 1.63 29-Jan-2008  pooka Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.62 28-Jan-2008  dholland 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.61 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.60 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.59 26-Nov-2007  pooka branches: 1.59.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.58 10-Oct-2007  ad branches: 1.58.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.57 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.56 31-Jul-2007  pooka branches: 1.56.2; 1.56.4; 1.56.6; 1.56.8;
* 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.55 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.54 26-Jul-2007  pooka ntfs_unmount:
* panic if flushing system nodes fails: we have released too many
resources and would die anyway the next time unmount is attempted
* KASSERT that VOP_CLOSE succeeds, but always return 0. once again
we have released too many resources

XXX: maybe rewrite to be a bit more robust
 1.53 23-Jul-2007  pooka Initialize size and/or writesize when creating a vnode.
 1.52 17-Jul-2007  pooka branches: 1.52.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.51 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.50 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.49 04-Mar-2007  christos branches: 1.49.2; 1.49.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.48 19-Jan-2007  hannken branches: 1.48.2;
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.47 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.46 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.45 13-Sep-2006  christos branches: 1.45.2;
Avoid empty if.
 1.44 02-Sep-2006  christos branches: 1.44.2;
add missing initializers
 1.43 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.42 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.41 14-May-2006  elad branches: 1.41.4;
integrate kauth.
 1.40 15-Apr-2006  christos Coverity CID 2863: Check for NULL before freeing.
 1.39 11-Apr-2006  xtraeme make this build again (initiliaze ntmp).
 1.38 11-Apr-2006  christos Coverity CID 2860: Free malloced resources on mount error.
 1.37 21-Feb-2006  thorpej branches: 1.37.2; 1.37.4; 1.37.6;
Use device_class() instead of accessing dv_class directly.
 1.36 11-Dec-2005  christos branches: 1.36.2; 1.36.4; 1.36.6;
merge ktrace-lwp.
 1.35 23-Oct-2005  christos make debugging code compile after 64 bit inode changes.
 1.34 23-Sep-2005  jmmv branches: 1.34.2;
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.33 30-Aug-2005  xtraeme Remove __P()
 1.32 19-Aug-2005  christos 64 bit inode changes.
 1.31 28-Jun-2005  yamt branches: 1.31.2;
- constify genfs_ops.
- use member designators.
 1.30 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.29 26-Feb-2005  perry branches: 1.29.2;
nuke trailing whitespace
 1.28 09-Jan-2005  mycroft branches: 1.28.2; 1.28.4;
Whoops -- move the location of the VOP_OPEN()/VOP_CLOSE(), et al, from
foo_mountfs() to foo_mount(), to match the new mountroot API.
Also, for ext2fs and lfs, copy some restructuring from ffs to allow changing
file system parameters without specifying the device name.
(ntfs could use some more work.)
 1.27 09-Jan-2005  mycroft Rework the mountroot interface so that vfs_mountroot() opens the root device
and just passes it on to the file system functions. This avoids opening and
closing the device several times.

Mentioned on tech-kern some time ago, IIRC. I've been running this for a
long time.
 1.26 02-Jan-2005  thorpej Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.25 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.24 15-Aug-2004  mycroft Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
FS-specific checks littered throughout the code. This may be used later to
make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
 1.23 30-May-2004  yamt use vn_lock instead of raw VOP_LOCK.
 1.22 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.21 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.20 04-May-2004  jrf Remove caddr_t inlines. Approved by christos@NetBSD.org.
 1.19 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.18 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.17 24-Mar-2004  atatat branches: 1.17.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.16 22-Feb-2004  jdolecek use 64bit local variable for free space computation
 1.15 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.14 11-Nov-2003  christos KASSERT was not the right thing here. Instead only set the type if f_type
has been inititialized. Reported by pooka
 1.13 25-Oct-2003  christos Fix typo.
 1.12 25-Oct-2003  christos Fix uninitialized variable warning
 1.11 02-Aug-2003  jdolecek remove all traces of non-working quota support
add quota support to TODO - makes sense only once writing support
would be implemented, and only once NTFS would support notion of file 'owner'

adresses kern/21967 by Martin Husemann
 1.10 29-Jun-2003  fvdl branches: 1.10.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.9 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.8 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7 24-Apr-2003  christos fix a few missing malloc attach/detach. Now this works.
 1.6 22-Apr-2003  christos forgot one malloc attach/detach
 1.5 22-Apr-2003  christos explicitly attach and detach malloc types like smbfs does; thanks jaromir.
 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 09-Apr-2003  jdolecek replace VOP__UNLOCK(), VN_LOCK(), VGET() macros with the real thing, to
imporove readability
g/c some non-NetBSD code for same reason
 1.2 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_vfsops.c was added on branch nathanw_sa on 2002-12-29 19:56:18 +0000
 1.10.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.9 01-Apr-2005  skrll Sync with HEAD.
 1.10.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.10.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.4 25-Aug-2004  skrll Sync with HEAD.
 1.10.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.10.2.2 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.17.2.1 29-May-2004  tron Pull up revision 1.21 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.28.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.28.2.1 29-Apr-2005  kent sync with -current
 1.29.2.1 24-Aug-2005  riz Pull up following revision(s) (requested by yamt in ticket #688):
sys/miscfs/genfs/genfs_vnops.c: revision 1.98 via patch
sys/ufs/ffs/ffs_vfsops.c: revision 1.165
sys/ufs/lfs/lfs_extern.h: revision 1.69
sys/fs/filecorefs/filecore_vfsops.c: revision 1.20
sys/nfs/nfs_node.c: revision 1.80
sys/fs/smbfs/smbfs_node.c: revision 1.24
sys/fs/cd9660/cd9660_vfsops.c: revision 1.24
sys/fs/msdosfs/msdosfs_denode.c: revision 1.8
sys/miscfs/genfs/genfs_node.h: revision 1.6
sys/ufs/lfs/lfs_vfsops.c: revision 1.183
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.86
sys/fs/adosfs/advfsops.c: revision 1.23
sys/fs/ntfs/ntfs_vfsops.c: revision 1.31
- constify genfs_ops.
- use member designators.

sys/miscfs/genfs/genfs_vnops.c: revision 1.99 via patch
genfs_getpages: don't forget to put the vnode onto the syncer's work que
ue
even in the case of PGO_LOCKED.

sys/uvm/uvm_bio.c: revision 1.40
sys/uvm/uvm_pager.h: revision 1.29
sys/miscfs/genfs/genfs_vnops.c: revision 1.100 via patch
sys/ufs/ufs/ufs_inode.c: revision 1.50
- introduce PGO_NOBLOCKALLOC and use it for ubc mapping
to prevent unnecessary block allocations in the case that
page size > block size.
- ufs_balloc_range: use VM_PROT_WRITE+PGO_NOBLOCKALLOC rather than
VM_PROT_READ.

sys/uvm/uvm_fault.c: revision 1.96
sys/miscfs/genfs/genfs_vnops.c: revision 1.101 via patch
sys/uvm/uvm_object.h: revision 1.19
sys/miscfs/genfs/genfs_node.h: revision 1.7
ensure that vnodes with dirty pages are always on syncer's queue.
- genfs_putpages: wait for i/o completion of PG_RELEASED/PG_PAGEOUT pages by
setting "wasclean" false when encountering them.
suggested by Stephan Uphoff in PR/24596 (1).
- genfs_putpages: write protect pages when cleaning out, if
we're going to take the vnode off the syncer's queue.
uvm_fault: don't write-map pages unless its vnode is already on
the syncer's queue.
fix PR/24596 (3) but in the different way from the suggested fix.
(to keep our current behaviour, ie. not to require explicit msync.
discussed on tech-kern@.)
- genfs_putpages: don't mistakenly take a vnode off the queue
by introducing a generation number in genfs_node.
genfs_getpages: increment the generation number.
suggested by Stephan Uphoff in PR/24596 (2).
- add some assertions.

sys/miscfs/genfs/genfs_vnops.c: revision 1.102 via patch
genfs_putpages: don't bother to clean the vnode unless VONWORKLST.

sys/ufs/ffs/ffs_vnops.c: revision 1.71
ffs_full_fsync: because VBLK/VCHR can be mmap'ed,
do VOP_PUTPAGES for them as well.

sys/uvm/uvm_fault.c: revision 1.97
uvm_fault: check a correct object in the case of layered filesystems.
fix PR/30811 from Jukka Salmi.

sys/uvm/uvm_object.h: revision 1.20
sys/ufs/ffs/ffs_vfsops.c: revision 1.167
sys/uvm/uvm_bio.c: revision 1.41
sys/ufs/ufs/ufs_vnops.c: revision 1.129
sys/uvm/uvm_mmap.c: revision 1.92
sys/uvm/uvm_fault.c: revision 1.98
sys/kern/vfs_subr.c: revision 1.252
sys/fs/msdosfs/denode.h: revision 1.5
sys/miscfs/genfs/genfs_vnops.c: revision 1.103 via patch
sys/fs/msdosfs/msdosfs_denode.c: revision 1.9
sys/sys/vnode.h: revision 1.141
sys/ufs/ufs/ufs_inode.c: revision 1.51
sys/ufs/ufs/ufs_extern.h: revision 1.45 via patch
sys/miscfs/genfs/genfs_node.h: revision 1.8
sys/ufs/lfs/lfs_vfsops.c: revision 1.184
sys/uvm/uvm_pager.h: revision 1.30
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.87
update file timestamps for nfsd loaned-read and mmap.
PR/25279. discussed on tech-kern@.

sys/miscfs/genfs/genfs_vnops.c: revision 1.104 via patch
don't write-protect wired pages. pointed by Chuck Silvers.
for now, leave a vnode on the syncer's queue, as suggested by him.

sys/ufs/ffs/ffs_vnops.c: revision 1.72
revert VCHR part of ffs_vnops.c 1.71.
as VCHR uses the device pager, no point to call VOP_PUTPAGES here.
pointed by Chuck Silvers.
 1.31.2.8 04-Feb-2008  yamt sync with head.
 1.31.2.7 21-Jan-2008  yamt sync with head
 1.31.2.6 07-Dec-2007  yamt sync with head
 1.31.2.5 27-Oct-2007  yamt sync with head.
 1.31.2.4 03-Sep-2007  yamt sync with head.
 1.31.2.3 26-Feb-2007  yamt sync with head.
 1.31.2.2 30-Dec-2006  yamt sync with head.
 1.31.2.1 21-Jun-2006  yamt sync with head.
 1.34.2.1 26-Oct-2005  yamt sync with head
 1.36.6.2 01-Jun-2006  kardel Sync with head.
 1.36.6.1 22-Apr-2006  simonb Sync with head.
 1.36.4.1 09-Sep-2006  rpaulo sync with head
 1.36.2.1 01-Mar-2006  yamt sync with head.
 1.37.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.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.37.4.2 19-Apr-2006  elad sync with head.
 1.37.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.37.2.4 14-Sep-2006  yamt sync with head.
 1.37.2.3 03-Sep-2006  yamt sync with head.
 1.37.2.2 11-Aug-2006  yamt sync with head
 1.37.2.1 24-May-2006  yamt sync with head.
 1.41.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.44.2.2 01-Feb-2007  ad Sync with head.
 1.44.2.1 18-Nov-2006  ad Sync with head.
 1.45.2.2 10-Dec-2006  yamt sync with head.
 1.45.2.1 22-Oct-2006  yamt sync with head
 1.48.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.49.4.1 11-Jul-2007  mjf Sync with head.
 1.49.2.6 20-Aug-2007  ad Sync with HEAD.
 1.49.2.5 29-Jul-2007  ad Add vfs_destroy() to free mount structures. The specificdata_ref was being
leaked.
 1.49.2.4 15-Jul-2007  ad Sync with head.
 1.49.2.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.49.2.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.49.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.52.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.56.8.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.56.8.1 31-Jul-2007  pooka file ntfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.56.6.1 14-Oct-2007  yamt sync with head.
 1.56.4.3 23-Mar-2008  matt sync with HEAD
 1.56.4.2 09-Jan-2008  matt sync with HEAD
 1.56.4.1 06-Nov-2007  matt sync with HEAD
 1.56.2.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.56.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.56.2.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.58.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.58.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.58.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.59.2.1 26-Dec-2007  ad Sync with head.
 1.65.10.6 11-Aug-2010  yamt sync with head.
 1.65.10.5 11-Mar-2010  yamt sync with head
 1.65.10.4 16-Sep-2009  yamt sync with head
 1.65.10.3 18-Jul-2009  yamt sync with head.
 1.65.10.2 04-May-2009  yamt sync with head.
 1.65.10.1 16-May-2008  yamt sync with head.
 1.65.8.1 18-May-2008  yamt sync with head.
 1.65.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.65.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.65.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.69.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.69.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.71.2.1 03-Jul-2008  simonb Sync with head.
 1.72.12.1 21-Apr-2010  matt sync to netbsd-5
 1.72.6.2 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.72.6.1 10-Sep-2009  snj branches: 1.72.6.1.2; 1.72.6.1.6;
Pull up following revision(s) (requested by pooka in ticket #942):
sys/fs/ntfs/ntfs_subr.c: revision 1.43
sys/fs/ntfs/ntfs_vfsops.c: revision 1.79
Set vnode size after creation(*). Fixes cp(1) from ntfs, the
complaint in the "ntfs ubc_uiomove error" (ubc_uiomove error was
not coming from ntfs but instead the "to" file system) and
PR kern/38531 (well, I assume the submitter wanted cp(1) working on
ntfs instead of mangling ntfs the way the PR title suggests). Yes,
mmap works on ntfs like it always has.
*) well, um, and in other places too ... uuuh ... no comments.
but I guess this works as long as in-kernel ntfs doesn't grow write
support.
 1.72.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.72.6.1.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.72.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.72.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.74.2.2 23-Jul-2009  jym Sync with HEAD.
 1.74.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.80.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.80.4.2 05-Mar-2011  rmind sync with head
 1.80.4.1 03-Jul-2010  rmind sync with head
 1.80.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.85.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.86.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.86.2.1 17-Apr-2012  yamt sync with head
 1.87.20.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.87.14.1 18-May-2014  rmind sync with head
 1.87.12.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.87.10.2 03-Dec-2017  jdolecek update from HEAD
 1.87.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.87.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.93.2.1 10-Aug-2014  tls Rebase.
 1.94.2.1 14-Feb-2015  snj Pull up following revision(s) (requested by maxv in ticket #513):
sys/fs/ntfs/ntfs_vfsops.c: revision 1.99, 1.100
sys/fs/ntfs/ntfs_subr.c: revision 1.59
Ensure bps != 0 to prevent a division by zero. Zero byte per sector makes
no sense.
--
Prevent another division by zero in ntfs_loadntnode() by ensuring
spc != 0.
--
Fix a node leak.
Sent on tech-kern@, tested by martin@
 1.97.2.2 28-Aug-2017  skrll Sync with HEAD
 1.97.2.1 06-Apr-2015  skrll Sync with HEAD
 1.104.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.104.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.104.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.104.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.107.16.1 21-Oct-2019  martin Pull up following revision(s) (requested by hannken in ticket #354):

sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
sys/fs/ntfs/ntfs_subr.c: revision 1.62

It is not possible to call vflush() from xxx_mount().
Replace with a vnode iterator and use vrecycle().

-

When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.
Should fix PR kern/54598: mount ntfs panic
 1.107.12.3 21-Apr-2020  martin Sync with HEAD
 1.107.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.107.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.4.1 21-Oct-2019  martin Pull up following revision(s) (requested by hannken in ticket #1410):

sys/fs/ntfs/ntfs_vfsops.c: revision 1.108
sys/fs/ntfs/ntfs_subr.c: revision 1.62

It is not possible to call vflush() from xxx_mount().
Replace with a vnode iterator and use vrecycle().

-

When the MFT record size is lower than the cluster size we have
to read consecutive clusters to fill the MFT record.
Should fix PR kern/54598: mount ntfs panic
 1.107.2.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.108.2.1 17-Jan-2020  ad Sync with head.
 1.109.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.9 13-Nov-2014  hannken - Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
 1.8 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.7 28-Jun-2008  rumble branches: 1.7.40;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.6 11-Dec-2005  christos branches: 1.6.70; 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 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.4 20-May-2004  atatat branches: 1.4.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.3 29-Jun-2003  fvdl branches: 1.3.2; 1.3.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.2 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_vfsops.h was added on branch nathanw_sa on 2002-12-29 19:56:19 +0000
 1.3.4.1 23-May-2004  tron Pull up revision 1.4 (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.3.2.6 11-Dec-2005  christos Sync with head.
 1.3.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.3.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.3.2.2 03-Aug-2004  skrll Sync with HEAD
 1.3.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.4.12.1 21-Jun-2006  yamt sync with head.
 1.6.78.1 03-Jul-2008  simonb Sync with head.
 1.6.76.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.74.1 04-May-2009  yamt sync with head.
 1.6.70.1 29-Jun-2008  mjf Sync with HEAD.
 1.7.40.1 03-Dec-2017  jdolecek update from HEAD
 1.66 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.65 27-Jun-2020  christos branches: 1.65.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.64 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.63 26-May-2017  riastradh Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.62 26-May-2017  riastradh 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.61 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.60 20-Aug-2016  hannken branches: 1.60.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.59 13-Nov-2014  hannken branches: 1.59.2; 1.59.4;
Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
 1.58 13-Nov-2014  hannken - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
 1.57 25-Jul-2014  dholland 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.56 07-Feb-2014  hannken branches: 1.56.2;
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.55 18-Mar-2013  plunky branches: 1.55.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.54 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.53 05-Nov-2012  dholland 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.52 22-Jul-2012  rmind branches: 1.52.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.51 29-Apr-2012  chs change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.50 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.49 19-May-2011  rmind branches: 1.49.4; 1.49.8; 1.49.10;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.48 26-Apr-2011  hannken Change vflushbuf() to return an error if a synchronous write fails.

Welcome to 5.99.51.
 1.47 24-Jun-2010  hannken branches: 1.47.2;
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.46 08-Jan-2010  pooka branches: 1.46.2; 1.46.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.45 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.44 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.43 29-Apr-2009  elad Replace open-coded vaccess() in ntfs_access() with a call to vaccess().

Similarly to msdosfs, always add the exec bit to keep the current
behavior.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/21/msg004881.html
 1.42 17-Dec-2008  cegger branches: 1.42.2;
kill MALLOC and FREE macros.
 1.41 30-Apr-2008  ad branches: 1.41.8;
Make various bits of debug code compile again.
 1.40 30-Jan-2008  ad branches: 1.40.6; 1.40.8; 1.40.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.39 29-Jan-2008  pooka Nuke #ifdef __OtherOS__ clutter to make maintaining slightly easier.
 1.38 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.37 17-Jan-2008  ad Fix dodgy tests of v_usecount.
 1.36 26-Nov-2007  pooka branches: 1.36.6;
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.35 29-Jul-2007  ad branches: 1.35.4; 1.35.6; 1.35.12; 1.35.14;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.34 26-Jul-2007  pooka Don't do nfs server consistency checks in readdir, especially since
the check depended on the nfs server implementation.
 1.33 04-Mar-2007  christos branches: 1.33.2; 1.33.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.32 20-Feb-2007  ad Call genfs_node_destroy() where appropriate.
 1.31 09-Dec-2006  chs branches: 1.31.2;
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.30 12-Oct-2006  christos branches: 1.30.2;
- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.29 14-May-2006  elad branches: 1.29.8; 1.29.10;
integrate kauth.
 1.28 01-Mar-2006  yamt branches: 1.28.2; 1.28.4; 1.28.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.27 11-Dec-2005  christos branches: 1.27.2; 1.27.4; 1.27.6;
merge ktrace-lwp.
 1.26 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.25 23-Oct-2005  christos make debugging code compile after 64 bit inode changes.
 1.24 30-Aug-2005  xtraeme branches: 1.24.2;
Remove __P()
 1.23 19-Aug-2005  christos 64 bit inode changes.
 1.22 25-Jul-2005  christos PR/30823: Dave Huang: Panic reading files larger than 4GB on NTFS
 1.21 26-Feb-2005  perry branches: 1.21.4;
nuke trailing whitespace
 1.20 13-Feb-2005  jdolecek use MIN()/MAX() rather than min()/max(), to avoid possible truncation
of 64bit values to 'int'
 1.19 13-Sep-2004  jdolecek branches: 1.19.4; 1.19.6;
set mp->mnt_stat.f_namemax on filesystem mount for use by statvfs, and use
the value for also pathconf(_PC_NAME_MAX) to keep the two in sync
 1.18 29-Feb-2004  jdolecek use global prtactive setting instead of ntfs-specific variable;
this also changes default, to not print the active vnodes
 1.17 22-Feb-2004  jdolecek make VOP_UPDATE() trivially succeed (without doing anything), instead
of returning error

this makes it possible to mount other filesystems on directory on NTFS
filesystem
 1.16 26-Jan-2004  hannken Fix xxx_strategy() to use the vnode arg instead of bp->b_vp.
 1.15 06-Oct-2003  jdolecek change accidentaly left debug printf to dprintf()
 1.14 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.13 02-Aug-2003  jdolecek remove all traces of non-working quota support
add quota support to TODO - makes sense only once writing support
would be implemented, and only once NTFS would support notion of file 'owner'

adresses kern/21967 by Martin Husemann
 1.12 29-Jun-2003  fvdl branches: 1.12.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.11 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.10 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.9 23-Jun-2003  martin #ifdef _KERNEL_OPT police
 1.8 23-Jun-2003  martin Disable QUOTA for ntfs - it's broken.
 1.7 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.6 10-Apr-2003  jdolecek back to genfs_eopnotsupp() for vop_remove, vop_link, vop_rename,
vop_mkdir, vop_rmdir - it does the right unlocking now
 1.5 09-Apr-2003  jdolecek move ntfs_remove() to be together with the other dummies - easier to c&p
eventually
 1.4 09-Apr-2003  jdolecek add dummy link, rename, mkdir, rmdir vnode ops, which release the
appropriate vnodes before failing with EOPNOTSUPP - this is necessary
to not deadlock later
 1.3 09-Apr-2003  jdolecek print some potentially useful stuff in ntfs_print()
replace the VOP__UNLOCK() macros with VOP_UNLOCK() directly - it just
obfuscates the code
similarily for VN_LOCK()->vn_lock()
unlock dvp before ntvattrget call in ntfs_lookup() in '..' case, not after
fix problem in ntfs_lookup() where PDIRUNLOCK was not set in one code path
after unlocking parent directory vnode
 1.2 09-Apr-2003  jdolecek add real ntfs remove vnode op, which releases vnode locks on parent directory
and the file vnode before returning EOPNOTSUPP
fixes PR kern/19595 by Erik Berls
 1.1 23-Dec-2002  jdolecek branches: 1.1.2;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfs_vnops.c was added on branch nathanw_sa on 2002-12-29 19:56:19 +0000
 1.12.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.2.8 15-Feb-2005  skrll Sync with HEAD.
 1.12.2.7 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.12.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.4 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.12.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.12.2.2 03-Aug-2004  skrll Sync with HEAD
 1.12.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.4.1 29-Apr-2005  kent sync with -current
 1.21.4.7 04-Feb-2008  yamt sync with head.
 1.21.4.6 21-Jan-2008  yamt sync with head
 1.21.4.5 07-Dec-2007  yamt sync with head
 1.21.4.4 03-Sep-2007  yamt sync with head.
 1.21.4.3 26-Feb-2007  yamt sync with head.
 1.21.4.2 30-Dec-2006  yamt sync with head.
 1.21.4.1 21-Jun-2006  yamt sync with head.
 1.24.2.2 26-Oct-2005  yamt sync with head
 1.24.2.1 20-Oct-2005  yamt adapt ntfs.
 1.27.6.2 01-Jun-2006  kardel Sync with head.
 1.27.6.1 22-Apr-2006  simonb Sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.27.2.2 18-Feb-2006  yamt fix a typo.
 1.27.2.1 18-Feb-2006  yamt adapt the rest of MI code.
 1.28.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.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.28.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.28.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.28.2.1 24-May-2006  yamt sync with head.
 1.29.10.2 10-Dec-2006  yamt sync with head.
 1.29.10.1 22-Oct-2006  yamt sync with head
 1.29.8.2 12-Jan-2007  ad Sync with head.
 1.29.8.1 18-Nov-2006  ad Sync with head.
 1.30.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.31.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.31.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.33.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.33.2.3 09-Oct-2007  ad Sync with head.
 1.33.2.2 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.33.2.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.35.14.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.35.14.1 29-Jul-2007  ad file ntfs_vnops.c was added on branch matt-mips64 on 2007-07-29 13:31:10 +0000
 1.35.12.2 18-Feb-2008  mjf Sync with HEAD.
 1.35.12.1 08-Dec-2007  mjf Sync with HEAD.
 1.35.6.2 23-Mar-2008  matt sync with HEAD
 1.35.6.1 09-Jan-2008  matt sync with HEAD
 1.35.4.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.36.6.1 19-Jan-2008  bouyer Sync with HEAD
 1.40.10.5 11-Aug-2010  yamt sync with head.
 1.40.10.4 11-Mar-2010  yamt sync with head
 1.40.10.3 18-Jul-2009  yamt sync with head.
 1.40.10.2 04-May-2009  yamt sync with head.
 1.40.10.1 16-May-2008  yamt sync with head.
 1.40.8.1 18-May-2008  yamt sync with head.
 1.40.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.40.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.42.2.2 23-Jul-2009  jym Sync with HEAD.
 1.42.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.46.4.2 31-May-2011  rmind sync with head
 1.46.4.1 03-Jul-2010  rmind sync with head
 1.46.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.47.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.10.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.49.10.1 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.49.8.2 02-Jun-2012  mrg sync to latest -current.
 1.49.8.1 05-Apr-2012  mrg sync to latest -current.
 1.49.4.5 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.49.4.4 16-Jan-2013  yamt sync with (a bit old) head
 1.49.4.3 30-Oct-2012  yamt sync with head
 1.49.4.2 23-May-2012  yamt sync with head.
 1.49.4.1 17-Apr-2012  yamt sync with head
 1.52.2.4 03-Dec-2017  jdolecek update from HEAD
 1.52.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.2.2 23-Jun-2013  tls resync from head
 1.52.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.55.6.1 18-May-2014  rmind sync with head
 1.56.2.1 10-Aug-2014  tls Rebase.
 1.59.4.1 26-Apr-2017  pgoyette Sync with HEAD
 1.59.2.2 28-Aug-2017  skrll Sync with HEAD
 1.59.2.1 05-Oct-2016  skrll Sync with HEAD
 1.60.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.65.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.5 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.4 25-Sep-2005  jmmv Follow compat naming tradition: rename compat_export_args to export_args30.
 1.3 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.2 03-Oct-2003  yamt branches: 1.2.16;
terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.1 23-Dec-2002  jdolecek branches: 1.1.2; 1.1.4;
move NTFS code from sys/ntfs to sys/fs/ntfs
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 29-Dec-2002  thorpej With with HEAD.
 1.1.2.1 23-Dec-2002  thorpej file ntfsmount.h was added on branch nathanw_sa on 2002-12-29 19:56:20 +0000
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.1 14-Jun-2010  pooka branches: 1.1.2; 1.1.4; 1.1.6;
Install ptyfs userspace header into user's space.
 1.1.6.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.6.1 14-Jun-2010  uebayasi file Makefile was added on branch uebayasi-xip on 2010-08-17 06:47:18 +0000
 1.1.4.2 11-Aug-2010  yamt sync with head.
 1.1.4.1 14-Jun-2010  yamt file Makefile was added on branch yamt-nfs-mp on 2010-08-11 22:54:34 +0000
 1.1.2.2 03-Jul-2010  rmind sync with head
 1.1.2.1 14-Jun-2010  rmind file Makefile was added on branch rmind-uvmplock on 2010-07-03 01:19:50 +0000
 1.4 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.3 02-Mar-2010  pooka branches: 1.3.20;
Don't generate unused fs_thefs.h headers.
 1.2 11-Dec-2005  christos branches: 1.2.74; 1.2.96;
merge ktrace-lwp.
 1.1 11-Nov-2004  jdolecek branches: 1.1.2;
move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.1.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 11-Nov-2004  skrll file files.ptyfs was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.2.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.74.1 11-Mar-2010  yamt sync with head
 1.3.20.1 03-Dec-2017  jdolecek update from HEAD
 1.16 27-Nov-2020  christos make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.15 17-Jan-2020  ad branches: 1.15.6;
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.14 15-Aug-2014  hannken branches: 1.14.20; 1.14.26;
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.13 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.12 04-Apr-2014  christos branches: 1.12.4;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.11 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.10 24-Oct-2012  christos branches: 1.10.2;
rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.9 18-Sep-2012  christos Always do the chroot filename mapping; it is pointless not to do it.
 1.8 15-Mar-2009  christos branches: 1.8.12; 1.8.18; 1.8.20; 1.8.22;
Add a chroot flag, so that ptyfs can be mounted in a chrooted environment.
XXX: This is a hack, in reality we should allow multiple ptyfs mounts.
 1.7 28-Jun-2008  rumble branches: 1.7.4; 1.7.10;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.6 11-Dec-2005  christos branches: 1.6.70; 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 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.4 12-Sep-2005  christos Fix the CHANGE part too.
 1.3 16-Dec-2004  atatat branches: 1.3.10;
Reorder ptyfs pseudo inode numbers so that 0 and 1 are unused, 2 is
the root of the file system, and slaves and masters alternate starting
at 3. This means the inode numbers won't be really large until you
really allocate a really lot of ptys.
 1.2 25-Nov-2004  christos Add pty group and mode settings.
 1.1 11-Nov-2004  jdolecek branches: 1.1.2;
move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.1.2.6 11-Dec-2005  christos Sync with head.
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.1.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 11-Nov-2004  skrll file ptyfs.h was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.3.10.1 21-Jun-2006  yamt sync with head.
 1.6.78.1 03-Jul-2008  simonb Sync with head.
 1.6.76.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.74.1 04-May-2009  yamt sync with head.
 1.6.70.1 29-Jun-2008  mjf Sync with HEAD.
 1.7.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.22.3 03-Dec-2017  jdolecek update from HEAD
 1.8.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.20.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.8.18.1 01-Oct-2012  riz Pull up following revision(s) (requested by christos in ticket #566):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.11
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.12
sys/fs/ptyfs/ptyfs.h: revision 1.9
sbin/mount_ptyfs/mount_ptyfs.c: revision 1.14
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.43
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.44
Does not make sense to mount this as NFS, so it is not a bug.
We can now mount multiple instances, but all of them show all the ptys.
let us get mounted multiple times.
remove -c and chroot option; they are always on now
Always do the chroot filename mapping; it is pointless not to do it.
 1.8.12.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.8.12.1 30-Oct-2012  yamt sync with head
 1.10.2.1 18-May-2014  rmind sync with head
 1.12.4.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.14.26.1 17-Jan-2020  ad Sync with head.
 1.14.20.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.6.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.34 27-Nov-2020  christos make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.33 15-Oct-2014  christos branches: 1.33.32;
From Ilia Zykov:
- correct some incorrect comments
- add XXX warning
- increase security by activating when get the slave
- make pty_vn_open() private to tty_ptm.c
 1.32 16-Aug-2014  hannken Needs HASH_SLIST, not HASH_LIST.
 1.31 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.30 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.29 27-Mar-2014  christos branches: 1.29.4;
From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
 1.28 26-Mar-2014  christos if one of the ptyfs instances has grabbed the handle don't grab it again,
Ilya Zykov
 1.27 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.26 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.25 24-Oct-2012  christos branches: 1.25.2;
rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.24 23-Oct-2012  christos fix the mystery of the bad directory times.
 1.23 12-Jun-2011  rmind branches: 1.23.2; 1.23.8; 1.23.12;
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.22 19-Nov-2010  dholland branches: 1.22.6;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.21 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.20 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.19 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.18 24-Mar-2009  haad branches: 1.18.2; 1.18.4;
Destroy mutexes used to guard hash table during vfs_detach. Fixes LOCKDEBUG
panic when ptyfs module is unloaded.
 1.17 17-Dec-2008  cegger branches: 1.17.2;
kill MALLOC and FREE macros.
 1.16 05-May-2008  ad branches: 1.16.8;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.15 30-Jan-2008  ad branches: 1.15.6; 1.15.8; 1.15.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.14 25-Jan-2008  ad - Make new vnode construction MPSAFE.
- Replace use of lockmgr().
 1.13 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.12 02-Jan-2008  ad Merge vmlocking2 to head.
 1.11 08-Dec-2007  pooka branches: 1.11.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.10 26-Nov-2007  pooka branches: 1.10.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.9 10-Oct-2007  ad branches: 1.9.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.8 21-Jul-2007  ad branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10;
Don't depend on uvm_extern.h pulling in proc.h.
 1.7 14-May-2006  elad branches: 1.7.18; 1.7.28;
integrate kauth.
 1.6 13-Apr-2006  christos Strip the chrooted portion of the path from the reported pty path. Reported
and tested by Lasse Kliemann. Thanks!
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.6; 1.5.8; 1.5.10; 1.5.12;
merge ktrace-lwp.
 1.4 12-Sep-2005  christos don't play with ctime directly anymore.
 1.3 12-Sep-2005  christos Fix the CHANGE part too.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2; 1.2.14;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.14.6 04-Feb-2008  yamt sync with head.
 1.2.14.5 21-Jan-2008  yamt sync with head
 1.2.14.4 07-Dec-2007  yamt sync with head
 1.2.14.3 27-Oct-2007  yamt sync with head.
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 21-Jun-2006  yamt sync with head.
 1.2.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_subr.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.5.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.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.5.10.2 19-Apr-2006  elad sync with head.
 1.5.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.5.8.1 24-May-2006  yamt sync with head.
 1.5.6.2 01-Jun-2006  kardel Sync with head.
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.7.28.1 15-Aug-2007  skrll Sync with HEAD.
 1.7.18.6 23-Oct-2007  ad Sync with head.
 1.7.18.5 09-Oct-2007  ad Sync with head.
 1.7.18.4 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.7.18.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.7.18.2 05-Apr-2007  ad Compile fixes.
 1.7.18.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.8.10.2 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.8.10.1 21-Jul-2007  ad file ptyfs_subr.c was added on branch matt-mips64 on 2007-07-21 19:06:22 +0000
 1.8.8.1 14-Oct-2007  yamt sync with head.
 1.8.6.3 23-Mar-2008  matt sync with HEAD
 1.8.6.2 09-Jan-2008  matt sync with HEAD
 1.8.6.1 06-Nov-2007  matt sync with HEAD
 1.8.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.8.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.9.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.9.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.9.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.2.2 26-Dec-2007  ad Sync with head.
 1.10.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.11.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.10.3 11-Aug-2010  yamt sync with head.
 1.15.10.2 04-May-2009  yamt sync with head.
 1.15.10.1 16-May-2008  yamt sync with head.
 1.15.8.1 18-May-2008  yamt sync with head.
 1.15.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.16.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.4 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.18.4.3 05-Mar-2011  rmind sync with head
 1.18.4.2 03-Jul-2010  rmind sync with head
 1.18.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.18.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.22.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.12.3 03-Dec-2017  jdolecek update from HEAD
 1.23.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.8.1 31-Oct-2012  riz Pull up following revision(s) (requested by christos in ticket #639):
sys/fs/ptyfs/ptyfs_subr.c: revision 1.24
fix the mystery of the bad directory times.
 1.23.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.23.2.1 30-Oct-2012  yamt sync with head
 1.25.2.1 18-May-2014  rmind sync with head
 1.29.4.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.33.32.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.58 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.57 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.56 17-Feb-2017  hannken branches: 1.56.14; 1.56.20;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.55 21-Oct-2014  christos branches: 1.55.2; 1.55.4; 1.55.6;
Revert previous; it does not work with COMPAT_BSDPTY, screen(1) fails because
it does a TIOCPTSNAME immediately after opening ptmx and finds an old style pty.
 1.54 15-Oct-2014  christos From Ilia Zykov:
- correct some incorrect comments
- add XXX warning
- increase security by activating when get the slave
- make pty_vn_open() private to tty_ptm.c
 1.53 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.52 14-Aug-2014  maxv Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.

Sent on tech-kern@, ok christos@
 1.51 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.50 16-Apr-2014  maxv branches: 1.50.2;
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.49 04-Apr-2014  christos branches: 1.49.2;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.48 27-Mar-2014  christos From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
 1.47 23-Mar-2014  hannken Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.46 19-Mar-2014  christos - return an error if we could not get the pts pathname
- correct getting pathname if the mount point inside a chroot
(Ilya Zykov)
 1.45 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.44 18-Sep-2012  christos branches: 1.44.2;
let us get mounted multiple times.
 1.43 18-Sep-2012  christos Always do the chroot filename mapping; it is pointless not to do it.
 1.42 08-Jan-2010  pooka branches: 1.42.12; 1.42.18; 1.42.20; 1.42.22;
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.41 30-Nov-2009  pooka Introduce genfs_statvfs() as pretty much a no-info statvfs and
convert several pseudo file systems to use it.
 1.40 21-Mar-2009  christos Fix old userland compat.
 1.39 15-Mar-2009  christos Add a chroot flag, so that ptyfs can be mounted in a chrooted environment.
XXX: This is a hack, in reality we should allow multiple ptyfs mounts.
 1.38 11-Jan-2009  christos branches: 1.38.2;
merge christos-time_t
 1.37 26-Oct-2008  joerg branches: 1.37.2; 1.37.4; 1.37.6; 1.37.14; 1.37.18;
Remove logic to compute relative pathes to chroots. It breaks the
default case of ptyfs mounted under /dev/pts as any chroot would get
/%d as slave names. This allows null mounts of ptyfs to work.
To allow pty allocation from within chroots, either no ptyfs must be
mounted or a null mount exist.
 1.36 28-Jun-2008  rumble branches: 1.36.2;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.35 13-May-2008  simonb branches: 1.35.2;
mnt_data is a pointer, set it to NULL not 0 when we're finished with it.
 1.34 13-May-2008  simonb Use the correct malloc type when free()ing the ptyfs mount structure.
Fixes the "free 2: inuse 0, probable double free" panic when using ptyfs
and KMEMSTATS.
 1.33 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.32 29-Apr-2008  ad branches: 1.32.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.31 28-Jan-2008  dholland branches: 1.31.6; 1.31.8; 1.31.10;
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.30 26-Nov-2007  pooka 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.29 24-Sep-2007  rumble branches: 1.29.4;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.28 31-Jul-2007  pooka branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8;
* 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.27 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.26 17-Jul-2007  pooka branches: 1.26.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.25 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.24 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.23 19-Jan-2007  hannken branches: 1.23.6; 1.23.8;
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.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 03-Sep-2006  christos branches: 1.19.2; 1.19.4;
add missing initializers
 1.18 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.17 20-Jun-2006  tron Make this compile again.
 1.16 20-Jun-2006  christos Don't allocate too much stuff on the stack.
 1.15 14-May-2006  elad branches: 1.15.4;
integrate kauth.
 1.14 28-Apr-2006  christos Do the count check after we process getargs.
 1.13 13-Apr-2006  christos Strip the chrooted portion of the path from the reported pty path. Reported
and tested by Lasse Kliemann. Thanks!
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 01-Oct-2005  christos use a counter to prevent from mounting ptyfs twice. Using save_ptm is not
good enough, because if we don't have COMPAT_BSDPTY, then it will stay NULL.
 1.10 29-Sep-2005  christos Move the duplicate mount check sooner, and fix a leak.
 1.9 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.8 29-May-2005  christos branches: 1.8.2;
- rename variables to avoid shadowing.
- add a few const.
 1.7 11-May-2005  christos Remove compat code that hard-codes default group and mode for pty creation.
Hi Matt!
 1.6 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.5 26-Feb-2005  perry nuke trailing whitespace
 1.4 02-Jan-2005  christos branches: 1.4.2; 1.4.4;
make this compile again; hi potr
 1.3 25-Nov-2004  christos Add pty group and mode settings.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.2.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_vfsops.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.4.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.8.2.7 04-Feb-2008  yamt sync with head.
 1.8.2.6 07-Dec-2007  yamt sync with head
 1.8.2.5 27-Oct-2007  yamt sync with head.
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.4 11-May-2006  elad sync with head
 1.12.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.12.10.2 19-Apr-2006  elad sync with head.
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.4 03-Sep-2006  yamt sync with head.
 1.12.8.3 11-Aug-2006  yamt sync with head
 1.12.8.2 26-Jun-2006  yamt sync with head.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.2 01-Jun-2006  kardel Sync with head.
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.15.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.19.4.2 10-Dec-2006  yamt sync with head.
 1.19.4.1 22-Oct-2006  yamt sync with head
 1.19.2.3 01-Feb-2007  ad Sync with head.
 1.19.2.2 12-Jan-2007  ad Sync with head.
 1.19.2.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.23.8.1 11-Jul-2007  mjf Sync with head.
 1.23.6.3 09-Oct-2007  ad Sync with head.
 1.23.6.2 20-Aug-2007  ad Sync with HEAD.
 1.23.6.1 15-Jul-2007  ad Sync with head.
 1.26.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.28.8.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.28.8.1 31-Jul-2007  pooka file ptyfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.28.6.1 06-Oct-2007  yamt sync with head.
 1.28.4.3 23-Mar-2008  matt sync with HEAD
 1.28.4.2 09-Jan-2008  matt sync with HEAD
 1.28.4.1 06-Nov-2007  matt sync with HEAD
 1.28.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.28.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.29.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.29.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.31.10.3 11-Mar-2010  yamt sync with head
 1.31.10.2 04-May-2009  yamt sync with head.
 1.31.10.1 16-May-2008  yamt sync with head.
 1.31.8.1 18-May-2008  yamt sync with head.
 1.31.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.35.2.1 03-Jul-2008  simonb Sync with head.
 1.36.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.37.18.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.37.14.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.37.6.2 09-Nov-2008  christos account for major and minor being unsigned long long
 1.37.6.1 26-Oct-2008  christos file ptyfs_vfsops.c was added on branch christos-time_t on 2008-11-09 02:05:20 +0000
 1.37.4.1 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.37.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.37.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.42.22.3 03-Dec-2017  jdolecek update from HEAD
 1.42.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.42.20.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.42.18.3 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.2 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.42.18.1 01-Oct-2012  riz branches: 1.42.18.1.2; 1.42.18.1.4;
Pull up following revision(s) (requested by christos in ticket #566):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.11
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.12
sys/fs/ptyfs/ptyfs.h: revision 1.9
sbin/mount_ptyfs/mount_ptyfs.c: revision 1.14
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.43
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.44
Does not make sense to mount this as NFS, so it is not a bug.
We can now mount multiple instances, but all of them show all the ptys.
let us get mounted multiple times.
remove -c and chroot option; they are always on now
Always do the chroot filename mapping; it is pointless not to do it.
 1.42.18.1.4.2 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.1.4.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.42.18.1.2.2 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.1.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.42.12.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.42.12.1 30-Oct-2012  yamt sync with head
 1.44.2.1 18-May-2014  rmind sync with head
 1.49.2.1 10-Aug-2014  tls Rebase.
 1.50.2.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.55.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.55.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.55.2.1 28-Aug-2017  skrll Sync with HEAD
 1.56.20.1 17-Jan-2020  ad Sync with head.
 1.56.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.69 05-Aug-2022  riastradh ptyfs: Don't copy out cookies past end of buffer.

Reported-by: syzbot+2aae7c4eddc796f917e6@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=5fe24c1da952ac2ea498d745d6479bc6be91a751
 1.68 08-Dec-2021  andvar s/efficent/efficient/ in comments.
 1.67 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.66 18-Jul-2021  dholland Fix ptyfs link and symlink ops.

They were set (via macro obfuscation just eliminated) to
genfs_abortop, which is the wrong thing. These code paths are
currently inaccessible because of EROFS enforcement in namei, but if
either were reached odd behavior would likely ensue. Use
genfs_eopnotsupp like the rest of the ops that don't make sense here.
 1.65 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.64 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.63 28-Jun-2021  chs VOP_BMAP() may be called via ioctl(FIOGETBMAP) on any vnode that applications
can open. change various pseudo-fs *_bmap methods return an error instead of
panic.

Reported-by: syzbot+8289a3eaf2ba60958c87@syzkaller.appspotmail.com
 1.62 27-Nov-2020  christos branches: 1.62.4;
make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.61 24-Nov-2020  christos PR/55821: tar can not extract base.tgz anymore (./dev/pts and mounted ptyfs)
Allow chown/chmod at the root of ptyfs.
 1.60 27-Jun-2020  christos branches: 1.60.2;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.59 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.58 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.57 26-Sep-2019  christos branches: 1.57.6;
provide VNOVALSIZE and VNOVALFLAGS to avoid casting in source.
 1.56 26-Sep-2019  christos cast VNOVAL to the the va_size type which is u_quad_t... I think it is time
to change this to uint64_t...
 1.55 03-Sep-2018  riastradh branches: 1.55.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.54 26-May-2017  riastradh branches: 1.54.8; 1.54.10;
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.53 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.52 20-Aug-2016  hannken branches: 1.52.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.51 23-Jun-2015  hannken branches: 1.51.2;
No need to call spec_inactive() from ptyfs_incative().
 1.50 21-Aug-2014  maxv branches: 1.50.2;
Remove dead returns:

return VAR/func(XX);
return VAR;

The latter is never reached. Sent on tech-kern@, no disagreement.
 1.49 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.48 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.47 25-Jul-2014  dholland branches: 1.47.2;
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.46 04-Apr-2014  christos branches: 1.46.2;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.45 27-Mar-2014  christos forgot to commit one patch:
Avoid returning released(free), but still hashed inode numbers.
(Ilya Zykov)
 1.44 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.43 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.42 05-Nov-2013  christos - support advisory locking on ptys
- get the link count correct for .
XXX: pullup 6
 1.41 18-Mar-2013  plunky branches: 1.41.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.40 24-Oct-2012  christos rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.39 13-Mar-2012  elad branches: 1.39.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.38 12-Dec-2011  njoly Start making fs read(2) fail with EISDIR if the implementation does
not allow read on directories (kernfs, rumpfs, ptyfs and sysvbfs).
Adjust man page accordingly, and add a small corresponding vfs
testcase.
 1.37 18-Nov-2011  christos branches: 1.37.4;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.36 16-Sep-2011  christos branches: 1.36.2;
don't update access/change times on open.
 1.35 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.34 24-Jun-2010  hannken branches: 1.34.6;
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.33 08-Jan-2010  pooka branches: 1.33.2; 1.33.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.32 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.31 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.30 07-May-2009  elad Extract the open-coded authorization logic for chtimes() from various
file-systems and put it in a single function, genfs_can_chtimes().

This also makes UDF follow the same policy as all other file-systems.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004951.html
 1.29 22-Apr-2009  elad Per discussion on tech-kern@:

- Replace use of label/goto with returns

- Rename, change prototype of, and move functions from vfs_subr.c to
genfs_vnops.c
 1.28 20-Apr-2009  elad Refactor some duplicated file-system code.

Proposed and received no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
 1.27 02-Jan-2008  ad branches: 1.27.10; 1.27.18; 1.27.24;
Merge vmlocking2 to head.
 1.26 26-Nov-2007  pooka branches: 1.26.2; 1.26.6;
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.25 24-Sep-2007  rumble branches: 1.25.4;
Simplify ptyfs_readdir at pooka's suggestion.

No functional change intended.
 1.24 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.23 09-Jul-2007  ad branches: 1.23.6; 1.23.8; 1.23.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.22 19-Jan-2007  christos branches: 1.22.6; 1.22.8;
only change atime on access.
 1.21 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.20 29-Dec-2006  elad Remove support for immutable and append-only flags on ptyfs.
 1.19 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.18 16-Nov-2006  christos branches: 1.18.2;
__unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 23-Jul-2006  ad branches: 1.16.4; 1.16.6;
Use the LWP cached credentials where sane.
 1.15 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.14 14-May-2006  elad branches: 1.14.2;
integrate kauth.
 1.13 14-Apr-2006  christos Remove dead code.
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.10 12-Oct-2005  simonb branches: 1.10.2;
Update the mod and access times directly from ptyfs_read() and
ptyfs_write() rather than setting a flag and updating these times
through ptyfs_itimes() at some indeterminate time in the future.
However, just use the "time" variable to set the times instead of
using a potentially expensive call to nanotime(). A HZ resolution
on these timestamps is more than enough.

(Possibly incomplete) fix for PR kern/31430.
OK'd be christos@.
 1.9 12-Sep-2005  christos Fix the CHANGE part too.
 1.8 12-Sep-2005  christos propagate itime changes from the other filesystems.
 1.7 26-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 18-Dec-2004  christos branches: 1.6.2; 1.6.4;
I don't think that the vgone() in vop_inactive is needed; in fact it might
be the source of my deadlocks.
 1.5 29-Nov-2004  atatat Remove the digits() function and simply set va_bytes and va_size to
zero in ptyfs_getattr(). There's no reason to make them something
else and no other devices (except for disk devices) report anything
other than zero here, so why should we be different?
 1.4 25-Nov-2004  atatat Properly set va_fsid so that st_dev ends up correct.
 1.3 19-Nov-2004  atatat Don't call ptyfs_time() with stack garbage. It makes the times look
funny. I was getting stuff somewhere around 1939, but that's where my
kernel is.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.2.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_vnops.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.6.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.2.1 29-Apr-2005  kent sync with -current
 1.7.4.7 21-Jan-2008  yamt sync with head
 1.7.4.6 07-Dec-2007  yamt sync with head
 1.7.4.5 27-Oct-2007  yamt sync with head.
 1.7.4.4 03-Sep-2007  yamt sync with head.
 1.7.4.3 26-Feb-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 20-Oct-2005  yamt adapt ptyfs.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.7 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.12.10.6 19-Apr-2006  elad sync with head.
 1.12.10.5 11-Mar-2006  elad Fix typo.
 1.12.10.4 11-Mar-2006  elad When calling kauth_cred_ismember_gid(), don't return the error code if
there is one, just treat it as if the check failed.

Pointed out by thorpej@.
 1.12.10.3 11-Mar-2006  elad kauth_cred_groupmember() -> kauth_cred_ismember_gid(), as requested by
thorpej@ to conform to the Darwin KPI.
 1.12.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.3 11-Aug-2006  yamt sync with head
 1.12.8.2 26-Jun-2006  yamt sync with head.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.4 01-Jun-2006  kardel Sync with head.
 1.12.6.3 22-Apr-2006  simonb Sync with head.
 1.12.6.2 05-Feb-2006  simonb In the *itimes functions, just call getnanotime() at the start of
the function and use the result if needed, rather than the previous
conditional calls/assignments method. The code is clearer this way,
and benchmarks at about the same speed.
 1.12.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 19-Jun-2006  chap Sync with head.
 1.16.6.2 10-Dec-2006  yamt sync with head.
 1.16.6.1 22-Oct-2006  yamt sync with head
 1.16.4.3 01-Feb-2007  ad Sync with head.
 1.16.4.2 12-Jan-2007  ad Sync with head.
 1.16.4.1 18-Nov-2006  ad Sync with head.
 1.18.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.22.8.1 11-Jul-2007  mjf Sync with head.
 1.22.6.3 09-Oct-2007  ad Sync with head.
 1.22.6.2 13-Apr-2007  ad - Make the devsw interface MP safe, and add some comments.
- Allow individual block/character drivers to be marked MP safe.
- Provide wrappers around the device methods that look up the
device, returning ENXIO if it's not found, and acquire the
kernel lock if needed.
 1.22.6.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.23.10.1 06-Oct-2007  yamt sync with head.
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.23.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.25.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.25.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.26.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.26.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.27.24.2 23-Jul-2009  jym Sync with HEAD.
 1.27.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.10.5 11-Aug-2010  yamt sync with head.
 1.27.10.4 11-Mar-2010  yamt sync with head
 1.27.10.3 18-Jul-2009  yamt sync with head.
 1.27.10.2 16-May-2009  yamt sync with head
 1.27.10.1 04-May-2009  yamt sync with head.
 1.33.4.2 03-Jul-2010  rmind sync with head
 1.33.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.33.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.34.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.36.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.36.2.2 30-Oct-2012  yamt sync with head
 1.36.2.1 17-Apr-2012  yamt sync with head
 1.37.4.2 05-Apr-2012  mrg sync to latest -current.
 1.37.4.1 18-Feb-2012  mrg merge to -current.
 1.39.2.4 03-Dec-2017  jdolecek update from HEAD
 1.39.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.2.2 23-Jun-2013  tls resync from head
 1.39.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.41.6.1 18-May-2014  rmind sync with head
 1.46.2.1 10-Aug-2014  tls Rebase.
 1.47.2.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.50.2.3 28-Aug-2017  skrll Sync with HEAD
 1.50.2.2 05-Oct-2016  skrll Sync with HEAD
 1.50.2.1 22-Sep-2015  skrll Sync with HEAD
 1.51.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.52.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.54.10.3 21-Apr-2020  martin Sync with HEAD
 1.54.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.54.10.1 10-Jun-2019  christos Sync with HEAD
 1.54.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.4.2 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1703):

sys/fs/ptyfs/ptyfs_vnops.c: revision 1.61

PR/55821: tar can not extract base.tgz anymore (./dev/pts and mounted ptyfs)

Allow chown/chmod at the root of ptyfs.
 1.55.4.1 29-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1504):

sys/fs/ptyfs/ptyfs_vnops.c: revision 1.69

ptyfs: Don't copy out cookies past end of buffer.
 1.57.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.60.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.62.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 22-Oct-2006  pooka branches: 1.1.2; 1.1.6; 1.1.8;
kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 22-Oct-2006  yamt file Makefile was added on branch yamt-lazymbuf on 2006-12-30 20:50:00 +0000
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 22-Oct-2006  yamt file Makefile was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 22-Oct-2006  ad file Makefile was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.1 18-May-2009  pooka branches: 1.1.2;
add some todo-items, based on a file which was lingering in my
local tree for apparently almost two years now
 1.1.2.2 20-Jun-2009  yamt sync with head
 1.1.2.1 18-May-2009  yamt file TODO was added on branch yamt-nfs-mp on 2009-06-20 07:20:30 +0000
 1.10 05-Feb-2019  pgoyette It turns out we do want the puffs compat code in any kernel which
has built-in compat_50 regardless of whether the kernel also has
puffs.

Should finally fix PR kern/53943
 1.9 04-Feb-2019  wiz try '&' instead of '&&'
 1.8 04-Feb-2019  pgoyette Don't include puffs_compat in a kernel unless the filesystem is
selected along with COMPAT_50. Also, don't include puffs_compat
in the main puffs filesystem module; it is part of the compat_50
module.

Should address PR kern/53943
 1.7 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.6 11-Oct-2014  uebayasi branches: 1.6.18; 1.6.20;
Define filesystem attributes with vfs dependency.
 1.5 06-Jul-2010  pooka branches: 1.5.18;
remember to add the new file to the build
 1.4 10-Nov-2007  pooka branches: 1.4.18; 1.4.38; 1.4.40;
Part 2/n of extensive changes to request transport to/from userspace:

Rip the transport code completely out of puffs and generalize it
into an independent module which will be used for multiple purposes
in the future. This module is called the Pass-to-Userspace
Transporter (known as "putter" among friends).

This is very much work-in-progress and one dependency with puffs
remains: the request framing format.

The device name is still /dev/puffs, but that will change soon.

Users of puffs need the following in their kernel configs now:
pseudo-device putter
 1.3 27-Sep-2007  pooka branches: 1.3.2; 1.3.4;
Split routines handling nodes from puffs_subr to puffs_node.
No functional change.
 1.2 05-Dec-2006  pooka branches: 1.2.2; 1.2.4; 1.2.10; 1.2.22; 1.2.24; 1.2.26;
shuffle functions around a bit: move the transport (/dev/puffs) to
a different file from the messaging (request contents). no functional
change
 1.1 22-Oct-2006  pooka branches: 1.1.2;
kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.1.2.3 12-Jan-2007  ad Sync with head.
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 22-Oct-2006  ad file files.puffs was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.2.26.1 06-Oct-2007  yamt sync with head.
 1.2.24.2 09-Jan-2008  matt sync with HEAD
 1.2.24.1 06-Nov-2007  matt sync with HEAD
 1.2.22.2 11-Nov-2007  joerg Sync with HEAD.
 1.2.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.2.10.1 09-Oct-2007  ad Sync with head.
 1.2.4.4 15-Nov-2007  yamt sync with head.
 1.2.4.3 27-Oct-2007  yamt sync with head.
 1.2.4.2 30-Dec-2006  yamt sync with head.
 1.2.4.1 05-Dec-2006  yamt file files.puffs was added on branch yamt-lazymbuf on 2006-12-30 20:50:00 +0000
 1.2.2.2 10-Dec-2006  yamt sync with head.
 1.2.2.1 05-Dec-2006  yamt file files.puffs was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.3.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.3.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.4.40.1 05-Mar-2011  rmind sync with head
 1.4.38.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.18.1 11-Aug-2010  yamt sync with head.
 1.5.18.1 03-Dec-2017  jdolecek update from HEAD
 1.6.20.1 10-Jun-2019  christos Sync with HEAD
 1.6.18.2 22-Sep-2018  pgoyette Include the compat code whether or not the calling device or filesystem
exists.
 1.6.18.1 24-Mar-2018  pgoyette Add fs/puffs compat_50 to the modules
 1.8 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.7 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.6 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.5 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.4 22-Apr-2015  pooka branches: 1.4.16; 1.4.18;
sprinkle COMPAT_50
 1.3 10-Nov-2014  maxv branches: 1.3.2;
Do not uselessly include <sys/malloc.h>.
 1.2 11-Jul-2010  pooka branches: 1.2.2; 1.2.4; 1.2.10; 1.2.24; 1.2.40;
Do fhtovp compat translation only for fhtovp ops, not all vfs ops.
Allocate tailing extra buffer for compat op too.
 1.1 06-Jul-2010  pooka Add compat to enable running puffs in a 64bit time_t kernel against
a server which runs in 32bit time_t namespace.
 1.2.40.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.2.24.1 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 05-Mar-2011  rmind sync with head
 1.2.10.1 11-Jul-2010  rmind file puffs_compat.c was added on branch rmind-uvmplock on 2011-03-05 20:55:07 +0000
 1.2.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.4.1 11-Jul-2010  uebayasi file puffs_compat.c was added on branch uebayasi-xip on 2010-08-17 06:47:19 +0000
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 11-Jul-2010  yamt file puffs_compat.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:34 +0000
 1.3.2.1 06-Jun-2015  skrll Sync with HEAD
 1.4.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.18.1 10-Jun-2019  christos Sync with HEAD
 1.4.16.6 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.4.16.5 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.4.16.4 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.4.16.3 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.4.16.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.4.16.1 24-Mar-2018  pgoyette Add fs/puffs compat_50 to the modules
 1.108 01-Feb-2025  andvar s/furher/further/ in comment.
 1.107 09-Feb-2024  andvar branches: 1.107.2;
fix spelling mistakes, mainly in comments and log messages.
 1.106 15-May-2020  maxv hardclock_ticks -> getticks()
 1.105 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.104 01-Mar-2019  pgoyette branches: 1.104.6;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.103 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.102 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.101 17-Apr-2017  hannken branches: 1.101.10; 1.101.12;
Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.100 26-Dec-2016  skrll branches: 1.100.2;
Hold the interlock when calling cv_broadcast as per condvar(9)
 1.99 07-Jul-2016  msaitoh branches: 1.99.2;
KNF. Remove extra spaces. No functional change.
 1.98 06-May-2015  hannken Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@
 1.97 10-Nov-2014  maxv branches: 1.97.2;
Do not uselessly include <sys/malloc.h>.
 1.96 05-Sep-2014  matt Don't use C++ class and this keywords as variables.
 1.95 28-Aug-2014  hannken Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.94 17-Oct-2013  christos branches: 1.94.4;
- remove unused variables
- add _NOERROR flavor macros for the case where errors are ignored.
 1.93 05-Nov-2012  dholland branches: 1.93.2;
Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.92 27-Jul-2012  manu branches: 1.92.2;
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
 1.91 22-Jul-2012  manu Fix hang unmount bug introduced by last commit.

We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
 1.90 21-Jul-2012  manu - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.

The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
 1.89 19-Oct-2011  manu branches: 1.89.2; 1.89.8;
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.88 18-Oct-2011  manu Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
 1.87 03-Jul-2011  mrg avoid some uninitialised variable warnings from GCC.
at least the puffs one seems valid, but i'm not 100% sure.
 1.86 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.85 11-Feb-2011  yamt branches: 1.85.2;
puffs_msg_wait: check PARKFLAG_HASERROR before PARKFLAG_CALL. PR/44240.
 1.84 15-Nov-2010  pooka branches: 1.84.2; 1.84.4;
Apply patch from PR kern/44093 by yamt:

Interrupt server wait only on certain signals (same set at nfs -i)
instead of all signals. According to the PR this helps with
"git clone" run on a puffs file system.
 1.83 12-Nov-2010  pooka Allow clients to reuse a "park".

Patch from <yamt>, fixes PR kern/44086 by him.
 1.82 06-Jul-2010  pooka Remove groolingly spooky variable which has been haunting us for
several years without doing anything useful.
 1.81 06-Jul-2010  pooka Add compat to enable running puffs in a 64bit time_t kernel against
a server which runs in 32bit time_t namespace.
 1.80 14-Jan-2010  pooka branches: 1.80.2; 1.80.4;
In case the operations thread has exited, do not queue any more
operations. This prevents kernel memory leaks (one of which happened
every time the file system was unmounted via PUFFSOP_UNMOUNT ...
and incidentally would've been trivially caught with the old
malloc(9) interface. I wonder if the message is to use a ton of
pools instead of regression-attractive kmem interface).
 1.79 07-Jan-2010  pooka Rename PUFFS_SOPREQ_EXIT to PUFFS_SOPREQSYS_EXIT to better signal
it comes from within the kernel instead of as a direct result of
a user request.

no functional change
 1.78 07-Jan-2010  pooka Fix variable name in my commit tree too.
 1.77 07-Jan-2010  pooka Add a PUFFS_UNMOUNT server->kernel request, which causes the kernel
to initiate self destruct, i.e. unmount(MNT_FORCE). This, however,
is a semi-controlled self-destruct, since all caches are flushed
before the (possibly) violent unmount takes place.
 1.76 07-Dec-2009  pooka Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.75 07-Dec-2009  pooka Need to send protocol layer response instead of transport layer
return value. While there, just collapse all non-supported types
into one entry.
 1.74 05-Nov-2009  pooka Kill suspend support. It was never implemented correctly:
* it depended on the biglock (in a very cruel way)
* it was attached to userspace transactions rather than logical
fs operations

(If someone wants to revisit it some day, most of the stuff can be
reused from cvs history)
 1.73 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.72 25-Sep-2008  ad branches: 1.72.2; 1.72.4; 1.72.8; 1.72.12;
PR kern/39307 (mfs will sometimes panic at umount time)

Change dounmount() so that it never drops the caller provided reference.
Garbage collecting 'struct mount' is up to the caller.
 1.71 06-May-2008  ad branches: 1.71.2; 1.71.6;
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.70 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.69 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.68 31-Jan-2008  tnn branches: 1.68.6; 1.68.8; 1.68.10;
- Needs sys/atomic.h for atomic_inc_uint()
- Quench compiler warning about signed/unsigned mismatch when building LKM
 1.67 30-Jan-2008  ad Expunge references to lockmgr.
 1.66 30-Jan-2008  ad Make it compile. I'll leave it to pooka to figure out what is the correct
thing here because I don't understand what this code is doing.
 1.65 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.64 28-Jan-2008  pooka For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.63 02-Jan-2008  pooka silence gcc about break type-punning
 1.62 02-Jan-2008  ad Merge vmlocking2 to head.
 1.61 05-Dec-2007  pooka branches: 1.61.4;
Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).
 1.60 26-Nov-2007  pooka branches: 1.60.2;
In case the userspace wait is interrupted, don't use ERESTART as
the return value, rather use EINTR.

reported by Reinoud
 1.59 20-Nov-2007  pooka Retire M_PUFFS, use kmem(9) instead.
 1.58 17-Nov-2007  pooka fix some debug prints
 1.57 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.56 12-Nov-2007  pooka Bounds-check responses from userspace.
 1.55 12-Nov-2007  pooka * split the putter header into a kernel version and a userland version
+ install latter to /usr/include/dev/putter
* remove last dependencies to puffs from putter, it's completely
independent now
 1.54 12-Nov-2007  pooka Move putter code from directly under dev/ to dev/putter/

no functional change
 1.53 10-Nov-2007  pooka Part 2/n of extensive changes to request transport to/from userspace:

Rip the transport code completely out of puffs and generalize it
into an independent module which will be used for multiple purposes
in the future. This module is called the Pass-to-Userspace
Transporter (known as "putter" among friends).

This is very much work-in-progress and one dependency with puffs
remains: the request framing format.

The device name is still /dev/puffs, but that will change soon.

Users of puffs need the following in their kernel configs now:
pseudo-device putter
 1.52 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.51 04-Nov-2007  pooka branches: 1.51.2;
Make some comments match current reality. No functional change.
 1.50 25-Oct-2007  pooka Reference mountpoint when fetching operations and release waiters
in unmount.
 1.49 21-Oct-2007  pooka Always provide caller information from the kernel based on curlwp.
(but don't deprecate the old puffs_cid interface just yet)
 1.48 19-Oct-2007  pooka When doing a read operation, don't copy the whole kernel buffer to
userspace, since it doesn't contain any information yet. I should
still rework this more so this is just a quickie to get the read/write
style interface more up to speed with the ioctl version.
 1.47 11-Oct-2007  pooka branches: 1.47.2;
Handle suspend and flush requests from the file server.
 1.46 11-Oct-2007  pooka Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.45 09-Oct-2007  pooka g/c vntouser_req(), it's not used anymore
 1.44 04-Oct-2007  pooka g/c the "sizeop" code previous used for ioctl/fcntl. It was already
commented out and has bitrotted beyond all recognition, so it needs
complete rethinking.
 1.43 02-Oct-2007  pooka If kernel resource allocation fails after the file server has
committed something, issue an abort. The abort is done through
the regular op channel, e.g. failed mkdir leads to regular rmdir,
inactive and reclaim. No internal interface is planned currently
for the one file system out of a million which would implement it
to benefit from the one case in a billion where kernel resource
allocation actually does fail and out of that one case in a trillion
where internal vs. external would make a difference.
 1.42 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.41 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.40 19-Jul-2007  pooka branches: 1.40.4; 1.40.6; 1.40.8; 1.40.10;
add debug printf
 1.39 09-Jul-2007  ad branches: 1.39.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.38 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.37 18-May-2007  pooka Introduce noref setbacks, which the file server can use to signal
the kernel it has 0 references to the node in question. In other
words, this can be used to avoid inactive(), or, if the file server
does not implement inactive, prompt reclaim for removed nodes.
 1.36 08-May-2007  pooka If the op was interrupted, decrease ops waiting for fetch from the
file server only if the op was still waiting for fetch (as opposed
to waiting for the response). Also, properly flag the possible
following inactive as an op for which we do not want to wait for
the response from the file server.
 1.35 07-May-2007  pooka Introduce puffs "setbacks", which can be used to set certain flags
for nodes upon return from the userspace. Currently it can be used
to indicate that the file server should be notified of "inactive"
in case the file server has opted to not receive inactive every
time the reference count for a vnode drops to zero. (inactive is
a common event, almost never requires any action and must be executed
sychronously, so it is wasteful).

While doing this, cleanup the release-relock nonsense from the
vntouser*() arguments. It was never enabled and the whole LOCKEDVP()
concept was very broken to begin with.
 1.34 01-May-2007  pooka Fix a problem introduced when I converted puffs to use newlock2:
when unmounting the file system in case of a certain timing (and
possibly some other conditions), a thread would wait on a condition
variable, while another thread broadcast the cv and immediately
proceeded to destroy it. The result was a system frozen completely
solid shorly after the process waiting for the cv woke up. So
introduce reference counting to synchronize destruction of the
resources in unmount.

I was able to repeat the problem only on my laptop in some special
cases, so I do not know how common it was. Ironically, killing
the file server process violently instead of unmount() didn't have
this problem because it never entered the unmount path from two
directions.
 1.33 24-Apr-2007  pooka remember to flag park as done when we're done with it
 1.32 22-Apr-2007  pooka Now that puffs_park is allocated from the heap and actually freed
by the userdead routine, don't do a TAILQ_FOREACH but rather an
honest for loop.
 1.31 21-Apr-2007  pooka Take care not to access park->park_preq if the waiter is gone, as
that memory is no longer available.
 1.30 20-Apr-2007  pooka don't mutex_enter() manually, we've already park_reference()d a few
lines earlier for entering the same mutex
 1.29 11-Apr-2007  pooka make overspammy debug printf less overspammy
 1.28 04-Apr-2007  pooka Fix one more bug from today's commit: don't remove the op for which
getops runs out of file server buffer space from the request queue.
Otherwise that operation silently vanishes and things go, well, quite
wrong.
 1.27 04-Apr-2007  pooka fix two loop mutex botches in previous
 1.26 04-Apr-2007  pooka Make it possible to interrupt waiters for fs operation completion
again. This is useful until locking is further developed and basically
any deadlocks can be solved by killing appropriate processes.

Thanks especially to Tommi Kyntola and Antti Louko for sitting down
with me and discussing resource ownership and locking strategies
in implementing this.
 1.25 04-Apr-2007  pooka s/ppark/park/ to make all the variable names consistent - park is
always a pointer now. no functional change
 1.24 30-Mar-2007  pooka * abstract ASYNCBIOREAD and let callers freely issue a callback called
from putop. even though there's only one user currently, makes code
more readable
* move "delta" to a standard parameter in vntouser and get rid of the
specialcase vntouser_delta
 1.23 29-Mar-2007  pooka in userdead assign waiter return value only if there is a waiter for
a particular request
 1.22 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.21 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.20 14-Mar-2007  pooka branches: 1.20.2;
Support B_READ|B_ASYNC in strategy by calling biodone() directly
when the file server puts the result.
 1.19 27-Feb-2007  pooka branches: 1.19.2; 1.19.4;
Make wait for the user file server PCATCHable. This makes it
possible to recover the system by just killing processes in case
a file server manages to recurse into itself either by fault of
file server implementation or by pilot error. The downside is that
the code is extremely hard to follow and practically screams out
for newlock2 (in addition to screaming "bug here"). The whole
PCATCH nonsense and induced megacomplexity can hopefully be avoided
in the future by tweaking other parts of the implementation.
 1.18 03-Feb-2007  pooka branches: 1.18.2;
fstrans owner automatically gets a normal lock, don't need to lazy lock

pointed out by hannken
 1.17 29-Jan-2007  hannken Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>
 1.16 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.15 19-Jan-2007  pooka debug print requests going into the queue
 1.14 15-Jan-2007  pooka Store puffs_node's on lists hashed with the cookie value instead
of just one flat list.
 1.13 29-Dec-2006  pooka branches: 1.13.2;
Don't allow calls to be queued while MOUNTING. We don't make any
kernel->server calls at that time and it allows a window where
operations use an incorrect root node cookie.

XXX: there's still a (very much smaller and biglock safe) race, but
that's going to be solved by some more thorough restructuring
 1.12 10-Dec-2006  pooka Don't return EWOULDBLOCK in case we have delivered some requests
even if we are operating on a nonblocking descriptor.
 1.11 10-Dec-2006  pooka PCATCH in tsleep while waiting for operations in getop. Otherwise
we could end up in an unkillable deadlock if GETOP was called when
an operation that had locked the root vnode was already in userspace.
 1.10 05-Dec-2006  pooka branches: 1.10.2;
shuffle functions around a bit: move the transport (/dev/puffs) to
a different file from the messaging (request contents). no functional
change
 1.9 05-Dec-2006  pooka Allow multiple requests to be transferred in each GET/PUTOP. For
a single request, the performance is still the same.
 1.8 21-Nov-2006  pooka if we are going to bail due to the mountpoint being gone from under
us while waiting for syncer lock, release the newly acquired syncer
lock prior to bailing
 1.7 21-Nov-2006  pooka cosmetics
 1.6 14-Nov-2006  pooka branches: 1.6.2;
Fix a race condition with unmount where the mountpoint might disappear
from under us while waiting for syncer_lock and before we got to vfs_busy.
This happens easily e.g. when the userspace server loses its will to
live in VOP_RECLAIM, which is called from vflush() in VFS_UNMOUNT. We
get two competing unmounters. When the first one finishes, it releases
syncer_lock. Now the second one tries to vfs_busy(), but is greeted
with garbage in *mp.

XXX: Technically this is a more general issue and should be fixed
elsewhere, but it's hard to trigger it with normal file systems
unless they are unmounted "simultaneously" twice and are dirty
enough for flushing to take a while. So make a note about it in
the little black book next to the poems and postpone the crusade
for now.
 1.5 09-Nov-2006  pooka few renames to better differentiate between mount & start.. plus some
other renaming
 1.4 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.3 06-Nov-2006  pooka puffs_park always contains a specific puffs_req, so make it a member
instead of a pointer
 1.2 25-Oct-2006  pooka If the control descriptor is closed, mark userspace dead and wakeup
all waiters *before* trying to get the syncer lock necessary for
dounmount(). This prevents a deadlock if the userspace server dies
while the syncer is running.
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.6.2.5 09-Feb-2007  ad Sync with HEAD.
 1.6.2.4 01-Feb-2007  ad Sync with head.
 1.6.2.3 12-Jan-2007  ad Sync with head.
 1.6.2.2 18-Nov-2006  ad Sync with head.
 1.6.2.1 14-Nov-2006  ad file puffs_msgif.c was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.10.2.3 18-Dec-2006  yamt sync with head.
 1.10.2.2 10-Dec-2006  yamt sync with head.
 1.10.2.1 05-Dec-2006  yamt file puffs_msgif.c was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.13.2.9 04-Feb-2008  yamt sync with head.
 1.13.2.8 21-Jan-2008  yamt sync with head
 1.13.2.7 07-Dec-2007  yamt sync with head
 1.13.2.6 15-Nov-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 29-Dec-2006  yamt file puffs_msgif.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:00 +0000
 1.18.2.5 17-May-2007  yamt sync with head.
 1.18.2.4 07-May-2007  yamt sync with head.
 1.18.2.3 15-Apr-2007  yamt sync with head.
 1.18.2.2 24-Mar-2007  yamt sync with head.
 1.18.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.4.1 11-Jul-2007  mjf Sync with head.
 1.19.2.8 12-Oct-2007  ad Sync with head.
 1.19.2.7 09-Oct-2007  ad Sync with head.
 1.19.2.6 01-Sep-2007  ad Update for pool_cache API changes.
 1.19.2.5 20-Aug-2007  ad Sync with HEAD.
 1.19.2.4 09-Jun-2007  ad Sync with head.
 1.19.2.3 08-Jun-2007  ad Sync with head.
 1.19.2.2 10-Apr-2007  ad Sync with head.
 1.19.2.1 05-Apr-2007  ad Compile fixes.
 1.20.2.1 29-Mar-2007  reinoud Pullup to -current
 1.39.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.40.10.2 19-Jul-2007  pooka add debug printf
 1.40.10.1 19-Jul-2007  pooka file puffs_msgif.c was added on branch matt-mips64 on 2007-07-19 22:05:23 +0000
 1.40.8.2 14-Oct-2007  yamt sync with head.
 1.40.8.1 06-Oct-2007  yamt sync with head.
 1.40.6.4 23-Mar-2008  matt sync with HEAD
 1.40.6.3 09-Jan-2008  matt sync with HEAD
 1.40.6.2 08-Nov-2007  matt sync with -HEAD
 1.40.6.1 06-Nov-2007  matt sync with HEAD
 1.40.4.10 09-Dec-2007  jmcneill Sync with HEAD.
 1.40.4.9 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.40.4.8 21-Nov-2007  joerg Sync with HEAD.
 1.40.4.7 14-Nov-2007  joerg Sync with HEAD.
 1.40.4.6 11-Nov-2007  joerg Sync with HEAD.
 1.40.4.5 04-Nov-2007  jmcneill Sync with HEAD.
 1.40.4.4 28-Oct-2007  joerg Sync with HEAD.
 1.40.4.3 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.40.4.2 07-Oct-2007  joerg Sync with HEAD.
 1.40.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.47.2.4 21-Nov-2007  bouyer Sync with HEAD
 1.47.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.47.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.47.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.51.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.51.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.51.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.60.2.1 08-Dec-2007  ad Sync with head.
 1.61.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.61.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.68.10.4 11-Aug-2010  yamt sync with head.
 1.68.10.3 11-Mar-2010  yamt sync with head
 1.68.10.2 04-May-2009  yamt sync with head.
 1.68.10.1 16-May-2008  yamt sync with head.
 1.68.8.1 18-May-2008  yamt sync with head.
 1.68.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.68.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.71.6.1 19-Oct-2008  haad Sync with HEAD.
 1.71.2.1 10-Oct-2008  skrll Sync with HEAD.
 1.72.12.1 21-Apr-2010  matt sync to netbsd-5
 1.72.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.72.4.5 02-Nov-2011  riz Pull up following revision(s) (requested by manu in ticket #1679):
sys/fs/puffs/puffs_vnops.c: revision 1.157
sys/fs/puffs/puffs_vnops.c: revision 1.158
sys/fs/puffs/puffs_vnops.c: revision 1.159
sys/fs/puffs/puffs_vfsops.c: revision 1.97
sys/fs/puffs/puffs_vfsops.c: revision 1.99
sys/fs/puffs/puffs_vnops.c: revision 1.160
sys/fs/puffs/puffs_vfsops.c: revision 1.100
sys/miscfs/syncfs/sync_subr.c: revision 1.47
sys/fs/puffs/puffs_node.c: revision 1.21
sys/fs/puffs/puffs_node.c: revision 1.22
sys/fs/puffs/puffs_msgif.c: revision 1.88
sys/fs/puffs/puffs_msgif.c: revision 1.89
sys/fs/puffs/puffs_vnops.c: revision 1.156
Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.
This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
Fix the build that was broken by struct lwp *updateproc reference in
RUMP-visible code. Instead of checking that updateproc (aka ioflush,
aka syncer) will not sleep in PUFFS code, I check for any kernel thread:
after all none of them are designed to hang awaiting for a remote filesystem
operation to complete.
Roll back the change that forced kernel threads to not sleep in PUFFS.
The change does not make consensus, since only pagedaemon should need it.
Other threads will tolerate sleeping, and problems here are only symptoms
that something is going wrong in memory management. The cause, not the
symptoms, need to be fixed.
Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.72.4.4 15-Jul-2011  riz Pull up following revision(s) (requested by manu in ticket #1604):
sys/fs/puffs/puffs_msgif.c: revision 1.84
Apply patch from PR kern/44093 by yamt:
Interrupt server wait only on certain signals (same set at nfs -i)
instead of all signals. According to the PR this helps with
"git clone" run on a puffs file system.
 1.72.4.3 20-May-2011  bouyer Revert ticket 1604, it does't build.
 1.72.4.2 19-May-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1604):
sys/fs/puffs/puffs_msgif.c: revision 1.84 via patch
Apply patch from PR kern/44093 by yamt:
Interrupt server wait only on certain signals (same set at nfs -i)
instead of all signals. According to the PR this helps with
"git clone" run on a puffs file system.
 1.72.4.1 09-Jan-2010  snj Pull up following revision(s) (requested by pooka in ticket #1212):
sys/fs/puffs/puffs_msgif.c: revision 1.76 via patch
sys/fs/puffs/puffs_sys.h: revision 1.73 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.84 via patch
Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.72.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.80.4.2 05-Mar-2011  rmind sync with head
 1.80.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.80.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.84.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.84.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.85.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.89.8.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #438):
lib/libperfuse/perfuse_priv.h: revision 1.31
sys/fs/puffs/puffs_msgif.h: revision 1.80
sys/fs/puffs/puffs_vnops.c: revision 1.171
lib/libpuffs/puffs_ops.3: revision 1.31
sys/fs/puffs/puffs_vnops.c: revision 1.172
sys/fs/puffs/puffs_vnops.c: revision 1.173
sys/fs/puffs/puffs_vnops.c: revision 1.174
usr.sbin/perfused/perfused.c: revision 1.24
sys/fs/puffs/puffs_sys.h: revision 1.80
sys/fs/puffs/puffs_sys.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.82
lib/libperfuse/subr.c: revision 1.19
lib/libperfuse/perfuse.c: revision 1.30
sys/fs/puffs/puffs_msgif.c: revision 1.90
sys/fs/puffs/puffs_msgif.c: revision 1.91
sys/fs/puffs/puffs_msgif.c: revision 1.92
lib/libperfuse/ops.c: revision 1.59
lib/libpuffs/puffs.3: revision 1.53
lib/libperfuse/debug.c: revision 1.12
lib/libpuffs/puffs.3: revision 1.54
sys/fs/puffs/puffs_vnops.c: revision 1.167
sys/fs/puffs/puffs_msgif.h: revision 1.79
usr.sbin/perfused/msg.c: revision 1.21
sys/fs/puffs/puffs_vfsops.c: revision 1.102
sys/fs/puffs/puffs_vfsops.c: revision 1.103
sys/fs/puffs/puffs_vfsops.c: revision 1.105
lib/libpuffs/puffs.h: revision 1.123
lib/libperfuse/perfuse_if.h: revision 1.20
lib/libperfuse/perfuse.c: revision 1.29
lib/libpuffs/dispatcher.c: revision 1.42
lib/libpuffs/dispatcher.c: revision 1.43
- Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).
We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed
- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().
- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.
- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.
- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode
and size set. This confuses some FUSE filesystem. Therefore we send two FUSE
operations, one for mode, and one for size.
- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
- Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.
We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.
- Fix lookup/reclaim race condition.
The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.
We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
Fix hang unmount bug introduced by last commit.
We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
Bump date for previous.
New sentence, new line; remove trailing whitespace; fix typos;
punctuation nits.
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.
Enable the featuure for perfused, as this is how FUSE works.
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.89.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.89.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.89.2.1 30-Oct-2012  yamt sync with head
 1.92.2.3 03-Dec-2017  jdolecek update from HEAD
 1.92.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.92.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.93.2.1 18-May-2014  rmind sync with head
 1.94.4.2 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.94.4.1 29-Aug-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_sys.h: revision 1.86
sys/fs/puffs/puffs_vfsops.c: revision 1.114
sys/fs/puffs/puffs_msgif.c: revision 1.95
sys/fs/puffs/puffs_node.c: revision 1.32
sys/fs/puffs/puffs_vnops.c: revision 1.184
Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.97.2.4 28-Aug-2017  skrll Sync with HEAD
 1.97.2.3 05-Feb-2017  skrll Sync with HEAD
 1.97.2.2 09-Jul-2016  skrll Sync with HEAD
 1.97.2.1 06-Jun-2015  skrll Sync with HEAD
 1.99.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.99.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.100.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.101.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.101.12.1 10-Jun-2019  christos Sync with HEAD
 1.101.10.11 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.101.10.10 21-Jan-2019  pgoyette No need to declare the hook_call() function for void hooks. So
remove and simplify.
 1.101.10.9 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.101.10.8 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.101.10.7 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.101.10.6 29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.101.10.5 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.101.10.4 18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.101.10.3 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.101.10.2 24-Mar-2018  pgoyette Use function pointers to call the compatability functions.
 1.101.10.1 24-Mar-2018  pgoyette Add fs/puffs compat_50 to the modules
 1.104.6.1 29-Feb-2020  ad Sync with head.
 1.107.2.1 02-Aug-2025  perseant Sync with HEAD
 1.87 03-Dec-2021  pho Avoid using register_t in <fs/puffs/puffs_msgif.h>

The purpose of this header file is to interface between the
kernel-space and user-space, and is #include'd by a user-space header
<puffs.h>. It should therefore not use any of kernel-only types, as
it's not reasonable to require user-land filesystems to #define
_KERNTYPES.
 1.86 08-Mar-2021  christos give names to the enums so we can cast by name for lint
 1.85 23-Sep-2019  christos branches: 1.85.8;
Restore binary compatibility by using the statvfs90 structure internally.
 1.84 15-Feb-2015  manu branches: 1.84.18;
Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.
 1.83 31-Oct-2014  manu branches: 1.83.2;
Add PUFFS_HAVE_FALLOCATE in puffs_msgif.h so that filesystem can decide
at build time wether fallocate is usable
 1.82 31-Oct-2014  manu Add PUFFS support for fallocate and fdiscard operations
 1.81 16-Aug-2014  manu Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.80 10-Aug-2012  manu branches: 1.80.2; 1.80.14;
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.

Enable the featuure for perfused, as this is how FUSE works.
 1.79 21-Jul-2012  manu - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.

The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
 1.78 08-Apr-2012  manu Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
 1.77 27-Sep-2011  christos branches: 1.77.2; 1.77.6; 1.77.8;
don't get affected by the NAME_MAX bump. Use the same constant as the
rest of the extrattr code.
 1.76 04-Jul-2011  manu Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.

There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)

This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
 1.75 06-Jul-2010  pooka Add compat to enable running puffs in a 64bit time_t kernel against
a server which runs in 32bit time_t namespace.
 1.74 07-Jun-2010  pooka Make retval argument for pathconf a register_t to match VOP_PATHCONF.
This makes the size the same on 64bit archs. Don't bother bumping
any version, since you'd have explicitly had to jump through some
hoops to use pathconf before.
 1.73 21-May-2010  pooka add option string for no attribute cache
(foreseeing the odd event I might actually implement one some day)
 1.72 21-May-2010  pooka Since libpuffs needs a major bump for extattr support anyway, make
some changes to the user-kernel protocol. Namely, try to be a
little more resilient some future changes.
 1.71 21-May-2010  pooka Support extended attributes.
 1.70 20-May-2010  pooka Fix typo.
 1.69 07-Jan-2010  pooka branches: 1.69.2; 1.69.4;
Add a PUFFS_UNMOUNT server->kernel request, which causes the kernel
to initiate self destruct, i.e. unmount(MNT_FORCE). This, however,
is a semi-controlled self-destruct, since all caches are flushed
before the (possibly) violent unmount takes place.
 1.68 17-Oct-2009  pooka Bump protocol version once more to allow for previous to be pulled
to netbsd-5 (protocols are not compatible due to time_t/dev_t
change).
 1.67 17-Oct-2009  pooka Transmit VOP_ABORTOP() to the server.
 1.66 12-Jan-2009  pooka Bump interface version number for the time_t/dev_t changes.
 1.65 28-Jan-2008  pooka branches: 1.65.6; 1.65.10; 1.65.18; 1.65.20; 1.65.26;
For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.64 08-Dec-2007  pooka Now that "l" is gone both as an argument to operations and from
componentname, remove all vestiges of puffs_cid.
 1.63 05-Dec-2007  pooka Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).
 1.62 04-Dec-2007  pooka Add a bit to differentiate if a message is a request or a response.
 1.61 27-Nov-2007  pooka branches: 1.61.2;
Remove "puffs_cid" from the puffs interface following l-removal
from the kernel vfs interfaces. puffs_cc_getcaller(pcc) can be
used now should the same information be desired.
 1.60 12-Nov-2007  pooka * split the putter header into a kernel version and a userland version
+ install latter to /usr/include/dev/putter
* remove last dependencies to puffs from putter, it's completely
independent now
 1.59 21-Oct-2007  pooka branches: 1.59.2;
Always provide caller information from the kernel based on curlwp.
(but don't deprecate the old puffs_cid interface just yet)
 1.58 19-Oct-2007  pooka When doing a read operation, don't copy the whole kernel buffer to
userspace, since it doesn't contain any information yet. I should
still rework this more so this is just a quickie to get the read/write
style interface more up to speed with the ioctl version.
 1.57 11-Oct-2007  pooka branches: 1.57.2;
g/c garbage
 1.56 11-Oct-2007  pooka Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.55 04-Oct-2007  pooka g/c the "sizeop" code previous used for ioctl/fcntl. It was already
commented out and has bitrotted beyond all recognition, so it needs
complete rethinking.
 1.54 02-Oct-2007  pooka If kernel resource allocation fails after the file server has
committed something, issue an abort. The abort is done through
the regular op channel, e.g. failed mkdir leads to regular rmdir,
inactive and reclaim. No internal interface is planned currently
for the one file system out of a million which would implement it
to benefit from the one case in a billion where kernel resource
allocation actually does fail and out of that one case in a trillion
where internal vs. external would make a difference.
 1.53 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.52 27-Sep-2007  pooka nuke trailing , from enum. spotted by xtraeme
 1.51 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.50 23-Aug-2007  pooka branches: 1.50.2; 1.50.4;
Add a third type of fh option, passthrough, where the kernel does
not attempt to handle struct fid at all and passes it as such to
userspace.
 1.49 22-Aug-2007  pooka Mimic namei structure changes for puffs. bump both kernel & lib version.
 1.48 15-Aug-2007  pooka Nuke PUFFSLOOKUP_FOO and move to NAMEI_FOO
 1.47 30-Jul-2007  pooka branches: 1.47.4; 1.47.6;
Move PUFFS_TYPEPREFIX to puffs_msgif.h since it's used in a macro there.
 1.46 27-Jul-2007  pooka include <uvm/uvm_prot.h>
 1.45 27-Jul-2007  pooka Change unused fflags parameter in VOP_MMAP to prot and pass in
desired vm protection.
 1.44 19-Jul-2007  pooka define PUFFSREQSIZEOP ioctl, which can be used to fetch the
maximum request size
 1.43 18-Jul-2007  pooka kill MFSNAMELEN limit
 1.42 17-Jul-2007  pooka branches: 1.42.2;
Set a file server supplied file system type in the type field and set
the mntfromname to be the place mounted from instead of the type.
 1.41 16-Jul-2007  pooka 1|2 is more correct when it's 3 instead of 2. This makes calls to
the file server inactive less over-eagerly executed and masks some
problems with the new mounting style. Effectively, it makes some
file systems such as psshfs mountable again (only without -o allops).
 1.40 02-Jul-2007  pooka support turning REQUIREDIR off and extra consume in lookup
 1.39 02-Jul-2007  pooka Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.
 1.38 01-Jul-2007  pooka Give the file server to ability to request the entire pathname buffer
under lookup by using PUFFS_KFLAG_LOOKUP_FULLPNBUF instead just the
current component.
 1.37 01-Jul-2007  pooka Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
 1.36 01-Jul-2007  pooka make puffs_cred an opaque type
 1.35 24-Jun-2007  pooka Actually, keep PUFFS_KFLAG_NOCACHE and -o cache around as shorthand
to neither page- nor namecache.
 1.34 24-Jun-2007  pooka Split the NOCACHE option in twain: NOCACHE_NAME & NOCACHE_PAGE.
 1.33 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.32 18-May-2007  pooka Introduce noref setbacks, which the file server can use to signal
the kernel it has 0 references to the node in question. In other
words, this can be used to avoid inactive(), or, if the file server
does not implement inactive, prompt reclaim for removed nodes.
 1.31 18-May-2007  pooka Support VOP_POLL. This requires some acrobatics on the puffs_node,
as we give a reference to userspace for the puffs_node for the
duration of the poll call. So reference count puffs_node separately
from the parent vnode. vref()/vrele() is not possible due to a possible
surprise visit from VOP_INACTIVE.
 1.30 17-May-2007  pooka Make it possible for the file server to specify the root vnode type
and other information instead of always using VDIR. To make this
possible without races, require all root node information already
in puffs_mount() and nuke puffs_start2() and the associated start
operation completely.

requested/inspired by Tobias Nygren
 1.29 07-May-2007  pooka Introduce puffs "setbacks", which can be used to set certain flags
for nodes upon return from the userspace. Currently it can be used
to indicate that the file server should be notified of "inactive"
in case the file server has opted to not receive inactive every
time the reference count for a vnode drops to zero. (inactive is
a common event, almost never requires any action and must be executed
sychronously, so it is wasteful).

While doing this, cleanup the release-relock nonsense from the
vntouser*() arguments. It was never enabled and the whole LOCKEDVP()
concept was very broken to begin with.
 1.28 22-Apr-2007  pooka define PUFFS_KFLAG_WTCACHE, which makes the page cache write-through
 1.27 16-Apr-2007  pooka Give the file server the ability to specify the file handle length
instead of defining a static length file handle on the framework-level.
 1.26 13-Apr-2007  pooka Allow file servers to request the number of hash cookie buckets for
pnode -> vnode reverse lookup.
 1.25 13-Apr-2007  pooka * add fhlen to kernel argument structure
* rename it to puffs_kargs instead of puffs_args
 1.24 11-Apr-2007  pooka * support VFS_FHTOVP and VFS_VPTOFH
* support cookies in for VOP_READDIR

nfs exporting puffs file systems works now
 1.23 06-Apr-2007  pooka actually, we don't need a separate op for flushing the whole page cache
of a node, just use the range op with endoff = 0
 1.22 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.21 20-Mar-2007  pooka export puffs version of namei ISLASTCN macro to userspace
 1.20 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.19 26-Jan-2007  pooka branches: 1.19.2; 1.19.6; 1.19.8; 1.19.10;
Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.18 16-Jan-2007  pooka g/c revoke msg structure
 1.17 09-Jan-2007  pooka comment out flushmulti for now, it's not done and kdump will complain
as mjf noted
 1.16 09-Jan-2007  pooka Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.15 07-Jan-2007  pooka vfs sync, flushes regular file data only (user server can take care of
flushing any metadata it might have hidden away)
 1.14 02-Jan-2007  pooka * check userspace version and prevent incompatible mount
* some general maintenance
 1.13 29-Dec-2006  pooka branches: 1.13.2;
rename the kernel-provided componentname to puffs_kcn; libpuffs now
provides puffs_cn built on top of it
 1.12 07-Dec-2006  pooka branches: 1.12.2;
let implementation ultimately decide if mmap is supported - pass
VOP_MMAP to fs server
 1.11 05-Dec-2006  pooka Allow multiple requests to be transferred in each GET/PUTOP. For
a single request, the performance is still the same.
 1.10 01-Dec-2006  pooka prefix kernel flags with PUFFS_KFLAG to have a separate namespace
from the library flags
 1.9 01-Dec-2006  pooka don't call the fs server for all operations, only those it has told
us that it implements
 1.8 18-Nov-2006  pooka branches: 1.8.2;
Require statvfs info from startreq so that we have that info available.
Also, don't pass fsid to userspace and just fill it in the kernel.
 1.7 17-Nov-2006  pooka Introduce uncached operation, makes sense when the file system backend
can be modified from elsewhere than the file system interface
 1.6 09-Nov-2006  pooka few renames to better differentiate between mount & start.. plus some
other renaming
 1.5 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.4 26-Oct-2006  pooka support specfs
 1.3 25-Oct-2006  pooka pass VOP_INACTIVE() to userspace
 1.2 23-Oct-2006  pooka bump the reqstruct minsize to something more believable (but I should
really fix this, still)
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.8.2.4 01-Feb-2007  ad Sync with head.
 1.8.2.3 12-Jan-2007  ad Sync with head.
 1.8.2.2 18-Nov-2006  ad Sync with head.
 1.8.2.1 18-Nov-2006  ad file puffs_msgif.h was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.12.2.2 10-Dec-2006  yamt sync with head.
 1.12.2.1 07-Dec-2006  yamt file puffs_msgif.h was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.13.2.9 04-Feb-2008  yamt sync with head.
 1.13.2.8 21-Jan-2008  yamt sync with head
 1.13.2.7 07-Dec-2007  yamt sync with head
 1.13.2.6 15-Nov-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 29-Dec-2006  yamt file puffs_msgif.h was added on branch yamt-lazymbuf on 2006-12-30 20:50:00 +0000
 1.19.10.1 29-Mar-2007  reinoud Pullup to -current
 1.19.8.1 11-Jul-2007  mjf Sync with head.
 1.19.6.7 12-Oct-2007  ad Sync with head.
 1.19.6.6 09-Oct-2007  ad Sync with head.
 1.19.6.5 20-Aug-2007  ad Sync with HEAD.
 1.19.6.4 15-Jul-2007  ad Sync with head.
 1.19.6.3 09-Jun-2007  ad Sync with head.
 1.19.6.2 08-Jun-2007  ad Sync with head.
 1.19.6.1 10-Apr-2007  ad Sync with head.
 1.19.2.4 17-May-2007  yamt sync with head.
 1.19.2.3 07-May-2007  yamt sync with head.
 1.19.2.2 15-Apr-2007  yamt sync with head.
 1.19.2.1 24-Mar-2007  yamt sync with head.
 1.42.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.42.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.47.6.2 30-Jul-2007  pooka Move PUFFS_TYPEPREFIX to puffs_msgif.h since it's used in a macro there.
 1.47.6.1 30-Jul-2007  pooka file puffs_msgif.h was added on branch matt-mips64 on 2007-07-30 09:04:59 +0000
 1.47.4.8 09-Dec-2007  jmcneill Sync with HEAD.
 1.47.4.7 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.47.4.6 14-Nov-2007  joerg Sync with HEAD.
 1.47.4.5 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.47.4.4 07-Oct-2007  joerg Sync with HEAD.
 1.47.4.3 02-Oct-2007  joerg Sync with HEAD.
 1.47.4.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.47.4.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.50.4.2 14-Oct-2007  yamt sync with head.
 1.50.4.1 06-Oct-2007  yamt sync with head.
 1.50.2.3 23-Mar-2008  matt sync with HEAD
 1.50.2.2 09-Jan-2008  matt sync with HEAD
 1.50.2.1 06-Nov-2007  matt sync with HEAD
 1.57.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.57.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.59.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.59.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.59.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.59.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.61.2.2 26-Dec-2007  ad Sync with head.
 1.61.2.1 08-Dec-2007  ad Sync with head.
 1.65.26.1 21-Apr-2010  matt sync to netbsd-5
 1.65.20.3 17-Jul-2011  riz Pull up following revision(s) (requested by manu in ticket #1645):
lib/libc/sys/Makefile.inc 1.207 via patch
lib/libc/sys/extattr_get_file.2 patch
lib/libpuffs/dispatcher.c 1.34,1.36 via patch
lib/libpuffs/puffs.c 1.107 via patch
lib/libpuffs/puffs.h 1.115,1.118 via patch
sys/fs/puffs/puffs_msgif.h 1.71,1.76 via patch
sys/fs/puffs/puffs_vfsops.c 1.88 via patch
sys/fs/puffs/puffs_vnops.c 1.145,1.154 via patch
sys/kern/vfs_xattr.c 1.24-1.27 via patch
sys/kern/vnode_if.c 1.87 via patch
sys/sys/Makefile 1.133 via patch
sys/sys/extattr.h 1.6 via patch
sys/sys/vnode_if.h 1.81 via patch
sys/ufs/ffs/ffs_vnops.c patch
sys/ufs/ufs/ufs_extattr.c 1.31,1.34 via patch

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness
Support extended attributes.
Fix multiple non compliances in our Linux-like extattr API, and make it
public so that it can be used.
Improve a bit listxattr(2). It attemps to list both system and user
extended attributes, and it faled if calling user did not have privilege
for reading system EA. Now we just lise user EA and skip system EA in
reading them is not allowed.
Fix bug introduced in previous commuit: Do not vrele() a vnode we did not
obtained.
Improve UFS1 extended attributes usability
- autocreate attribute backing file for new attributes
- autoload attributes when issuing extattrctl start
- when autoloading attributes, do not display garbage warning when looking
up entries that got ENOENT
Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.
There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)
This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
 1.65.20.2 14-Dec-2009  sborrill Revert previous version bump which should not have been in the supplied
patch. This maintains compatibility between 5.0 and 5.1 (at the cost of
needing userland libraries recompiled if one's been tracking netbsd-5).
 1.65.20.1 18-Oct-2009  sborrill Pull up the following revisions(s) (requested by pooka in ticket #1100):
lib/libpuffs/dispatcher.c: revision 1.33
lib/libpuffs/puffs.c: revision 1.99
lib/libpuffs/puffs.h: revision 1.111
sys/fs/puffs/puffs_msgif.h: revision 1.67 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.136

Support VOP_ABORTOP() in puffs.
 1.65.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.65.10.3 11-Aug-2010  yamt sync with head.
 1.65.10.2 11-Mar-2010  yamt sync with head
 1.65.10.1 04-May-2009  yamt sync with head.
 1.65.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.69.4.3 05-Mar-2011  rmind sync with head
 1.69.4.2 03-Jul-2010  rmind sync with head
 1.69.4.1 30-May-2010  rmind sync with head
 1.69.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.77.8.4 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #1260):
lib/libpuffs/puffs.3: revision 1,55,1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Use more markup. New sentence, new line. Bump date for previous.

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.77.8.3 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1140):
lib/libperfuse/ops.c 1.63-1.69
lib/libperfuse/perfuse.c 1.32-1.33
lib/libperfuse/perfuse_priv.h 1.32-1.34
lib/libperfuse/subr.c 1.20
lib/libpuffs/creds.c 1.16
lib/libpuffs/dispatcher.c 1.47
lib/libpuffs/puffs.h 1.125
lib/libpuffs/puffs_ops.3 1.37-1.38
lib/libpuffs/requests.c 1.24
sys/fs/puffs/puffs_msgif.h 1.81
sys/fs/puffs/puffs_sys.h 1.85
sys/fs/puffs/puffs_vnops.c 1.183
usr.sbin/perfused/msg.c 1.22
Bring libpuffs, libperfuse and perfused on par with -current:
- implement FUSE direct I/O
- remove useless code and warnings
- fix missing GETATTR bugs
- fix exended attribute get and list operations
 1.77.8.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #438):
lib/libperfuse/perfuse_priv.h: revision 1.31
sys/fs/puffs/puffs_msgif.h: revision 1.80
sys/fs/puffs/puffs_vnops.c: revision 1.171
lib/libpuffs/puffs_ops.3: revision 1.31
sys/fs/puffs/puffs_vnops.c: revision 1.172
sys/fs/puffs/puffs_vnops.c: revision 1.173
sys/fs/puffs/puffs_vnops.c: revision 1.174
usr.sbin/perfused/perfused.c: revision 1.24
sys/fs/puffs/puffs_sys.h: revision 1.80
sys/fs/puffs/puffs_sys.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.82
lib/libperfuse/subr.c: revision 1.19
lib/libperfuse/perfuse.c: revision 1.30
sys/fs/puffs/puffs_msgif.c: revision 1.90
sys/fs/puffs/puffs_msgif.c: revision 1.91
sys/fs/puffs/puffs_msgif.c: revision 1.92
lib/libperfuse/ops.c: revision 1.59
lib/libpuffs/puffs.3: revision 1.53
lib/libperfuse/debug.c: revision 1.12
lib/libpuffs/puffs.3: revision 1.54
sys/fs/puffs/puffs_vnops.c: revision 1.167
sys/fs/puffs/puffs_msgif.h: revision 1.79
usr.sbin/perfused/msg.c: revision 1.21
sys/fs/puffs/puffs_vfsops.c: revision 1.102
sys/fs/puffs/puffs_vfsops.c: revision 1.103
sys/fs/puffs/puffs_vfsops.c: revision 1.105
lib/libpuffs/puffs.h: revision 1.123
lib/libperfuse/perfuse_if.h: revision 1.20
lib/libperfuse/perfuse.c: revision 1.29
lib/libpuffs/dispatcher.c: revision 1.42
lib/libpuffs/dispatcher.c: revision 1.43
- Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).
We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed
- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().
- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.
- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.
- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode
and size set. This confuses some FUSE filesystem. Therefore we send two FUSE
operations, one for mode, and one for size.
- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
- Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.
We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.
- Fix lookup/reclaim race condition.
The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.
We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
Fix hang unmount bug introduced by last commit.
We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
Bump date for previous.
New sentence, new line; remove trailing whitespace; fix typos;
punctuation nits.
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.
Enable the featuure for perfused, as this is how FUSE works.
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.77.8.1 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.77.6.1 29-Apr-2012  mrg sync to latest -current.
 1.77.2.2 30-Oct-2012  yamt sync with head
 1.77.2.1 17-Apr-2012  yamt sync with head
 1.80.14.3 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #555):
lib/libpuffs/puffs.3: revision 1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.80.14.2 05-Nov-2014  snj Pull up following revision(s) (requested by manu in ticket #181):
lib/libperfuse/fuse.h: revision 1.6
lib/libperfuse/ops.c: revision 1.78
lib/libperfuse/perfuse.c: revision 1.35
lib/libperfuse/perfuse_priv.h: revision 1.36
lib/libpuffs/dispatcher.c: revision 1.48
lib/libpuffs/opdump.c: revision 1.37
lib/libpuffs/puffs.c: revision 1.118
lib/libpuffs/puffs.h: revision 1.126
lib/libpuffs/puffs_ops.3: revisions 1.40-1.41
sys/fs/puffs/puffs_msgif.h: revision 1.82-1.83
sys/fs/puffs/puffs_msgif.h: revision 1.82
sys/fs/puffs/puffs_vnops.c: revision 1.196
Add PUFFS support for fallocate and fdiscard operations
--
libpuffs support for fallocate and fdiscard operations
--
Add PUFFS_HAVE_FALLOCATE in puffs_msgif.h so that filesystem can decide
at build time wether fallocate is usable
--
FUSE fallocate support
There seems to be no fdiscard FUSE operation at the moment, hence that
one is left unused.
 1.80.14.1 26-Aug-2014  riz Pull up following revision(s) (requested by manu in ticket #52):
sys/fs/puffs/puffs_msgif.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.85
sys/fs/puffs/puffs_vnops.c: revision 1.183
Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.80.2.1 03-Dec-2017  jdolecek update from HEAD
 1.83.2.1 06-Apr-2015  skrll Sync with HEAD
 1.84.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.85.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.38 08-Feb-2018  dholland Typos.
 1.37 20-Aug-2016  hannken Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.36 10-Nov-2014  maxv branches: 1.36.2;
Do not uselessly include <sys/malloc.h>.
 1.35 04-Nov-2014  manu Fix PUFFS node use-after-reclaim

When puffs_cookie2vnode() misses an entry, vcache_get()
creates a new node (puffs_vfsop_loadvnode being called to
initialize the PUFFS part), then it discovers it is VNON,
and tries to vrele() it. vrele() calls VOP_INACTIVE(),
which led us in puffs_vnop_inactive() where we sent a
request to the filesystem for a node that already had been
reclaimed.

The fix is to check for VNON nodes in puffs_vnop_inactive()
and to return without doing anyting. This is suboptimal, but
a better workaround would probably need to modify vcache API,
with an impact on other filesystems. Let us keep it simple.
 1.34 30-Sep-2014  hannken Fix the puffs_sop_thread -> puffs_cookie2vnode path:
- pass the cookie by reference
- add missing mutex_exit()
- update assertion for VNON typed vnodes
 1.33 05-Sep-2014  manu When changing a directory content, update the ctime/mtime in kernel cache,
otherwise the updated ctime/mtime appears after the cached entry expire.
 1.32 28-Aug-2014  hannken Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.31 23-Jan-2014  hannken branches: 1.31.4;
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.30 17-Oct-2013  christos - remove unused variables
- add _NOERROR flavor macros for the case where errors are ignored.
 1.29 06-Mar-2013  yamt branches: 1.29.6;
comments
use sizeof(var) instead of sizeof(type) where possibly confusing
 1.28 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.27 23-Jul-2012  manu branches: 1.27.2;
Backout NCHNAMLEN check for cache_enter. That change collided with rmind's
move of this exact check into cache_enter
 1.26 23-Jul-2012  manu Di not call cache_enter with path components bigger than NCHNAMLEN, as it
panics the kernel.
 1.25 22-Jul-2012  rmind Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.24 08-Apr-2012  manu Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
 1.23 19-Jan-2012  manu branches: 1.23.2;
Fix a race condition where the filesystem lookups a vnode that is
being recycled, producing ENOENT while the file does exist.

Approved by yamt
 1.22 19-Oct-2011  manu branches: 1.22.2; 1.22.6;
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.21 18-Oct-2011  manu Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
 1.20 29-Aug-2011  manu Add a mutex for operations that touch size (setattr, getattr, write, fsync).

This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.

Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.

This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.19 30-Jun-2011  wiz dependant -> dependent
 1.18 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.17 25-Jul-2010  hannken branches: 1.17.6;
It makes no sense to call vget() with LK_RETRY.
 1.16 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.15 05-Nov-2009  pooka branches: 1.15.2; 1.15.4;
Kill suspend support. It was never implemented correctly:
* it depended on the biglock (in a very cruel way)
* it was attached to userspace transactions rather than logical
fs operations

(If someone wants to revisit it some day, most of the stuff can be
reused from cvs history)
 1.14 30-Sep-2009  pooka * fix a race i introduced almost two years ago in rev 1.116:
operations creating a node cannot be considered outgoing operations,
since after return from userspace they modify file system state
by creating a new node. if we do not protect the file system by
holding the directory lock, a lookup operation might race us into
the kernel and create the node earlier.
* remove pnode from hashlish before sending the reclaim faf off to
userspace. also, hold pmp_lock while frobbing the list.
 1.13 06-May-2008  ad branches: 1.13.10; 1.13.18;
PR kern/37950 Unmounting psshfs immediately panics the machine

puffs_getvnode() was inserting vnodes into mnt_vnodelist without taking
a reference to the mount for each. When vnodes are scrubbed, refs to the
vnodes mount structure are dropped => boom.
 1.12 01-Mar-2008  rmind branches: 1.12.2; 1.12.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.11 28-Jan-2008  pooka branches: 1.11.2; 1.11.6;
For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.10 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.9 02-Jan-2008  ad Merge vmlocking2 to head.
 1.8 17-Nov-2007  pooka branches: 1.8.2; 1.8.6;
Make puffs_updatenode() take a puffs_node instead of a vnode. This
way we don't need to worry if a vnode has been reclaimed from under
us.
 1.7 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.6 11-Oct-2007  pooka branches: 1.6.2; 1.6.4; 1.6.6; 1.6.8;
Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.5 10-Oct-2007  ad 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.4 02-Oct-2007  pooka branches: 1.4.2; 1.4.4; 1.4.6;
If kernel resource allocation fails after the file server has
committed something, issue an abort. The abort is done through
the regular op channel, e.g. failed mkdir leads to regular rmdir,
inactive and reclaim. No internal interface is planned currently
for the one file system out of a million which would implement it
to benefit from the one case in a billion where kernel resource
allocation actually does fail and out of that one case in a trillion
where internal vs. external would make a difference.
 1.3 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.2 27-Sep-2007  pooka comments & other minor maintenance
 1.1 27-Sep-2007  pooka Split routines handling nodes from puffs_subr to puffs_node.
No functional change.
 1.4.6.6 28-Oct-2007  ad Fix up mnt_vnodelist handling.
 1.4.6.5 23-Oct-2007  ad Sync with head.
 1.4.6.4 12-Oct-2007  ad Sync with head.
 1.4.6.3 09-Oct-2007  ad Sync with head.
 1.4.6.2 09-Oct-2007  ad Sync with head.
 1.4.6.1 02-Oct-2007  ad file puffs_node.c was added on branch vmlocking on 2007-10-09 13:44:18 +0000
 1.4.4.3 14-Oct-2007  yamt sync with head.
 1.4.4.2 06-Oct-2007  yamt sync with head.
 1.4.4.1 02-Oct-2007  yamt file puffs_node.c was added on branch yamt-x86pmap on 2007-10-06 15:29:48 +0000
 1.4.2.4 21-Nov-2007  joerg Sync with HEAD.
 1.4.2.3 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.4.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.4.2.1 02-Oct-2007  joerg file puffs_node.c was added on branch jmcneill-pm on 2007-10-02 18:28:52 +0000
 1.6.8.4 23-Mar-2008  matt sync with HEAD
 1.6.8.3 09-Jan-2008  matt sync with HEAD
 1.6.8.2 06-Nov-2007  matt sync with HEAD
 1.6.8.1 11-Oct-2007  matt file puffs_node.c was added on branch matt-armv6 on 2007-11-06 23:31:15 +0000
 1.6.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.6.6.1 19-Nov-2007  mjf Sync with HEAD.
 1.6.4.6 17-Mar-2008  yamt sync with head.
 1.6.4.5 04-Feb-2008  yamt sync with head.
 1.6.4.4 21-Jan-2008  yamt sync with head
 1.6.4.3 07-Dec-2007  yamt sync with head
 1.6.4.2 27-Oct-2007  yamt sync with head.
 1.6.4.1 11-Oct-2007  yamt file puffs_node.c was added on branch yamt-lazymbuf on 2007-10-27 11:35:10 +0000
 1.6.2.1 18-Nov-2007  bouyer Sync with HEAD
 1.8.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.11.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.11.2.1 24-Mar-2008  keiichi sync with head.
 1.12.4.3 11-Aug-2010  yamt sync with head.
 1.12.4.2 11-Mar-2010  yamt sync with head
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.18.1 21-Apr-2010  matt sync to netbsd-5
 1.13.10.4 25-Jan-2012  riz Pull up following revision(s) (requested by manu in ticket #1714):
sys/fs/puffs/puffs_node.c: revision 1.23
Fix a race condition where the filesystem lookups a vnode that is
being recycled, producing ENOENT while the file does exist.
Approved by yamt
 1.13.10.3 02-Nov-2011  riz Pull up following revision(s) (requested by manu in ticket #1679):
sys/fs/puffs/puffs_vnops.c: revision 1.157
sys/fs/puffs/puffs_vnops.c: revision 1.158
sys/fs/puffs/puffs_vnops.c: revision 1.159
sys/fs/puffs/puffs_vfsops.c: revision 1.97
sys/fs/puffs/puffs_vfsops.c: revision 1.99
sys/fs/puffs/puffs_vnops.c: revision 1.160
sys/fs/puffs/puffs_vfsops.c: revision 1.100
sys/miscfs/syncfs/sync_subr.c: revision 1.47
sys/fs/puffs/puffs_node.c: revision 1.21
sys/fs/puffs/puffs_node.c: revision 1.22
sys/fs/puffs/puffs_msgif.c: revision 1.88
sys/fs/puffs/puffs_msgif.c: revision 1.89
sys/fs/puffs/puffs_vnops.c: revision 1.156
Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.
This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
Fix the build that was broken by struct lwp *updateproc reference in
RUMP-visible code. Instead of checking that updateproc (aka ioflush,
aka syncer) will not sleep in PUFFS code, I check for any kernel thread:
after all none of them are designed to hang awaiting for a remote filesystem
operation to complete.
Roll back the change that forced kernel threads to not sleep in PUFFS.
The change does not make consensus, since only pagedaemon should need it.
Other threads will tolerate sleeping, and problems here are only symptoms
that something is going wrong in memory management. The cause, not the
symptoms, need to be fixed.
Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.13.10.2 17-Sep-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1666):
sys/fs/puffs/puffs_sys.h: revision 1.78 via patch
sys/fs/puffs/puffs_node.c: revision 1.20 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.155 via patch
Add a mutex for operations that touch size (setattr, getattr, write, fsync).
This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.
Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.
This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.13.10.1 03-Oct-2009  snj Pull up following revision(s) (requested by pooka in ticket #1042):
sys/fs/puffs/puffs_node.c: revision 1.14
sys/fs/puffs/puffs_vnops.c: revision 1.134
* fix a race i introduced almost two years ago in rev 1.116:
operations creating a node cannot be considered outgoing operations,
since after return from userspace they modify file system state
by creating a new node. if we do not protect the file system by
holding the directory lock, a lookup operation might race us into
the kernel and create the node earlier.
* remove pnode from hashlish before sending the reclaim faf off to
userspace. also, hold pmp_lock while frobbing the list.
 1.15.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.15.4.2 05-Mar-2011  rmind sync with head
 1.15.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.15.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.17.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.6.2 29-Apr-2012  mrg sync to latest -current.
 1.22.6.1 18-Feb-2012  mrg merge to -current.
 1.22.2.4 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.22.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.22.2.2 30-Oct-2012  yamt sync with head
 1.22.2.1 17-Apr-2012  yamt sync with head
 1.23.2.3 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1149):
sys/fs/puffs/puffs_node.c: revision 1.33
sys/fs/puffs/puffs_vnops.c: revision 1.185
When changing a directory content, update the ctime/mtime in kernel
cache,
otherwise the updated ctime/mtime appears after the cached entry expire.
 1.23.2.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.23.2.1 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.27.2.4 03-Dec-2017  jdolecek update from HEAD
 1.27.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.2.2 23-Jun-2013  tls resync from head
 1.27.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.6.1 18-May-2014  rmind sync with head
 1.31.4.5 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.31.4.4 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #194):
sys/fs/puffs/puffs_vnops.c: revision 1.197
sys/fs/puffs/puffs_node.c: revision 1.35
Fix PUFFS node use-after-reclaim
When puffs_cookie2vnode() misses an entry, vcache_get()
creates a new node (puffs_vfsop_loadvnode being called to
initialize the PUFFS part), then it discovers it is VNON,
and tries to vrele() it. vrele() calls VOP_INACTIVE(),
which led us in puffs_vnop_inactive() where we sent a
request to the filesystem for a node that already had been
reclaimed.
The fix is to check for VNON nodes in puffs_vnop_inactive()
and to return without doing anyting. This is suboptimal, but
a better workaround would probably need to modify vcache API,
with an impact on other filesystems. Let us keep it simple.
 1.31.4.3 30-Sep-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_node.c: revision 1.34
sys/fs/puffs/puffs_vnops.c: revision 1.187
Fix the puffs_sop_thread -> puffs_cookie2vnode path:
- pass the cookie by reference
- add missing mutex_exit()
- update assertion for VNON typed vnodes
 1.31.4.2 10-Sep-2014  martin Pull up following revision(s) (requested by manu in ticket #79):
sys/fs/puffs/puffs_node.c: revision 1.33
sys/fs/puffs/puffs_vnops.c: revision 1.185
When changing a directory content, update the ctime/mtime in kernel
cache, otherwise the updated ctime/mtime appears after the cached
entry expire.
 1.31.4.1 29-Aug-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_sys.h: revision 1.86
sys/fs/puffs/puffs_vfsops.c: revision 1.114
sys/fs/puffs/puffs_msgif.c: revision 1.95
sys/fs/puffs/puffs_node.c: revision 1.32
sys/fs/puffs/puffs_vnops.c: revision 1.184
Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.36.2.1 05-Oct-2016  skrll Sync with HEAD
 1.67 10-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.66 16-Nov-2008  pooka branches: 1.66.26; 1.66.42;
more <sys/buf.h> police
 1.65 01-Mar-2008  rmind branches: 1.65.4; 1.65.10; 1.65.12;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.64 28-Jan-2008  pooka branches: 1.64.2; 1.64.6;
For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.63 02-Jan-2008  pooka More type-punning workarounds. Curiously the kernel compilation
flags cause gcc to not complain.
 1.62 08-Dec-2007  pooka branches: 1.62.4;
Now that "l" is gone both as an argument to operations and from
componentname, remove all vestiges of puffs_cid.
 1.61 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.60 17-Nov-2007  pooka branches: 1.60.2;
Make puffs_updatenode() take a puffs_node instead of a vnode. This
way we don't need to worry if a vnode has been reclaimed from under
us.
 1.59 17-Nov-2007  pooka Implement a biodone callback for async writes similar to reads and
use that when possible.
 1.58 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.57 11-Oct-2007  pooka branches: 1.57.2; 1.57.4;
Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.56 10-Oct-2007  ad 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.55 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.54 29-Sep-2007  pooka kill trailing whitespace
 1.53 27-Sep-2007  pooka Split routines handling nodes from puffs_subr to puffs_node.
No functional change.
 1.52 27-Sep-2007  pooka Revert previous, it makes no sense whatsoever.
 1.51 27-Sep-2007  pooka Undo state created in cookie2vnode if an error is returned.
 1.50 27-Sep-2007  pooka Differentiate between cookie2vnode returning an error and
return to caller, address unknown: no such cookie, no such node.
Make the callers use this info to either create a new vnode or bail.
 1.49 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.48 27-Sep-2007  pooka Don't forget to insert the root node on the hash list.

... I should remember to test also if unmounting a file system works
before I commit stuff.
 1.47 27-Sep-2007  pooka Fix a race in how new cookies are checked. Previously the checking
was done separate of inserting the cookie into the lookup structure
and without any form of interlock. This could lead to the same
cookie pointing to two different nodes. Remedy the race by creating
a separate "checked and ready to be inserted" cookie list which
serves as an interlock without having to hold a fs-global creation
lock.
 1.46 24-Sep-2007  pooka add a few comments and g/c dead code
 1.45 04-Sep-2007  pooka branches: 1.45.2;
* don't allow the file server to specify a node size to be VSIZENOTSET
* KASSERT that VNOVAL == VSIZENOTSET
 1.44 01-Aug-2007  pooka branches: 1.44.2; 1.44.4; 1.44.6;
add comment to flag a slight problem
 1.43 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.42 22-Jul-2007  pooka Keep track of the maximum size we have supplied the file server (or
it has supplied us). If we fault pages which are at offset >= server
size, but less than the in-kernel vnode size, inform the file server
of the latest developments in file size before issueing the fault.
The avoids confusion with files which are not written start to finish.

fixes kern/36429 by yamt
 1.41 19-Jul-2007  pooka Initialize pnode to 0 after fetching it from the pool. At least
one effect is poll() working much better, as selinfo doesn't contain
random bits.
 1.40 09-Jul-2007  ad branches: 1.40.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.39 02-Jul-2007  pooka check for invalid vtype
 1.38 01-Jul-2007  pooka Give the file server to ability to request the entire pathname buffer
under lookup by using PUFFS_KFLAG_LOOKUP_FULLPNBUF instead just the
current component.
 1.37 01-Jul-2007  pooka Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
 1.36 01-Jul-2007  pooka make puffs_cred an opaque type
 1.35 24-Jun-2007  pooka Split the NOCACHE option in twain: NOCACHE_NAME & NOCACHE_PAGE.
 1.34 21-Jun-2007  pooka Refactor the pnode2vnode translation slightly so that VFS_ROOT
can use it directly.
 1.33 21-Jun-2007  pooka Reorganize how the root vnode is fetched so that it doesn't always
go through VFS_ROOT() and allow to fetch it without locking it.
This allows us to call the cache flush operations also for the root
vnode and most notably fixes e.g. a "No such file or directory"
for a psshfs root directory ls -l when a file was locally deleted
and remotely re-created.

Also fix some sloppy programming in root node fetch (mostly cosmetic).
 1.32 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.31 18-May-2007  pooka Support VOP_POLL. This requires some acrobatics on the puffs_node,
as we give a reference to userspace for the puffs_node for the
duration of the poll call. So reference count puffs_node separately
from the parent vnode. vref()/vrele() is not possible due to a possible
surprise visit from VOP_INACTIVE.
 1.30 17-May-2007  pooka Make it possible for the file server to specify the root vnode type
and other information instead of always using VDIR. To make this
possible without races, require all root node information already
in puffs_mount() and nuke puffs_start2() and the associated start
operation completely.

requested/inspired by Tobias Nygren
 1.29 08-May-2007  pooka Adventures in file systems, part (u_quad_t)-1: we can't use the
file system value for the size of device special files, as that
comes from specfs instead of the "host" file system. Therefore,
take care that getattr doesn't override the value of vp->v_size.
 1.28 01-May-2007  pooka Fix a problem introduced when I converted puffs to use newlock2:
when unmounting the file system in case of a certain timing (and
possibly some other conditions), a thread would wait on a condition
variable, while another thread broadcast the cv and immediately
proceeded to destroy it. The result was a system frozen completely
solid shorly after the process waiting for the cv woke up. So
introduce reference counting to synchronize destruction of the
resources in unmount.

I was able to repeat the problem only on my laptop in some special
cases, so I do not know how common it was. Ironically, killing
the file server process violently instead of unmount() didn't have
this problem because it never entered the unmount path from two
directions.
 1.27 30-Mar-2007  pooka * abstract ASYNCBIOREAD and let callers freely issue a callback called
from putop. even though there's only one user currently, makes code
more readable
* move "delta" to a standard parameter in vntouser and get rid of the
specialcase vntouser_delta
 1.26 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.25 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.24 14-Mar-2007  pooka branches: 1.24.2;
Support B_READ|B_ASYNC in strategy by calling biodone() directly
when the file server puts the result.
 1.23 12-Mar-2007  ad branches: 1.23.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.22 27-Feb-2007  pooka branches: 1.22.2;
Make wait for the user file server PCATCHable. This makes it
possible to recover the system by just killing processes in case
a file server manages to recurse into itself either by fault of
file server implementation or by pilot error. The downside is that
the code is extremely hard to follow and practically screams out
for newlock2 (in addition to screaming "bug here"). The whole
PCATCH nonsense and induced megacomplexity can hopefully be avoided
in the future by tweaking other parts of the implementation.
 1.21 20-Feb-2007  ad Call genfs_node_destroy() where appropriate.
 1.20 16-Feb-2007  pooka branches: 1.20.2;
Check against root node cookie when fetching a new vnode and invoke
VFS_ROOT() if the cookies match. Without this fix, if the root
vnode was reclaimed, doing lookups for dotdot from the root vnode
was possible. In practice this occured only through getcwd.
 1.19 15-Feb-2007  pooka Hide the debug prints behind PUFFSDEBUG instead of DEBUG. Make the
latter define the former.
 1.18 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.17 25-Jan-2007  pooka don't hold spinlocks (except vnode interlock) when doing vget()
 1.16 15-Jan-2007  pooka Store puffs_node's on lists hashed with the cookie value instead
of just one flat list.
 1.15 15-Jan-2007  pooka * do not accept the directory cookie as the result of a lookup (otherwise
we'd be locking against ourselves)
* do not accept duplicate cookies when creating new nodes
 1.14 09-Jan-2007  pooka Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.13 30-Dec-2006  pooka branches: 1.13.2;
* use PUFFS_KFLAG_NOCACHE to also signal that we don't want the namecache
* enter files into the namecache immediately when new nodes are created
(if it's a caching mount, of course)
 1.12 29-Dec-2006  pooka rename the kernel-provided componentname to puffs_kcn; libpuffs now
provides puffs_cn built on top of it
 1.11 05-Dec-2006  pooka branches: 1.11.2;
shuffle functions around a bit: move the transport (/dev/puffs) to
a different file from the messaging (request contents). no functional
change
 1.10 05-Dec-2006  pooka Allow multiple requests to be transferred in each GET/PUTOP. For
a single request, the performance is still the same.
 1.9 18-Nov-2006  pooka branches: 1.9.2;
As a first generation best-effort hack, use NOCACHE to mean "file
size can change without the kernel knowing" and therefore query
the file size before invoking read or write operations.
 1.8 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.7 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.6 27-Oct-2006  pooka fix checkalias true branch: don't unlock or lock twice
 1.5 27-Oct-2006  pooka support fifos
 1.4 26-Oct-2006  pooka support specfs
 1.3 26-Oct-2006  pooka Fix operations creating new nodes to honor the vnode locking protocol
if the userspace server returns an error. Fixes lockups if any
of the following operations failed: create, mknod, mkdir, symlink
 1.2 23-Oct-2006  pooka Apply a little eggwash to a deadlock condition where calling
getnewvnode() while holding on to any vnode lock deadlocks the
system if the file system is being forcibly unmounted.

Normal file systems don't trigger this problem because of two reaons:
1) they don't hold on to vnode locks while idling who-knows-where, so
the race doesn't trigger
2) they aren't usually unmounted with FORCE; puffs is, in case "someone"
manages to make a crashy userspace server

Nevertheless, a real solution is slowly being braised.
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.9.2.4 01-Feb-2007  ad Sync with head.
 1.9.2.3 12-Jan-2007  ad Sync with head.
 1.9.2.2 18-Nov-2006  ad Sync with head.
 1.9.2.1 18-Nov-2006  ad file puffs_subr.c was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.11.2.2 10-Dec-2006  yamt sync with head.
 1.11.2.1 05-Dec-2006  yamt file puffs_subr.c was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 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 30-Dec-2006  yamt file puffs_subr.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:01 +0000
 1.20.2.6 17-May-2007  yamt sync with head.
 1.20.2.5 07-May-2007  yamt sync with head.
 1.20.2.4 15-Apr-2007  yamt sync with head.
 1.20.2.3 24-Mar-2007  yamt sync with head.
 1.20.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.20.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.2.14 12-Oct-2007  ad Sync with head.
 1.22.2.13 09-Oct-2007  ad Sync with head.
 1.22.2.12 09-Oct-2007  ad Sync with head.
 1.22.2.11 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.22.2.10 20-Aug-2007  ad Sync with HEAD.
 1.22.2.9 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.22.2.8 15-Jul-2007  ad Sync with head.
 1.22.2.7 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.22.2.6 09-Jun-2007  ad Sync with head.
 1.22.2.5 08-Jun-2007  ad Sync with head.
 1.22.2.4 10-Apr-2007  ad Sync with head.
 1.22.2.3 05-Apr-2007  ad Compile fixes.
 1.22.2.2 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.22.2.1 13-Mar-2007  ad Sync with head.
 1.23.2.1 11-Jul-2007  mjf Sync with head.
 1.24.2.1 29-Mar-2007  reinoud Pullup to -current
 1.40.2.2 10-Sep-2007  skrll Sync with HEAD.
 1.40.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.44.6.2 01-Aug-2007  pooka add comment to flag a slight problem
 1.44.6.1 01-Aug-2007  pooka file puffs_subr.c was added on branch matt-mips64 on 2007-08-01 14:20:46 +0000
 1.44.4.3 23-Mar-2008  matt sync with HEAD
 1.44.4.2 09-Jan-2008  matt sync with HEAD
 1.44.4.1 06-Nov-2007  matt sync with HEAD
 1.44.2.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.44.2.3 21-Nov-2007  joerg Sync with HEAD.
 1.44.2.2 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.44.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.45.2.2 14-Oct-2007  yamt sync with head.
 1.45.2.1 06-Oct-2007  yamt sync with head.
 1.57.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.57.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.57.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.57.2.1 18-Nov-2007  bouyer Sync with HEAD
 1.60.2.1 26-Dec-2007  ad Sync with head.
 1.62.4.1 08-Jan-2008  bouyer Sync with HEAD
 1.64.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.64.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.64.2.1 24-Mar-2008  keiichi sync with head.
 1.65.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.65.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.65.4.1 04-May-2009  yamt sync with head.
 1.66.42.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.66.26.1 03-Dec-2017  jdolecek update from HEAD
 1.91 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.90 07-Jul-2016  msaitoh branches: 1.90.16; 1.90.18;
KNF. Remove extra spaces. No functional change.
 1.89 15-Feb-2015  manu Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.
 1.88 05-Oct-2014  apb branches: 1.88.2;
Add close brace, accidentally omitted from previous change.
 1.87 05-Oct-2014  apb Safer definitions of DPRINTF and DPRINTF_VERBOSE.

In the PUFFSDEBUG case, wrap do { ... } while (/*CONSTCOND*/0)
around the definitions. In the non-PUFFSDEBUG case, define them
as ((void)0) instead of as empty.
 1.86 28-Aug-2014  hannken Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.85 16-Aug-2014  manu Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.84 17-Oct-2013  christos branches: 1.84.4;
- remove unused variables
- add _NOERROR flavor macros for the case where errors are ignored.
 1.83 06-Mar-2013  yamt branches: 1.83.6;
comment
 1.82 11-Aug-2012  manu branches: 1.82.2;
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.81 27-Jul-2012  manu Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
 1.80 21-Jul-2012  manu - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.

The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
 1.79 08-Apr-2012  manu Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
 1.78 29-Aug-2011  manu branches: 1.78.2; 1.78.6; 1.78.8;
Add a mutex for operations that touch size (setattr, getattr, write, fsync).

This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.

Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.

This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.77 11-Jan-2011  kefren add advlock to puffs. ok pooka@
should fix kern/43321
 1.76 06-Jul-2010  pooka Add compat to enable running puffs in a 64bit time_t kernel against
a server which runs in 32bit time_t namespace.
 1.75 07-Jan-2010  pooka branches: 1.75.2; 1.75.4;
Rename PUFFS_SOPREQ_EXIT to PUFFS_SOPREQSYS_EXIT to better signal
it comes from within the kernel instead of as a direct result of
a user request.

no functional change
 1.74 07-Jan-2010  pooka Add a PUFFS_UNMOUNT server->kernel request, which causes the kernel
to initiate self destruct, i.e. unmount(MNT_FORCE). This, however,
is a semi-controlled self-destruct, since all caches are flushed
before the (possibly) violent unmount takes place.
 1.73 07-Dec-2009  pooka Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.72 05-Nov-2009  pooka Kill suspend support. It was never implemented correctly:
* it depended on the biglock (in a very cruel way)
* it was attached to userspace transactions rather than logical
fs operations

(If someone wants to revisit it some day, most of the stuff can be
reused from cvs history)
 1.71 05-Nov-2009  pooka Reinstante PNODE_DYING. vmlocking had a brief hiatus when it was not
a valid optimization, but that's long gone and once VOP_INACTIVE is
called and the file server says that the vnode is going to be recycled,
it really is going to be recycled extra references gained or not.
 1.70 28-Jan-2008  pooka branches: 1.70.10; 1.70.20; 1.70.28;
For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.69 02-Jan-2008  pooka More type-punning workarounds. Curiously the kernel compilation
flags cause gcc to not complain.
 1.68 02-Jan-2008  ad Merge vmlocking2 to head.
 1.67 08-Dec-2007  pooka branches: 1.67.4;
Now that "l" is gone both as an argument to operations and from
componentname, remove all vestiges of puffs_cid.
 1.66 05-Dec-2007  pooka Send a response message for flush operations from the kernel instead
of abusing the return value of write(2).
 1.65 20-Nov-2007  pooka branches: 1.65.2;
Retire M_PUFFS, use kmem(9) instead.
 1.64 17-Nov-2007  pooka Make puffs_updatenode() take a puffs_node instead of a vnode. This
way we don't need to worry if a vnode has been reclaimed from under
us.
 1.63 17-Nov-2007  pooka Implement a biodone callback for async writes similar to reads and
use that when possible.
 1.62 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.61 12-Nov-2007  pooka Bounds-check responses from userspace.
 1.60 10-Nov-2007  pooka Part 2/n of extensive changes to request transport to/from userspace:

Rip the transport code completely out of puffs and generalize it
into an independent module which will be used for multiple purposes
in the future. This module is called the Pass-to-Userspace
Transporter (known as "putter" among friends).

This is very much work-in-progress and one dependency with puffs
remains: the request framing format.

The device name is still /dev/puffs, but that will change soon.

Users of puffs need the following in their kernel configs now:
pseudo-device putter
 1.59 11-Oct-2007  pooka branches: 1.59.2; 1.59.4;
Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.58 09-Oct-2007  pooka g/c more unused stuff
 1.57 09-Oct-2007  pooka g/c vntouser_req(), it's not used anymore
 1.56 04-Oct-2007  pooka g/c the "sizeop" code previous used for ioctl/fcntl. It was already
commented out and has bitrotted beyond all recognition, so it needs
complete rethinking.
 1.55 02-Oct-2007  pooka If kernel resource allocation fails after the file server has
committed something, issue an abort. The abort is done through
the regular op channel, e.g. failed mkdir leads to regular rmdir,
inactive and reclaim. No internal interface is planned currently
for the one file system out of a million which would implement it
to benefit from the one case in a billion where kernel resource
allocation actually does fail and out of that one case in a trillion
where internal vs. external would make a difference.
 1.54 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.53 27-Sep-2007  pooka Split routines handling nodes from puffs_subr to puffs_node.
No functional change.
 1.52 27-Sep-2007  pooka Differentiate between cookie2vnode returning an error and
return to caller, address unknown: no such cookie, no such node.
Make the callers use this info to either create a new vnode or bail.
 1.51 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.50 27-Sep-2007  pooka Fix a race in how new cookies are checked. Previously the checking
was done separate of inserting the cookie into the lookup structure
and without any form of interlock. This could lead to the same
cookie pointing to two different nodes. Remedy the race by creating
a separate "checked and ready to be inserted" cookie list which
serves as an interlock without having to hold a fs-global creation
lock.
 1.49 24-Sep-2007  pooka add a few comments and g/c dead code
 1.48 30-Jul-2007  pooka branches: 1.48.4; 1.48.6; 1.48.8; 1.48.10;
Move PUFFS_TYPEPREFIX to puffs_msgif.h since it's used in a macro there.
 1.47 22-Jul-2007  pooka Keep track of the maximum size we have supplied the file server (or
it has supplied us). If we fault pages which are at offset >= server
size, but less than the in-kernel vnode size, inform the file server
of the latest developments in file size before issueing the fault.
The avoids confusion with files which are not written start to finish.

fixes kern/36429 by yamt
 1.46 17-Jul-2007  pooka branches: 1.46.2;
Set a file server supplied file system type in the type field and set
the mntfromname to be the place mounted from instead of the type.
 1.45 01-Jul-2007  pooka Give the file server to ability to request the entire pathname buffer
under lookup by using PUFFS_KFLAG_LOOKUP_FULLPNBUF instead just the
current component.
 1.44 01-Jul-2007  pooka Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
 1.43 01-Jul-2007  pooka make puffs_cred an opaque type
 1.42 24-Jun-2007  pooka Split the NOCACHE option in twain: NOCACHE_NAME & NOCACHE_PAGE.
 1.41 21-Jun-2007  pooka Refactor the pnode2vnode translation slightly so that VFS_ROOT
can use it directly.
 1.40 21-Jun-2007  pooka Reorganize how the root vnode is fetched so that it doesn't always
go through VFS_ROOT() and allow to fetch it without locking it.
This allows us to call the cache flush operations also for the root
vnode and most notably fixes e.g. a "No such file or directory"
for a psshfs root directory ls -l when a file was locally deleted
and remotely re-created.

Also fix some sloppy programming in root node fetch (mostly cosmetic).
 1.39 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.38 19-May-2007  pooka forgot to commit this with puffs_vnops.c 1.72:

Actually, we do need separate "no references in file server" and
"noref + inactive" flags if we wish to correctly support unix open
file semantics and optimize away pre-reclaim cache flushes. So,
add PNODE_DYING which stands for norefs + inactive.
 1.37 18-May-2007  pooka Introduce noref setbacks, which the file server can use to signal
the kernel it has 0 references to the node in question. In other
words, this can be used to avoid inactive(), or, if the file server
does not implement inactive, prompt reclaim for removed nodes.
 1.36 18-May-2007  pooka Support VOP_POLL. This requires some acrobatics on the puffs_node,
as we give a reference to userspace for the puffs_node for the
duration of the poll call. So reference count puffs_node separately
from the parent vnode. vref()/vrele() is not possible due to a possible
surprise visit from VOP_INACTIVE.
 1.35 17-May-2007  pooka Make it possible for the file server to specify the root vnode type
and other information instead of always using VDIR. To make this
possible without races, require all root node information already
in puffs_mount() and nuke puffs_start2() and the associated start
operation completely.

requested/inspired by Tobias Nygren
 1.34 07-May-2007  pooka Introduce puffs "setbacks", which can be used to set certain flags
for nodes upon return from the userspace. Currently it can be used
to indicate that the file server should be notified of "inactive"
in case the file server has opted to not receive inactive every
time the reference count for a vnode drops to zero. (inactive is
a common event, almost never requires any action and must be executed
sychronously, so it is wasteful).

While doing this, cleanup the release-relock nonsense from the
vntouser*() arguments. It was never enabled and the whole LOCKEDVP()
concept was very broken to begin with.
 1.33 01-May-2007  pooka Fix a problem introduced when I converted puffs to use newlock2:
when unmounting the file system in case of a certain timing (and
possibly some other conditions), a thread would wait on a condition
variable, while another thread broadcast the cv and immediately
proceeded to destroy it. The result was a system frozen completely
solid shorly after the process waiting for the cv woke up. So
introduce reference counting to synchronize destruction of the
resources in unmount.

I was able to repeat the problem only on my laptop in some special
cases, so I do not know how common it was. Ironically, killing
the file server process violently instead of unmount() didn't have
this problem because it never entered the unmount path from two
directions.
 1.32 16-Apr-2007  pooka Give the file server the ability to specify the file handle length
instead of defining a static length file handle on the framework-level.
 1.31 13-Apr-2007  pooka * add fhlen to kernel argument structure
* rename it to puffs_kargs instead of puffs_args
 1.30 04-Apr-2007  pooka Make it possible to interrupt waiters for fs operation completion
again. This is useful until locking is further developed and basically
any deadlocks can be solved by killing appropriate processes.

Thanks especially to Tommi Kyntola and Antti Louko for sitting down
with me and discussing resource ownership and locking strategies
in implementing this.
 1.29 30-Mar-2007  pooka * abstract ASYNCBIOREAD and let callers freely issue a callback called
from putop. even though there's only one user currently, makes code
more readable
* move "delta" to a standard parameter in vntouser and get rid of the
specialcase vntouser_delta
 1.28 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.27 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.26 14-Mar-2007  pooka branches: 1.26.2;
Support B_READ|B_ASYNC in strategy by calling biodone() directly
when the file server puts the result.
 1.25 27-Feb-2007  pooka branches: 1.25.2; 1.25.4;
Make wait for the user file server PCATCHable. This makes it
possible to recover the system by just killing processes in case
a file server manages to recurse into itself either by fault of
file server implementation or by pilot error. The downside is that
the code is extremely hard to follow and practically screams out
for newlock2 (in addition to screaming "bug here"). The whole
PCATCH nonsense and induced megacomplexity can hopefully be avoided
in the future by tweaking other parts of the implementation.
 1.24 15-Feb-2007  pooka branches: 1.24.2;
Hide the debug prints behind PUFFSDEBUG instead of DEBUG. Make the
latter define the former.
 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 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.21 21-Jan-2007  pooka optimize a bit: don't flush pages for vnodes which have no references
in the kernel or links in the backend
 1.20 15-Jan-2007  pooka Store puffs_node's on lists hashed with the cookie value instead
of just one flat list.
 1.19 15-Jan-2007  pooka * do not accept the directory cookie as the result of a lookup (otherwise
we'd be locking against ourselves)
* do not accept duplicate cookies when creating new nodes
 1.18 09-Jan-2007  pooka Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.17 02-Jan-2007  pooka * check userspace version and prevent incompatible mount
* some general maintenance
 1.16 30-Dec-2006  pooka branches: 1.16.2;
* use PUFFS_KFLAG_NOCACHE to also signal that we don't want the namecache
* enter files into the namecache immediately when new nodes are created
(if it's a caching mount, of course)
 1.15 29-Dec-2006  pooka rename the kernel-provided componentname to puffs_kcn; libpuffs now
provides puffs_cn built on top of it
 1.14 10-Dec-2006  pooka Fix a race condition that would cause the mountpoint to be cleaned
from under someone waiting for the fs server response in puffs_unmount()
if the descriptor was closed during the response wait (such as bug
leading to a crash in fs implementation unmount()).
 1.13 05-Dec-2006  pooka branches: 1.13.2;
shuffle functions around a bit: move the transport (/dev/puffs) to
a different file from the messaging (request contents). no functional
change
 1.12 05-Dec-2006  pooka Allow multiple requests to be transferred in each GET/PUTOP. For
a single request, the performance is still the same.
 1.11 01-Dec-2006  pooka prefix kernel flags with PUFFS_KFLAG to have a separate namespace
from the library flags
 1.10 01-Dec-2006  pooka don't call the fs server for all operations, only those it has told
us that it implements
 1.9 18-Nov-2006  pooka branches: 1.9.2;
As a first generation best-effort hack, use NOCACHE to mean "file
size can change without the kernel knowing" and therefore query
the file size before invoking read or write operations.
 1.8 17-Nov-2006  pooka Introduce uncached operation, makes sense when the file system backend
can be modified from elsewhere than the file system interface
 1.7 09-Nov-2006  pooka few renames to better differentiate between mount & start.. plus some
other renaming
 1.6 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.5 06-Nov-2006  pooka puffs_park always contains a specific puffs_req, so make it a member
instead of a pointer
 1.4 06-Nov-2006  pooka make it possible to build & load puffs as an LKM

by Lubomir Kundrak, PR kern/35000
 1.3 27-Oct-2006  pooka support fifos
 1.2 26-Oct-2006  pooka support specfs
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.9.2.4 01-Feb-2007  ad Sync with head.
 1.9.2.3 12-Jan-2007  ad Sync with head.
 1.9.2.2 18-Nov-2006  ad Sync with head.
 1.9.2.1 18-Nov-2006  ad file puffs_sys.h was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.13.2.3 18-Dec-2006  yamt sync with head.
 1.13.2.2 10-Dec-2006  yamt sync with head.
 1.13.2.1 05-Dec-2006  yamt file puffs_sys.h was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.16.2.9 04-Feb-2008  yamt sync with head.
 1.16.2.8 21-Jan-2008  yamt sync with head
 1.16.2.7 07-Dec-2007  yamt sync with head
 1.16.2.6 15-Nov-2007  yamt sync with head.
 1.16.2.5 27-Oct-2007  yamt sync with head.
 1.16.2.4 03-Sep-2007  yamt sync with head.
 1.16.2.3 26-Feb-2007  yamt sync with head.
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 30-Dec-2006  yamt file puffs_sys.h was added on branch yamt-lazymbuf on 2006-12-30 20:50:01 +0000
 1.24.2.5 17-May-2007  yamt sync with head.
 1.24.2.4 07-May-2007  yamt sync with head.
 1.24.2.3 15-Apr-2007  yamt sync with head.
 1.24.2.2 24-Mar-2007  yamt sync with head.
 1.24.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.4.1 11-Jul-2007  mjf Sync with head.
 1.25.2.8 12-Oct-2007  ad Sync with head.
 1.25.2.7 09-Oct-2007  ad Sync with head.
 1.25.2.6 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.25.2.5 20-Aug-2007  ad Sync with HEAD.
 1.25.2.4 15-Jul-2007  ad Sync with head.
 1.25.2.3 09-Jun-2007  ad Sync with head.
 1.25.2.2 08-Jun-2007  ad Sync with head.
 1.25.2.1 10-Apr-2007  ad Sync with head.
 1.26.2.1 29-Mar-2007  reinoud Pullup to -current
 1.46.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.48.10.2 30-Jul-2007  pooka Move PUFFS_TYPEPREFIX to puffs_msgif.h since it's used in a macro there.
 1.48.10.1 30-Jul-2007  pooka file puffs_sys.h was added on branch matt-mips64 on 2007-07-30 09:04:59 +0000
 1.48.8.2 14-Oct-2007  yamt sync with head.
 1.48.8.1 06-Oct-2007  yamt sync with head.
 1.48.6.3 23-Mar-2008  matt sync with HEAD
 1.48.6.2 09-Jan-2008  matt sync with HEAD
 1.48.6.1 06-Nov-2007  matt sync with HEAD
 1.48.4.7 09-Dec-2007  jmcneill Sync with HEAD.
 1.48.4.6 21-Nov-2007  joerg Sync with HEAD.
 1.48.4.5 14-Nov-2007  joerg Sync with HEAD.
 1.48.4.4 11-Nov-2007  joerg Sync with HEAD.
 1.48.4.3 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.48.4.2 07-Oct-2007  joerg Sync with HEAD.
 1.48.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.59.4.4 18-Feb-2008  mjf Sync with HEAD.
 1.59.4.3 27-Dec-2007  mjf Sync with HEAD.
 1.59.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.59.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.59.2.3 21-Nov-2007  bouyer Sync with HEAD
 1.59.2.2 18-Nov-2007  bouyer Sync with HEAD
 1.59.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.65.2.3 26-Dec-2007  ad Sync with head.
 1.65.2.2 08-Dec-2007  ad Sync with head.
 1.65.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.67.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.67.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.70.28.1 21-Apr-2010  matt sync to netbsd-5
 1.70.20.3 17-Sep-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1666):
sys/fs/puffs/puffs_sys.h: revision 1.78 via patch
sys/fs/puffs/puffs_node.c: revision 1.20 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.155 via patch
Add a mutex for operations that touch size (setattr, getattr, write, fsync).
This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.
Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.
This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.70.20.2 18-Jun-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1623):
lib/libpuffs/puffs.c: revision 1.116
sys/fs/puffs/puffs_vnops.c: revision 1.151
Call advlock method if supplied
 1.70.20.1 09-Jan-2010  snj Pull up following revision(s) (requested by pooka in ticket #1212):
sys/fs/puffs/puffs_msgif.c: revision 1.76 via patch
sys/fs/puffs/puffs_sys.h: revision 1.73 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.84 via patch
Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.70.10.2 11-Aug-2010  yamt sync with head.
 1.70.10.1 11-Mar-2010  yamt sync with head
 1.75.4.1 05-Mar-2011  rmind sync with head
 1.75.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.78.8.4 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #1260):
lib/libpuffs/puffs.3: revision 1,55,1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Use more markup. New sentence, new line. Bump date for previous.

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.78.8.3 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1140):
lib/libperfuse/ops.c 1.63-1.69
lib/libperfuse/perfuse.c 1.32-1.33
lib/libperfuse/perfuse_priv.h 1.32-1.34
lib/libperfuse/subr.c 1.20
lib/libpuffs/creds.c 1.16
lib/libpuffs/dispatcher.c 1.47
lib/libpuffs/puffs.h 1.125
lib/libpuffs/puffs_ops.3 1.37-1.38
lib/libpuffs/requests.c 1.24
sys/fs/puffs/puffs_msgif.h 1.81
sys/fs/puffs/puffs_sys.h 1.85
sys/fs/puffs/puffs_vnops.c 1.183
usr.sbin/perfused/msg.c 1.22
Bring libpuffs, libperfuse and perfused on par with -current:
- implement FUSE direct I/O
- remove useless code and warnings
- fix missing GETATTR bugs
- fix exended attribute get and list operations
 1.78.8.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #438):
lib/libperfuse/perfuse_priv.h: revision 1.31
sys/fs/puffs/puffs_msgif.h: revision 1.80
sys/fs/puffs/puffs_vnops.c: revision 1.171
lib/libpuffs/puffs_ops.3: revision 1.31
sys/fs/puffs/puffs_vnops.c: revision 1.172
sys/fs/puffs/puffs_vnops.c: revision 1.173
sys/fs/puffs/puffs_vnops.c: revision 1.174
usr.sbin/perfused/perfused.c: revision 1.24
sys/fs/puffs/puffs_sys.h: revision 1.80
sys/fs/puffs/puffs_sys.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.82
lib/libperfuse/subr.c: revision 1.19
lib/libperfuse/perfuse.c: revision 1.30
sys/fs/puffs/puffs_msgif.c: revision 1.90
sys/fs/puffs/puffs_msgif.c: revision 1.91
sys/fs/puffs/puffs_msgif.c: revision 1.92
lib/libperfuse/ops.c: revision 1.59
lib/libpuffs/puffs.3: revision 1.53
lib/libperfuse/debug.c: revision 1.12
lib/libpuffs/puffs.3: revision 1.54
sys/fs/puffs/puffs_vnops.c: revision 1.167
sys/fs/puffs/puffs_msgif.h: revision 1.79
usr.sbin/perfused/msg.c: revision 1.21
sys/fs/puffs/puffs_vfsops.c: revision 1.102
sys/fs/puffs/puffs_vfsops.c: revision 1.103
sys/fs/puffs/puffs_vfsops.c: revision 1.105
lib/libpuffs/puffs.h: revision 1.123
lib/libperfuse/perfuse_if.h: revision 1.20
lib/libperfuse/perfuse.c: revision 1.29
lib/libpuffs/dispatcher.c: revision 1.42
lib/libpuffs/dispatcher.c: revision 1.43
- Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).
We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed
- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().
- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.
- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.
- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode
and size set. This confuses some FUSE filesystem. Therefore we send two FUSE
operations, one for mode, and one for size.
- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
- Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.
We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.
- Fix lookup/reclaim race condition.
The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.
We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
Fix hang unmount bug introduced by last commit.
We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
Bump date for previous.
New sentence, new line; remove trailing whitespace; fix typos;
punctuation nits.
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.
Enable the featuure for perfused, as this is how FUSE works.
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.78.8.1 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.78.6.1 29-Apr-2012  mrg sync to latest -current.
 1.78.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.78.2.2 30-Oct-2012  yamt sync with head
 1.78.2.1 17-Apr-2012  yamt sync with head
 1.82.2.3 03-Dec-2017  jdolecek update from HEAD
 1.82.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.82.2.1 23-Jun-2013  tls resync from head
 1.83.6.1 18-May-2014  rmind sync with head
 1.84.4.3 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #555):
lib/libpuffs/puffs.3: revision 1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.84.4.2 29-Aug-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_sys.h: revision 1.86
sys/fs/puffs/puffs_vfsops.c: revision 1.114
sys/fs/puffs/puffs_msgif.c: revision 1.95
sys/fs/puffs/puffs_node.c: revision 1.32
sys/fs/puffs/puffs_vnops.c: revision 1.184
Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.84.4.1 26-Aug-2014  riz Pull up following revision(s) (requested by manu in ticket #52):
sys/fs/puffs/puffs_msgif.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.85
sys/fs/puffs/puffs_vnops.c: revision 1.183
Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.88.2.2 09-Jul-2016  skrll Sync with HEAD
 1.88.2.1 06-Apr-2015  skrll Sync with HEAD
 1.90.18.1 10-Jun-2019  christos Sync with HEAD
 1.90.16.3 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.90.16.2 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.90.16.1 24-Mar-2018  pgoyette Add fs/puffs compat_50 to the modules
 1.28 10-Nov-2007  pooka Part 2/n of extensive changes to request transport to/from userspace:

Rip the transport code completely out of puffs and generalize it
into an independent module which will be used for multiple purposes
in the future. This module is called the Pass-to-Userspace
Transporter (known as "putter" among friends).

This is very much work-in-progress and one dependency with puffs
remains: the request framing format.

The device name is still /dev/puffs, but that will change soon.

Users of puffs need the following in their kernel configs now:
pseudo-device putter
 1.27 11-Oct-2007  pooka branches: 1.27.2; 1.27.4;
Handle suspend and flush requests from the file server.
 1.26 11-Oct-2007  pooka Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.25 04-Oct-2007  pooka g/c the "sizeop" code previous used for ioctl/fcntl. It was already
commented out and has bitrotted beyond all recognition, so it needs
complete rethinking.
 1.24 27-Sep-2007  pooka Differentiate between cookie2vnode returning an error and
return to caller, address unknown: no such cookie, no such node.
Make the callers use this info to either create a new vnode or bail.
 1.23 27-Sep-2007  pooka Fix a race in how new cookies are checked. Previously the checking
was done separate of inserting the cookie into the lookup structure
and without any form of interlock. This could lead to the same
cookie pointing to two different nodes. Remedy the race by creating
a separate "checked and ready to be inserted" cookie list which
serves as an interlock without having to hold a fs-global creation
lock.
 1.22 19-Jul-2007  pooka branches: 1.22.4; 1.22.6; 1.22.8; 1.22.10;
define PUFFSREQSIZEOP ioctl, which can be used to fetch the
maximum request size
 1.21 09-Jul-2007  ad branches: 1.21.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.20 21-Jun-2007  pooka Refactor the pnode2vnode translation slightly so that VFS_ROOT
can use it directly.
 1.19 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.18 17-May-2007  pooka Make it possible for the file server to specify the root vnode type
and other information instead of always using VDIR. To make this
possible without races, require all root node information already
in puffs_mount() and nuke puffs_start2() and the associated start
operation completely.

requested/inspired by Tobias Nygren
 1.17 01-May-2007  pooka Fix a problem introduced when I converted puffs to use newlock2:
when unmounting the file system in case of a certain timing (and
possibly some other conditions), a thread would wait on a condition
variable, while another thread broadcast the cv and immediately
proceeded to destroy it. The result was a system frozen completely
solid shorly after the process waiting for the cv woke up. So
introduce reference counting to synchronize destruction of the
resources in unmount.

I was able to repeat the problem only on my laptop in some special
cases, so I do not know how common it was. Ironically, killing
the file server process violently instead of unmount() didn't have
this problem because it never entered the unmount path from two
directions.
 1.16 16-Apr-2007  pooka fix comment in previous
 1.15 16-Apr-2007  pooka Allow to set non-blocking mode for transport fd even if the file
system is not yet mounted.
 1.14 06-Apr-2007  pooka support flushing pagecache
 1.13 06-Apr-2007  pooka actually, we don't need a separate op for flushing the whole page cache
of a node, just use the range op with endoff = 0
 1.12 06-Apr-2007  pooka * enable PUFFS_INVAL_PAGECACHE_NODE_RANGE
* add input parameter validation
 1.11 30-Mar-2007  pooka g/c some commented ltsleep calls accidentally left from newlock2 adaptation
 1.10 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.9 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.8 16-Feb-2007  hannken branches: 1.8.2; 1.8.6; 1.8.8; 1.8.10;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().
 1.7 09-Feb-2007  ad Merge newlock2 to head.
 1.6 28-Jan-2007  pooka don't need pi_lock for struct member access, so don't take it
 1.5 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.4 09-Jan-2007  pooka branches: 1.4.2;
Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.3 10-Dec-2006  pooka branches: 1.3.2;
* free puffs_instance structure in all cases when closing the descriptor
* comment, rcsid & kassert police
 1.2 10-Dec-2006  pooka Fix a race condition that would cause the mountpoint to be cleaned
from under someone waiting for the fs server response in puffs_unmount()
if the descriptor was closed during the response wait (such as bug
leading to a crash in fs implementation unmount()).
 1.1 05-Dec-2006  pooka branches: 1.1.2;
shuffle functions around a bit: move the transport (/dev/puffs) to
a different file from the messaging (request contents). no functional
change
 1.1.2.3 18-Dec-2006  yamt sync with head.
 1.1.2.2 10-Dec-2006  yamt sync with head.
 1.1.2.1 05-Dec-2006  yamt file puffs_transport.c was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.3.2.6 15-Nov-2007  yamt sync with head.
 1.3.2.5 27-Oct-2007  yamt sync with head.
 1.3.2.4 03-Sep-2007  yamt sync with head.
 1.3.2.3 26-Feb-2007  yamt sync with head.
 1.3.2.2 30-Dec-2006  yamt sync with head.
 1.3.2.1 10-Dec-2006  yamt file puffs_transport.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:01 +0000
 1.4.2.4 01-Feb-2007  ad Sync with head.
 1.4.2.3 18-Jan-2007  christos make things compile.
 1.4.2.2 12-Jan-2007  ad Sync with head.
 1.4.2.1 09-Jan-2007  ad file puffs_transport.c was added on branch newlock2 on 2007-01-12 01:04:05 +0000
 1.8.10.1 29-Mar-2007  reinoud Pullup to -current
 1.8.8.1 11-Jul-2007  mjf Sync with head.
 1.8.6.11 12-Oct-2007  ad Sync with head.
 1.8.6.10 09-Oct-2007  ad Sync with head.
 1.8.6.9 20-Aug-2007  ad Sync with HEAD.
 1.8.6.8 15-Jul-2007  ad Sync with head.
 1.8.6.7 09-Jun-2007  ad Sync with head.
 1.8.6.6 08-Jun-2007  ad Sync with head.
 1.8.6.5 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.8.6.4 10-Apr-2007  ad Sync with head.
 1.8.6.3 10-Apr-2007  ad Nuke the deferred kthread creation stuff, as it's no longer needed.
Pointed out by thorpej@.
 1.8.6.2 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.8.6.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.8.2.3 07-May-2007  yamt sync with head.
 1.8.2.2 15-Apr-2007  yamt sync with head.
 1.8.2.1 24-Mar-2007  yamt sync with head.
 1.21.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.22.10.2 19-Jul-2007  pooka define PUFFSREQSIZEOP ioctl, which can be used to fetch the
maximum request size
 1.22.10.1 19-Jul-2007  pooka file puffs_transport.c was added on branch matt-mips64 on 2007-07-19 07:52:46 +0000
 1.22.8.2 14-Oct-2007  yamt sync with head.
 1.22.8.1 06-Oct-2007  yamt sync with head.
 1.22.6.2 23-Mar-2008  matt sync with HEAD
 1.22.6.1 06-Nov-2007  matt sync with HEAD
 1.22.4.4 11-Nov-2007  joerg Sync with HEAD.
 1.22.4.3 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.2 07-Oct-2007  joerg Sync with HEAD.
 1.22.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.27.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.27.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.126 01-Apr-2021  christos Put a copy of our existing data first in the non-error case (noticed by RVP).
 1.125 27-Feb-2020  ad branches: 1.125.6; 1.125.8;
Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.
 1.124 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.123 27-Sep-2019  christos branches: 1.123.2;
Fix copying issue that was causing errors in unit_test puffs_tstavfs by
removing code.
 1.122 23-Sep-2019  christos Restore binary compatibility by using the statvfs90 structure internally.
 1.121 28-May-2018  chs branches: 1.121.2;
add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.120 01-Apr-2017  riastradh branches: 1.120.12;
KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.119 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.118 20-Dec-2015  christos branches: 1.118.2; 1.118.4;
PR/50573: Andreas Gustafsson: puffs can crash kernel for lack of argument
checking
 1.117 16-Feb-2015  martin Remove debug printf
 1.116 15-Feb-2015  manu Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.
 1.115 10-Nov-2014  maxv branches: 1.115.2;
Do not uselessly include <sys/malloc.h>.
 1.114 28-Aug-2014  hannken Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.113 25-May-2014  christos branches: 1.113.2;
use standard dirty vnode test.
 1.112 25-May-2014  hannken The pageflush_selector gets a vnode with v_interlock held.
Remove the mutex_enter()/mutex_exit() and simplify.

Hi christos...
 1.111 24-May-2014  christos Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.
 1.110 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.109 23-Mar-2014  hannken branches: 1.109.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.108 17-Mar-2014  hannken Change pageflush() to use vfs_vnode_iterator.
 1.107 16-Jan-2013  pooka branches: 1.107.2;
Do the protocol consistency check hack only when compiling ELF.
 1.106 09-Aug-2012  manu branches: 1.106.2;
Backout previous bugfix attempt for unmounts. That changes did not
address the real problem.
 1.105 27-Jul-2012  manu Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
 1.104 27-Jul-2012  manu puffs mounts share global pools. This means that the puffs_vfsops cannot
be vfs_detach'ed by module autounload before puffs_vfsop_unmount() completes
and has freed ressource from the pools. By holding a reference on
puffs_vfsops from each mount, we ensure that no race can occur here.

Works around the crash in kern/46734
 1.103 22-Jul-2012  manu Fix hang unmount bug introduced by last commit.

We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
 1.102 21-Jul-2012  manu - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.

The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
 1.101 08-Apr-2012  manu Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
 1.100 19-Oct-2011  manu branches: 1.100.2; 1.100.6; 1.100.8;
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.99 18-Oct-2011  manu Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
 1.98 07-Oct-2011  hannken As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.
 1.97 21-Sep-2011  manu Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.

This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
 1.96 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.95 21-Jul-2010  hannken branches: 1.95.6;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.94 15-Jul-2010  pooka f_namemax is one of the static fields overridden by copy_statvfs_info(),
so be sure to set it to the value coming from the file server as
part of mount args.

exposed, like so many other problems, by njoly's tests
 1.93 06-Jul-2010  pooka Add compat to enable running puffs in a 64bit time_t kernel against
a server which runs in 32bit time_t namespace.
 1.92 06-Jul-2010  pooka ctassert size of some key structures does not change
 1.91 06-Jul-2010  pooka Make sure that pa_spare is zero-filled and does not contain any
garbage which might disrupt future use.
 1.90 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.89 21-May-2010  pooka Since libpuffs needs a major bump for extattr support anyway, make
some changes to the user-kernel protocol. Namely, try to be a
little more resilient some future changes.
 1.88 21-May-2010  pooka Support extended attributes.
 1.87 17-Feb-2010  pooka branches: 1.87.2;
* add a rant about why MPSAFE isn't enabled even though puffs code is
* predict_false that we are mounting when calling statvfs
* KNF
 1.86 14-Jan-2010  pooka branches: 1.86.2;
In case the operations thread has exited, do not queue any more
operations. This prevents kernel memory leaks (one of which happened
every time the file system was unmounted via PUFFSOP_UNMOUNT ...
and incidentally would've been trivially caught with the old
malloc(9) interface. I wonder if the message is to use a ton of
pools instead of regression-attractive kmem interface).
 1.85 07-Jan-2010  pooka Rename PUFFS_SOPREQ_EXIT to PUFFS_SOPREQSYS_EXIT to better signal
it comes from within the kernel instead of as a direct result of
a user request.

no functional change
 1.84 07-Dec-2009  pooka Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.83 05-Nov-2009  pooka Kill suspend support. It was never implemented correctly:
* it depended on the biglock (in a very cruel way)
* it was attached to userspace transactions rather than logical
fs operations

(If someone wants to revisit it some day, most of the stuff can be
reused from cvs history)
 1.82 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.81 20-May-2008  jmcneill branches: 1.81.6; 1.81.8; 1.81.12; 1.81.16;
Add module dependency on putter.
 1.80 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.79 29-Apr-2008  ad branches: 1.79.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.78 28-Jan-2008  dholland branches: 1.78.6; 1.78.8; 1.78.10;
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.77 03-Jan-2008  pooka fix vmlocking2 fallout: fstrans_mount/unmount
 1.76 03-Jan-2008  pooka valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok
 1.75 02-Jan-2008  pooka More type-punning workarounds. Curiously the kernel compilation
flags cause gcc to not complain.
 1.74 02-Jan-2008  ad Merge vmlocking2 to head.
 1.73 30-Dec-2007  pooka namespace a bit: vfsops -> puffs_vfsop_x() and vops -> puffs_vnop_x()
 1.72 27-Nov-2007  pooka branches: 1.72.2; 1.72.6;
Remove "puffs_cid" from the puffs interface following l-removal
from the kernel vfs interfaces. puffs_cc_getcaller(pcc) can be
used now should the same information be desired.
 1.71 26-Nov-2007  pooka 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.70 20-Nov-2007  pooka Retire M_PUFFS, use kmem(9) instead.
 1.69 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.68 12-Nov-2007  pooka * split the putter header into a kernel version and a userland version
+ install latter to /usr/include/dev/putter
* remove last dependencies to puffs from putter, it's completely
independent now
 1.67 12-Nov-2007  pooka Move putter code from directly under dev/ to dev/putter/

no functional change
 1.66 10-Nov-2007  pooka Part 2/n of extensive changes to request transport to/from userspace:

Rip the transport code completely out of puffs and generalize it
into an independent module which will be used for multiple purposes
in the future. This module is called the Pass-to-Userspace
Transporter (known as "putter" among friends).

This is very much work-in-progress and one dependency with puffs
remains: the request framing format.

The device name is still /dev/puffs, but that will change soon.

Users of puffs need the following in their kernel configs now:
pseudo-device putter
 1.65 11-Oct-2007  pooka branches: 1.65.2; 1.65.4;
Handle suspend and flush requests from the file server.
 1.64 11-Oct-2007  pooka in case of version mismatch, print the numbers
 1.63 11-Oct-2007  pooka Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.62 11-Oct-2007  pooka Cache vnode member variables necessary for operations after the
userspace call, namely our private mount structure, in the activation
record. This avoids problems in situations where the userspace
file server happens to die during our upcall and the vnode is
forcibly reclaimed before we roll back to the current stack frame.
 1.61 09-Oct-2007  pooka g/c more unused stuff
 1.60 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.59 27-Sep-2007  pooka Differentiate between cookie2vnode returning an error and
return to caller, address unknown: no such cookie, no such node.
Make the callers use this info to either create a new vnode or bail.
 1.58 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.57 27-Sep-2007  pooka Fix a race in how new cookies are checked. Previously the checking
was done separate of inserting the cookie into the lookup structure
and without any form of interlock. This could lead to the same
cookie pointing to two different nodes. Remedy the race by creating
a separate "checked and ready to be inserted" cookie list which
serves as an interlock without having to hold a fs-global creation
lock.
 1.56 05-Sep-2007  pooka branches: 1.56.2;
move static KASSERT from mount to init
 1.55 04-Sep-2007  pooka * don't allow the file server to specify a node size to be VSIZENOTSET
* KASSERT that VNOVAL == VSIZENOTSET
 1.54 23-Aug-2007  pooka branches: 1.54.2;
Add a third type of fh option, passthrough, where the kernel does
not attempt to handle struct fid at all and passes it as such to
userspace.
 1.53 31-Jul-2007  pooka branches: 1.53.2; 1.53.4;
* 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.52 19-Jul-2007  pooka Make the minimum request size twice the minimum request structure size.
Otherwise ops with payload would have no room for payload.
 1.51 17-Jul-2007  pooka branches: 1.51.2;
Set a file server supplied file system type in the type field and set
the mntfromname to be the place mounted from instead of the type.
 1.50 17-Jul-2007  pooka 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.49 14-Jul-2007  dsl Remove the copyout() of the mount args from puffs_mount(), the buffer
supplied is a kernel address.
The puffs userspace code has been changed to do a 2nd call with
MNT_GETARGS to retrieve the information.
 1.48 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.47 09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.46 01-Jul-2007  pooka Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
 1.45 21-Jun-2007  pooka Refactor the pnode2vnode translation slightly so that VFS_ROOT
can use it directly.
 1.44 21-Jun-2007  pooka Reorganize how the root vnode is fetched so that it doesn't always
go through VFS_ROOT() and allow to fetch it without locking it.
This allows us to call the cache flush operations also for the root
vnode and most notably fixes e.g. a "No such file or directory"
for a psshfs root directory ls -l when a file was locally deleted
and remotely re-created.

Also fix some sloppy programming in root node fetch (mostly cosmetic).
 1.43 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.42 17-May-2007  pooka Make it possible for the file server to specify the root vnode type
and other information instead of always using VDIR. To make this
possible without races, require all root node information already
in puffs_mount() and nuke puffs_start2() and the associated start
operation completely.

requested/inspired by Tobias Nygren
 1.41 01-May-2007  pooka Fix a problem introduced when I converted puffs to use newlock2:
when unmounting the file system in case of a certain timing (and
possibly some other conditions), a thread would wait on a condition
variable, while another thread broadcast the cv and immediately
proceeded to destroy it. The result was a system frozen completely
solid shorly after the process waiting for the cv woke up. So
introduce reference counting to synchronize destruction of the
resources in unmount.

I was able to repeat the problem only on my laptop in some special
cases, so I do not know how common it was. Ironically, killing
the file server process violently instead of unmount() didn't have
this problem because it never entered the unmount path from two
directions.
 1.40 16-Apr-2007  pooka Sanity-check & possibly adjust number of hash buckets already before
returning the mount argument structure to userspace.
 1.39 16-Apr-2007  pooka catch invalid size file handles already in the kernel
 1.38 16-Apr-2007  pooka Give the file server the ability to specify the file handle length
instead of defining a static length file handle on the framework-level.
 1.37 14-Apr-2007  xtraeme size_t is unsigned, so use zu rather than zd which is for ssize_t,
as Matt Thomas pointed out.
 1.36 14-Apr-2007  xtraeme Use zd to printf size_t.
 1.35 13-Apr-2007  pooka Allow file servers to request the number of hash cookie buckets for
pnode -> vnode reverse lookup.
 1.34 13-Apr-2007  pooka * add fhlen to kernel argument structure
* rename it to puffs_kargs instead of puffs_args
 1.33 11-Apr-2007  pooka * support VFS_FHTOVP and VFS_VPTOFH
* support cookies in for VOP_READDIR

nfs exporting puffs file systems works now
 1.32 29-Mar-2007  pooka convert to MALLOC_JUSTDEFINE
 1.31 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.30 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.29 13-Mar-2007  ad branches: 1.29.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.28 16-Feb-2007  hannken branches: 1.28.2; 1.28.6; 1.28.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().
 1.27 29-Jan-2007  hannken Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>
 1.26 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.25 25-Jan-2007  pooka don't hold spinlocks (except vnode interlock) when doing vget()
 1.24 23-Jan-2007  pooka fix comment (no functional change)
 1.23 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.22 15-Jan-2007  pooka Store puffs_node's on lists hashed with the cookie value instead
of just one flat list.
 1.21 09-Jan-2007  pooka In vfs_sync(), call VOP_PUTPAGES() for dirty vnodes directly instead
of rolling around VOP_FSYNC(). The user server will be given the
VFS_SYNC instruction and it can do its own equivalent of VOP_FSYNC()
if it pleases, no need for the kernel to explicitly issue #{vnodes}
FSYNCs.
 1.20 09-Jan-2007  pooka Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.19 09-Jan-2007  pooka in vfs_sync flush page cache only for vnodes with dirty pages, not for
vnodes with pages (dirty or otherwise)
 1.18 07-Jan-2007  pooka vfs sync, flushes regular file data only (user server can take care of
flushing any metadata it might have hidden away)
 1.17 02-Jan-2007  pooka * check userspace version and prevent incompatible mount
* some general maintenance
 1.16 10-Dec-2006  pooka branches: 1.16.2;
Fix a race condition that would cause the mountpoint to be cleaned
from under someone waiting for the fs server response in puffs_unmount()
if the descriptor was closed during the response wait (such as bug
leading to a crash in fs implementation unmount()).
 1.15 09-Dec-2006  chs branches: 1.15.2;
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.14 07-Dec-2006  pooka In case of an error, return an error. Otherwise the worst case was
that dostatvfs() wrote to a recently deceased struct mount.
 1.13 01-Dec-2006  pooka branches: 1.13.2;
prefix kernel flags with PUFFS_KFLAG to have a separate namespace
from the library flags
 1.12 01-Dec-2006  pooka don't call the fs server for all operations, only those it has told
us that it implements
 1.11 18-Nov-2006  pooka branches: 1.11.2;
Always override f_iosize from stat() to DEV_BSIZE for now. Places such
as vnd use the information, so until "dealing with it" is defined, it's
overriden by the kernel.
 1.10 18-Nov-2006  pooka prevent value 0 for mnt_stat.f_iosize, it is sometimes used as a divider
 1.9 18-Nov-2006  pooka Require statvfs info from startreq so that we have that info available.
Also, don't pass fsid to userspace and just fill it in the kernel.
 1.8 17-Nov-2006  pooka Introduce uncached operation, makes sense when the file system backend
can be modified from elsewhere than the file system interface
 1.7 09-Nov-2006  pooka few renames to better differentiate between mount & start.. plus some
other renaming
 1.6 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.5 06-Nov-2006  pooka make it possible to build & load puffs as an LKM

by Lubomir Kundrak, PR kern/35000
 1.4 27-Oct-2006  pooka support fifos
 1.3 26-Oct-2006  pooka support specfs
 1.2 26-Oct-2006  pooka debug print fixes
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.11.2.4 01-Feb-2007  ad Sync with head.
 1.11.2.3 12-Jan-2007  ad Sync with head.
 1.11.2.2 18-Nov-2006  ad Sync with head.
 1.11.2.1 18-Nov-2006  ad file puffs_vfsops.c was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.13.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.15.2.3 18-Dec-2006  yamt sync with head.
 1.15.2.2 10-Dec-2006  yamt sync with head.
 1.15.2.1 09-Dec-2006  yamt file puffs_vfsops.c was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.16.2.9 04-Feb-2008  yamt sync with head.
 1.16.2.8 21-Jan-2008  yamt sync with head
 1.16.2.7 07-Dec-2007  yamt sync with head
 1.16.2.6 15-Nov-2007  yamt sync with head.
 1.16.2.5 27-Oct-2007  yamt sync with head.
 1.16.2.4 03-Sep-2007  yamt sync with head.
 1.16.2.3 26-Feb-2007  yamt sync with head.
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 10-Dec-2006  yamt file puffs_vfsops.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:01 +0000
 1.28.8.1 11-Jul-2007  mjf Sync with head.
 1.28.6.12 28-Oct-2007  ad Fix up mnt_vnodelist handling.
 1.28.6.11 12-Oct-2007  ad Sync with head.
 1.28.6.10 09-Oct-2007  ad Sync with head.
 1.28.6.9 20-Aug-2007  ad Sync with HEAD.
 1.28.6.8 15-Jul-2007  ad Sync with head.
 1.28.6.7 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.28.6.6 09-Jun-2007  ad Sync with head.
 1.28.6.5 08-Jun-2007  ad Sync with head.
 1.28.6.4 10-Apr-2007  ad Sync with head.
 1.28.6.3 05-Apr-2007  ad Compile fixes.
 1.28.6.2 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.28.6.1 13-Mar-2007  ad Sync with head.
 1.28.2.3 07-May-2007  yamt sync with head.
 1.28.2.2 15-Apr-2007  yamt sync with head.
 1.28.2.1 24-Mar-2007  yamt sync with head.
 1.29.2.1 29-Mar-2007  reinoud Pullup to -current
 1.51.2.3 10-Sep-2007  skrll Sync with HEAD.
 1.51.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.51.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.53.4.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.53.4.1 31-Jul-2007  pooka file puffs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.53.2.7 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.53.2.6 21-Nov-2007  joerg Sync with HEAD.
 1.53.2.5 14-Nov-2007  joerg Sync with HEAD.
 1.53.2.4 11-Nov-2007  joerg Sync with HEAD.
 1.53.2.3 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.53.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.53.2.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.54.2.3 23-Mar-2008  matt sync with HEAD
 1.54.2.2 09-Jan-2008  matt sync with HEAD
 1.54.2.1 06-Nov-2007  matt sync with HEAD
 1.56.2.2 14-Oct-2007  yamt sync with head.
 1.56.2.1 06-Oct-2007  yamt sync with head.
 1.65.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.65.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.65.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.65.2.3 21-Nov-2007  bouyer Sync with HEAD
 1.65.2.2 18-Nov-2007  bouyer Sync with HEAD
 1.65.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.72.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.72.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.72.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.78.10.4 11-Aug-2010  yamt sync with head.
 1.78.10.3 11-Mar-2010  yamt sync with head
 1.78.10.2 04-May-2009  yamt sync with head.
 1.78.10.1 16-May-2008  yamt sync with head.
 1.78.8.2 04-Jun-2008  yamt sync with head
 1.78.8.1 18-May-2008  yamt sync with head.
 1.78.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.79.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.81.16.1 21-Apr-2010  matt sync to netbsd-5
 1.81.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.81.8.4 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.81.8.3 02-Nov-2011  riz branches: 1.81.8.3.2;
Pull up following revision(s) (requested by manu in ticket #1679):
sys/fs/puffs/puffs_vnops.c: revision 1.157
sys/fs/puffs/puffs_vnops.c: revision 1.158
sys/fs/puffs/puffs_vnops.c: revision 1.159
sys/fs/puffs/puffs_vfsops.c: revision 1.97
sys/fs/puffs/puffs_vfsops.c: revision 1.99
sys/fs/puffs/puffs_vnops.c: revision 1.160
sys/fs/puffs/puffs_vfsops.c: revision 1.100
sys/miscfs/syncfs/sync_subr.c: revision 1.47
sys/fs/puffs/puffs_node.c: revision 1.21
sys/fs/puffs/puffs_node.c: revision 1.22
sys/fs/puffs/puffs_msgif.c: revision 1.88
sys/fs/puffs/puffs_msgif.c: revision 1.89
sys/fs/puffs/puffs_vnops.c: revision 1.156
Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.
This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
Fix the build that was broken by struct lwp *updateproc reference in
RUMP-visible code. Instead of checking that updateproc (aka ioflush,
aka syncer) will not sleep in PUFFS code, I check for any kernel thread:
after all none of them are designed to hang awaiting for a remote filesystem
operation to complete.
Roll back the change that forced kernel threads to not sleep in PUFFS.
The change does not make consensus, since only pagedaemon should need it.
Other threads will tolerate sleeping, and problems here are only symptoms
that something is going wrong in memory management. The cause, not the
symptoms, need to be fixed.
Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.81.8.2 17-Jul-2011  riz Pull up following revision(s) (requested by manu in ticket #1645):
lib/libc/sys/Makefile.inc 1.207 via patch
lib/libc/sys/extattr_get_file.2 patch
lib/libpuffs/dispatcher.c 1.34,1.36 via patch
lib/libpuffs/puffs.c 1.107 via patch
lib/libpuffs/puffs.h 1.115,1.118 via patch
sys/fs/puffs/puffs_msgif.h 1.71,1.76 via patch
sys/fs/puffs/puffs_vfsops.c 1.88 via patch
sys/fs/puffs/puffs_vnops.c 1.145,1.154 via patch
sys/kern/vfs_xattr.c 1.24-1.27 via patch
sys/kern/vnode_if.c 1.87 via patch
sys/sys/Makefile 1.133 via patch
sys/sys/extattr.h 1.6 via patch
sys/sys/vnode_if.h 1.81 via patch
sys/ufs/ffs/ffs_vnops.c patch
sys/ufs/ufs/ufs_extattr.c 1.31,1.34 via patch

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness
Support extended attributes.
Fix multiple non compliances in our Linux-like extattr API, and make it
public so that it can be used.
Improve a bit listxattr(2). It attemps to list both system and user
extended attributes, and it faled if calling user did not have privilege
for reading system EA. Now we just lise user EA and skip system EA in
reading them is not allowed.
Fix bug introduced in previous commuit: Do not vrele() a vnode we did not
obtained.
Improve UFS1 extended attributes usability
- autocreate attribute backing file for new attributes
- autoload attributes when issuing extattrctl start
- when autoloading attributes, do not display garbage warning when looking
up entries that got ENOENT
Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.
There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)
This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
 1.81.8.1 09-Jan-2010  snj branches: 1.81.8.1.2;
Pull up following revision(s) (requested by pooka in ticket #1212):
sys/fs/puffs/puffs_msgif.c: revision 1.76 via patch
sys/fs/puffs/puffs_sys.h: revision 1.73 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.84 via patch
Process flush requests from the file server in a separate thread
context. This fixes a long-standing but seldomly seen deadlock,
where the kernel was holding pages busy (due to e.g. readahead
request) while waiting for the server to respond, and the server
made a callback into the kernel asking to invalidate those pages.
... or, well, theoretically fixes, since I didn't have any reliable
way of repeating the deadlock and I think I saw it only twice.
 1.81.8.3.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.81.8.1.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.81.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.86.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.86.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.87.2.4 05-Mar-2011  rmind sync with head
 1.87.2.3 03-Jul-2010  rmind sync with head
 1.87.2.2 30-May-2010  rmind sync with head
 1.87.2.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.95.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.100.8.4 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #1260):
lib/libpuffs/puffs.3: revision 1,55,1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Use more markup. New sentence, new line. Bump date for previous.

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.100.8.3 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.100.8.2 12-Aug-2012  martin branches: 1.100.8.2.4; 1.100.8.2.6;
Pull up following revision(s) (requested by manu in ticket #438):
lib/libperfuse/perfuse_priv.h: revision 1.31
sys/fs/puffs/puffs_msgif.h: revision 1.80
sys/fs/puffs/puffs_vnops.c: revision 1.171
lib/libpuffs/puffs_ops.3: revision 1.31
sys/fs/puffs/puffs_vnops.c: revision 1.172
sys/fs/puffs/puffs_vnops.c: revision 1.173
sys/fs/puffs/puffs_vnops.c: revision 1.174
usr.sbin/perfused/perfused.c: revision 1.24
sys/fs/puffs/puffs_sys.h: revision 1.80
sys/fs/puffs/puffs_sys.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.82
lib/libperfuse/subr.c: revision 1.19
lib/libperfuse/perfuse.c: revision 1.30
sys/fs/puffs/puffs_msgif.c: revision 1.90
sys/fs/puffs/puffs_msgif.c: revision 1.91
sys/fs/puffs/puffs_msgif.c: revision 1.92
lib/libperfuse/ops.c: revision 1.59
lib/libpuffs/puffs.3: revision 1.53
lib/libperfuse/debug.c: revision 1.12
lib/libpuffs/puffs.3: revision 1.54
sys/fs/puffs/puffs_vnops.c: revision 1.167
sys/fs/puffs/puffs_msgif.h: revision 1.79
usr.sbin/perfused/msg.c: revision 1.21
sys/fs/puffs/puffs_vfsops.c: revision 1.102
sys/fs/puffs/puffs_vfsops.c: revision 1.103
sys/fs/puffs/puffs_vfsops.c: revision 1.105
lib/libpuffs/puffs.h: revision 1.123
lib/libperfuse/perfuse_if.h: revision 1.20
lib/libperfuse/perfuse.c: revision 1.29
lib/libpuffs/dispatcher.c: revision 1.42
lib/libpuffs/dispatcher.c: revision 1.43
- Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).
We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed
- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().
- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.
- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.
- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode
and size set. This confuses some FUSE filesystem. Therefore we send two FUSE
operations, one for mode, and one for size.
- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
- Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.
We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.
- Fix lookup/reclaim race condition.
The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.
We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
Fix hang unmount bug introduced by last commit.
We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
Bump date for previous.
New sentence, new line; remove trailing whitespace; fix typos;
punctuation nits.
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.
Enable the featuure for perfused, as this is how FUSE works.
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.100.8.1 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.100.8.2.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.100.8.2.4.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.100.6.1 29-Apr-2012  mrg sync to latest -current.
 1.100.2.4 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.100.2.3 23-Jan-2013  yamt sync with head
 1.100.2.2 30-Oct-2012  yamt sync with head
 1.100.2.1 17-Apr-2012  yamt sync with head
 1.106.2.3 03-Dec-2017  jdolecek update from HEAD
 1.106.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.106.2.1 25-Feb-2013  tls resync with head
 1.107.2.1 18-May-2014  rmind sync with head
 1.109.2.1 10-Aug-2014  tls Rebase.
 1.113.2.4 15-Mar-2015  snj Pull up following revision(s) (requested by tron in ticket #587):
sys/fs/puffs/puffs_vfsops.c: revision 1.117
Remove debug printf
 1.113.2.3 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #555):
lib/libpuffs/puffs.3: revision 1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.113.2.2 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.113.2.1 29-Aug-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_sys.h: revision 1.86
sys/fs/puffs/puffs_vfsops.c: revision 1.114
sys/fs/puffs/puffs_msgif.c: revision 1.95
sys/fs/puffs/puffs_node.c: revision 1.32
sys/fs/puffs/puffs_vnops.c: revision 1.184
Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.115.2.3 28-Aug-2017  skrll Sync with HEAD
 1.115.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.115.2.1 06-Apr-2015  skrll Sync with HEAD
 1.118.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.118.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.118.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.120.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.121.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.121.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.123.2.2 29-Feb-2020  ad Sync with head.
 1.123.2.1 17-Jan-2020  ad Sync with head.
 1.125.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.125.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.226 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.225 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.224 05-Dec-2021  msaitoh s/invlid/invalid/ in comment.
 1.223 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.222 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.221 19-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 2; cvs randomly didn't commit these changes before, and then hid
them from me until I touched the files to force it to rethink. Dunno
what happened.

There's probably more of these, going to have to scan the tree the
hard way.
 1.220 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.219 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.218 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.217 16-May-2020  christos branches: 1.217.6;
Add ACL support for FFS. From FreeBSD.
 1.216 15-May-2020  maxv hardclock_ticks -> getticks()
 1.215 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.214 23-Feb-2020  ad branches: 1.214.4;
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.213 06-Nov-2018  manu branches: 1.213.6;
Fix use after RECLAIM in PUFFS filesystems

From hannken@

When puffs_cookie2vnode() misses an entry and vrele() it operations
puffs_vnop_reclaim() and puffs_vnop_fsync() get called with a VNON
vnode.

Do not notify the server in this case as the cookie is stale.
 1.212 05-Nov-2018  manu Add missing mutex pn->pn_sizemtx lock in puffs_vnop_open()

puffs_vnop_open() calls flushvncache(), which calls dosetattr()
if pn->pn_stat has PNODE_METACACHE_MASK. In that case, the lock
on pn->pn_sizemtx is mandatory and asserted.
 1.211 26-May-2017  riastradh branches: 1.211.2; 1.211.8; 1.211.10;
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.210 26-Apr-2017  riastradh 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.209 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.208 08-Apr-2017  hannken Update mtime when updating file size.

PR kern/51762 (mtime not updated by open(O_TRUNC))
 1.207 06-Apr-2017  christos use ubc_zerorange
 1.206 04-Apr-2017  christos use MAX_PAGE_SIZE.
 1.205 21-Jul-2016  christos branches: 1.205.2;
replace variable stack declaration with a large enough one and KASSERT.
 1.204 07-Jul-2016  msaitoh branches: 1.204.2;
KNF. Remove extra spaces. No functional change.
 1.203 20-Apr-2015  riastradh Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.202 25-Feb-2015  christos make this compile again.
 1.201 25-Feb-2015  manu Update file size after write without metadata flush

If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.200 15-Feb-2015  manu Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.
 1.199 13-Jan-2015  manu Make sure reads on empty files reach PUFFS filesystems

Sending a read through the page cache will get the operation
short-circuited. This is a problem with some filesystems that
expect to receive the read operation in order to update atime.

We fix that by bypassing the page cache when reading a file
wich a size known to be zero.
 1.198 04-Nov-2014  manu branches: 1.198.2;
PUFFS direct I/O cache fix

There are a few situations where we must take care of the cache if direct
I/O was enabled:
- if we do direct I/O for write but not for read, then any write must
invalidate the cache so that a reader gets the written data and not
the not-updated cache.
- if we used a vnode without direct I/O and it is enabled for writing,
we must flush the cache before compeling the open operation, so that
the cachec write are not lost.

And at inactive time, we wipe direct I/O flags so that a new open without
direct I/O does not inherit direct I/O.
 1.197 04-Nov-2014  manu Fix PUFFS node use-after-reclaim

When puffs_cookie2vnode() misses an entry, vcache_get()
creates a new node (puffs_vfsop_loadvnode being called to
initialize the PUFFS part), then it discovers it is VNON,
and tries to vrele() it. vrele() calls VOP_INACTIVE(),
which led us in puffs_vnop_inactive() where we sent a
request to the filesystem for a node that already had been
reclaimed.

The fix is to check for VNON nodes in puffs_vnop_inactive()
and to return without doing anyting. This is suboptimal, but
a better workaround would probably need to modify vcache API,
with an impact on other filesystems. Let us keep it simple.
 1.196 31-Oct-2014  manu Add PUFFS support for fallocate and fdiscard operations
 1.195 31-Oct-2014  manu According to pooka@'s comment, a long time ago, VOP_STRATEGY could not
fail without taking down the kernel. It seems this is not the case anymore,
hence we can stop dropping errors in puffs_vnop_strategy()

Approved by pooka@
 1.194 07-Oct-2014  he Do the previous correctly...
 1.193 07-Oct-2014  he As is evidenced by several of our 32-bit MIPS ports, it's wrong to
print vsize_t with PRIx64 -- instead use our own PRIxVSIZE macro.
 1.192 06-Oct-2014  he Make this build again without debugging enabled; DPRINTF() can end up
as empty, and in an if conditional, you then need braces if that's the
only potential body.
 1.191 06-Oct-2014  manu Retore LP64 fix that was removed by mistake
 1.190 06-Oct-2014  manu Improve zero-fill of last page after shrink fix:
1) do it only if the file is open for writing, otherwise we send write
requests to the FS on a file that has never been open.
2) do it inside existing if (vap->va_size != VNOVAL) block
 1.189 05-Oct-2014  justin Use PRIx64 for printing offsets
 1.188 05-Oct-2014  manu If we truncate the file, make sure we zero-fill the end of the last
page, otherwise if the file is later truncated to a larger size
(creating a hole), that area will not return zeroes as it should.
 1.187 30-Sep-2014  hannken Fix the puffs_sop_thread -> puffs_cookie2vnode path:
- pass the cookie by reference
- add missing mutex_exit()
- update assertion for VNON typed vnodes
 1.186 11-Sep-2014  manu PUFFS fixes for size update ater write plus read/write sanity checks

- Always update kernel metadata cache for size when writing
This fixes situation where size update after appending to a file lagged
- Make read/write nilpotent when called with null size, as FFS does
- Return EFBIG instead of EINVAL for negative offsets, as FFS does
 1.185 05-Sep-2014  manu When changing a directory content, update the ctime/mtime in kernel cache,
otherwise the updated ctime/mtime appears after the cached entry expire.
 1.184 28-Aug-2014  hannken Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.183 16-Aug-2014  manu Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.182 25-Jul-2014  dholland branches: 1.182.2;
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.181 24-Mar-2014  hannken branches: 1.181.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.180 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.179 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.178 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.177 17-Oct-2013  christos - remove unused variables
- add _NOERROR flavor macros for the case where errors are ignored.
 1.176 05-Nov-2012  dholland branches: 1.176.2;
Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.175 05-Nov-2012  dholland 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.174 10-Aug-2012  manu branches: 1.174.2;
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.

Enable the featuure for perfused, as this is how FUSE works.
 1.173 10-Aug-2012  manu Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
 1.172 10-Aug-2012  manu Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
 1.171 27-Jul-2012  manu Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
 1.170 23-Jul-2012  manu Backout NCHNAMLEN check for cache_enter. That change collided with rmind's
move of this exact check into cache_enter
 1.169 23-Jul-2012  manu Di not call cache_enter with path components bigger than NCHNAMLEN, as it
panics the kernel.
 1.168 22-Jul-2012  rmind Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.167 21-Jul-2012  manu - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.

The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
 1.166 18-Apr-2012  manu - Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
 1.165 08-Apr-2012  manu Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
 1.164 16-Mar-2012  jakllsch Prevent access beyond end of PUFFS file on read,
similar to as is done for NFS.
 1.163 17-Jan-2012  martin branches: 1.163.2;
Add a few KASSERT() - I have a crash that likely will cause one of them to
fire...
 1.162 18-Nov-2011  christos branches: 1.162.4;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.161 30-Oct-2011  hannken branches: 1.161.2;
Add a comment that pn_sizemtx should be useless as VOP_GETATTR now
needs a shared lock at least.
 1.160 19-Oct-2011  manu Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.159 18-Oct-2011  manu Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
 1.158 17-Oct-2011  manu Roll back the change that forced kernel threads to not sleep in PUFFS.
The change does not make consensus, since only pagedaemon should need it.
Other threads will tolerate sleeping, and problems here are only symptoms
that something is going wrong in memory management. The cause, not the
symptoms, need to be fixed.
 1.157 23-Sep-2011  manu Fix the build that was broken by struct lwp *updateproc reference in
RUMP-visible code. Instead of checking that updateproc (aka ioflush,
aka syncer) will not sleep in PUFFS code, I check for any kernel thread:
after all none of them are designed to hang awaiting for a remote filesystem
operation to complete.
 1.156 21-Sep-2011  manu Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.

This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
 1.155 29-Aug-2011  manu Add a mutex for operations that touch size (setattr, getattr, write, fsync).

This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.

Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.

This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.154 04-Jul-2011  manu Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.

There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)

This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
 1.153 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.152 19-May-2011  rmind branches: 1.152.2;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.151 03-May-2011  manu Call advlock method if supplied
 1.150 11-Jan-2011  kefren branches: 1.150.2;
add advlock to puffs. ok pooka@
should fix kern/43321
 1.149 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.148 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.147 14-Jul-2010  pooka RENAME lookup semantics say return EISDIR if dvp = *vpp for the
last component .... obviously(!!)
 1.146 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.145 21-May-2010  pooka Support extended attributes.
 1.144 29-Mar-2010  pooka Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.143 27-Mar-2010  pooka \n, police!
 1.142 14-Jan-2010  pooka branches: 1.142.2; 1.142.4;
Since VOP_GETATTR() does not require a locked vnode, resolve and
reference the puffs_node before sending the request to the file
server. This diminishes the window where the inode can be reclaimed
and be invalidated before it is accessed (but does not completely
eliminate the race, as that is a caller problem which we cannot
fix here).
 1.141 04-Dec-2009  pooka Push all information cached in the vnode to the file server before
issuing INACTIVE. PR kern/42194.
Also, send setattr in fsync asynchronously if FSYNC_WAIT is not set.
 1.140 19-Nov-2009  pooka Send VOP_ABORTOP() in case attempting cross-dev rename, part of
PR kern/42210. Also, fix a memory management error in said case.
 1.139 19-Nov-2009  pooka Send VOP_ABORTOP() as a FAF -- we don't care about the return value.
 1.138 05-Nov-2009  pooka Kill suspend support. It was never implemented correctly:
* it depended on the biglock (in a very cruel way)
* it was attached to userspace transactions rather than logical
fs operations

(If someone wants to revisit it some day, most of the stuff can be
reused from cvs history)
 1.137 05-Nov-2009  pooka Reinstante PNODE_DYING. vmlocking had a brief hiatus when it was not
a valid optimization, but that's long gone and once VOP_INACTIVE is
called and the file server says that the vnode is going to be recycled,
it really is going to be recycled extra references gained or not.
 1.136 17-Oct-2009  pooka Transmit VOP_ABORTOP() to the server.
 1.135 30-Sep-2009  pooka remove leading whitespace. no functional change.
 1.134 30-Sep-2009  pooka * fix a race i introduced almost two years ago in rev 1.116:
operations creating a node cannot be considered outgoing operations,
since after return from userspace they modify file system state
by creating a new node. if we do not protect the file system by
holding the directory lock, a lookup operation might race us into
the kernel and create the node earlier.
* remove pnode from hashlish before sending the reclaim faf off to
userspace. also, hold pmp_lock while frobbing the list.
 1.133 19-Sep-2009  pooka Set SAVENAME for rmdir and remove.

Addresses an easy part of PR kern/38188
 1.132 12-Sep-2009  tsutsui Fix typo:
- pcinfo = kmem_zalloc(sizeof_puffs_cacheinfo) + runsize,
+ pcinfo = kmem_zalloc(sizeof(struct puffs_cacheinfo) + runsize,
in #ifdef'ed out code, per paired kmem_free() in the same function.
Closes PR kern/41840.
 1.131 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.130 16-Nov-2008  pooka more <sys/buf.h> police
 1.129 10-Sep-2008  christos branches: 1.129.2; 1.129.4; 1.129.8;
replace 0xa0 with space from Andy Shevchenko
 1.128 30-Jan-2008  ad branches: 1.128.6; 1.128.10; 1.128.12; 1.128.16;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.127 28-Jan-2008  pooka For code clarity typedef void *puffs_cookie_t.

No functional change.
 1.126 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.125 02-Jan-2008  pooka More type-punning workarounds. Curiously the kernel compilation
flags cause gcc to not complain.
 1.124 02-Jan-2008  ad Merge vmlocking2 to head.
 1.123 30-Dec-2007  pooka namespace a bit: vfsops -> puffs_vfsop_x() and vops -> puffs_vnop_x()
 1.122 08-Dec-2007  pooka branches: 1.122.4;
Now that "l" is gone both as an argument to operations and from
componentname, remove all vestiges of puffs_cid.
 1.121 27-Nov-2007  pooka branches: 1.121.2;
Remove "puffs_cid" from the puffs interface following l-removal
from the kernel vfs interfaces. puffs_cc_getcaller(pcc) can be
used now should the same information be desired.
 1.120 26-Nov-2007  pooka 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.119 21-Nov-2007  pooka use BUF_ISREAD/WRITE instead of homegrown variants
 1.118 20-Nov-2007  pooka Retire M_PUFFS, use kmem(9) instead.
 1.117 17-Nov-2007  pooka Make puffs_updatenode() take a puffs_node instead of a vnode. This
way we don't need to worry if a vnode has been reclaimed from under
us.
 1.116 17-Nov-2007  pooka Start playing around with vnode locks. For now, do the very easy
thing and release locks before the userspace wait for operations
which release the lock before exit from the method in any case.
However, releasing the lock after inserting the request on the
operation queue gives us proper ordering possibilities in userspace
(at least if that bit were implemented, but I don't think there
any file system in userspace that depends on kernel locking and
probably there never should be one).

inspired by a conversation with Nacho Navarro
 1.115 17-Nov-2007  pooka Implement a biodone callback for async writes similar to reads and
use that when possible.
 1.114 16-Nov-2007  pooka Restructure the messaging interface a bit more: make all interfacing
with the file server happen through puffs_msg_enqueue() and
puffs_msg_wait() instead of having a billion different routines.
Build the existing system upon these two. Most importantly though,
decouple insertation into the op queue from the actual wait. This
is useful for a number of reasons coming soon to a cvs repo near you.
 1.113 26-Oct-2007  pooka branches: 1.113.2;
Read/write can reuse message memory if operating uncached. This
will change evetually, but for now just appease a KASSERT by
resetting the message header to 0 after each loop.
 1.112 23-Oct-2007  pooka The kernel (genfs, uvm) can't deal with strategy returning an error
when vclean()ing. Pending an adventure to the genfs/vm labyrinth
to fix this properly, compensate here by not allowing unstrategic
(no pun) return values. They are always due to the userspace server
crashing anyway, so it's no big deal if we lie about the final
resting place of the pages.
 1.111 21-Oct-2007  pooka * release pathname buffer in link
* some variable massage
 1.110 19-Oct-2007  pooka When doing a read operation, don't copy the whole kernel buffer to
userspace, since it doesn't contain any information yet. I should
still rework this more so this is just a quickie to get the read/write
style interface more up to speed with the ioctl version.
 1.109 19-Oct-2007  pooka comment polish
 1.108 18-Oct-2007  pooka Fix wrong argument order which just happened to work by luck.
 1.107 11-Oct-2007  pooka branches: 1.107.2;
Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

* since the kernel-user communication is not purely request-response
anymore (hasn't been since 2006), try to rename some "request" to
"message". more similar mangling will take place in the future.

* completely rework how messages are allocated. previously most of
them were borrowed from the stack (originally *all* of them),
but now always allocate dynamically. this makes the structure
of the code much cleaner. also makes it possible to fix a
locking order violation. it enables plenty of future enhancements.

* start generalizing the transport interface to be independent of puffs

* move transport interface to read/write instead of ioctl. the
old one had legacy design problems, and besides, ioctl's suck.
implement a very generic version for now; this will be
worked on later hopefully some day reaching "highly optimized".

* implement libpuffs support behind existing library request
interfaces. this will change eventually (I hate those interfaces)
 1.106 11-Oct-2007  pooka Cache vnode member variables necessary for operations after the
userspace call, namely our private mount structure, in the activation
record. This avoids problems in situations where the userspace
file server happens to die during our upcall and the vnode is
forcibly reclaimed before we roll back to the current stack frame.
 1.105 10-Oct-2007  ad 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.104 04-Oct-2007  pooka g/c the "sizeop" code previous used for ioctl/fcntl. It was already
commented out and has bitrotted beyond all recognition, so it needs
complete rethinking.
 1.103 02-Oct-2007  pooka If kernel resource allocation fails after the file server has
committed something, issue an abort. The abort is done through
the regular op channel, e.g. failed mkdir leads to regular rmdir,
inactive and reclaim. No internal interface is planned currently
for the one file system out of a million which would implement it
to benefit from the one case in a billion where kernel resource
allocation actually does fail and out of that one case in a trillion
where internal vs. external would make a difference.
 1.102 01-Oct-2007  pooka * better error checking: validate error values received from userland
to be vaild errno values
* include string describing error in PUFFS_ERR
* get rid of union in puffs_req, it's nothing but trouble
* pass pmp to async i/o callbacks
 1.101 27-Sep-2007  pooka Differentiate between cookie2vnode returning an error and
return to caller, address unknown: no such cookie, no such node.
Make the callers use this info to either create a new vnode or bail.
 1.100 27-Sep-2007  pooka Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET. The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
 1.99 27-Sep-2007  pooka Fix a race in how new cookies are checked. Previously the checking
was done separate of inserting the cookie into the lookup structure
and without any form of interlock. This could lead to the same
cookie pointing to two different nodes. Remedy the race by creating
a separate "checked and ready to be inserted" cookie list which
serves as an interlock without having to hold a fs-global creation
lock.
 1.98 22-Aug-2007  pooka branches: 1.98.2; 1.98.4;
Mimic namei structure changes for puffs. bump both kernel & lib version.
 1.97 13-Aug-2007  pooka * don't call VOP_ACCESS in lookup, that's the file system's problem
* be more careful with r/o fs to catch EEXIST in lookup CREATE
* some comment polish
 1.96 12-Aug-2007  pooka enforce MNT_RDONLY
 1.95 30-Jul-2007  pooka branches: 1.95.4; 1.95.6;
properly setup ubcflags
 1.94 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.93 27-Jul-2007  yamt ubc_uiomove: add an "advice" argument rather than using UVM_ADV_RANDOM blindly.
 1.92 27-Jul-2007  pooka Change unused fflags parameter in VOP_MMAP to prot and pass in
desired vm protection.
 1.91 22-Jul-2007  pooka use NULL, not 0, to pass a pointer
 1.90 22-Jul-2007  pooka Keep track of the maximum size we have supplied the file server (or
it has supplied us). If we fault pages which are at offset >= server
size, but less than the in-kernel vnode size, inform the file server
of the latest developments in file size before issueing the fault.
The avoids confusion with files which are not written start to finish.

fixes kern/36429 by yamt
 1.89 19-Jul-2007  pooka don't request more than the maximum request size in readdir
 1.88 09-Jul-2007  ad branches: 1.88.2;
s/pagedaemon_lwp/pagedaemon_proc/
 1.87 09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.86 02-Jul-2007  pooka support turning REQUIREDIR off and extra consume in lookup
 1.85 02-Jul-2007  pooka Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.
 1.84 01-Jul-2007  pooka loosen KASSERT: we can also fail due to ENOMEM
 1.83 01-Jul-2007  pooka Give the file server to ability to request the entire pathname buffer
under lookup by using PUFFS_KFLAG_LOOKUP_FULLPNBUF instead just the
current component.
 1.82 01-Jul-2007  pooka Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
 1.81 01-Jul-2007  pooka make puffs_cred an opaque type
 1.80 30-Jun-2007  pooka Fix logic flaw in KASSERT. Seems like my lkm wasn't compiled with
DIAGNOSTIC ...
 1.79 26-Jun-2007  pooka Simplify code, mainly vop_strategy. No functional change
 1.78 24-Jun-2007  pooka Split the NOCACHE option in twain: NOCACHE_NAME & NOCACHE_PAGE.
 1.77 21-Jun-2007  pooka Refactor the pnode2vnode translation slightly so that VFS_ROOT
can use it directly.
 1.76 06-Jun-2007  pooka Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
 1.75 06-Jun-2007  pooka In very verbose debug mode, print also return values for operations
(well, at least for those that go through checkop()).
 1.74 05-Jun-2007  yamt improve post-ubc file overwrite performance in common cases.
ie. when it's safe, actually overwrite blocks rather than doing
read-modify-write.

also fixes PR/33152 and PR/36303.
 1.73 01-Jun-2007  yamt \xa0 -> space.
 1.72 19-May-2007  pooka Actually, we do need separate "no references in file server" and
"noref + inactive" flags if we wish to correctly support unix open
file semantics and optimize away pre-reclaim cache flushes. So,
add PNODE_DYING which stands for norefs + inactive.
 1.71 18-May-2007  pooka Introduce noref setbacks, which the file server can use to signal
the kernel it has 0 references to the node in question. In other
words, this can be used to avoid inactive(), or, if the file server
does not implement inactive, prompt reclaim for removed nodes.
 1.70 18-May-2007  pooka selrecord() before calling userspace to avoid (very theoretical) race
where selinfo contains uninitialized garbage
 1.69 18-May-2007  pooka Support VOP_POLL. This requires some acrobatics on the puffs_node,
as we give a reference to userspace for the puffs_node for the
duration of the poll call. So reference count puffs_node separately
from the parent vnode. vref()/vrele() is not possible due to a possible
surprise visit from VOP_INACTIVE.
 1.68 15-May-2007  pooka In case strategy memory allocation for B_ASYNC|B_READ fails,
make sure to release the buf.
 1.67 08-May-2007  pooka Adventures in file systems, part (u_quad_t)-1: we can't use the
file system value for the size of device special files, as that
comes from specfs instead of the "host" file system. Therefore,
take care that getattr doesn't override the value of vp->v_size.
 1.66 07-May-2007  pooka Introduce puffs "setbacks", which can be used to set certain flags
for nodes upon return from the userspace. Currently it can be used
to indicate that the file server should be notified of "inactive"
in case the file server has opted to not receive inactive every
time the reference count for a vnode drops to zero. (inactive is
a common event, almost never requires any action and must be executed
sychronously, so it is wasteful).

While doing this, cleanup the release-relock nonsense from the
vntouser*() arguments. It was never enabled and the whole LOCKEDVP()
concept was very broken to begin with.
 1.65 06-May-2007  pooka If setattr is called explicitly, use that as the sign to flush out
all metadata info cached in the kernel while we're setattr'ing in
any case. Solves problems such as truncate (via extend-by-write)
+ chmod resulting in EPERM because the file was already read-only
when the actual truncate was flushed out of the kernel in fsync.
 1.64 24-Apr-2007  pooka If ubc style write fails, do not extend the file by zero-padding
it. It might be that the file server is either crashing or just
returning consistent errors. uiomove() would handle the error,
but if the pages weren't faulted in, memset() to the unfaultable
ubc window would cause a kernel page fault.
 1.63 22-Apr-2007  pooka Issue close to the file server asynchronously. We're not interested
in the return value.
 1.62 22-Apr-2007  pooka define PUFFS_KFLAG_WTCACHE, which makes the page cache write-through
 1.61 20-Apr-2007  pooka * in readdir, don't copy extra memory back and forth to userspace
* consistent usage of the variable argsize with the rest of the module
 1.60 20-Apr-2007  pooka Size of a readdir cookie is sizeof(**ap->a_cookies), not
sizeof(*ap->a_cookies). Fixes nfs readdir in the case that a
directory had lots of entries with short names.
 1.59 16-Apr-2007  pooka Give the file server the ability to specify the file handle length
instead of defining a static length file handle on the framework-level.
 1.58 11-Apr-2007  pooka * support VFS_FHTOVP and VFS_VPTOFH
* support cookies in for VOP_READDIR

nfs exporting puffs file systems works now
 1.57 04-Apr-2007  pooka Make it possible to interrupt waiters for fs operation completion
again. This is useful until locking is further developed and basically
any deadlocks can be solved by killing appropriate processes.

Thanks especially to Tommi Kyntola and Antti Louko for sitting down
with me and discussing resource ownership and locking strategies
in implementing this.
 1.56 30-Mar-2007  pooka * abstract ASYNCBIOREAD and let callers freely issue a callback called
from putop. even though there's only one user currently, makes code
more readable
* move "delta" to a standard parameter in vntouser and get rid of the
specialcase vntouser_delta
 1.55 29-Mar-2007  pooka Convert spinlocks & sleep/wakeup to newlock2 locking stuff. Fix a
bunch of bugs.

* park structures are now always allocated from a pool instead of a
mixed stack/malloc allocation
* get rid of the whole adjbuf concept, always just alloc the maximal
amount of memory to satisfy a request
* little regression: don't allow interrupting wait from file system
to userspace; this had problems already before, but now the problems
really started to shine through. I'll try to make this work again
some day.
* fix bmap to return a sensible value in runp
 1.54 20-Mar-2007  pooka * rework the page cache interaction a bit: cache metadata in the
kernel and flush it out all at once instead of continuous updating
* add support for delivering notifications to the file server about
when a page was written to (but disabled by default for now). the
file server can use this to request flushing or invalidating the
kernel page cache
 1.53 14-Mar-2007  pooka branches: 1.53.2;
Support B_READ|B_ASYNC in strategy by calling biodone() directly
when the file server puts the result.
 1.52 20-Feb-2007  pooka branches: 1.52.4; 1.52.6;
Properly fix rev 1.44: limit error values from the file server to
positive values of errno and 0. Otherwise it can return internal values
such as EJUSTRETURN and screw things up.

thanks to Bill for reminding me to revisit this
 1.51 15-Feb-2007  pooka branches: 1.51.2;
Sanity-check linklen returned from file server in READLINK.
 1.50 10-Feb-2007  pooka * in write, do sync pageflush for the ubc case every 64k, otherwise
the user file server can't really keep up and just writing and writing
may result in kernel memory exhaustion. this lossage is also partially
due to the stupid way mtime + size info is handled currently, but that
should change soon (*knock knock* ;)
* score a few debug printfs
 1.49 09-Feb-2007  pooka honor B_ASYNC
 1.48 09-Feb-2007  pooka assign value for strategy output parameter b_resid instead of decreasing it
 1.47 08-Feb-2007  pooka If the file server doesn't support write, don't use genfs_null_putpages
for putpages, as it assumes a vnode doesn't have any pages. For
mounts using the page cache this is simply not true. Rather,
prevent opening a regular file in write-mode. That way a vnode
can never have dirty pages which would need to be flushed (i.e.
written).
 1.46 08-Feb-2007  pooka chuq shone arcane wisdom on me: b_bcount comes in, b_resid goes out
 1.45 08-Feb-2007  pooka Don't block and wait for file server response in case strategy is
run in pagedaemon context: it gives the file server way more control
over the fate of the entire kernel than what we're comfortable with.
 1.44 06-Feb-2007  pooka Limit errors from puffs_lookup to 0, EJUSTRETURN and ENOENT, as
that's what namei/lookup expects.
 1.43 29-Jan-2007  hannken Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>
 1.42 26-Jan-2007  pooka We don't handle fsync in checkop anymore, so direct the fifoop fsync
also to a place less panicy, namely fifo_fsync (because currently the
metadata information is update when the node is changed. This will
probably change soon, though).
 1.41 26-Jan-2007  pooka Initial attempt at suspend/snapshot support for userspace file
servers. This is still pretty much on the level "if it breaks ...".
It should work for single-threaded servers which handle one operation
from start to finish in one go. Also, it does not yet totally
correctly synchronize metadata and data in some cases. So needless
to say, it needs improvement, but it is possible that will have to
wait for some lock revampage.
 1.40 25-Jan-2007  pooka if strategy fails, set bp->b_error and B_ERROR
 1.39 25-Jan-2007  pooka don't hold spinlocks (except vnode interlock) when doing vget()
 1.38 21-Jan-2007  pooka optimize a bit: don't flush pages for vnodes which have no references
in the kernel or links in the backend
 1.37 21-Jan-2007  pooka remove diagnostic printf
 1.36 19-Jan-2007  pooka hannken noted that the latest gcc (?) complains about uninitialized
variable use in puffs_strategy() for "dowritefaf" (incorrectly)
and "error" (correctly, although the function is practically of
type void)
 1.35 19-Jan-2007  pooka In case the fs server is in the kernel doing an operation on a
completely different file system, we still might re-enter the same
puffs fs in case we execute something on the other file system,
which wants to get a new vnode and ends up recycling a puffs vnode
for the purpose. In this case the fs server will sleep in the
kernel until it itself handles the operation .... which of course
is a slightly unlikely event.

After analyzing the path from getcleanvnode() to the vnode cemetary,
identify that fsync and putpages (strategy) are the ones in danger
of striking a deadlock deal. Abuse the vnode flag VXLOCK to tell
them "this vnode is irreversably going to meet its maker, don't
care about user server return values" (failure is not acceptable
down the vgonel() path) and issue the respective operations as
Fire-And-Forget (FAF) operations. no wait -> no deadlock.

This of course is a "fix" skating on thin ice. A better, more
generic solution is already in sight, but will take more effort to
implement.
 1.34 16-Jan-2007  pooka * don't wait for the answer of VOP_RECLAIM, just fire-and-forget
* revoke puffs_revoke. we can deal with it just by calling genfs_revoke
 1.33 15-Jan-2007  pooka Store puffs_node's on lists hashed with the cookie value instead
of just one flat list.
 1.32 15-Jan-2007  pooka * do not accept the directory cookie as the result of a lookup (otherwise
we'd be locking against ourselves)
* do not accept duplicate cookies when creating new nodes
 1.31 11-Jan-2007  pooka Since fsync is really putpages + fsync, check for both separately
instead of using just putpages to decide the op's faith.

And the real beef in this commit is of course a tyop fix in a comment.
 1.30 09-Jan-2007  pooka Introduce flush operations, which the fs server can use to control
kernel caching. Currently supported are only flushing the name
cache for a directory or flushing the name cache for the entire fs.

Also, get rid of PNODE_INACTIVE status, since it was racy and
essentially didn't work. All this on top of being useless in the
first place ....
 1.29 07-Jan-2007  pooka getcwd wants eofflag - set eofflag in readdir if amount of data is 0
 1.28 02-Jan-2007  pooka In rename, tdvp == tvp holds if we are renaming a directory to "."
(XXX: for all the sense that makes). Deal with it gracefully here
for now.
 1.27 01-Jan-2007  pooka remove r/o mount check done also in vfs lookup()
 1.26 01-Jan-2007  pooka async update node metadata for spec- and fifoops
 1.25 01-Jan-2007  pooka properly handle VOP_REMOVE case where vp == dvp
 1.24 01-Jan-2007  pooka explicitly disable ioctl and fcntl for now - support has bitrotted
 1.23 30-Dec-2006  pooka branches: 1.23.2;
* use PUFFS_KFLAG_NOCACHE to also signal that we don't want the namecache
* enter files into the namecache immediately when new nodes are created
(if it's a caching mount, of course)
 1.22 09-Dec-2006  chs branches: 1.22.2;
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 07-Dec-2006  pooka let implementation ultimately decide if mmap is supported - pass
VOP_MMAP to fs server
 1.20 05-Dec-2006  pooka adjust file size in write only if file grows. but since this change is
in the "never use ubc" branch, I don't think it matters except for cosmetics.
 1.19 05-Dec-2006  pooka Allow multiple requests to be transferred in each GET/PUTOP. For
a single request, the performance is still the same.
 1.18 01-Dec-2006  pooka branches: 1.18.2;
prefix kernel flags with PUFFS_KFLAG to have a separate namespace
from the library flags
 1.17 01-Dec-2006  pooka don't call the fs server for all operations, only those it has told
us that it implements
 1.16 28-Nov-2006  pooka don't allow mmap if operating uncached
 1.15 18-Nov-2006  pooka Actually, for NOCACHE, use direct read/write instead of going through
page cache at all and invalidating. XXX: mmap
 1.14 18-Nov-2006  pooka branches: 1.14.2;
make puffs_strategy more robust
 1.13 18-Nov-2006  pooka Require statvfs info from startreq so that we have that info available.
Also, don't pass fsid to userspace and just fill it in the kernel.
 1.12 18-Nov-2006  pooka As a first generation best-effort hack, use NOCACHE to mean "file
size can change without the kernel knowing" and therefore query
the file size before invoking read or write operations.
 1.11 17-Nov-2006  pooka Introduce uncached operation, makes sense when the file system backend
can be modified from elsewhere than the file system interface
 1.10 13-Nov-2006  pooka No need to return a special value for CREATE/RENAME lookup, so just
handle ENOENT. If there's a real error, userspace will return
something else.
 1.9 08-Nov-2006  pooka update struct buf resid in strategy according to what was transferred.
seems like only nestiobuf complains when it wasn't updated ...
 1.8 07-Nov-2006  pooka attach to genfs & support page cache. most noticeable effect is
mmap and therefore execution of binaries starting to work, some
speed improvements with large file I/O also. caching semantics
and error case handling most likely need revisiting.
 1.7 27-Oct-2006  pooka Use spec_fsync for specops vop_fsync: it knows about vflushbuf(), which
is more than what puffs currently knows. makes e.g. ffs unmount for a
puffs-based device node work.
 1.6 27-Oct-2006  pooka support fifos
 1.5 26-Oct-2006  pooka support specfs
 1.4 26-Oct-2006  pooka Fix operations creating new nodes to honor the vnode locking protocol
if the userspace server returns an error. Fixes lockups if any
of the following operations failed: create, mknod, mkdir, symlink
 1.3 25-Oct-2006  pooka pass VOP_INACTIVE() to userspace
 1.2 23-Oct-2006  pooka fix print in VOP_PRINT

also make it compile on amd64. problem noticed by Blair Sadewitz
on current-users
 1.1 22-Oct-2006  pooka kernel portion of puffs - the Pass-to-Userspace Framework File System.
It contains the VFS attachment and userspace message-passing interface.

This work was initially started and completed for Google SoC 2005
and tweaked to work a bit better in the past few weeks. While
being far from complete, it is functional enough to be able and
stable to host a fairly general-purpose in-memory file system in
userspace. Even so, puffs should be considered experimental and
no binary compatibility for interfaces or crash-freedom or zero
security implications should be relied upon just yet.

The GSoC project was mentored by William Studenmund and the final
review for the code was done by Christos.
 1.14.2.5 09-Feb-2007  ad Sync with HEAD.
 1.14.2.4 01-Feb-2007  ad Sync with head.
 1.14.2.3 12-Jan-2007  ad Sync with head.
 1.14.2.2 18-Nov-2006  ad Sync with head.
 1.14.2.1 18-Nov-2006  ad file puffs_vnops.c was added on branch newlock2 on 2006-11-18 21:39:20 +0000
 1.18.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.22.2.2 10-Dec-2006  yamt sync with head.
 1.22.2.1 09-Dec-2006  yamt file puffs_vnops.c was added on branch yamt-splraiseipl on 2006-12-10 07:18:38 +0000
 1.23.2.8 04-Feb-2008  yamt sync with head.
 1.23.2.7 21-Jan-2008  yamt sync with head
 1.23.2.6 07-Dec-2007  yamt sync with head
 1.23.2.5 27-Oct-2007  yamt sync with head.
 1.23.2.4 03-Sep-2007  yamt sync with head.
 1.23.2.3 26-Feb-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 30-Dec-2006  yamt file puffs_vnops.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:01 +0000
 1.51.2.5 17-May-2007  yamt sync with head.
 1.51.2.4 07-May-2007  yamt sync with head.
 1.51.2.3 15-Apr-2007  yamt sync with head.
 1.51.2.2 24-Mar-2007  yamt sync with head.
 1.51.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.52.6.1 11-Jul-2007  mjf Sync with head.
 1.52.4.14 23-Oct-2007  ad Sync with head.
 1.52.4.13 12-Oct-2007  ad Sync with head.
 1.52.4.12 09-Oct-2007  ad Sync with head.
 1.52.4.11 09-Oct-2007  ad Sync with head.
 1.52.4.10 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.52.4.9 20-Aug-2007  ad Sync with HEAD.
 1.52.4.8 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.52.4.7 15-Jul-2007  ad Sync with head.
 1.52.4.6 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.52.4.5 09-Jun-2007  ad Sync with head.
 1.52.4.4 08-Jun-2007  ad Sync with head.
 1.52.4.3 10-Apr-2007  ad Sync with head.
 1.52.4.2 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.52.4.1 05-Apr-2007  ad Compile fixes.
 1.53.2.1 29-Mar-2007  reinoud Pullup to -current
 1.88.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.88.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.95.6.2 30-Jul-2007  pooka properly setup ubcflags
 1.95.6.1 30-Jul-2007  pooka file puffs_vnops.c was added on branch matt-mips64 on 2007-07-30 14:49:02 +0000
 1.95.4.9 09-Dec-2007  jmcneill Sync with HEAD.
 1.95.4.8 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.95.4.7 21-Nov-2007  joerg Sync with HEAD.
 1.95.4.6 28-Oct-2007  joerg Sync with HEAD.
 1.95.4.5 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.95.4.4 07-Oct-2007  joerg Sync with HEAD.
 1.95.4.3 02-Oct-2007  joerg Sync with HEAD.
 1.95.4.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.95.4.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.98.4.2 14-Oct-2007  yamt sync with head.
 1.98.4.1 06-Oct-2007  yamt sync with head.
 1.98.2.3 23-Mar-2008  matt sync with HEAD
 1.98.2.2 09-Jan-2008  matt sync with HEAD
 1.98.2.1 06-Nov-2007  matt sync with HEAD
 1.107.2.4 21-Nov-2007  bouyer Sync with HEAD
 1.107.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.107.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.107.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.113.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.113.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.113.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.113.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.121.2.2 26-Dec-2007  ad Sync with head.
 1.121.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.122.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.122.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.128.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.128.16.1 19-Oct-2008  haad Sync with HEAD.
 1.128.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.128.10.4 11-Aug-2010  yamt sync with head.
 1.128.10.3 11-Mar-2010  yamt sync with head
 1.128.10.2 16-Sep-2009  yamt sync with head
 1.128.10.1 04-May-2009  yamt sync with head.
 1.128.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.128.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.129.8.1 21-Apr-2010  matt sync to netbsd-5
 1.129.4.11 02-Nov-2011  riz Pull up following revision(s) (requested by manu in ticket #1679):
sys/fs/puffs/puffs_vnops.c: revision 1.157
sys/fs/puffs/puffs_vnops.c: revision 1.158
sys/fs/puffs/puffs_vnops.c: revision 1.159
sys/fs/puffs/puffs_vfsops.c: revision 1.97
sys/fs/puffs/puffs_vfsops.c: revision 1.99
sys/fs/puffs/puffs_vnops.c: revision 1.160
sys/fs/puffs/puffs_vfsops.c: revision 1.100
sys/miscfs/syncfs/sync_subr.c: revision 1.47
sys/fs/puffs/puffs_node.c: revision 1.21
sys/fs/puffs/puffs_node.c: revision 1.22
sys/fs/puffs/puffs_msgif.c: revision 1.88
sys/fs/puffs/puffs_msgif.c: revision 1.89
sys/fs/puffs/puffs_vnops.c: revision 1.156
Make sure ioflush does not sleep in PUFFS code path, waiting for a mutex,
a memory allocation, or a response from the filesystem.
This avoids deadlocks in the following situations:
1) when memory is low: ioflush waits the fileystem, the fielsystem waits
for memory
2) when the filesystem does not respond (e.g.: network outage ona
distributed filesystem)
Fix the build that was broken by struct lwp *updateproc reference in
RUMP-visible code. Instead of checking that updateproc (aka ioflush,
aka syncer) will not sleep in PUFFS code, I check for any kernel thread:
after all none of them are designed to hang awaiting for a remote filesystem
operation to complete.
Roll back the change that forced kernel threads to not sleep in PUFFS.
The change does not make consensus, since only pagedaemon should need it.
Other threads will tolerate sleeping, and problems here are only symptoms
that something is going wrong in memory management. The cause, not the
symptoms, need to be fixed.
Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
Remove #ifdef DIAGNOSTIC guards around KASSERT, as the macro contains them
 1.129.4.10 17-Sep-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1666):
sys/fs/puffs/puffs_sys.h: revision 1.78 via patch
sys/fs/puffs/puffs_node.c: revision 1.20 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.155 via patch
Add a mutex for operations that touch size (setattr, getattr, write, fsync).
This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.
Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.
This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
 1.129.4.9 17-Jul-2011  riz Pull up following revision(s) (requested by manu in ticket #1645):
lib/libc/sys/Makefile.inc 1.207 via patch
lib/libc/sys/extattr_get_file.2 patch
lib/libpuffs/dispatcher.c 1.34,1.36 via patch
lib/libpuffs/puffs.c 1.107 via patch
lib/libpuffs/puffs.h 1.115,1.118 via patch
sys/fs/puffs/puffs_msgif.h 1.71,1.76 via patch
sys/fs/puffs/puffs_vfsops.c 1.88 via patch
sys/fs/puffs/puffs_vnops.c 1.145,1.154 via patch
sys/kern/vfs_xattr.c 1.24-1.27 via patch
sys/kern/vnode_if.c 1.87 via patch
sys/sys/Makefile 1.133 via patch
sys/sys/extattr.h 1.6 via patch
sys/sys/vnode_if.h 1.81 via patch
sys/ufs/ffs/ffs_vnops.c patch
sys/ufs/ufs/ufs_extattr.c 1.31,1.34 via patch

* support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness
Support extended attributes.
Fix multiple non compliances in our Linux-like extattr API, and make it
public so that it can be used.
Improve a bit listxattr(2). It attemps to list both system and user
extended attributes, and it faled if calling user did not have privilege
for reading system EA. Now we just lise user EA and skip system EA in
reading them is not allowed.
Fix bug introduced in previous commuit: Do not vrele() a vnode we did not
obtained.
Improve UFS1 extended attributes usability
- autocreate attribute backing file for new attributes
- autoload attributes when issuing extattrctl start
- when autoloading attributes, do not display garbage warning when looking
up entries that got ENOENT
Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.
There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)
This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
 1.129.4.8 18-Jun-2011  bouyer Pull up following revision(s) (requested by manu in ticket #1623):
lib/libpuffs/puffs.c: revision 1.116 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.151 via patch
Call advlock method if supplied
 1.129.4.7 16-Jan-2010  bouyer Pull up following revision(s) (requested by pooka in ticket #1244):
sys/fs/puffs/puffs_vnops.c: revision 1.142
Since VOP_GETATTR() does not require a locked vnode, resolve and
reference the puffs_node before sending the request to the file
server. This diminishes the window where the inode can be reclaimed
and be invalidated before it is accessed (but does not completely
eliminate the race, as that is a caller problem which we cannot
fix here).
 1.129.4.6 18-Dec-2009  snj Pull up following revision(s) (requested by pooka in ticket #1184):
sys/fs/puffs/puffs_vnops.c: revision 1.141 via patch
Push all information cached in the vnode to the file server before
issuing INACTIVE. PR kern/42194.
Also, send setattr in fsync asynchronously if FSYNC_WAIT is not set.
 1.129.4.5 28-Nov-2009  bouyer Pull up following revision(s) (requested by pooka in ticket #1154):
sys/fs/puffs/puffs_vnops.c: revision 1.140
Send VOP_ABORTOP() in case attempting cross-dev rename, part of
PR kern/42210. Also, fix a memory management error in said case.
 1.129.4.4 28-Nov-2009  bouyer Pull up following revision(s) (requested by pooka in ticket #1153):
sys/fs/puffs/puffs_vnops.c: revision 1.139
Send VOP_ABORTOP() as a FAF -- we don't care about the return value.
 1.129.4.3 18-Oct-2009  sborrill Pull up the following revisions(s) (requested by pooka in ticket #1100):
lib/libpuffs/dispatcher.c: revision 1.33
lib/libpuffs/puffs.c: revision 1.99
lib/libpuffs/puffs.h: revision 1.111
sys/fs/puffs/puffs_msgif.h: revision 1.67 via patch
sys/fs/puffs/puffs_vnops.c: revision 1.136

Support VOP_ABORTOP() in puffs.
 1.129.4.2 03-Oct-2009  snj Pull up following revision(s) (requested by pooka in ticket #1042):
sys/fs/puffs/puffs_node.c: revision 1.14
sys/fs/puffs/puffs_vnops.c: revision 1.134
* fix a race i introduced almost two years ago in rev 1.116:
operations creating a node cannot be considered outgoing operations,
since after return from userspace they modify file system state
by creating a new node. if we do not protect the file system by
holding the directory lock, a lookup operation might race us into
the kernel and create the node earlier.
* remove pnode from hashlish before sending the reclaim faf off to
userspace. also, hold pmp_lock while frobbing the list.
 1.129.4.1 26-Sep-2009  snj Pull up following revision(s) (requested by pooka in ticket #1014):
sys/fs/puffs/puffs_vnops.c: revision 1.133
Set SAVENAME for rmdir and remove.
Addresses an easy part of PR kern/38188
 1.129.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.142.4.5 31-May-2011  rmind sync with head
 1.142.4.4 05-Mar-2011  rmind sync with head
 1.142.4.3 03-Jul-2010  rmind sync with head
 1.142.4.2 30-May-2010  rmind sync with head
 1.142.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.142.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.142.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.150.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.152.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.161.2.5 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.161.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.161.2.3 30-Oct-2012  yamt sync with head
 1.161.2.2 23-May-2012  yamt sync with head.
 1.161.2.1 17-Apr-2012  yamt sync with head
 1.162.4.3 29-Apr-2012  mrg sync to latest -current.
 1.162.4.2 05-Apr-2012  mrg sync to latest -current.
 1.162.4.1 18-Feb-2012  mrg merge to -current.
 1.163.2.12 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #1260):
lib/libpuffs/puffs.3: revision 1,55,1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Use more markup. New sentence, new line. Bump date for previous.

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.163.2.11 16-Jan-2015  martin Pull up following revision(s) (requested by manu in ticket #1236):
sys/fs/puffs/puffs_vnops.c: revision 1.199
Make sure reads on empty files reach PUFFS filesystems
Sending a read through the page cache will get the operation
short-circuited. This is a problem with some filesystems that
expect to receive the read operation in order to update atime.
We fix that by bypassing the page cache when reading a file
wich a size known to be zero.
 1.163.2.10 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1187):
sys/fs/puffs/puffs_vnops.c: revision 1.198
PUFFS direct I/O cache fix
There are a few situations where we must take care of the cache if
direct
I/O was enabled:
- if we do direct I/O for write but not for read, then any write must
invalidate the cache so that a reader gets the written data and not
the not-updated cache.
- if we used a vnode without direct I/O and it is enabled for writing,
we must flush the cache before compeling the open operation, so that
the cachec write are not lost.
And at inactive time, we wipe direct I/O flags so that a new open
without
direct I/O does not inherit direct I/O.
 1.163.2.9 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1184):
sys/fs/puffs/puffs_vnops.c: revision 1.195
According to pooka@'s comment, a long time ago, VOP_STRATEGY could not
fail without taking down the kernel. It seems this is not the case
anymore,
hence we can stop dropping errors in puffs_vnop_strategy()
Approved by pooka@
 1.163.2.8 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1166):
sys/fs/puffs/puffs_vnops.c: revision 1.188-1.194
- If we truncate the file, make sure we zero-fill the end of the last
page, otherwise if the file is later truncated to a larger size
(creating a hole), that area will not return zeroes as it should.
- Use PRIx64 for printing offsets
- Improve zero-fill of last page after shrink fix:
1) do it only if the file is open for writing, otherwise we send write
requests to the FS on a file that has never been open.
2) do it inside existing if (vap->va_size != VNOVAL) block
- Retore LP64 fix that was removed by mistake
- Make this build again without debugging enabled; DPRINTF() can end up
as empty, and in an if conditional, you then need braces if that's the
only potential body.
- As is evidenced by several of our 32-bit MIPS ports, it's wrong to
print vsize_t with PRIx64 -- instead use our own PRIxVSIZE macro.
- Do the previous correctly...
 1.163.2.7 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1152):
sys/fs/puffs/puffs_vnops.c: revision 1.186
PUFFS fixes for size update ater write plus read/write sanity checks
- Always update kernel metadata cache for size when writing
This fixes situation where size update after appending to a file lagged
- Make read/write nilpotent when called with null size, as FFS does
- Return EFBIG instead of EINVAL for negative offsets, as FFS does
 1.163.2.6 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1149):
sys/fs/puffs/puffs_node.c: revision 1.33
sys/fs/puffs/puffs_vnops.c: revision 1.185
When changing a directory content, update the ctime/mtime in kernel
cache,
otherwise the updated ctime/mtime appears after the cached entry expire.
 1.163.2.5 03-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1140):
lib/libperfuse/ops.c 1.63-1.69
lib/libperfuse/perfuse.c 1.32-1.33
lib/libperfuse/perfuse_priv.h 1.32-1.34
lib/libperfuse/subr.c 1.20
lib/libpuffs/creds.c 1.16
lib/libpuffs/dispatcher.c 1.47
lib/libpuffs/puffs.h 1.125
lib/libpuffs/puffs_ops.3 1.37-1.38
lib/libpuffs/requests.c 1.24
sys/fs/puffs/puffs_msgif.h 1.81
sys/fs/puffs/puffs_sys.h 1.85
sys/fs/puffs/puffs_vnops.c 1.183
usr.sbin/perfused/msg.c 1.22
Bring libpuffs, libperfuse and perfused on par with -current:
- implement FUSE direct I/O
- remove useless code and warnings
- fix missing GETATTR bugs
- fix exended attribute get and list operations
 1.163.2.4 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #438):
lib/libperfuse/perfuse_priv.h: revision 1.31
sys/fs/puffs/puffs_msgif.h: revision 1.80
sys/fs/puffs/puffs_vnops.c: revision 1.171
lib/libpuffs/puffs_ops.3: revision 1.31
sys/fs/puffs/puffs_vnops.c: revision 1.172
sys/fs/puffs/puffs_vnops.c: revision 1.173
sys/fs/puffs/puffs_vnops.c: revision 1.174
usr.sbin/perfused/perfused.c: revision 1.24
sys/fs/puffs/puffs_sys.h: revision 1.80
sys/fs/puffs/puffs_sys.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.82
lib/libperfuse/subr.c: revision 1.19
lib/libperfuse/perfuse.c: revision 1.30
sys/fs/puffs/puffs_msgif.c: revision 1.90
sys/fs/puffs/puffs_msgif.c: revision 1.91
sys/fs/puffs/puffs_msgif.c: revision 1.92
lib/libperfuse/ops.c: revision 1.59
lib/libpuffs/puffs.3: revision 1.53
lib/libperfuse/debug.c: revision 1.12
lib/libpuffs/puffs.3: revision 1.54
sys/fs/puffs/puffs_vnops.c: revision 1.167
sys/fs/puffs/puffs_msgif.h: revision 1.79
usr.sbin/perfused/msg.c: revision 1.21
sys/fs/puffs/puffs_vfsops.c: revision 1.102
sys/fs/puffs/puffs_vfsops.c: revision 1.103
sys/fs/puffs/puffs_vfsops.c: revision 1.105
lib/libpuffs/puffs.h: revision 1.123
lib/libperfuse/perfuse_if.h: revision 1.20
lib/libperfuse/perfuse.c: revision 1.29
lib/libpuffs/dispatcher.c: revision 1.42
lib/libpuffs/dispatcher.c: revision 1.43
- Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).
We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed
- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().
- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.
- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.
- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode
and size set. This confuses some FUSE filesystem. Therefore we send two FUSE
operations, one for mode, and one for size.
- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
- Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.
We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.
- Fix lookup/reclaim race condition.
The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.
We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
Fix hang unmount bug introduced by last commit.
We introduced a slow queue for delayed reclaims, while the existing
queue for unmount, flush and exist has been renamed fast queue. Both
queues had timestamp for when an operation should be done, but it was
useless for the fast queue, which is always used to run an operation
ASAP. And the timestamp test had an error that turned ASAP into "at next
tick", but nobody what there to wake the thread at next tick, hence
the hang. The fix is to remove the useless and buggy timestamp test for
fast queue.
Rename slow sopreq queue into node sopreq queue, to refet the fact that
is only intended for postponed node reclaims.
When purging the node sopreq queue, do not call puffs_msg_sendresp(), as
it makes no sense.
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
Missing bit in previous commit (prevent race between create|mknod|mkdir|symlink
and reclaim)
Bump date for previous.
New sentence, new line; remove trailing whitespace; fix typos;
punctuation nits.
Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.
Enable the featuure for perfused, as this is how FUSE works.
Missing bit in previous commit (PUFFS_KFLAG_CACHE_DOTDOT option to avoid
looking up ..)
 1.163.2.3 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.163.2.2 23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.163.2.1 03-Apr-2012  riz Pull up following revision(s) (requested by jakllsch in ticket #154):
sys/fs/puffs/puffs_vnops.c: revision 1.164
Prevent access beyond end of PUFFS file on read,
similar to as is done for NFS.
 1.174.2.3 03-Dec-2017  jdolecek update from HEAD
 1.174.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.174.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.176.2.1 18-May-2014  rmind sync with head
 1.181.2.1 10-Aug-2014  tls Rebase.
 1.182.2.13 27-Feb-2015  martin Pull up following revision(s) (requested by manu in ticket #555):
lib/libpuffs/puffs.3: revision 1.60
sys/fs/puffs/puffs_msgif.h: revision 1.84
lib/libperfuse/ops.c: revision 1.83
sys/fs/puffs/puffs_sys.h: revision 1.89
sys/fs/puffs/puffs_vfsops.c: revision 1.116
lib/libperfuse/perfuse.c: revision 1.36
sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE

FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.
 1.182.2.12 17-Jan-2015  martin Pull up following revision(s) (requested by manu in ticket #423):
sys/fs/puffs/puffs_vnops.c: revision 1.199
Make sure reads on empty files reach PUFFS filesystems
Sending a read through the page cache will get the operation
short-circuited. This is a problem with some filesystems that
expect to receive the read operation in order to update atime.
We fix that by bypassing the page cache when reading a file
wich a size known to be zero.
 1.182.2.11 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #194):
sys/fs/puffs/puffs_vnops.c: revision 1.197
sys/fs/puffs/puffs_node.c: revision 1.35
Fix PUFFS node use-after-reclaim
When puffs_cookie2vnode() misses an entry, vcache_get()
creates a new node (puffs_vfsop_loadvnode being called to
initialize the PUFFS part), then it discovers it is VNON,
and tries to vrele() it. vrele() calls VOP_INACTIVE(),
which led us in puffs_vnop_inactive() where we sent a
request to the filesystem for a node that already had been
reclaimed.
The fix is to check for VNON nodes in puffs_vnop_inactive()
and to return without doing anyting. This is suboptimal, but
a better workaround would probably need to modify vcache API,
with an impact on other filesystems. Let us keep it simple.
 1.182.2.10 09-Nov-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #193):
sys/fs/puffs/puffs_vnops.c: revision 1.198
PUFFS direct I/O cache fix
There are a few situations where we must take care of the cache if
direct
I/O was enabled:
- if we do direct I/O for write but not for read, then any write must
invalidate the cache so that a reader gets the written data and not
the not-updated cache.
- if we used a vnode without direct I/O and it is enabled for writing,
we must flush the cache before compeling the open operation, so that
the cachec write are not lost.
And at inactive time, we wipe direct I/O flags so that a new open
without
direct I/O does not inherit direct I/O.
 1.182.2.9 05-Nov-2014  snj Pull up following revision(s) (requested by manu in ticket #182):
sys/fs/puffs/puffs_vnops.c: revision 1.195
According to pooka@'s comment, a long time ago, VOP_STRATEGY could not
fail without taking down the kernel. It seems this is not the case
anymore,
hence we can stop dropping errors in puffs_vnop_strategy()
Approved by pooka@
 1.182.2.8 05-Nov-2014  snj Pull up following revision(s) (requested by manu in ticket #181):
lib/libperfuse/fuse.h: revision 1.6
lib/libperfuse/ops.c: revision 1.78
lib/libperfuse/perfuse.c: revision 1.35
lib/libperfuse/perfuse_priv.h: revision 1.36
lib/libpuffs/dispatcher.c: revision 1.48
lib/libpuffs/opdump.c: revision 1.37
lib/libpuffs/puffs.c: revision 1.118
lib/libpuffs/puffs.h: revision 1.126
lib/libpuffs/puffs_ops.3: revisions 1.40-1.41
sys/fs/puffs/puffs_msgif.h: revision 1.82-1.83
sys/fs/puffs/puffs_msgif.h: revision 1.82
sys/fs/puffs/puffs_vnops.c: revision 1.196
Add PUFFS support for fallocate and fdiscard operations
--
libpuffs support for fallocate and fdiscard operations
--
Add PUFFS_HAVE_FALLOCATE in puffs_msgif.h so that filesystem can decide
at build time wether fallocate is usable
--
FUSE fallocate support
There seems to be no fdiscard FUSE operation at the moment, hence that
one is left unused.
 1.182.2.7 14-Oct-2014  martin Pull up revisions 1.192-1.194: fix debug printf formatting and make
it compile without debugging enabled.
 1.182.2.6 13-Oct-2014  martin Pull up following revision(s) (requested by manu in ticket #136):
sys/fs/puffs/puffs_vnops.c: revision 1.189-1.191
If we truncate a file open for writing, make sure we zero-fill the end
of the last page, otherwise if the file is later truncated to a larger
size (creating a hole), that area will not return zeroes as it should.
 1.182.2.5 30-Sep-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_node.c: revision 1.34
sys/fs/puffs/puffs_vnops.c: revision 1.187
Fix the puffs_sop_thread -> puffs_cookie2vnode path:
- pass the cookie by reference
- add missing mutex_exit()
- update assertion for VNON typed vnodes
 1.182.2.4 11-Sep-2014  martin Pull up following revision(s) (requested by manu in ticket #93):
sys/fs/puffs/puffs_vnops.c: revision 1.186
PUFFS fixes for size update ater write plus read/write sanity checks
- Always update kernel metadata cache for size when writing
This fixes situation where size update after appending to a file lagged
- Make read/write nilpotent when called with null size, as FFS does
- Return EFBIG instead of EINVAL for negative offsets, as FFS does
 1.182.2.3 10-Sep-2014  martin Pull up following revision(s) (requested by manu in ticket #79):
sys/fs/puffs/puffs_node.c: revision 1.33
sys/fs/puffs/puffs_vnops.c: revision 1.185
When changing a directory content, update the ctime/mtime in kernel
cache, otherwise the updated ctime/mtime appears after the cached
entry expire.
 1.182.2.2 29-Aug-2014  martin Pull up following revision(s) (requested by hannken in ticket #67):
sys/fs/puffs/puffs_sys.h: revision 1.86
sys/fs/puffs/puffs_vfsops.c: revision 1.114
sys/fs/puffs/puffs_msgif.c: revision 1.95
sys/fs/puffs/puffs_node.c: revision 1.32
sys/fs/puffs/puffs_vnops.c: revision 1.184
Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
and should be removed on the next protocol version bump.
 1.182.2.1 26-Aug-2014  riz Pull up following revision(s) (requested by manu in ticket #52):
sys/fs/puffs/puffs_msgif.h: revision 1.81
sys/fs/puffs/puffs_sys.h: revision 1.85
sys/fs/puffs/puffs_vnops.c: revision 1.183
Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
 1.198.2.5 28-Aug-2017  skrll Sync with HEAD
 1.198.2.4 05-Oct-2016  skrll Sync with HEAD
 1.198.2.3 09-Jul-2016  skrll Sync with HEAD
 1.198.2.2 06-Jun-2015  skrll Sync with HEAD
 1.198.2.1 06-Apr-2015  skrll Sync with HEAD
 1.204.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.204.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.205.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.211.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.211.10.1 10-Jun-2019  christos Sync with HEAD
 1.211.8.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.211.2.1 06-Nov-2018  martin Pull up following revision(s) (requested by manu in ticket #1082):

sys/fs/puffs/puffs_vnops.c: revision 1.213

Fix use after RECLAIM in PUFFS filesystems

From hannken@

When puffs_cookie2vnode() misses an entry and vrele() it operations
puffs_vnop_reclaim() and puffs_vnop_fsync() get called with a VNON
vnode.

Do not notify the server in this case as the cookie is stale.
 1.213.6.1 29-Feb-2020  ad Sync with head.
 1.214.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.217.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 04-Sep-2008  pooka Install sysvbfs argument structure header into userlandia.
 1.1 29-Dec-2005  tsutsui branches: 1.1.18; 1.1.72; 1.1.76; 1.1.78; 1.1.82;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.82.1 19-Oct-2008  haad Sync with HEAD.
 1.1.78.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.76.1 04-May-2009  yamt sync with head.
 1.1.72.1 28-Sep-2008  mjf Sync with HEAD.
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 29-Dec-2005  yamt file Makefile was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.19 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.18 26-Dec-2014  hannken branches: 1.18.18;
Sysvbfs_rename: Call bfs_file_delete(bfs, to_name, true) before calling
bfs_file_rename() and remove the bfs_file_delete() from bfs_file_rename().

After calling bfs_file_rename() it was too late to set "tnode->removed"
as the inode already disappeared.
 1.17 09-Jan-2014  hannken branches: 1.17.6;
Operation sysvbfs_remove() destructs inodes attached to active vnodes.
Defer the destruction to sysvbfs_reclaim().

Disable test t_renamerace:sysvbfs_renamerace as it will exhaust the
inode table (sysvbfs has space for 8 inodes only).

Ok: Izumi Tsutsui <tsutsui@netbsd.org>
 1.16 11-Jun-2012  agc branches: 1.16.2; 1.16.4;
cosmetic change: fix two casts to be of the appropriate type
 1.15 08-May-2012  tsutsui Move bfs_file_setsize() from bfs.c to sysvbfs_vnops.c
(and rename it to sysvbfs_file_setsize()) because it's actually
part of vnode ops and bfs.c is also pulled by standalone bootloaders
which don't want vnode header mess.
 1.14 18-Mar-2012  christos handle file resizing.
 1.13 26-Jul-2010  njoly branches: 1.13.8; 1.13.12;
Make sysvbfs rename work for filenames longer than {NAME_MAX}.
 1.12 26-Apr-2009  uch branches: 1.12.2; 1.12.4;
added error check.
 1.11 28-Apr-2008  martin branches: 1.11.8; 1.11.14;
Remove clause 3 and 4 from TNF licenses
 1.10 15-Dec-2007  perry branches: 1.10.6; 1.10.8; 1.10.10;
__FUNCTION__ -> __func__
 1.9 30-Jun-2007  pooka branches: 1.9.8; 1.9.16; 1.9.20;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.8 22-Feb-2007  thorpej branches: 1.8.4; 1.8.6;
TRUE -> true, FALSE -> false
 1.7 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.6 26-Aug-2006  tsutsui branches: 1.6.8;
Change types from int8_t to char for arrays which store char names.
 1.5 06-Jul-2006  martin Make it compile on 64 bit machines
 1.4 01-Jul-2006  martin Redo previous differently - just use time_second.
Pointed out by Frank Kardel.
 1.3 01-Jul-2006  martin Make it compile post time-counter merge
 1.2 26-Jan-2006  tsutsui branches: 1.2.2; 1.2.6; 1.2.14; 1.2.16;
free() -> dealloc() for _STANDALONE.
 1.1 29-Dec-2005  tsutsui branches: 1.1.2;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.2.1 01-Feb-2006  yamt sync with head.
 1.2.16.6 21-Jan-2008  yamt sync with head
 1.2.16.5 03-Sep-2007  yamt sync with head.
 1.2.16.4 26-Feb-2007  yamt sync with head.
 1.2.16.3 30-Dec-2006  yamt sync with head.
 1.2.16.2 21-Jun-2006  yamt sync with head.
 1.2.16.1 26-Jan-2006  yamt file bfs.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.2.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.2.6.2 03-Sep-2006  yamt sync with head.
 1.2.6.1 11-Aug-2006  yamt sync with head
 1.2.2.1 09-Sep-2006  rpaulo sync with head
 1.6.8.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.6.1 11-Jul-2007  mjf Sync with head.
 1.8.4.1 15-Jul-2007  ad Sync with head.
 1.9.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.16.1 26-Dec-2007  ad Sync with head.
 1.9.8.1 09-Jan-2008  matt sync with HEAD
 1.10.10.3 11-Aug-2010  yamt sync with head.
 1.10.10.2 04-May-2009  yamt sync with head.
 1.10.10.1 16-May-2008  yamt sync with head.
 1.10.8.1 18-May-2008  yamt sync with head.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.4.1 05-Mar-2011  rmind sync with head
 1.12.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.12.2 02-Jun-2012  mrg sync to latest -current.
 1.13.12.1 05-Apr-2012  mrg sync to latest -current.
 1.13.8.4 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.13.8.3 30-Oct-2012  yamt sync with head
 1.13.8.2 23-May-2012  yamt sync with head.
 1.13.8.1 17-Apr-2012  yamt sync with head
 1.16.4.1 18-May-2014  rmind sync with head
 1.16.2.2 03-Dec-2017  jdolecek update from HEAD
 1.16.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.1 06-Apr-2015  skrll Sync with HEAD
 1.18.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8 09-Jan-2014  hannken Operation sysvbfs_remove() destructs inodes attached to active vnodes.
Defer the destruction to sysvbfs_reclaim().

Disable test t_renamerace:sysvbfs_renamerace as it will exhaust the
inode table (sysvbfs has space for 8 inodes only).

Ok: Izumi Tsutsui <tsutsui@netbsd.org>
 1.7 08-May-2012  tsutsui branches: 1.7.2; 1.7.4;
Move bfs_file_setsize() from bfs.c to sysvbfs_vnops.c
(and rename it to sysvbfs_file_setsize()) because it's actually
part of vnode ops and bfs.c is also pulled by standalone bootloaders
which don't want vnode header mess.
 1.6 18-Mar-2012  christos handle file resizing.
 1.5 28-Apr-2008  martin branches: 1.5.34; 1.5.38;
Remove clause 3 and 4 from TNF licenses
 1.4 25-Dec-2007  perry branches: 1.4.6; 1.4.8; 1.4.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.3 21-Feb-2007  thorpej branches: 1.3.18; 1.3.24; 1.3.26; 1.3.30;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.2 26-Aug-2006  tsutsui branches: 1.2.8;
Change types from int8_t to char for arrays which store char names.
 1.1 29-Dec-2005  tsutsui branches: 1.1.4; 1.1.8; 1.1.18;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.18.5 21-Jan-2008  yamt sync with head
 1.1.18.4 26-Feb-2007  yamt sync with head.
 1.1.18.3 30-Dec-2006  yamt sync with head.
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 29-Dec-2005  yamt file bfs.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.1.8.1 03-Sep-2006  yamt sync with head.
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.2.8.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.3.30.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.26.1 26-Dec-2007  ad Sync with head.
 1.3.24.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.18.1 09-Jan-2008  matt sync with HEAD
 1.4.10.1 16-May-2008  yamt sync with head.
 1.4.8.1 18-May-2008  yamt sync with head.
 1.4.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.38.2 02-Jun-2012  mrg sync to latest -current.
 1.5.38.1 05-Apr-2012  mrg sync to latest -current.
 1.5.34.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.5.34.2 23-May-2012  yamt sync with head.
 1.5.34.1 17-Apr-2012  yamt sync with head
 1.7.4.1 18-May-2014  rmind sync with head
 1.7.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.10 16-May-2008  hannken branches: 1.10.42; 1.10.62;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.9 28-Apr-2008  martin branches: 1.9.2;
Remove clause 3 and 4 from TNF licenses
 1.8 15-Dec-2007  perry branches: 1.8.6; 1.8.8; 1.8.10;
__FUNCTION__ -> __func__
 1.7 08-Oct-2007  ad branches: 1.7.6; 1.7.10;
Merge brelse() changes from the vmlocking branch.
 1.6 22-Feb-2007  thorpej branches: 1.6.4; 1.6.16; 1.6.18; 1.6.20;
TRUE -> true, FALSE -> false
 1.5 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.4 06-Jul-2006  martin branches: 1.4.10;
Make it compile on 64 bit machines
 1.3 15-May-2006  yamt branches: 1.3.4; 1.3.6;
include kauth.h for NOCRED.
 1.2 14-May-2006  elad integrate kauth.
 1.1 29-Dec-2005  tsutsui branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.1.8.2 11-Aug-2006  yamt sync with head
 1.1.8.1 24-May-2006  yamt sync with head.
 1.1.6.1 01-Jun-2006  kardel Sync with head.
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.3.6.6 21-Jan-2008  yamt sync with head
 1.3.6.5 27-Oct-2007  yamt sync with head.
 1.3.6.4 26-Feb-2007  yamt sync with head.
 1.3.6.3 30-Dec-2006  yamt sync with head.
 1.3.6.2 21-Jun-2006  yamt sync with head.
 1.3.6.1 15-May-2006  yamt file bfs_sysvbfs.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.3.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.4.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.6.20.1 14-Oct-2007  yamt sync with head.
 1.6.18.2 09-Jan-2008  matt sync with HEAD
 1.6.18.1 06-Nov-2007  matt sync with HEAD
 1.6.16.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.6.4.1 15-Jul-2007  ad Sync with head.
 1.7.10.1 02-Jan-2008  bouyer Sync with HEAD
 1.7.6.1 26-Dec-2007  ad Sync with head.
 1.8.10.2 04-May-2009  yamt sync with head.
 1.8.10.1 16-May-2008  yamt sync with head.
 1.8.8.1 18-May-2008  yamt sync with head.
 1.8.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.62.1 06-Apr-2015  skrll Sync with HEAD
 1.10.42.1 03-Dec-2017  jdolecek update from HEAD
 1.2 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.1 29-Dec-2005  tsutsui branches: 1.1.18; 1.1.122;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.122.1 03-Dec-2017  jdolecek update from HEAD
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 29-Dec-2005  yamt file files.sysvbfs was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.19 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.18 16-May-2020  christos branches: 1.18.6;
Add ACL support for FFS. From FreeBSD.
 1.17 28-May-2018  chs add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.16 17-Feb-2017  hannken branches: 1.16.12;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.15 26-Dec-2014  hannken branches: 1.15.2; 1.15.4;
Change sysvbfs to vcache.
 1.14 25-Jul-2014  dholland branches: 1.14.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.13 23-Mar-2014  hannken branches: 1.13.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.12 10-May-2008  rumble branches: 1.12.32; 1.12.42; 1.12.48;
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.11 29-Apr-2008  ad branches: 1.11.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.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 28-Jan-2008  dholland branches: 1.9.6; 1.9.8; 1.9.10;
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.8 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.7 26-Nov-2007  pooka 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.6 26-Jul-2007  pooka branches: 1.6.4; 1.6.6; 1.6.12; 1.6.14;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.5 12-Jul-2007  dsl branches: 1.5.2;
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.4 19-Jan-2007  hannken branches: 1.4.6;
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.3 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.2 01-Jul-2006  martin branches: 1.2.4; 1.2.6; 1.2.8;
Make it compile post time-counter merge
 1.1 29-Dec-2005  tsutsui branches: 1.1.4; 1.1.8; 1.1.16; 1.1.18;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.18.7 04-Feb-2008  yamt sync with head.
 1.1.18.6 07-Dec-2007  yamt sync with head
 1.1.18.5 03-Sep-2007  yamt sync with head.
 1.1.18.4 26-Feb-2007  yamt sync with head.
 1.1.18.3 30-Dec-2006  yamt sync with head.
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 29-Dec-2005  yamt file sysvbfs.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.1.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.8.1 11-Aug-2006  yamt sync with head
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.2.8.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.2.6.1 10-Dec-2006  yamt sync with head.
 1.2.4.2 01-Feb-2007  ad Sync with head.
 1.2.4.1 12-Jan-2007  ad Sync with head.
 1.4.6.2 20-Aug-2007  ad Sync with HEAD.
 1.4.6.1 15-Jul-2007  ad Sync with head.
 1.5.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.6.14.2 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.6.14.1 26-Jul-2007  pooka file sysvbfs.c was added on branch matt-mips64 on 2007-07-26 22:57:39 +0000
 1.6.12.2 18-Feb-2008  mjf Sync with HEAD.
 1.6.12.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.6.2 23-Mar-2008  matt sync with HEAD
 1.6.6.1 09-Jan-2008  matt sync with HEAD
 1.6.4.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.9.10.1 16-May-2008  yamt sync with head.
 1.9.8.1 18-May-2008  yamt sync with head.
 1.9.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.48.1 18-May-2014  rmind sync with head
 1.12.42.2 03-Dec-2017  jdolecek update from HEAD
 1.12.42.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.32.1 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.13.2.1 10-Aug-2014  tls Rebase.
 1.14.4.2 28-Aug-2017  skrll Sync with HEAD
 1.14.4.1 06-Apr-2015  skrll Sync with HEAD
 1.15.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.15.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.16.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.18.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.10 26-Dec-2014  hannken Change sysvbfs to vcache.
 1.9 27-May-2010  pooka branches: 1.9.18; 1.9.36;
Mark files removed in the in-memory structure. This allows us
to do two things:

1) properly set "recycle?" in inactive
2) easily check if we are renaming a removed vnode. without the
check, it was possible to enter a dirent in the file system for
a removed (and hence scheduled to be vcleaned) vnode. this would
lead to the succesful vget() of a clean vnode. the use of the
cleaned vnode was, however, less succesful, except for purposes
of crashing.
 1.8 04-Sep-2008  pooka branches: 1.8.14; 1.8.16;
Install sysvbfs argument structure header into userlandia.
 1.7 28-Apr-2008  martin branches: 1.7.2; 1.7.6;
Remove clause 3 and 4 from TNF licenses
 1.6 31-Jul-2007  pooka branches: 1.6.24; 1.6.26; 1.6.28; 1.6.30;
* 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.5 12-Jul-2007  dsl branches: 1.5.2;
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.4 06-Oct-2006  chs branches: 1.4.8;
move includes only needed for kernel inside ifdef _KERNEL.
 1.3 13-Jul-2006  martin branches: 1.3.4; 1.3.6;
Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.2 14-May-2006  elad branches: 1.2.4; 1.2.6;
integrate kauth.
 1.1 29-Dec-2005  tsutsui branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.1.8.2 11-Aug-2006  yamt sync with head
 1.1.8.1 24-May-2006  yamt sync with head.
 1.1.6.1 01-Jun-2006  kardel Sync with head.
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.2.6.4 03-Sep-2007  yamt sync with head.
 1.2.6.3 30-Dec-2006  yamt sync with head.
 1.2.6.2 21-Jun-2006  yamt sync with head.
 1.2.6.1 14-May-2006  yamt file sysvbfs.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.2.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.6.1 22-Oct-2006  yamt sync with head
 1.3.4.1 18-Nov-2006  ad Sync with head.
 1.4.8.2 20-Aug-2007  ad Sync with HEAD.
 1.4.8.1 15-Jul-2007  ad Sync with head.
 1.5.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.6.30.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.6.30.1 31-Jul-2007  pooka file sysvbfs.h was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.6.28.3 11-Aug-2010  yamt sync with head.
 1.6.28.2 04-May-2009  yamt sync with head.
 1.6.28.1 16-May-2008  yamt sync with head.
 1.6.26.1 18-May-2008  yamt sync with head.
 1.6.24.2 28-Sep-2008  mjf Sync with HEAD.
 1.6.24.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.6.1 19-Oct-2008  haad Sync with HEAD.
 1.7.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.16.1 30-May-2010  rmind sync with head
 1.8.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.36.1 06-Apr-2015  skrll Sync with HEAD
 1.9.18.1 03-Dec-2017  jdolecek update from HEAD
 1.1 04-Sep-2008  pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.18;
Install sysvbfs argument structure header into userlandia.
 1.1.18.2 04-May-2009  yamt sync with head.
 1.1.18.1 04-Sep-2008  yamt file sysvbfs_args.h was added on branch yamt-nfs-mp on 2009-05-04 08:13:44 +0000
 1.1.6.2 19-Oct-2008  haad Sync with HEAD.
 1.1.6.1 04-Sep-2008  haad file sysvbfs_args.h was added on branch haad-dm on 2008-10-19 22:17:18 +0000
 1.1.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.4.1 04-Sep-2008  mjf file sysvbfs_args.h was added on branch mjf-devfs2 on 2008-09-28 10:40:50 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 04-Sep-2008  wrstuden file sysvbfs_args.h was added on branch wrstuden-revivesa on 2008-09-18 04:36:55 +0000
 1.48 03-May-2022  hannken Lock devvp for kauth KAUTH_REQ_SYSTEM_MOUNT_DEVICE.
 1.47 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.46 02-Jan-2015  hannken branches: 1.46.2; 1.46.8; 1.46.18; 1.46.24;
Add forgotten memset() to clear sysvbfs nodes before setting them up.
 1.45 26-Dec-2014  hannken Change sysvbfs to vcache.
 1.44 07-Dec-2014  justin Simplify control flow

Removes a variable and compiler warnings in some cases.
 1.43 16-Apr-2014  maxv branches: 1.43.4;
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.42 25-Dec-2013  mlelstv branches: 1.42.2;
At least fetch mount data pointer before using it.
Coverity CID 274767
 1.41 14-Jun-2012  agc branches: 1.41.2; 1.41.4;
calculate inode capacities using the correct values
 1.40 13-Jun-2012  joerg Ensure that error is initialized in all code paths.
 1.39 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.38 13-Nov-2011  christos branches: 1.38.4; 1.38.6;
remove unused call to DIOCGPART that was only used for debugging.
malloc M_WAITOK, does not fail.
 1.37 13-Jul-2011  njoly branches: 1.37.2;
Add function name to a few debug messages.
 1.36 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.35 25-Jul-2010  hannken branches: 1.35.6;
It makes no sense to call vget() with LK_RETRY.
 1.34 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.33 07-Jul-2010  njoly Do set f_namemax at mount, to provide sensible value for statvfs(2)
calls.
 1.32 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.31 01-Dec-2009  pooka branches: 1.31.2; 1.31.4;
Call VOP_CLOSE() in mount error branch with the device locked to
prevent crash when specfs attempts to unlock the vnode.
 1.30 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.29 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.28 09-Apr-2009  pooka * create only one vnode per inode
* add locking
 1.27 09-Apr-2009  pooka VOP_CLOSE in error branches
 1.26 04-Sep-2008  pooka branches: 1.26.2; 1.26.4; 1.26.8; 1.26.14; 1.26.18;
Actually, use FWRITE for device open only if we aren't doing MNT_RDONLY.
This still allows to mount read-only images with -o ro.
 1.25 04-Sep-2008  pooka Open devvp for both reading and writing.
 1.24 30-Apr-2008  ad branches: 1.24.2; 1.24.6;
Make various bits of debug code compile again.
 1.23 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.22 24-Jan-2008  ad branches: 1.22.6; 1.22.8; 1.22.10;
specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.21 02-Jan-2008  ad Merge vmlocking2 to head.
 1.20 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.19 08-Dec-2007  pooka branches: 1.19.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.18 26-Nov-2007  pooka branches: 1.18.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.17 10-Oct-2007  ad branches: 1.17.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.16 08-Sep-2007  rumble branches: 1.16.2;
Don't explicitly set vp->v_size and then call uvm_vnp_setsize(). This is
not only unnecessary, but trips a kernel assertion introduced in r1.85 of
uvm/uvm_vnode.c.
 1.15 31-Jul-2007  pooka branches: 1.15.2; 1.15.4; 1.15.6;
* 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.14 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.13 17-Jul-2007  pooka branches: 1.13.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.12 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.11 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.10 28-Jun-2007  tsutsui Fix mnt_dev_bshift value. Pointed out by rumble@.

I'm not sure how mnt_dev_bshift is used and
whether BFS_BSHIFT is correct for it, but as rumble
said shifting BFS_BSIZE (==512) seems completly wrong.
 1.9 20-Mar-2007  tsutsui Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.8 21-Feb-2007  thorpej branches: 1.8.4; 1.8.6; 1.8.8;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.7 04-Jan-2007  elad branches: 1.7.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.6 23-Jul-2006  ad branches: 1.6.4;
Use the LWP cached credentials where sane.
 1.5 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.4 15-May-2006  yamt branches: 1.4.4; 1.4.6;
include kauth.h for NOCRED.
 1.3 14-May-2006  elad integrate kauth.
 1.2 25-Feb-2006  wiz branches: 1.2.2; 1.2.4; 1.2.6;
Fix some typos.
 1.1 29-Dec-2005  tsutsui branches: 1.1.2; 1.1.4; 1.1.6;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.6.2 01-Jun-2006  kardel Sync with head.
 1.1.6.1 22-Apr-2006  simonb Sync with head.
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.1.2.1 01-Mar-2006  yamt sync with head.
 1.2.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.2.2.2 11-Aug-2006  yamt sync with head
 1.2.2.1 24-May-2006  yamt sync with head.
 1.4.6.9 04-Feb-2008  yamt sync with head.
 1.4.6.8 21-Jan-2008  yamt sync with head
 1.4.6.7 07-Dec-2007  yamt sync with head
 1.4.6.6 27-Oct-2007  yamt sync with head.
 1.4.6.5 03-Sep-2007  yamt sync with head.
 1.4.6.4 26-Feb-2007  yamt sync with head.
 1.4.6.3 30-Dec-2006  yamt sync with head.
 1.4.6.2 21-Jun-2006  yamt sync with head.
 1.4.6.1 15-May-2006  yamt file sysvbfs_vfsops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.4.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.4.1 12-Jan-2007  ad Sync with head.
 1.7.2.2 24-Mar-2007  yamt sync with head.
 1.7.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.8.1 29-Mar-2007  reinoud Pullup to -current
 1.8.6.1 11-Jul-2007  mjf Sync with head.
 1.8.4.6 09-Oct-2007  ad Sync with head.
 1.8.4.5 20-Aug-2007  ad Sync with HEAD.
 1.8.4.4 15-Jul-2007  ad Sync with head.
 1.8.4.3 15-Jul-2007  ad Sync with head.
 1.8.4.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.8.4.1 10-Apr-2007  ad Sync with head.
 1.13.2.2 10-Sep-2007  skrll Sync with HEAD.
 1.13.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.15.6.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.15.6.1 31-Jul-2007  pooka file sysvbfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.15.4.3 23-Mar-2008  matt sync with HEAD
 1.15.4.2 09-Jan-2008  matt sync with HEAD
 1.15.4.1 06-Nov-2007  matt sync with HEAD
 1.15.2.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.2.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.15.2.2 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.15.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.16.2.1 14-Oct-2007  yamt sync with head.
 1.17.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.17.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.17.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.18.2.2 26-Dec-2007  ad Sync with head.
 1.18.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.19.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.22.10.5 11-Aug-2010  yamt sync with head.
 1.22.10.4 11-Mar-2010  yamt sync with head
 1.22.10.3 18-Jul-2009  yamt sync with head.
 1.22.10.2 04-May-2009  yamt sync with head.
 1.22.10.1 16-May-2008  yamt sync with head.
 1.22.8.1 18-May-2008  yamt sync with head.
 1.22.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.22.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.6.1 19-Oct-2008  haad Sync with HEAD.
 1.24.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.26.18.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.26.14.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.26.8.2 23-Jul-2009  jym Sync with HEAD.
 1.26.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.4.1 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.26.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.31.4.4 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.31.4.3 05-Mar-2011  rmind sync with head
 1.31.4.2 03-Jul-2010  rmind sync with head
 1.31.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.31.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.35.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.37.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.37.2.2 30-Oct-2012  yamt sync with head
 1.37.2.1 17-Apr-2012  yamt sync with head
 1.38.6.2 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.38.6.1 24-Jun-2012  jdc branches: 1.38.6.1.4; 1.38.6.1.6;
Pull up revisions:
src/sys/fs/hfs/hfs_vfsops.c revision 1.29
src/sys/fs/sysvbfs/sysvbfs_vfsops.c revision 1.40
src/sys/fs/v7fs/v7fs_vfsops.c revision 1.7
(requested by joerg in ticket #344).
 1.38.6.1.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.38.6.1.4.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.38.4.1 05-Apr-2012  mrg sync to latest -current.
 1.41.4.1 18-May-2014  rmind sync with head
 1.41.2.2 03-Dec-2017  jdolecek update from HEAD
 1.41.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.2.1 10-Aug-2014  tls Rebase.
 1.43.4.1 06-Apr-2015  skrll Sync with HEAD
 1.46.24.1 17-Jan-2020  ad Sync with head.
 1.46.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.46.8.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.46.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.69 31-Jul-2022  mlelstv Don't panic for a negative offset, just fail the operation with EINVAL.
 1.68 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.67 27-Jun-2020  christos Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.66 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.65 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.64 17-Jan-2020  ad branches: 1.64.4;
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.63 26-May-2017  riastradh branches: 1.63.10; 1.63.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.62 26-Apr-2017  riastradh 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.61 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.60 20-Aug-2016  hannken branches: 1.60.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.59 13-Nov-2015  pooka branches: 1.59.2;
Fix bug in readdir loop condition.

Reading all dirents using a small buffer and multiple calls now works.

Bug found by "Shamar" on #rumpkernel
 1.58 04-Apr-2015  riastradh Make sure err is initialized.
 1.57 04-Apr-2015  riastradh Fix remaining read(fd, NULL, 1) cases.
 1.56 26-Dec-2014  hannken Change sysvbfs to vcache.
 1.55 26-Dec-2014  hannken Sysvbfs_rename: Call bfs_file_delete(bfs, to_name, true) before calling
bfs_file_rename() and remove the bfs_file_delete() from bfs_file_rename().

After calling bfs_file_rename() it was too late to set "tnode->removed"
as the inode already disappeared.
 1.54 08-Aug-2014  gson branches: 1.54.4;
Whitespace fix
 1.53 07-Feb-2014  hannken branches: 1.53.2;
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.52 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.51 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.50 09-Jan-2014  hannken Operation sysvbfs_remove() destructs inodes attached to active vnodes.
Defer the destruction to sysvbfs_reclaim().

Disable test t_renamerace:sysvbfs_renamerace as it will exhaust the
inode table (sysvbfs has space for 8 inodes only).

Ok: Izumi Tsutsui <tsutsui@netbsd.org>
 1.49 24-Dec-2013  hannken It is not the task of sysvbfs_open() to check for unlinked nodes.
 1.48 15-May-2013  pooka branches: 1.48.2;
Don't change a read-only file system.
 1.47 18-Mar-2013  plunky C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.46 11-Jun-2012  agc branches: 1.46.2;
cosmetic change: fix two casts to be of the appropriate type
 1.45 08-May-2012  tsutsui Move bfs_file_setsize() from bfs.c to sysvbfs_vnops.c
(and rename it to sysvbfs_file_setsize()) because it's actually
part of vnode ops and bfs.c is also pulled by standalone bootloaders
which don't want vnode header mess.
 1.44 29-Apr-2012  chs change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.43 30-Mar-2012  njoly sysvbfs do not support file flags; fail with EOPNOTSUPP.
 1.42 18-Mar-2012  christos handle file resizing.
 1.41 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.40 27-Jan-2012  njoly branches: 1.40.2;
Check credentials when setting uid, gid or mode attributes.
 1.39 12-Dec-2011  njoly Start making fs read(2) fail with EISDIR if the implementation does
not allow read on directories (kernfs, rumpfs, ptyfs and sysvbfs).
Adjust man page accordingly, and add a small corresponding vfs
testcase.
 1.38 19-May-2011  rmind branches: 1.38.4; 1.38.8;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.37 26-Apr-2011  hannken Change vflushbuf() to return an error if a synchronous write fails.

Welcome to 5.99.51.
 1.36 31-Jan-2011  njoly In sysvbfs_lookup(), deny last component write operation on a
read-only mount.
Fix PR/44302: sysvbfs allows unlink on fs mounted MNT_RDONLY.

Reviewed by pooka.
 1.35 30-Nov-2010  dholland branches: 1.35.2; 1.35.4;
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.34 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.33 17-Jul-2010  njoly Fix build with SYSVBFS_VNOPS_DEBUG.
 1.32 16-Jul-2010  njoly Small typo in comment.
 1.31 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.30 27-May-2010  pooka Mark files removed in the in-memory structure. This allows us
to do two things:

1) properly set "recycle?" in inactive
2) easily check if we are renaming a removed vnode. without the
check, it was possible to enter a dirent in the file system for
a removed (and hence scheduled to be vcleaned) vnode. this would
lead to the succesful vget() of a clean vnode. the use of the
cleaned vnode was, however, less succesful, except for purposes
of crashing.
 1.29 27-May-2010  pooka Release pathname buffers after use.
 1.28 26-May-2010  pooka fix refcounting
 1.27 26-May-2010  pooka Initialize *vpp to NULL: relookup() requires it without initializing
the value before the call (yea, changing relookup would probably
be smart, but other file systems already initialize vpp, so I'm
letting someone else experiment with tylenol od).
 1.26 08-Jan-2010  pooka branches: 1.26.2; 1.26.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.25 05-Jan-2010  mbalmer Remove extra semicolons.
 1.24 03-Jul-2009  pgoyette Define error before using it.

(Hello again, elad!)
 1.23 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.22 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.21 26-Nov-2008  pooka branches: 1.21.4;
Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.20 16-Nov-2008  pooka more <sys/buf.h> police
 1.19 30-Apr-2008  ad branches: 1.19.6; 1.19.8;
Make various bits of debug code compile again.
 1.18 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.17 02-Jan-2008  ad branches: 1.17.6; 1.17.8; 1.17.10;
Merge vmlocking2 to head.
 1.16 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.15 26-Nov-2007  pooka branches: 1.15.2; 1.15.6;
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.14 24-Sep-2007  rumble branches: 1.14.4;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.13 29-Jul-2007  ad branches: 1.13.4; 1.13.6; 1.13.8; 1.13.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.12 30-Jun-2007  pooka branches: 1.12.2;
Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.11 22-Feb-2007  thorpej branches: 1.11.4; 1.11.6;
TRUE -> true, FALSE -> false
 1.10 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.9 20-Feb-2007  ad Call genfs_node_destroy() where appropriate.
 1.8 29-Jan-2007  hubertf branches: 1.8.2;
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.7 25-Dec-2006  wiz Spell "algorithm" correctly. From Zafer Aydogan.
 1.6 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.5 01-Jul-2006  martin branches: 1.5.4; 1.5.6; 1.5.8;
Redo previous differently - just use time_second.
Pointed out by Frank Kardel.
 1.4 01-Jul-2006  martin Make it compile post time-counter merge
 1.3 15-May-2006  yamt branches: 1.3.4; 1.3.6;
don't try to dereference kauth_cred_t.
 1.2 14-May-2006  elad integrate kauth.
 1.1 29-Dec-2005  tsutsui branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add preliminary support for System V Boot File System.
Written by UCHIYAMA Yasushi <uch@netbsd>.
 1.1.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.1.8.2 11-Aug-2006  yamt sync with head
 1.1.8.1 24-May-2006  yamt sync with head.
 1.1.6.1 01-Jun-2006  kardel Sync with head.
 1.1.4.1 09-Sep-2006  rpaulo sync with head
 1.3.6.8 21-Jan-2008  yamt sync with head
 1.3.6.7 07-Dec-2007  yamt sync with head
 1.3.6.6 27-Oct-2007  yamt sync with head.
 1.3.6.5 03-Sep-2007  yamt sync with head.
 1.3.6.4 26-Feb-2007  yamt sync with head.
 1.3.6.3 30-Dec-2006  yamt sync with head.
 1.3.6.2 21-Jun-2006  yamt sync with head.
 1.3.6.1 15-May-2006  yamt file sysvbfs_vnops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:30 +0000
 1.3.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.8.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.5.6.1 10-Dec-2006  yamt sync with head.
 1.5.4.2 01-Feb-2007  ad Sync with head.
 1.5.4.1 12-Jan-2007  ad Sync with head.
 1.8.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.11.6.1 11-Jul-2007  mjf Sync with head.
 1.11.4.5 09-Oct-2007  ad Sync with head.
 1.11.4.4 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.11.4.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.11.4.2 15-Jul-2007  ad Sync with head.
 1.11.4.1 15-Jul-2007  ad Sync with head.
 1.12.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.13.10.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.13.10.1 29-Jul-2007  ad file sysvbfs_vnops.c was added on branch matt-mips64 on 2007-07-29 13:31:11 +0000
 1.13.8.1 06-Oct-2007  yamt sync with head.
 1.13.6.2 09-Jan-2008  matt sync with HEAD
 1.13.6.1 06-Nov-2007  matt sync with HEAD
 1.13.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.13.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.14.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.14.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.14.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.2.3 26-Dec-2007  ad Sync with head.
 1.15.2.2 08-Dec-2007  ad Sync with head.
 1.15.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.17.10.5 11-Aug-2010  yamt sync with head.
 1.17.10.4 11-Mar-2010  yamt sync with head
 1.17.10.3 18-Jul-2009  yamt sync with head.
 1.17.10.2 04-May-2009  yamt sync with head.
 1.17.10.1 16-May-2008  yamt sync with head.
 1.17.8.1 18-May-2008  yamt sync with head.
 1.17.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.21.4.1 23-Jul-2009  jym Sync with HEAD.
 1.26.4.4 31-May-2011  rmind sync with head
 1.26.4.3 05-Mar-2011  rmind sync with head
 1.26.4.2 03-Jul-2010  rmind sync with head
 1.26.4.1 30-May-2010  rmind sync with head
 1.26.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.35.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.35.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.8.3 02-Jun-2012  mrg sync to latest -current.
 1.38.8.2 05-Apr-2012  mrg sync to latest -current.
 1.38.8.1 18-Feb-2012  mrg merge to -current.
 1.38.4.4 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.38.4.3 30-Oct-2012  yamt sync with head
 1.38.4.2 23-May-2012  yamt sync with head.
 1.38.4.1 17-Apr-2012  yamt sync with head
 1.40.2.1 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.46.2.3 03-Dec-2017  jdolecek update from HEAD
 1.46.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.2.1 23-Jun-2013  tls resync from head
 1.48.2.1 18-May-2014  rmind sync with head
 1.53.2.1 10-Aug-2014  tls Rebase.
 1.54.4.4 28-Aug-2017  skrll Sync with HEAD
 1.54.4.3 05-Oct-2016  skrll Sync with HEAD
 1.54.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.54.4.1 06-Apr-2015  skrll Sync with HEAD
 1.59.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.60.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.63.16.1 17-Jan-2020  ad Sync with head.
 1.63.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.64.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.1 28-Jul-2008  pooka branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.20;
Install mount argument structure header just like every other file system.
 1.1.20.2 04-May-2009  yamt sync with head.
 1.1.20.1 28-Jul-2008  yamt file Makefile was added on branch yamt-nfs-mp on 2009-05-04 08:13:44 +0000
 1.1.8.2 19-Oct-2008  haad Sync with HEAD.
 1.1.8.1 28-Jul-2008  haad file Makefile was added on branch haad-dm on 2008-10-19 22:17:18 +0000
 1.1.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.1 28-Jul-2008  mjf file Makefile was added on branch mjf-devfs2 on 2008-09-28 10:40:50 +0000
 1.1.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.4.1 28-Jul-2008  wrstuden file Makefile was added on branch wrstuden-revivesa on 2008-09-18 04:36:55 +0000
 1.1.2.2 28-Jul-2008  simonb Sync with head.
 1.1.2.1 28-Jul-2008  simonb file Makefile was added on branch simonb-wapbl on 2008-07-28 14:37:35 +0000
 1.8 20-Apr-2015  riastradh Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.7 22-Jun-2010  rmind branches: 1.7.18; 1.7.36;
Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.6 09-Nov-2006  jmmv branches: 1.6.52; 1.6.74; 1.6.76;
Audit kqueue notifications. The reference behavior is taken from MFS and
is represented in the regression tests.
 1.5 05-Nov-2006  jmmv Exporting tmpfs file systems through NFS now works. Sure, file handles are
not persistent across reboots but neither are those of MFS, which we are
trying to replace. We should probably warn the user somehow, but not
prevent him doing this if he really wants to.

While here add a "reply" to the code-style change item.
 1.4 05-Nov-2006  jdolecek add one code style and one knote-related item
 1.3 23-Sep-2005  jmmv branches: 1.3.6; 1.3.26; 1.3.30; 1.3.32;
Synchronize NFS status with reality. After yamt@ changes (I think with the
implementation of getpages and putpages and the use of UBC in the read and
write operations), the worst problem has gone away which was a panic when
a file's contents were modified in the original file system and then read
through the NFS mount point.

Also remove the entry about optimization. While tmpfs still has room for
improvement, it has become a lot better lately, thanks to the string pools
and the changes yamt@ did in the anonymous objects handling.
 1.2 23-Sep-2005  wiz Fix typo, add missing parenthesis.
 1.1 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.3.32.1 10-Dec-2006  yamt sync with head.
 1.3.30.1 18-Nov-2006  ad Sync with head.
 1.3.26.3 30-Dec-2006  yamt sync with head.
 1.3.26.2 21-Jun-2006  yamt sync with head.
 1.3.26.1 23-Sep-2005  yamt file TODO was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 23-Sep-2005  skrll file TODO was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.6.76.1 03-Jul-2010  rmind sync with head
 1.6.74.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.52.1 11-Aug-2010  yamt sync with head.
 1.7.36.1 06-Jun-2015  skrll Sync with HEAD
 1.7.18.1 03-Dec-2017  jdolecek update from HEAD
 1.6 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.5 09-May-2012  riastradh branches: 1.5.2;
Adapt tmpfs_rename to use genfs_rename.
 1.4 22-Jun-2010  rmind branches: 1.4.8; 1.4.12;
Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.3 02-Mar-2010  pooka branches: 1.3.2;
Don't generate unused fs_thefs.h headers.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.76; 1.2.98;
merge ktrace-lwp.
 1.1 10-Sep-2005  jmmv branches: 1.1.6;
Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Sep-2005  skrll file files.tmpfs was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.2.98.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.98.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.76.2 11-Aug-2010  yamt sync with head.
 1.2.76.1 11-Mar-2010  yamt sync with head
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file files.tmpfs was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.3.2.1 03-Jul-2010  rmind sync with head
 1.4.12.1 02-Jun-2012  mrg sync to latest -current.
 1.4.8.1 23-May-2012  yamt sync with head.
 1.5.2.1 03-Dec-2017  jdolecek update from HEAD
 1.56 17-May-2020  ad PR kern/55268: tmpfs is slow

tmpfs_getpages(): handle the PGO_LOCKED case and implement lazy update of
atime/mtime.
 1.55 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.54 01-Mar-2017  hannken branches: 1.54.12;
Change the protocol to update a mounted file system from read-write
to read-only and vice versa:

- Add an internal flag IMNT_WANTRDONLY.
- Set either IMNT_WANTRDWR or IMNT_WANTRDONLY if going from or to read-only.
- After successfull call to VFS_MOUNT() set or clear MNT_RDONLY.

Adapt tmpfs and rumpfs to the new protocol. Other file systems will be
updated when they get the IMNT_CAN_RWTORO property.

Welcome to 7.99.64
 1.53 27-Jan-2017  hannken Run vflush() when going from read/write to read only.
 1.52 06-Jul-2015  hannken branches: 1.52.2; 1.52.4;
Change tmpfs to vcache.
- Use tmpfs node address as key.
- Remove tn_vlock, field tn_vnode now protected by vcache.
- Add a hold count to tmpfs node to prevent nodes from disappearing
while tmpfs_fhtovp() trys to vcache_get() them. Last holder
destroys reclaimed nodes.
- Remove the now unneeded parent unlock/lock for lookup of '..'.
 1.51 06-Jul-2015  hannken Use VFS_PROTOS() for tmpfs.
 1.50 07-Jun-2014  martin branches: 1.50.4;
Remove the hardcoded 4 MB free kernel memory limit and replace it
by uvmexp.freetarg, as discussed on tech-kern.
Main purpose is to make tmpfs usable (as far as possible) on small memory
machines.
This is a bit experimental, but we need to give it some real world exposure
to see how well it works.
 1.49 30-Apr-2014  christos handle MNT_UPDATE
 1.48 23-Nov-2013  rmind branches: 1.48.2;
- Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.47 18-Nov-2013  rmind Make tmpfs_node_t::tn_gen a 32-bit number, keep it in sync with tmpfs_fid_t.
Also, change tn_status to unsigned while here.
 1.46 08-Nov-2013  rmind tmpfs: replace the broken tmpfs_dircookie() logic which uses the node
address truncated to 31 bits (required for 32-bit readdir compatibility,
e.g. linux32). Instead, assign 2^31 range using the following logic:
- The first half of the 2^31 is assigned incrementally (the fast path).
- When exceeded, use the second half of 2^31, but manage with vmem(9).

It will require 2 billion files per-directory to trigger vmem(9) usage.
Also, while here, add some fixes for tmpfs_unmount().

Should fix PR/47739, PR/47480, PR/46088 and PR/41068.
Thanks to wiz@ for stress testing.
 1.45 27-Sep-2011  christos branches: 1.45.2; 1.45.12; 1.45.16;
define and use TMPFS_MAXNAMLEN instead of MAXNAMLEN
 1.44 29-May-2011  rmind - Rework and document inode reference counting. Also document inode life
cycle (destruction part). Perform link counting in tmpfs_dir_attach()
and tmpfs_dir_detach(), instead of alloc/free and arbitrary places.
Fixes PR/44285, PR/44288, PR/44657 and likely PR/42484.

- Fix the race between the lookup and inode destruction. Fixes PR/43167
and its duplicates PR/40088, PR/40757.

- Improve tmpfs_rename() locking a little, fix kqueue event notifications
and also fix PR/43617. Add simplistic tmpfs_parentcheck_p(); to be
expanded and used for further rename() locking fixes.

- Cache directory entry "hint" in the tmpfs node, add tmpfs_dir_cached(),
and thus avoid unnecessary lookup in tmpfs_remove() and tmpfs_rmdir().

- Set correct _PC_FILESIZEBITS value in tmpfs_pathconf(). Fixes PR/43576.

- Few minor fixes.
 1.43 29-May-2011  christos undo the multiple inclusion protection part.
 1.42 29-May-2011  rmind - Prevent tmpfs.h from inclusion in userland.
- Clean up and KNF tmpfs.h a little bit.
 1.41 24-May-2011  rmind - Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.40 19-May-2011  rmind - tmpfs: do not create dirent/node pools per-mount, there is no need to.
- tmpfs_mount: fix a leak of mount structures in error path.
 1.39 13-Jan-2011  pooka branches: 1.39.2;
Add some support for unionfs (not built by default). It's still
missing at least opaque directory support, but until someone figures
out how that should work on ffs (see PR kern/kern/44383), there's
no point in trying to figure out how it should work here.
 1.38 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.37 29-Jul-2008  pooka branches: 1.37.14; 1.37.16;
Solve the fstat-wants-to-look-at-kernel-data-structures in a nicer
way: don't export the fs internals to innocent userspace programs
which just want to mount the file system.
 1.36 28-Jul-2008  pooka shuffle around some more defs for fstat

noticed by Kurt Schreiner on current-users
 1.35 28-Jul-2008  pooka Install mount argument structure header just like every other file system.
 1.34 19-Jun-2008  christos branches: 1.34.2;
- setting the birthdate is valid in setattr.
- don't call nanotime if not needed.
- don't call tempfs_update() if tempfs_chtimes succeeded, because it just did.
 1.33 28-Apr-2008  martin branches: 1.33.2; 1.33.4;
Remove clause 3 and 4 from TNF licenses
 1.32 06-Feb-2008  jmmv branches: 1.32.6; 1.32.8; 1.32.10;
u_int is not a C99 standard type, so spell it out completely as
unsigned int.
 1.31 06-Feb-2008  jmmv Drop trailing whitespace.
 1.30 02-Jan-2008  ad Merge vmlocking2 to head.
 1.29 08-Dec-2007  pooka branches: 1.29.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.28 10-Nov-2007  ad branches: 1.28.2;
Back out the tmpfs changes; there appears to be a bug lurking.
 1.27 06-Nov-2007  ad Merge from vmlocking.
 1.26 22-Feb-2007  thorpej branches: 1.26.4; 1.26.16; 1.26.18; 1.26.24;
TRUE -> true, FALSE -> false
 1.25 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.24 13-Nov-2006  jmmv branches: 1.24.4;
Fix typo in comment.
 1.23 05-Nov-2006  jmmv Protect the dircookie stuff with _KERNEL. Fixes build problems of
mount_tmpfs as reported by Hisashi T Fujinaka in private mail.
 1.22 05-Nov-2006  jmmv Truncate directory cookies to 31 bits to avoid problems exposed in Linux
binaries which cast the returned values to 64-bits and fail due to sign
expansion. More details are provided in the big comment in tmpfs.h that
describes how the new tmpfs_dircookie works.

This is a rather ugly hack that shall be fixed with a cleaner solution,
but this resolves the problem in an effective way.

Fixes kern PR/32034.
 1.21 23-Jul-2006  ad branches: 1.21.4; 1.21.6;
Use the LWP cached credentials where sane.
 1.20 27-May-2006  yamt branches: 1.20.4;
hide more by ifdef _KERNEL.
 1.19 14-May-2006  elad branches: 1.19.2;
integrate kauth.
 1.18 31-Mar-2006  riz Swap the order of the tf_gen and tf_id members of struct tmpfs_fid,
since tf_id needs 8-byte alignment on some architectures (like amd64).
struct tmpfs_fid now fits in 16 bytes on amd64 again.
OK matt@
 1.17 26-Mar-2006  martin Restrict generation numbers to 32bit values - we would have had to bump
_VFS_MAXFIDSZ to 24 otherwise for 64bit archs.
 1.16 16-Feb-2006  perry branches: 1.16.2; 1.16.4; 1.16.6;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.15 16-Feb-2006  jmmv Do not use unnamed structures/unions without instances; they break the
build under vax because of gcc 2.95. Found by he@.
 1.14 10-Feb-2006  christos make the include files usable from userland.
 1.13 24-Dec-2005  jmmv branches: 1.13.2; 1.13.4; 1.13.6;
Remove a conditional by always using inlined functions in favour of macros.
This way, the code is clearer and there shouldn't be any performance
difference (if the compiler DTRT). Suggested by chs@.
 1.12 11-Dec-2005  christos merge ktrace-lwp.
 1.11 06-Dec-2005  yamt VFS_TO_TMPFS: remove a wrong assertion.
it's wrong because TMPFS_PAGES_MAX can be decreased.
 1.10 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.9 02-Nov-2005  yamt branches: 1.9.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.8 29-Sep-2005  jmmv branches: 1.8.2;
Implement the tmpfs_advlock operation. Makes "user-level" file locking
work (aka lockf(3)).
 1.7 28-Sep-2005  yamt tmpfs_getattr: return up-to-date timestamps.
 1.6 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.5 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.4 15-Sep-2005  yamt change the way to handle directory "offsets" so that
they won't be changed when removing entries in the directory.
some applications like cvs rely on this.
 1.3 13-Sep-2005  yamt - don't waste/leak kva.
- implement getpages/putpages. support mmap.
- eliminate meaningless memcpy.
- ubcify.
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.8.2.2 29-Oct-2005  yamt as tmpfs_update never fails, make it return void.
suggested by Chuck Silvers.
 1.8.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.9.2.4 11-Dec-2005  christos Sync with head.
 1.9.2.3 12-Nov-2005  skrll Adapt to branch
 1.9.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.1 02-Nov-2005  skrll file tmpfs.h was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.13.6.2 01-Jun-2006  kardel Sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 18-Feb-2006  yamt sync with head.
 1.16.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.6.1 28-Mar-2006  tron Merge 2006-03-28 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.4 11-Aug-2006  yamt sync with head
 1.16.2.3 26-Jun-2006  yamt sync with head.
 1.16.2.2 24-May-2006  yamt sync with head.
 1.16.2.1 01-Apr-2006  yamt sync with head.
 1.19.2.1 19-Jun-2006  chap Sync with head.
 1.20.4.6 11-Feb-2008  yamt sync with head.
 1.20.4.5 21-Jan-2008  yamt sync with head
 1.20.4.4 26-Feb-2007  yamt sync with head.
 1.20.4.3 30-Dec-2006  yamt sync with head.
 1.20.4.2 21-Jun-2006  yamt sync with head.
 1.20.4.1 27-May-2006  yamt file tmpfs.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.21.6.1 10-Dec-2006  yamt sync with head.
 1.21.4.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.26.24.3 18-Feb-2008  mjf Sync with HEAD.
 1.26.24.2 27-Dec-2007  mjf Sync with HEAD.
 1.26.24.1 19-Nov-2007  mjf Sync with HEAD.
 1.26.18.3 23-Mar-2008  matt sync with HEAD
 1.26.18.2 09-Jan-2008  matt sync with HEAD
 1.26.18.1 08-Nov-2007  matt sync with -HEAD
 1.26.16.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.26.16.2 11-Nov-2007  joerg Sync with HEAD.
 1.26.16.1 06-Nov-2007  joerg Sync with HEAD.
 1.26.4.2 08-Oct-2007  ad - Don't leave nodes dangling in order to keep track of the inode generation
number. Free them back to the pool as soon as the referenced file becomes
unused. Using arc4random() for the generation and ino_t based off the
node's in-core address is just about as as good as a disk-based file
system is going to give.
- Add assertion to catch empty directories with linkcount > 1 being freed.
This fires frequently but I haven't tracked the bug down yet..
- Use kmem_alloc.
 1.26.4.1 21-Aug-2007  ad - Add locking around tmpfs shared data structures and mark it MP safe.
It's enough to last for about 45m of fsx+postmark, but it doesn't
survive SGI fsstress yet.
- Close a race where multiple vnodes could maybe have been allocated
for a tmpnode with linkcount > 1.
 1.28.2.6 26-Dec-2007  ad Sync with head.
 1.28.2.5 15-Dec-2007  ad Fix accounting problem that allowed a tmpfs to be filled beyond its limit
when running multithreaded.
 1.28.2.4 13-Dec-2007  ad Kill tn_lookup_dirent and find the correct node using the supplied
componentname.
 1.28.2.3 12-Dec-2007  ad - Don't use LK_RETRY in tmpfs_alloc_vp().
- Reduce cosmetic diffs to head.
 1.28.2.2 08-Dec-2007  ad Reduce coverage of the per-mount lock by using atomic ops.
 1.28.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.32.10.3 11-Aug-2010  yamt sync with head.
 1.32.10.2 04-May-2009  yamt sync with head.
 1.32.10.1 16-May-2008  yamt sync with head.
 1.32.8.1 18-May-2008  yamt sync with head.
 1.32.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.32.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.32.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.4.4 31-Jul-2008  simonb Sync with head.
 1.33.4.3 29-Jul-2008  simonb Sync with head.
 1.33.4.2 28-Jul-2008  simonb Sync with head.
 1.33.4.1 27-Jun-2008  simonb Sync with head.
 1.33.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.34.2.1 19-Oct-2008  haad Sync with HEAD.
 1.37.16.3 31-May-2011  rmind sync with head
 1.37.16.2 05-Mar-2011  rmind sync with head
 1.37.16.1 03-Jul-2010  rmind sync with head
 1.37.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.39.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.16.1 18-May-2014  rmind sync with head
 1.45.12.2 03-Dec-2017  jdolecek update from HEAD
 1.45.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.45.2.1 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.48.2.1 10-Aug-2014  tls Rebase.
 1.50.4.3 28-Aug-2017  skrll Sync with HEAD
 1.50.4.2 05-Feb-2017  skrll Sync with HEAD
 1.50.4.1 22-Sep-2015  skrll Sync with HEAD
 1.52.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.52.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.54.12.1 22-Apr-2018  pgoyette Sync with HEAD
 1.3 29-Jul-2008  pooka branches: 1.3.2; 1.3.4; 1.3.6; 1.3.18;
Solve the fstat-wants-to-look-at-kernel-data-structures in a nicer
way: don't export the fs internals to innocent userspace programs
which just want to mount the file system.
 1.2 28-Jul-2008  pooka shuffle around some more defs for fstat

noticed by Kurt Schreiner on current-users
 1.1 28-Jul-2008  pooka branches: 1.1.2;
Install mount argument structure header just like every other file system.
 1.1.2.4 31-Jul-2008  simonb Sync with head.
 1.1.2.3 29-Jul-2008  simonb Sync with head.
 1.1.2.2 28-Jul-2008  simonb Sync with head.
 1.1.2.1 28-Jul-2008  simonb file tmpfs_args.h was added on branch simonb-wapbl on 2008-07-28 14:37:35 +0000
 1.3.18.2 04-May-2009  yamt sync with head.
 1.3.18.1 29-Jul-2008  yamt file tmpfs_args.h was added on branch yamt-nfs-mp on 2009-05-04 08:13:44 +0000
 1.3.6.2 19-Oct-2008  haad Sync with HEAD.
 1.3.6.1 29-Jul-2008  haad file tmpfs_args.h was added on branch haad-dm on 2008-10-19 22:17:18 +0000
 1.3.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.4.1 29-Jul-2008  mjf file tmpfs_args.h was added on branch mjf-devfs2 on 2008-09-28 10:40:50 +0000
 1.3.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1 29-Jul-2008  wrstuden file tmpfs_args.h was added on branch wrstuden-revivesa on 2008-09-18 04:36:55 +0000
 1.15 19-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 2; cvs randomly didn't commit these changes before, and then hid
them from me until I touched the files to force it to rethink. Dunno
what happened.

There's probably more of these, going to have to scan the tree the
hard way.
 1.14 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.13 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.12 16-May-2020  christos branches: 1.12.6;
Add ACL support for FFS. From FreeBSD.
 1.11 25-Jul-2014  dholland 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.10 23-Nov-2013  rmind branches: 1.10.2;
- Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.9 24-May-2011  rmind branches: 1.9.4; 1.9.14; 1.9.18;
- Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.8 19-Jun-2008  skd branches: 1.8.18; 1.8.24;
add arg so it will compile.
 1.7 28-Apr-2008  martin branches: 1.7.2; 1.7.4;
Remove clause 3 and 4 from TNF licenses
 1.6 25-Jan-2008  ad branches: 1.6.6; 1.6.8; 1.6.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.5 11-Dec-2005  christos branches: 1.5.18; 1.5.48; 1.5.54;
merge ktrace-lwp.
 1.4 02-Nov-2005  yamt branches: 1.4.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.3 23-Sep-2005  jmmv branches: 1.3.2;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.3.2.2 29-Oct-2005  yamt as tmpfs_update never fails, make it return void.
suggested by Chuck Silvers.
 1.3.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.4.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.1 02-Nov-2005  skrll file tmpfs_fifoops.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.5.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.48.1 23-Mar-2008  matt sync with HEAD
 1.5.18.3 04-Feb-2008  yamt sync with head.
 1.5.18.2 21-Jun-2006  yamt sync with head.
 1.5.18.1 11-Dec-2005  yamt file tmpfs_fifoops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.6.10.2 04-May-2009  yamt sync with head.
 1.6.10.1 16-May-2008  yamt sync with head.
 1.6.8.1 18-May-2008  yamt sync with head.
 1.6.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.6.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.4.1 27-Jun-2008  simonb Sync with head.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.18.1 31-May-2011  rmind sync with head
 1.9.18.1 18-May-2014  rmind sync with head
 1.9.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.4.1 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.10.2.1 10-Aug-2014  tls Rebase.
 1.12.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.9 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.8 24-May-2011  rmind branches: 1.8.72;
- Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.7 29-Mar-2010  pooka branches: 1.7.2;
Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.6 28-Apr-2008  martin branches: 1.6.20; 1.6.22;
Remove clause 3 and 4 from TNF licenses
 1.5 25-Jan-2008  ad branches: 1.5.6; 1.5.8; 1.5.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.4 03-Dec-2005  christos branches: 1.4.18; 1.4.48; 1.4.54;
- 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.3 02-Nov-2005  yamt branches: 1.3.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.2 23-Sep-2005  jmmv branches: 1.2.2;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.2.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.3.2.3 11-Dec-2005  christos Sync with head.
 1.3.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.1 02-Nov-2005  skrll file tmpfs_fifoops.h was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.4.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.48.1 23-Mar-2008  matt sync with HEAD
 1.4.18.3 04-Feb-2008  yamt sync with head.
 1.4.18.2 21-Jun-2006  yamt sync with head.
 1.4.18.1 03-Dec-2005  yamt file tmpfs_fifoops.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.5.10.2 11-Aug-2010  yamt sync with head.
 1.5.10.1 16-May-2008  yamt sync with head.
 1.5.8.1 18-May-2008  yamt sync with head.
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.22.2 31-May-2011  rmind sync with head
 1.6.22.1 30-May-2010  rmind sync with head
 1.6.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.72.1 01-Aug-2021  thorpej Sync with HEAD.
 1.14 29-Apr-2023  riastradh tmpfs: Nix trailing whitespace. No functional change intended.
 1.13 11-Jun-2020  ad uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched. It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
 1.12 31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.11 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.10 13-Jul-2019  maxv Remove the roundups, they are incorrect and cause memcmp to wrongfully fail
because of uninitialized bytes at the end of the buffers.

ok rmind@
 1.9 22-Aug-2016  skrll branches: 1.9.8; 1.9.16;
Two fixes from rmind

- tmpfs_node_get: restore (decrement) the node count on the error path.
- tmpfs_bytes_max: save the value of uvmexp.freetarg (since it is
unlocked/racy).
 1.8 13-Jun-2014  pooka branches: 1.8.4;
use psize_t for physical memory calculation
 1.7 10-Jun-2014  martin Make sure to expand "freepages" to 64bit before shifting to byte values -
on rump we may have all our virtual address space "free".
Pointed out by pooka@.
 1.6 07-Jun-2014  martin Remove the hardcoded 4 MB free kernel memory limit and replace it
by uvmexp.freetarg, as discussed on tech-kern.
Main purpose is to make tmpfs usable (as far as possible) on small memory
machines.
This is a bit experimental, but we need to give it some real world exposure
to see how well it works.
 1.5 30-Apr-2014  christos handle MNT_UPDATE
 1.4 24-May-2011  rmind branches: 1.4.4; 1.4.14; 1.4.18; 1.4.28;
- tmpfs_alloc_node/tmpfs_free_node: move inode limiting into tmpfs_node_get()
and tmpfs_node_put(), update outdated/wrong comments and move/add asserts.
- tmpfs_mount: check for the version of arguments a bit earlier.
 1.3 19-May-2011  rmind - tmpfs: do not create dirent/node pools per-mount, there is no need to.
- tmpfs_mount: fix a leak of mount structures in error path.
 1.2 28-Jun-2010  rmind branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
tmpfs_bytes_max: use MIN() rather than min(), which returns int.
Spotted by Wolfgang Solfrank.
 1.1 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.2.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.6.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.6.1 28-Jun-2010  uebayasi file tmpfs_mem.c was added on branch uebayasi-xip on 2010-08-17 06:47:21 +0000
 1.2.4.2 11-Aug-2010  yamt sync with head.
 1.2.4.1 28-Jun-2010  yamt file tmpfs_mem.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:36 +0000
 1.2.2.3 31-May-2011  rmind sync with head
 1.2.2.2 03-Jul-2010  rmind sync with head
 1.2.2.1 28-Jun-2010  rmind file tmpfs_mem.c was added on branch rmind-uvmplock on 2010-07-03 01:19:51 +0000
 1.4.28.1 10-Aug-2014  tls Rebase.
 1.4.18.1 18-May-2014  rmind sync with head
 1.4.14.2 03-Dec-2017  jdolecek update from HEAD
 1.4.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.4.1 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.8.4.1 05-Oct-2016  skrll Sync with HEAD
 1.9.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.9.8.1 04-Aug-2019  martin Pull up following revision(s) (requested by maxv in ticket #1321):

sys/fs/tmpfs/tmpfs_mem.c: revision 1.10

Remove the roundups, they are incorrect and cause memcmp to wrongfully fail
because of uninitialized bytes at the end of the buffers.

ok rmind@
 1.15 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.14 28-Apr-2008  martin branches: 1.14.20; 1.14.22;
Remove clause 3 and 4 from TNF licenses
 1.13 06-Feb-2008  jmmv branches: 1.13.6; 1.13.8; 1.13.10;
u_int is not a C99 standard type, so spell it out completely as
unsigned int.
 1.12 02-Jan-2008  ad Merge vmlocking2 to head.
 1.11 22-Nov-2007  pooka branches: 1.11.2; 1.11.6;
Don't KASSERT that the pool allocator returns a page - it might be
called with NOWAIT.

XXX: this is just a quick fix to stop the diagnostic panic. I
think ENOSPC should be treated elsewhere depending on how much
memory tmpfs claims.
 1.10 10-Nov-2007  ad Back out the tmpfs changes; there appears to be a bug lurking.
 1.9 06-Nov-2007  ad Merge from vmlocking.
 1.8 23-Oct-2007  dyoung branches: 1.8.2;
Put _tmpfs_ in the name of the pools instead of _pool_. Obviously
they're pools; it's not so obvious that they come from tmpfs. :-)
 1.7 12-Mar-2007  ad branches: 1.7.12; 1.7.14; 1.7.18;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.6 09-Nov-2006  jmmv branches: 1.6.2; 1.6.4; 1.6.8; 1.6.10;
Add 2006 to the copyright notice; should have done this when touching the
files before.
 1.5 03-Sep-2006  christos branches: 1.5.2; 1.5.4;
use c99 initializers
 1.4 11-Dec-2005  christos branches: 1.4.4; 1.4.8; 1.4.18;
merge ktrace-lwp.
 1.3 23-Sep-2005  jmmv branches: 1.3.6;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.2 12-Sep-2005  yamt - don't keep a reference to a variable on stack.
- remove a meaningless assumption about the order of structure members.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 23-Sep-2005  skrll file tmpfs_pool.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.4.18.8 11-Feb-2008  yamt sync with head.
 1.4.18.7 21-Jan-2008  yamt sync with head
 1.4.18.6 07-Dec-2007  yamt sync with head
 1.4.18.5 27-Oct-2007  yamt sync with head.
 1.4.18.4 03-Sep-2007  yamt sync with head.
 1.4.18.3 30-Dec-2006  yamt sync with head.
 1.4.18.2 21-Jun-2006  yamt sync with head.
 1.4.18.1 11-Dec-2005  yamt file tmpfs_pool.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.4.8.1 03-Sep-2006  yamt sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.4.1 10-Dec-2006  yamt sync with head.
 1.5.2.1 18-Nov-2006  ad Sync with head.
 1.6.10.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.6.8.4 08-Oct-2007  ad - Don't leave nodes dangling in order to keep track of the inode generation
number. Free them back to the pool as soon as the referenced file becomes
unused. Using arc4random() for the generation and ino_t based off the
node's in-core address is just about as as good as a disk-based file
system is going to give.
- Add assertion to catch empty directories with linkcount > 1 being freed.
This fires frequently but I haven't tracked the bug down yet..
- Use kmem_alloc.
 1.6.8.3 18-Sep-2007  ad tmpfs_pool_page_alloc:

- If we can't allocate a page, just return NULL instead of panicing.

- Specify PR_NOWAIT to the back-end allocator. This is a bit risky since
we are relying on the results of a stale check that there is free memory,
but for now it's better than failing allocations because another thread
has kernel_map locked.
 1.6.8.2 21-Aug-2007  ad - Add locking around tmpfs shared data structures and mark it MP safe.
It's enough to last for about 45m of fsx+postmark, but it doesn't
survive SGI fsstress yet.
- Close a race where multiple vnodes could maybe have been allocated
for a tmpnode with linkcount > 1.
 1.6.8.1 13-Mar-2007  ad Sync with head.
 1.6.4.1 24-Mar-2007  yamt sync with head.
 1.6.2.1 01-Feb-2008  riz Pull up following revision(s) (requested by pooka in ticket #1008):
sys/fs/tmpfs/tmpfs_pool.c: revision 1.11
Don't KASSERT that the pool allocator returns a page - it might be
called with NOWAIT.
XXX: this is just a quick fix to stop the diagnostic panic. I
think ENOSPC should be treated elsewhere depending on how much
memory tmpfs claims.
 1.7.18.1 13-Nov-2007  bouyer Sync with HEAD
 1.7.14.4 23-Mar-2008  matt sync with HEAD
 1.7.14.3 09-Jan-2008  matt sync with HEAD
 1.7.14.2 08-Nov-2007  matt sync with -HEAD
 1.7.14.1 06-Nov-2007  matt sync with HEAD
 1.7.12.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7.12.3 11-Nov-2007  joerg Sync with HEAD.
 1.7.12.2 06-Nov-2007  joerg Sync with HEAD.
 1.7.12.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.8.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.8.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.8.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.11.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.2.5 15-Dec-2007  ad Fix accounting problem that allowed a tmpfs to be filled beyond its limit
when running multithreaded.
 1.11.2.4 12-Dec-2007  ad Minor corrections to previous.
 1.11.2.3 12-Dec-2007  ad - Don't use LK_RETRY in tmpfs_alloc_vp().
- Reduce cosmetic diffs to head.
 1.11.2.2 08-Dec-2007  ad Reduce coverage of the per-mount lock by using atomic ops.
 1.11.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.13.10.2 11-Aug-2010  yamt sync with head.
 1.13.10.1 16-May-2008  yamt sync with head.
 1.13.8.1 18-May-2008  yamt sync with head.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.22.1 03-Jul-2010  rmind sync with head
 1.14.20.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.8 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.7 28-Apr-2008  martin branches: 1.7.20; 1.7.22;
Remove clause 3 and 4 from TNF licenses
 1.6 09-Nov-2006  jmmv branches: 1.6.48; 1.6.50; 1.6.52;
Add 2006 to the copyright notice; should have done this when touching the
files before.
 1.5 10-Feb-2006  christos branches: 1.5.12; 1.5.16; 1.5.18;
make the include files usable from userland.
 1.4 03-Dec-2005  christos branches: 1.4.2; 1.4.4; 1.4.6;
- 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.3 23-Sep-2005  jmmv branches: 1.3.6;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.2 12-Sep-2005  yamt - don't keep a reference to a variable on stack.
- remove a meaningless assumption about the order of structure members.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 23-Sep-2005  skrll file tmpfs_pool.h was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.4.2.1 18-Feb-2006  yamt sync with head.
 1.5.18.1 10-Dec-2006  yamt sync with head.
 1.5.16.1 18-Nov-2006  ad Sync with head.
 1.5.12.3 30-Dec-2006  yamt sync with head.
 1.5.12.2 21-Jun-2006  yamt sync with head.
 1.5.12.1 10-Feb-2006  yamt file tmpfs_pool.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.6.52.2 11-Aug-2010  yamt sync with head.
 1.6.52.1 16-May-2008  yamt sync with head.
 1.6.50.1 18-May-2008  yamt sync with head.
 1.6.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.22.1 03-Jul-2010  rmind sync with head
 1.7.20.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.7.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.12 20-Oct-2021  thorpej Move a mis-placed KASSERT().
 1.11 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.10 03-Dec-2019  riastradh Omit obsolete comment and needless __diagused marker.
 1.9 14-Jul-2019  maxv Fix uninitialized variable: if 'tvp' is NULL, '*tdep' is not initialized.
This could have caused the KASSERT to wrongfully fire.

ok riastradh@
 1.8 06-Jul-2015  wiz branches: 1.8.10; 1.8.18;
Fix typo in comment.
 1.7 06-Jul-2015  hannken Change tmpfs to vcache.
- Use tmpfs node address as key.
- Remove tn_vlock, field tn_vnode now protected by vcache.
- Add a hold count to tmpfs node to prevent nodes from disappearing
while tmpfs_fhtovp() trys to vcache_get() them. Last holder
destroys reclaimed nodes.
- Remove the now unneeded parent unlock/lock for lookup of '..'.
 1.6 23-Nov-2013  rmind branches: 1.6.6;
- Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.5 08-Nov-2013  rmind tmpfs: replace the broken tmpfs_dircookie() logic which uses the node
address truncated to 31 bits (required for 32-bit readdir compatibility,
e.g. linux32). Instead, assign 2^31 range using the following logic:
- The first half of the 2^31 is assigned incrementally (the fast path).
- When exceeded, use the second half of 2^31, but manage with vmem(9).

It will require 2 billion files per-directory to trigger vmem(9) usage.
Also, while here, add some fixes for tmpfs_unmount().

Should fix PR/47739, PR/47480, PR/46088 and PR/41068.
Thanks to wiz@ for stress testing.
 1.4 27-Sep-2012  riastradh branches: 1.4.2;
Uncomment call to genfs_rename_cache_purge.

Fixes a side issue mentioned in PR kern/46990.

I left this commented to preserve the old behaviour of tmpfs_rename,
but it is obviously broken to omit the cache purge, and I'm surprised
nobody had encountered any problems with it until now.
 1.3 25-Sep-2012  riastradh Check tmpfs_rmdired_p after tmpfs_vnode_get when walking up the tree.

tmpfs_vnode_get drops all locks except possibly the reclaiming bit
lock to keep the tmpfs node from being reclaimed while we're still
interested in it. Consequently, it does not keep the directory's
existence invariant, so we must check that after tmpfs_vnode_get.

Fixes PR kern/46990. Tested by Wolfgang Stukenbrock.
 1.2 09-May-2012  riastradh branches: 1.2.2; 1.2.4; 1.2.6;
Fix omitted VN_KNOTE(fvp, NOTE_RENAME) in tmpfs_rename.

Missed that line while refactoring tmpfs_rename to use genfs_rename.
 1.1 09-May-2012  riastradh Adapt tmpfs_rename to use genfs_rename.
 1.2.6.3 03-Dec-2017  jdolecek update from HEAD
 1.2.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.4.2 02-Jun-2012  mrg sync to latest -current.
 1.2.4.1 09-May-2012  mrg file tmpfs_rename.c was added on branch jmcneill-usbmp on 2012-06-02 11:09:32 +0000
 1.2.2.4 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.2.2.3 30-Oct-2012  yamt sync with head
 1.2.2.2 23-May-2012  yamt sync with head.
 1.2.2.1 09-May-2012  yamt file tmpfs_rename.c was added on branch yamt-pagecache on 2012-05-23 10:08:09 +0000
 1.4.2.1 18-May-2014  rmind sync with head
 1.6.6.1 22-Sep-2015  skrll Sync with HEAD
 1.8.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8.10.1 29-Aug-2019  martin Pull up following revision(s) (requested by maxv in ticket #1345):

sys/fs/tmpfs/tmpfs_rename.c: revision 1.9

Fix uninitialized variable: if 'tvp' is NULL, '*tdep' is not initialized.

This could have caused the KASSERT to wrongfully fire.

ok riastradh@
 1.16 19-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 2; cvs randomly didn't commit these changes before, and then hid
them from me until I touched the files to force it to rethink. Dunno
what happened.

There's probably more of these, going to have to scan the tree the
hard way.
 1.15 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.14 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.13 16-May-2020  christos branches: 1.13.6;
Add ACL support for FFS. From FreeBSD.
 1.12 25-Jul-2014  dholland 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.11 23-Nov-2013  rmind branches: 1.11.2;
- Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.10 24-May-2011  rmind branches: 1.10.4; 1.10.14; 1.10.18;
- Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.9 20-Jun-2008  skd branches: 1.9.18; 1.9.24;
add NULL arg so it will compile.
 1.8 28-Apr-2008  martin branches: 1.8.2; 1.8.4;
Remove clause 3 and 4 from TNF licenses
 1.7 25-Jan-2008  ad branches: 1.7.6; 1.7.8; 1.7.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.6 11-Dec-2005  christos branches: 1.6.18; 1.6.48; 1.6.54;
merge ktrace-lwp.
 1.5 02-Nov-2005  yamt branches: 1.5.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.4 02-Nov-2005  dyoung Bug fix: correct the sense of an if-condition in tmpfs_spec_close:
because VOP_UPDATE() usually succeeded, spec_close() was not usually
called. Only skip the spec_close() step if VOP_UPDATE() returns
an error result. Now /dev/watchdog works as expected when /dev/
is a tmpfs; previously, it was impossible to disarm a user-tickled
watchdog.
 1.3 23-Sep-2005  jmmv branches: 1.3.2;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.3.2.3 02-Nov-2005  yamt sync with head.
 1.3.2.2 29-Oct-2005  yamt as tmpfs_update never fails, make it return void.
suggested by Chuck Silvers.
 1.3.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.5.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.1 02-Nov-2005  skrll file tmpfs_specops.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.6.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.48.1 23-Mar-2008  matt sync with HEAD
 1.6.18.3 04-Feb-2008  yamt sync with head.
 1.6.18.2 21-Jun-2006  yamt sync with head.
 1.6.18.1 11-Dec-2005  yamt file tmpfs_specops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.7.10.2 04-May-2009  yamt sync with head.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.4.1 27-Jun-2008  simonb Sync with head.
 1.8.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.18.1 31-May-2011  rmind sync with head
 1.10.18.1 18-May-2014  rmind sync with head
 1.10.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.4.1 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.11.2.1 10-Aug-2014  tls Rebase.
 1.13.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.9 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.8 24-May-2011  rmind branches: 1.8.72;
- Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.7 28-Apr-2008  martin branches: 1.7.22; 1.7.28;
Remove clause 3 and 4 from TNF licenses
 1.6 25-Jan-2008  ad branches: 1.6.6; 1.6.8; 1.6.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.5 03-Dec-2005  christos branches: 1.5.18; 1.5.48; 1.5.54;
- 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.4 02-Nov-2005  yamt branches: 1.4.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.3 02-Nov-2005  dyoung Bug fix: change tmpfs_spec_bwrite from tmpfs_bwrite to vn_bwrite,
per yamt's suggestion. Previously, if /dev/ was mounted on a tmpfs,
block device buffers were never flushed to disk. Trying to unmount
a dirty filesystem (umount /dev/wd0e, say) caused an endless stream
of vflushbuf warnings, because tmpfs_bwrite was not flushing buffers.
The fix told to me by yamt solves the problem.
 1.2 23-Sep-2005  jmmv branches: 1.2.2;
Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.2.2.2 02-Nov-2005  yamt sync with head.
 1.2.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.4.2.3 11-Dec-2005  christos Sync with head.
 1.4.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.1 02-Nov-2005  skrll file tmpfs_specops.h was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.5.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.48.1 23-Mar-2008  matt sync with HEAD
 1.5.18.3 04-Feb-2008  yamt sync with head.
 1.5.18.2 21-Jun-2006  yamt sync with head.
 1.5.18.1 03-Dec-2005  yamt file tmpfs_specops.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.6.10.1 16-May-2008  yamt sync with head.
 1.6.8.1 18-May-2008  yamt sync with head.
 1.6.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.22.1 31-May-2011  rmind sync with head
 1.8.72.1 01-Aug-2021  thorpej Sync with HEAD.
 1.117 29-Apr-2023  riastradh tmpfs: Assert no arithmetic overflow in directory node tn_size.

Need >2^57 directory entries before this is a problem. If we created
a million per second, this would take over 4000 years.
 1.116 29-Apr-2023  riastradh tmpfs: Refuse sizes that overflow round_page.

Reported-by: syzbot+8dbeee84de15f86df65b@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=4a27b9fe074f8d4b0afbe22969339b8dfdb157e8
 1.115 29-Apr-2023  riastradh tmpfs: Nix trailing whitespace. No functional change intended.
 1.114 20-Oct-2021  thorpej branches: 1.114.4;
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.113 05-Sep-2020  riastradh Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.112 17-May-2020  ad PR kern/55268: tmpfs is slow

tmpfs_getpages(): handle the PGO_LOCKED case and implement lazy update of
atime/mtime.
 1.111 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.110 12-May-2020  ad cache_enter_id(): give it a boolean parameter to indicate whether the cached
identity is valid.
 1.109 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.108 04-Apr-2020  ad branches: 1.108.2;
Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.107 14-Mar-2020  ad tmpfs_reg_resize(): do nothing if newsize == oldsize.
 1.106 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.105 18-Sep-2019  christos branches: 1.105.2;
Add newly created vnodes to the namei cache. The rest of the filesystems
already did that (or they don't support writing). Discussed in tech-kern.
 1.104 01-Jan-2019  hannken branches: 1.104.4;
Add "void *extra" argument to vcache_new() so a file system may
pass more information about the file to create.

Welcome to 8.99.30
 1.103 28-May-2018  chs branches: 1.103.2;
allow tmpfs files to be larger than 4GB.
 1.102 04-Jan-2017  hannken branches: 1.102.8; 1.102.14;
Change tmpfs_chsize() to update mtime etc. even if "length == node->tn_size".

Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)"
 1.101 29-Oct-2015  leot branches: 1.101.2;
Make sure that nde->td_node is NULL for asserts.
Thanks and from Mindaugas Rasiukevicius.

Fixes PR kern/50381.
 1.100 07-Jul-2015  justin This enum is likely to be made unsigned by the compiler, so the assertion
will not work and clang objects with -Wtautological-constant-out-of-range-compare
 1.99 06-Jul-2015  hannken Change tmpfs to vcache.
- Use tmpfs node address as key.
- Remove tn_vlock, field tn_vnode now protected by vcache.
- Add a hold count to tmpfs node to prevent nodes from disappearing
while tmpfs_fhtovp() trys to vcache_get() them. Last holder
destroys reclaimed nodes.
- Remove the now unneeded parent unlock/lock for lookup of '..'.
 1.98 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.97 08-Sep-2014  gson branches: 1.97.2;
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length. Fixes the tmpfs part of PR kern/48864.
 1.96 23-Jan-2014  hannken branches: 1.96.4;
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.95 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.94 08-Jan-2014  pedro Allocate direntp on the stack in tmpfs_dir_getdents(), thus saving
calls to kmem_zalloc() and kmem_free(); OK rmind@. From OpenBSD.
 1.93 03-Jan-2014  hannken Fix a race where thread1 runs VOP_REMOVE() and gets preempted in
tmpfs_reclaim() before the call to tmpfs_free_node(). Thread2
runs VFS_FHTOVP() and gets a new vnode attached to the node thread1
is about to destroy.

Change tmpfs_alloc_node() to always assign non-zero generation number
and tmpfs_inactive() to set the generation number of unlinked nodes
to zero.
 1.92 24-Nov-2013  rmind - tmpfs_construct_node: prevent from the new node construction if the
directory was removed. Fixes the crash reported by Nicolas Joly.
- tmpfs_reclaim: avoid race by checking tn_links with the vnode locked.
 1.91 23-Nov-2013  rmind tmpfs_reg_resize: use size_t.
 1.90 23-Nov-2013  rmind - Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.89 21-Nov-2013  rmind tmpfs_dir_getdotents: fix the recent regression, set the correct
d_fileno value for dot-dot. Spotted by Pedro Martelletto, thanks!
 1.88 18-Nov-2013  rmind Make tmpfs_node_t::tn_gen a 32-bit number, keep it in sync with tmpfs_fid_t.
Also, change tn_status to unsigned while here.
 1.87 16-Nov-2013  rmind tmpfs_dir_getdents: avoid leaking kernel memory to the userspace.
From Pedro Martelletto.

XXX: regress/sys/fs/getdents should be a part of the test suite
 1.86 11-Nov-2013  rmind tmpfs_alloc_node: use cprng_fast64(), the old random(9) shall be removed.
 1.85 10-Nov-2013  rmind Handle whiteout case in tmpfs_dir_detach() and tmpfs_unmount().
 1.84 10-Nov-2013  christos mark variable __diagused
 1.83 08-Nov-2013  rmind tmpfs: replace the broken tmpfs_dircookie() logic which uses the node
address truncated to 31 bits (required for 32-bit readdir compatibility,
e.g. linux32). Instead, assign 2^31 range using the following logic:
- The first half of the 2^31 is assigned incrementally (the fast path).
- When exceeded, use the second half of 2^31, but manage with vmem(9).

It will require 2 billion files per-directory to trigger vmem(9) usage.
Also, while here, add some fixes for tmpfs_unmount().

Should fix PR/47739, PR/47480, PR/46088 and PR/41068.
Thanks to wiz@ for stress testing.
 1.82 01-Nov-2013  rmind tmpfs: fix the zero-length symlink target case as NetBSD supports them.
 1.81 31-Oct-2013  rmind tmpfs_alloc_node: it is less error-prone to store the link path with
the NIL terminator included. Adjust tmpfs_readlink() to exclude NIL.
Also, remove the check for zero-length and add some asserts.
 1.80 04-Oct-2013  rmind - tmpfs_remove: check 'appendable' flag for the parent directory as well.
Patch from Pedro Martelletto.
- tmpfs_dir_detach: remove missleading check.
- tmpfs_link: remove unused variable.
 1.79 13-Mar-2012  elad branches: 1.79.2; 1.79.4;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.78 19-Nov-2011  tls branches: 1.78.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.77 27-Aug-2011  hannken branches: 1.77.2;
Finish and enable whiteout support for tmpfs:

- Enable VOP tmpfs_whiteout().
- Support ISWHITEOUT in tmpfs_alloc_file().
- Support DOWHITEOUT in tmpfs_remove() and tmpfs_rmdir().
- Make rmdir on a directory containing whiteouts working.

Should fix PR #35112 (tmpfs doesn't play well with unionfs).
 1.76 30-Jun-2011  enami Backout previous. May be I need more coffee.
 1.75 30-Jun-2011  enami - Use << PAGE_SHIFT rather than calling round_page again.
- No need to call uao_dropswap_range() here since uao_dropswap()
is already called for each pages by uvm_vnp_setsize().
 1.74 16-Jun-2011  hannken Rename uvm_vnp_zerorange(struct vnode *, off_t, size_t) to
ubc_zerorange(struct uvm_object *, off_t, size_t, int) changing
the first argument to an uvm_object and adding a flags argument.

Modify tmpfs_reg_resize() to zero the backing store (aobj) instead
of the vnode. Ubc_purge() no longer panics when unmounting tmpfs.

Keep uvm_vnp_zerorange() until the next kernel version bump.
 1.73 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.72 29-May-2011  rmind branches: 1.72.2;
Fix non-DEBUG build.
 1.71 29-May-2011  rmind - Rework and document inode reference counting. Also document inode life
cycle (destruction part). Perform link counting in tmpfs_dir_attach()
and tmpfs_dir_detach(), instead of alloc/free and arbitrary places.
Fixes PR/44285, PR/44288, PR/44657 and likely PR/42484.

- Fix the race between the lookup and inode destruction. Fixes PR/43167
and its duplicates PR/40088, PR/40757.

- Improve tmpfs_rename() locking a little, fix kqueue event notifications
and also fix PR/43617. Add simplistic tmpfs_parentcheck_p(); to be
expanded and used for further rename() locking fixes.

- Cache directory entry "hint" in the tmpfs node, add tmpfs_dir_cached(),
and thus avoid unnecessary lookup in tmpfs_remove() and tmpfs_rmdir().

- Set correct _PC_FILESIZEBITS value in tmpfs_pathconf(). Fixes PR/43576.

- Few minor fixes.
 1.70 25-May-2011  rmind tmpfs_update: comment out assert for now.
 1.69 25-May-2011  rmind tmpfs_dir_lookup: use 'name' variable in memcmp() as intended; fix warning.
 1.68 24-May-2011  rmind - tmpfs_lookup: cache (cnp->cn_flags & ISLASTCN) in const bool; de-indent.
- Group tmpfs_{alloc,free}_dirent() with other dirent routines.

No functional changes.
 1.67 24-May-2011  rmind - Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.66 24-May-2011  rmind tmpfs_free_node: comment out assert, which can fire e.g. on shutdown.
 1.65 24-May-2011  rmind - tmpfs_alloc_node/tmpfs_free_node: move inode limiting into tmpfs_node_get()
and tmpfs_node_put(), update outdated/wrong comments and move/add asserts.
- tmpfs_mount: check for the version of arguments a bit earlier.
 1.64 22-May-2011  rmind tmpfs_alloc_vp:
- Do not check for vn_lock(9) error, if LK_RETRY.
- Fix/improve comments.
 1.63 01-Apr-2011  hannken Make zero length symlinks work on tmpfs.

Fixes PR #43843 (tmpfs dies with kassert panic for 0 length symlink target)
 1.62 13-Jan-2011  pooka branches: 1.62.2;
Add some support for unionfs (not built by default). It's still
missing at least opaque directory support, but until someone figures
out how that should work on ffs (see PR kern/kern/44383), there's
no point in trying to figure out how it should work here.
 1.61 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.60 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.59 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.58 02-Jul-2010  rmind tmpfs_lookup: add comment, de-ident main path. No functional change.
tmpfs_dir_attach: add assert.
 1.57 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.56 11-Nov-2009  rmind branches: 1.56.2; 1.56.4;
Simplify tmpfs_itimes() and use vfs_timestamp(). Also, replace unnecessary
kmem_zalloc()s with kmem_alloc()s.
 1.55 03-Sep-2009  pooka "kauth_action_t = KAUTH_VNODE_WRITE_FLAGS;" must be C**. However,
we still use plain ISO C, so additionally supply the variable name.
Compile-tested only, but at least that's some testing.
 1.54 03-Sep-2009  elad Implement the vnode scope and adapt tmpfs to use it.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/07/04/msg005404.html
 1.53 07-May-2009  elad Extract the open-coded authorization logic for chtimes() from various
file-systems and put it in a single function, genfs_can_chtimes().

This also makes UDF follow the same policy as all other file-systems.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004951.html
 1.52 22-Apr-2009  elad Per discussion on tech-kern@:

- Replace use of label/goto with returns

- Rename, change prototype of, and move functions from vfs_subr.c to
genfs_vnops.c
 1.51 20-Apr-2009  elad Refactor some duplicated file-system code.

Proposed and received no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
 1.50 11-Apr-2009  markd For chown make auth checks consistent with UFS. Fixes PR kern/40933.
 1.49 10-Apr-2009  yamt - tmpfs_dir_lookup: simplify.
- add some assertions.
 1.48 19-Jun-2008  christos branches: 1.48.4; 1.48.6; 1.48.10;
- setting the birthdate is valid in setattr.
- don't call nanotime if not needed.
- don't call tempfs_update() if tempfs_chtimes succeeded, because it just did.
 1.47 28-Apr-2008  martin branches: 1.47.2; 1.47.4;
Remove clause 3 and 4 from TNF licenses
 1.46 06-Feb-2008  jmmv branches: 1.46.6; 1.46.8; 1.46.10;
u_int is not a C99 standard type, so spell it out completely as
unsigned int.
 1.45 06-Feb-2008  jmmv Drop trailing whitespace.
 1.44 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.43 02-Jan-2008  ad Merge vmlocking2 to head.
 1.42 08-Dec-2007  pooka branches: 1.42.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.41 26-Nov-2007  pooka branches: 1.41.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.40 10-Nov-2007  ad Back out the tmpfs changes; there appears to be a bug lurking.
 1.39 06-Nov-2007  ad Merge from vmlocking.
 1.38 10-Oct-2007  ad branches: 1.38.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.37 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.36 06-Aug-2007  pooka branches: 1.36.2; 1.36.4; 1.36.6;
When resizing a node, first drop extra pages and zero tail, and only
then set the new size. Otherwise zerolen will always be, well, 0.
 1.35 09-Jul-2007  ad branches: 1.35.2; 1.35.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.34 22-Feb-2007  thorpej branches: 1.34.4; 1.34.6;
TRUE -> true, FALSE -> false
 1.33 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.32 04-Jan-2007  elad branches: 1.32.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.31 02-Jan-2007  elad Add KAUTH_SYSTEM_CHSYSFLAGS so we can get rid of the last three
securelevel references (ufs, ext2fs, tmpfs).

Intentionally undocumented.
 1.30 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.29 09-Nov-2006  jmmv Audit kqueue notifications. The reference behavior is taken from MFS and
is represented in the regression tests.
 1.28 05-Nov-2006  jmmv Randomly initialize the node's generation to make file handles less
predictable. This solves a problem that may appear when serving a tmpfs
over NFS: if the server reboots, newly allocated files should have
different file handles; otherwise the remote clients could access files
they were not supposed to touch.
 1.27 05-Nov-2006  jmmv Truncate directory cookies to 31 bits to avoid problems exposed in Linux
binaries which cast the returned values to 64-bits and fail due to sign
expansion. More details are provided in the big comment in tmpfs.h that
describes how the new tmpfs_dircookie works.

This is a rather ugly hack that shall be fixed with a cleaner solution,
but this resolves the problem in an effective way.

Fixes kern PR/32034.
 1.26 30-Oct-2006  jmmv Grr... cvs diff scrolled too much and I didn't notice there were some
unwanted changes in this file. Revert them; sorry.
 1.25 30-Oct-2006  jmmv When renaming a file, we have to modify the mtime of the directory holding
it, not the mtime of the file itself. This fixes the problems exposed when
unpacking software under a tmpfs and trying to build it because dependencies
were not calculated properly (e.g. autoconf 2.60 as reported by tls@).
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 03-Sep-2006  christos branches: 1.23.2; 1.23.4;
comment out empty code
 1.22 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.21 07-Jun-2006  kardel branches: 1.21.4;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.20 15-May-2006  christos branches: 1.20.2;
kauth fallout
 1.19 14-May-2006  elad integrate kauth.
 1.18 16-Feb-2006  jmmv branches: 1.18.2; 1.18.4; 1.18.6;
Do not use unnamed structures/unions without instances; they break the
build under vax because of gcc 2.95. Found by he@.
 1.17 11-Dec-2005  christos branches: 1.17.2; 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 28-Nov-2005  dan take into account memory used for file cache pages, and wired pages,
when calculating potential free space
 1.15 28-Nov-2005  dan simplify calculation of free swap space using uvm-exported statistics,
with thanks to yamt@ for useful hints.
 1.14 11-Nov-2005  yamt branches: 1.14.2;
- ignore truncation for VCHR/VBLK/VFIFO as it used to be
before yamt-vop merge. PR/32049 from Atsushi Onoe.
- reject setattr which attempts to change size of VLNK/VSOCK.
 1.13 08-Nov-2005  yamt branches: 1.13.2;
tmpfs_reg_resize: drop swap slots on truncation.
fix a problem pointed by jmmv@.
 1.12 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.11 30-Sep-2005  jmmv branches: 1.11.2;
Explicitly initialize the tn_lockf field. I expect problems in some
situations otherwise...
 1.10 28-Sep-2005  yamt tmpfs_getattr: return up-to-date timestamps.
 1.9 27-Sep-2005  jmmv Some style fixes in comments.
 1.8 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.7 17-Sep-2005  yamt fix buffer overrun for symbolic links. PR/31325.
 1.6 16-Sep-2005  yamt tmpfs_dir_getdotdotdent: correct fileid.
 1.5 15-Sep-2005  yamt change the way to handle directory "offsets" so that
they won't be changed when removing entries in the directory.
some applications like cvs rely on this.
 1.4 13-Sep-2005  yamt - don't waste/leak kva.
- implement getpages/putpages. support mmap.
- eliminate meaningless memcpy.
- ubcify.
 1.3 12-Sep-2005  christos convert to use it nanotime, but don't call it unless it is necessary.
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.11.2.2 29-Oct-2005  yamt as tmpfs_update never fails, make it return void.
suggested by Chuck Silvers.
 1.11.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.13.2.4 11-Dec-2005  christos Sync with head.
 1.13.2.3 12-Nov-2005  skrll Adapt to branch
 1.13.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.1 08-Nov-2005  skrll file tmpfs_subr.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.14.2.1 29-Nov-2005  yamt sync with head.
 1.17.6.4 01-Jun-2006  kardel Sync with head.
 1.17.6.3 22-Apr-2006  simonb Sync with head.
 1.17.6.2 05-Feb-2006  simonb In the *itimes functions, just call getnanotime() at the start of
the function and use the result if needed, rather than the previous
conditional calls/assignments method. The code is clearer this way,
and benchmarks at about the same speed.
 1.17.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 18-Feb-2006  yamt sync with head.
 1.18.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.18.4.3 18-Apr-2006  elad adapt to kauth, pointed out by yamt@, thanks!
 1.18.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.18.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.18.2.4 03-Sep-2006  yamt sync with head.
 1.18.2.3 11-Aug-2006  yamt sync with head
 1.18.2.2 26-Jun-2006  yamt sync with head.
 1.18.2.1 24-May-2006  yamt sync with head.
 1.20.2.1 19-Jun-2006  chap Sync with head.
 1.21.4.10 11-Feb-2008  yamt sync with head.
 1.21.4.9 04-Feb-2008  yamt sync with head.
 1.21.4.8 21-Jan-2008  yamt sync with head
 1.21.4.7 07-Dec-2007  yamt sync with head
 1.21.4.6 27-Oct-2007  yamt sync with head.
 1.21.4.5 03-Sep-2007  yamt sync with head.
 1.21.4.4 26-Feb-2007  yamt sync with head.
 1.21.4.3 30-Dec-2006  yamt sync with head.
 1.21.4.2 21-Jun-2006  yamt sync with head.
 1.21.4.1 07-Jun-2006  yamt file tmpfs_subr.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.23.4.2 10-Dec-2006  yamt sync with head.
 1.23.4.1 22-Oct-2006  yamt sync with head
 1.23.2.2 12-Jan-2007  ad Sync with head.
 1.23.2.1 18-Nov-2006  ad Sync with head.
 1.32.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.34.6.1 11-Jul-2007  mjf Sync with head.
 1.34.4.11 23-Oct-2007  ad Sync with head.
 1.34.4.10 09-Oct-2007  ad Sync with head.
 1.34.4.9 09-Oct-2007  ad Sync with head.
 1.34.4.8 08-Oct-2007  ad - Don't leave nodes dangling in order to keep track of the inode generation
number. Free them back to the pool as soon as the referenced file becomes
unused. Using arc4random() for the generation and ino_t based off the
node's in-core address is just about as as good as a disk-based file
system is going to give.
- Add assertion to catch empty directories with linkcount > 1 being freed.
This fires frequently but I haven't tracked the bug down yet..
- Use kmem_alloc.
 1.34.4.7 18-Sep-2007  ad tmpfs_alloc_vp: deal with vget() failure. Another thread may be reclaiming
the vnode.
 1.34.4.6 16-Sep-2007  ad Fix another minor concurrency problem.
 1.34.4.5 22-Aug-2007  ad Fix some more concurrency problems.
 1.34.4.4 21-Aug-2007  ad - Add locking around tmpfs shared data structures and mark it MP safe.
It's enough to last for about 45m of fsx+postmark, but it doesn't
survive SGI fsstress yet.
- Close a race where multiple vnodes could maybe have been allocated
for a tmpnode with linkcount > 1.
 1.34.4.3 20-Aug-2007  ad Sync with HEAD.
 1.34.4.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.34.4.1 05-Apr-2007  ad Compile fixes.
 1.35.6.7 09-Dec-2007  jmcneill Sync with HEAD.
 1.35.6.6 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.35.6.5 11-Nov-2007  joerg Sync with HEAD.
 1.35.6.4 06-Nov-2007  joerg Sync with HEAD.
 1.35.6.3 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.35.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.35.6.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.35.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.36.6.2 06-Aug-2007  pooka When resizing a node, first drop extra pages and zero tail, and only
then set the new size. Otherwise zerolen will always be, well, 0.
 1.36.6.1 06-Aug-2007  pooka file tmpfs_subr.c was added on branch matt-mips64 on 2007-08-06 16:08:56 +0000
 1.36.4.2 14-Oct-2007  yamt sync with head.
 1.36.4.1 06-Oct-2007  yamt sync with head.
 1.36.2.4 23-Mar-2008  matt sync with HEAD
 1.36.2.3 09-Jan-2008  matt sync with HEAD
 1.36.2.2 08-Nov-2007  matt sync with -HEAD
 1.36.2.1 06-Nov-2007  matt sync with HEAD
 1.38.4.4 18-Feb-2008  mjf Sync with HEAD.
 1.38.4.3 27-Dec-2007  mjf Sync with HEAD.
 1.38.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.38.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.41.2.8 26-Dec-2007  ad Sync with head.
 1.41.2.7 15-Dec-2007  ad tmpfs_reg_resize: drop swapslots after resizing to work around a panic.
It may not be necessary to drop the swapslots at this point.
 1.41.2.6 15-Dec-2007  ad Fix accounting problem that allowed a tmpfs to be filled beyond its limit
when running multithreaded.
 1.41.2.5 13-Dec-2007  yamt don't leak linkcount on errors.
 1.41.2.4 12-Dec-2007  ad Minor corrections to previous.
 1.41.2.3 12-Dec-2007  ad - Don't use LK_RETRY in tmpfs_alloc_vp().
- Reduce cosmetic diffs to head.
 1.41.2.2 08-Dec-2007  ad Reduce coverage of the per-mount lock by using atomic ops.
 1.41.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.42.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.46.10.6 11-Aug-2010  yamt sync with head.
 1.46.10.5 11-Mar-2010  yamt sync with head
 1.46.10.4 16-Sep-2009  yamt sync with head
 1.46.10.3 16-May-2009  yamt sync with head
 1.46.10.2 04-May-2009  yamt sync with head.
 1.46.10.1 16-May-2008  yamt sync with head.
 1.46.8.1 18-May-2008  yamt sync with head.
 1.46.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.46.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.47.4.1 27-Jun-2008  simonb Sync with head.
 1.47.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.48.6.1 12-Apr-2009  snj Pull up following revision(s) (requested by markd in ticket #689):
sys/fs/tmpfs/tmpfs_subr.c: revision 1.50
For chown make auth checks consistent with UFS. Fixes PR kern/40933.
 1.48.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.56.4.9 31-May-2011  rmind sync with head
 1.56.4.8 31-May-2011  rmind tmpfs_alloc_vp: perform lock sharing only for VREG.
 1.56.4.7 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.56.4.6 22-May-2011  rmind Fix vnode interlock sharing.
 1.56.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.56.4.4 21-Apr-2011  rmind sync with head
 1.56.4.3 05-Mar-2011  rmind sync with head
 1.56.4.2 03-Jul-2010  rmind sync with head
 1.56.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.56.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.62.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.72.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.77.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.77.2.1 17-Apr-2012  yamt sync with head
 1.78.2.1 05-Apr-2012  mrg sync to latest -current.
 1.79.4.1 18-May-2014  rmind sync with head
 1.79.2.2 03-Dec-2017  jdolecek update from HEAD
 1.79.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.96.4.2 08-Nov-2015  riz Pull up following revision(s) (requested by leot in ticket #1023):
sys/fs/tmpfs/tmpfs_subr.c: revision 1.101
Make sure that nde->td_node is NULL for asserts.
Thanks and from Mindaugas Rasiukevicius.
Fixes PR kern/50381.
 1.96.4.1 22-Dec-2014  msaitoh branches: 1.96.4.1.2;
Pull up following revision(s) (requested by gson in ticket #344):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.121
sys/fs/tmpfs/tmpfs_subr.c: revision 1.97
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length. Fixes the tmpfs part of PR kern/48864.
 1.96.4.1.2.1 08-Nov-2015  riz Pull up following revision(s) (requested by leot in ticket #1023):
sys/fs/tmpfs/tmpfs_subr.c: revision 1.101
Make sure that nde->td_node is NULL for asserts.
Thanks and from Mindaugas Rasiukevicius.
Fixes PR kern/50381.
 1.97.2.4 05-Feb-2017  skrll Sync with HEAD
 1.97.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.97.2.2 22-Sep-2015  skrll Sync with HEAD
 1.97.2.1 06-Jun-2015  skrll Sync with HEAD
 1.101.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.102.14.2 18-Jan-2019  pgoyette Synch with HEAD
 1.102.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.102.8.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1872):

sys/fs/tmpfs/tmpfs_subr.c: revision 1.116
sys/fs/tmpfs/tmpfs_subr.c: revision 1.117

tmpfs: Refuse sizes that overflow round_page.

tmpfs: Assert no arithmetic overflow in directory node tn_size.
Need >2^57 directory entries before this is a problem. If we created
a million per second, this would take over 4000 years.
 1.103.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.103.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.103.2.1 10-Jun-2019  christos Sync with HEAD
 1.104.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1691):

sys/fs/tmpfs/tmpfs_subr.c: revision 1.116
sys/fs/tmpfs/tmpfs_subr.c: revision 1.117

tmpfs: Refuse sizes that overflow round_page.

tmpfs: Assert no arithmetic overflow in directory node tn_size.
Need >2^57 directory entries before this is a problem. If we created
a million per second, this would take over 4000 years.
 1.105.2.3 29-Feb-2020  ad Sync with head.
 1.105.2.2 24-Jan-2020  ad - Put all the namecache stuff back into vnode_impl_t.
- Tidy vfs_cache.c up, finish the comments.
- Finalise how ID information is entered to the cache.
- Handle very small/old systems.
 1.105.2.1 17-Jan-2020  ad vfs_lookup:

- Do the easy component name lookups directly in the namecache without
taking vnode locks nor vnode references (between the start and the leaf /
parent), which seems to largely solve the lock contention problem with
namei(). It needs support from the file system, which has to tell the
name cache about directory permissions (only ffs and tmpfs tried so far),
and I'm not sure how or if it can work with layered file systems yet.
Work in progress.

vfs_cache:

- Make the rbtree operations more efficient: inline the lookup, and key on a
64-bit hash value (32 bits plus 16 bits length) rather than names.

- Take namecache stuff out of vnode_impl, and take the rwlocks, and put them
all together an an nchnode struct which is mapped 1:1: with vnodes. Saves
memory and nicer cache profile.

- Add a routine to help vfs_lookup do its easy component name lookups.

- Report some more stats.

- Tidy up the file a bit.
 1.108.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.114.4.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #289):

sys/fs/tmpfs/tmpfs_subr.c: revision 1.116
sys/fs/tmpfs/tmpfs_subr.c: revision 1.117

tmpfs: Refuse sizes that overflow round_page.

tmpfs: Assert no arithmetic overflow in directory node tn_size.
Need >2^57 directory entries before this is a problem. If we created
a million per second, this would take over 4000 years.
 1.78 10-Nov-2022  hannken Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails.
This will not work as tmpfs_unmount() needs a suspended file system.

Just call set_statvfs_info() before allocating the root vnode and add
and use a common error exit label.

Reported-by: syzbot+343f2bfea65a32ab4222@syzkaller.appspotmail.com
 1.77 04-Apr-2020  ad Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
 1.76 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.75 04-Oct-2019  mrg branches: 1.75.2;
remove an always false check and its' "This can never happen?" comment.
 1.74 01-Jan-2019  hannken branches: 1.74.4;
Add "void *extra" argument to vcache_new() so a file system may
pass more information about the file to create.

Welcome to 8.99.30
 1.73 09-Aug-2018  christos FIx performance regression from rmind@:

Just from a very quick look, it seems like a regression introduced with
the vcache changes: the MP-safe flag is set too late and not inherited
by the root vnode.
 1.72 01-Jun-2017  chs branches: 1.72.2; 1.72.8; 1.72.10;
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.71 01-Mar-2017  hannken Change the protocol to update a mounted file system from read-write
to read-only and vice versa:

- Add an internal flag IMNT_WANTRDONLY.
- Set either IMNT_WANTRDWR or IMNT_WANTRDONLY if going from or to read-only.
- After successfull call to VFS_MOUNT() set or clear MNT_RDONLY.

Adapt tmpfs and rumpfs to the new protocol. Other file systems will be
updated when they get the IMNT_CAN_RWTORO property.

Welcome to 7.99.64
 1.70 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.69 27-Jan-2017  hannken Run vflush() when going from read/write to read only.
 1.68 26-Aug-2016  dholland branches: 1.68.2;
In the event that loading the root vnode fails, bail out of
tmpfs_mount instead of crashing.

Came up in PR 51436, where kmem issues caused internal allocations to
wrongly fail. However, that could happen for real sometime (e.g.
probably if you tried to mount a new tmpfs when the system was very
low on memory, or possibly for other reasons entirely) and crashing
isn't the ticket.

(This is not a fix for PR 51436)
 1.67 12-Mar-2016  joerg branches: 1.67.2;
Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.
 1.66 12-Mar-2016  joerg Only recheck size/node limits on update mounts, if there actually have
been specified.
 1.65 06-Jul-2015  hannken Change tmpfs to vcache.
- Use tmpfs node address as key.
- Remove tn_vlock, field tn_vnode now protected by vcache.
- Add a hold count to tmpfs node to prevent nodes from disappearing
while tmpfs_fhtovp() trys to vcache_get() them. Last holder
destroys reclaimed nodes.
- Remove the now unneeded parent unlock/lock for lookup of '..'.
 1.64 06-Jul-2015  hannken Use VFS_PROTOS() for tmpfs.
 1.63 10-Jun-2014  martin branches: 1.63.2; 1.63.4;
Check for invalid mount arguments early and gracefully fail the mount.
Spotted by pooka@
 1.62 07-Jun-2014  martin Remove the hardcoded 4 MB free kernel memory limit and replace it
by uvmexp.freetarg, as discussed on tech-kern.
Main purpose is to make tmpfs usable (as far as possible) on small memory
machines.
This is a bit experimental, but we need to give it some real world exposure
to see how well it works.
 1.61 30-Apr-2014  christos fix typo
 1.60 30-Apr-2014  christos handle MNT_UPDATE
 1.59 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.58 23-Mar-2014  hannken branches: 1.58.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.57 06-Feb-2014  hannken Remove an annoying printf. And to answer the question: VFS_VGET() gets
used by NFS V3 server for readdirplus.
 1.56 04-Jan-2014  hannken Fix a race where thread1 runs VOP_REMOVE() and gets preempted in
tmpfs_reclaim() before the call to tmpfs_free_node(). Thread2
runs VFS_FHTOVP() and gets a new vnode attached to the node thread1
is about to destroy.

Change tmpfs_fhtovp() to check the generation number after
tmpfs_vnode_get() succeeded.
 1.55 23-Nov-2013  rmind - Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.54 10-Nov-2013  rmind Handle whiteout case in tmpfs_dir_detach() and tmpfs_unmount().
 1.53 08-Nov-2013  rmind tmpfs: replace the broken tmpfs_dircookie() logic which uses the node
address truncated to 31 bits (required for 32-bit readdir compatibility,
e.g. linux32). Instead, assign 2^31 range using the following logic:
- The first half of the 2^31 is assigned incrementally (the fast path).
- When exceeded, use the second half of 2^31, but manage with vmem(9).

It will require 2 billion files per-directory to trigger vmem(9) usage.
Also, while here, add some fixes for tmpfs_unmount().

Should fix PR/47739, PR/47480, PR/46088 and PR/41068.
Thanks to wiz@ for stress testing.
 1.52 27-Sep-2011  christos branches: 1.52.2; 1.52.8; 1.52.12; 1.52.14; 1.52.16; 1.52.22;
define and use TMPFS_MAXNAMLEN instead of MAXNAMLEN
 1.51 29-May-2011  rmind - Rework and document inode reference counting. Also document inode life
cycle (destruction part). Perform link counting in tmpfs_dir_attach()
and tmpfs_dir_detach(), instead of alloc/free and arbitrary places.
Fixes PR/44285, PR/44288, PR/44657 and likely PR/42484.

- Fix the race between the lookup and inode destruction. Fixes PR/43167
and its duplicates PR/40088, PR/40757.

- Improve tmpfs_rename() locking a little, fix kqueue event notifications
and also fix PR/43617. Add simplistic tmpfs_parentcheck_p(); to be
expanded and used for further rename() locking fixes.

- Cache directory entry "hint" in the tmpfs node, add tmpfs_dir_cached(),
and thus avoid unnecessary lookup in tmpfs_remove() and tmpfs_rmdir().

- Set correct _PC_FILESIZEBITS value in tmpfs_pathconf(). Fixes PR/43576.

- Few minor fixes.
 1.50 24-May-2011  rmind - Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.49 24-May-2011  rmind - tmpfs_alloc_node/tmpfs_free_node: move inode limiting into tmpfs_node_get()
and tmpfs_node_put(), update outdated/wrong comments and move/add asserts.
- tmpfs_mount: check for the version of arguments a bit earlier.
 1.48 19-May-2011  rmind - tmpfs: do not create dirent/node pools per-mount, there is no need to.
- tmpfs_mount: fix a leak of mount structures in error path.
 1.47 02-Apr-2011  hannken Fix file handle operations for tmpfs by removing a now bogus test and
fixing the return value of tmpfs_fhtovp() in the not-found case.

When vmlocking2 was merged to head (Jan 2008 !!) the inode numbering was
changed. Before inodes were numbered 2..tm_nodes_max-1 and after the
merge the numbers are derived from the nodes memory address.

Fixes PR #43605 (tmpfs file handles are broken)
 1.46 26-Jun-2010  rmind branches: 1.46.2;
tmpfs_statvfs: hold accounting lock, since tmpfs_pages_avail() and
tmpfs_bytes_max() may fluctuate while in calculations.
 1.45 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.44 29-Jul-2008  pooka branches: 1.44.4; 1.44.14; 1.44.16; 1.44.18; 1.44.22;
Solve the fstat-wants-to-look-at-kernel-data-structures in a nicer
way: don't export the fs internals to innocent userspace programs
which just want to mount the file system.
 1.43 28-Jul-2008  pooka shuffle around some more defs for fstat

noticed by Kurt Schreiner on current-users
 1.42 28-Jul-2008  pooka Install mount argument structure header just like every other file system.
 1.41 10-May-2008  rumble branches: 1.41.2; 1.41.4;
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.40 29-Apr-2008  ad branches: 1.40.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.39 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.38 06-Feb-2008  jmmv branches: 1.38.6; 1.38.8; 1.38.10;
Drop trailing whitespace.
 1.37 05-Feb-2008  ad Limit kva usage to 8TB and the number of inodes to 2G. Should fix
PR kern/37951.
 1.36 28-Jan-2008  dholland 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.35 17-Jan-2008  pooka Remove bogus KASSERT: we can't make any assumptions about a dirent's
node in unmount since it might have been freed already.

fixes PR kern/37667. per discussion with ad & simonb.
 1.34 02-Jan-2008  ad Merge vmlocking2 to head.
 1.33 08-Dec-2007  pooka branches: 1.33.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.32 26-Nov-2007  pooka branches: 1.32.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.31 10-Nov-2007  ad Back out the tmpfs changes; there appears to be a bug lurking.
 1.30 06-Nov-2007  ad Merge from vmlocking.
 1.29 23-Oct-2007  dyoung branches: 1.29.2;
Fix typo: I'm pretty sure that in tmpfs_done(), both of the malloc(9)
types are supposed to be detached, not attached.
 1.28 24-Sep-2007  rumble branches: 1.28.2;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.27 03-Aug-2007  pooka branches: 1.27.2; 1.27.4; 1.27.6; 1.27.8;
Set mnt_fs_bshift and mnt_dev_bshift to reasonable dummy-values.
 1.26 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.25 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.24 17-Jul-2007  pooka branches: 1.24.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.23 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.22 09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.21 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.20 22-Feb-2007  thorpej branches: 1.20.4; 1.20.6;
TRUE -> true, FALSE -> false
 1.19 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.18 19-Jan-2007  hannken branches: 1.18.2;
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.17 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.16 09-Nov-2006  jmmv Audit kqueue notifications. The reference behavior is taken from MFS and
is represented in the regression tests.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 03-Sep-2006  christos branches: 1.14.2; 1.14.4;
add missing initializers
 1.13 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.12 14-May-2006  elad branches: 1.12.4; 1.12.6;
integrate kauth.
 1.11 16-Feb-2006  jmmv branches: 1.11.2; 1.11.4; 1.11.6;
Do not use unnamed structures/unions without instances; they break the
build under vax because of gcc 2.95. Found by he@.
 1.10 11-Dec-2005  christos branches: 1.10.2; 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 26-Sep-2005  jmmv branches: 1.9.6;
Handle too big numbers given in the max size argument.
 1.8 25-Sep-2005  jmmv Only consider valid flags in the root mode's parameter given by the user.
I doubt the unchecked value could bring us problems, but better to be safe
than sorry.
 1.7 25-Sep-2005  jmmv Sanity check negative values in the maximum size and number of nodes
arguments to avoid a crash while mounting a tmpfs file system. Add a
regression test for this too. Noticed by chs@.
 1.6 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.5 23-Sep-2005  jmmv Start inode numbers on 2 to mimic UFS tradition (and to avoid problems if
some utility relies on this).
 1.4 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.3 13-Sep-2005  jmmv Nodes cannot use the '0' identifier or they will be skipped by readdir.
E.g., the root node's '.' and '..' directory entries did not appear in
a directory list, because the root node always holds the first id.
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.9.6.3 12-Nov-2005  skrll Adapt to branch
 1.9.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.1 26-Sep-2005  skrll file tmpfs_vfsops.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.10.6.2 01-Jun-2006  kardel Sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 18-Feb-2006  yamt sync with head.
 1.11.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.11.2.3 03-Sep-2006  yamt sync with head.
 1.11.2.2 11-Aug-2006  yamt sync with head
 1.11.2.1 24-May-2006  yamt sync with head.
 1.12.6.10 11-Feb-2008  yamt sync with head.
 1.12.6.9 04-Feb-2008  yamt sync with head.
 1.12.6.8 21-Jan-2008  yamt sync with head
 1.12.6.7 07-Dec-2007  yamt sync with head
 1.12.6.6 27-Oct-2007  yamt sync with head.
 1.12.6.5 03-Sep-2007  yamt sync with head.
 1.12.6.4 26-Feb-2007  yamt sync with head.
 1.12.6.3 30-Dec-2006  yamt sync with head.
 1.12.6.2 21-Jun-2006  yamt sync with head.
 1.12.6.1 14-May-2006  yamt file tmpfs_vfsops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.12.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.14.4.2 10-Dec-2006  yamt sync with head.
 1.14.4.1 22-Oct-2006  yamt sync with head
 1.14.2.2 01-Feb-2007  ad Sync with head.
 1.14.2.1 18-Nov-2006  ad Sync with head.
 1.18.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.20.6.1 11-Jul-2007  mjf Sync with head.
 1.20.4.7 08-Oct-2007  ad - Don't leave nodes dangling in order to keep track of the inode generation
number. Free them back to the pool as soon as the referenced file becomes
unused. Using arc4random() for the generation and ino_t based off the
node's in-core address is just about as as good as a disk-based file
system is going to give.
- Add assertion to catch empty directories with linkcount > 1 being freed.
This fires frequently but I haven't tracked the bug down yet..
- Use kmem_alloc.
 1.20.4.6 22-Aug-2007  ad Fix some more concurrency problems.
 1.20.4.5 21-Aug-2007  ad - Add locking around tmpfs shared data structures and mark it MP safe.
It's enough to last for about 45m of fsx+postmark, but it doesn't
survive SGI fsstress yet.
- Close a race where multiple vnodes could maybe have been allocated
for a tmpnode with linkcount > 1.
 1.20.4.4 20-Aug-2007  ad Sync with HEAD.
 1.20.4.3 15-Jul-2007  ad Sync with head.
 1.20.4.2 15-Jul-2007  ad Sync with head.
 1.20.4.1 05-Apr-2007  ad Compile fixes.
 1.24.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.27.8.2 03-Aug-2007  pooka Set mnt_fs_bshift and mnt_dev_bshift to reasonable dummy-values.
 1.27.8.1 03-Aug-2007  pooka file tmpfs_vfsops.c was added on branch matt-mips64 on 2007-08-03 13:00:20 +0000
 1.27.6.1 06-Oct-2007  yamt sync with head.
 1.27.4.4 23-Mar-2008  matt sync with HEAD
 1.27.4.3 09-Jan-2008  matt sync with HEAD
 1.27.4.2 08-Nov-2007  matt sync with -HEAD
 1.27.4.1 06-Nov-2007  matt sync with HEAD
 1.27.2.7 09-Dec-2007  jmcneill Sync with HEAD.
 1.27.2.6 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.27.2.5 11-Nov-2007  joerg Sync with HEAD.
 1.27.2.4 06-Nov-2007  joerg Sync with HEAD.
 1.27.2.3 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.27.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.27.2.1 03-Aug-2007  joerg file tmpfs_vfsops.c was added on branch jmcneill-pm on 2007-10-02 18:28:55 +0000
 1.28.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.29.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.29.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.29.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.29.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.32.2.6 26-Dec-2007  ad Sync with head.
 1.32.2.5 13-Dec-2007  yamt don't leak linkcount on errors.
 1.32.2.4 12-Dec-2007  ad Minor corrections to previous.
 1.32.2.3 12-Dec-2007  ad - Don't use LK_RETRY in tmpfs_alloc_vp().
- Reduce cosmetic diffs to head.
 1.32.2.2 08-Dec-2007  ad Reduce coverage of the per-mount lock by using atomic ops.
 1.32.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.33.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.33.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.38.10.3 11-Aug-2010  yamt sync with head.
 1.38.10.2 04-May-2009  yamt sync with head.
 1.38.10.1 16-May-2008  yamt sync with head.
 1.38.8.1 18-May-2008  yamt sync with head.
 1.38.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.38.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.40.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.40.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.41.4.1 19-Oct-2008  haad Sync with HEAD.
 1.41.2.3 31-Jul-2008  simonb Sync with head.
 1.41.2.2 29-Jul-2008  simonb Sync with head.
 1.41.2.1 28-Jul-2008  simonb Sync with head.
 1.44.22.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.44.18.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.44.16.3 31-May-2011  rmind sync with head
 1.44.16.2 21-Apr-2011  rmind sync with head
 1.44.16.1 03-Jul-2010  rmind sync with head
 1.44.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.44.4.1 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.46.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.22.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.52.16.1 18-May-2014  rmind sync with head
 1.52.14.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.52.12.2 03-Dec-2017  jdolecek update from HEAD
 1.52.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.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.52.2.1 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.58.2.1 10-Aug-2014  tls Rebase.
 1.63.4.5 28-Aug-2017  skrll Sync with HEAD
 1.63.4.4 05-Feb-2017  skrll Sync with HEAD
 1.63.4.3 05-Oct-2016  skrll Sync with HEAD
 1.63.4.2 19-Mar-2016  skrll Sync with HEAD
 1.63.4.1 22-Sep-2015  skrll Sync with HEAD
 1.63.2.1 09-May-2016  snj Pull up following revision(s) (requested by joerg in ticket #1163):
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.66, 1.67
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.124
Only recheck size/node limits on update mounts, if there actually have
been specified.
--
Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.
 1.67.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.68.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.72.10.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.72.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.72.10.1 10-Jun-2019  christos Sync with HEAD
 1.72.8.2 18-Jan-2019  pgoyette Synch with HEAD
 1.72.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.72.2.1 09-Aug-2018  martin Pull up following revision(s) (requested by christos in ticket #968):

sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.73

Fix tmpfs performance regression from rmind@:
Just from a very quick look, it seems like a regression introduced with
the vcache changes: the MP-safe flag is set too late and not inherited
by the root vnode.
 1.74.4.1 03-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #753):

sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.75

remove an always false check and its' "This can never happen?" comment.
 1.75.2.3 24-Jan-2020  ad - Put all the namecache stuff back into vnode_impl_t.
- Tidy vfs_cache.c up, finish the comments.
- Finalise how ID information is entered to the cache.
- Handle very small/old systems.
 1.75.2.2 19-Jan-2020  ad Set IMNT_SHRLOOKUP and use it for the in-cache case. Need to check what
more can be done with tmpfs though, it can probably do the whole lookup.
 1.75.2.1 17-Jan-2020  ad Sync with head.
 1.150 01-Jun-2022  hannken tmpfs_read: respect MNT_NOATIME.
 1.149 27-Mar-2022  christos add a kauth vnode check for creating links
 1.148 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.147 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.146 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.145 13-Dec-2020  chs branches: 1.145.4;
Disable use of UBC_FAULTBUSY in tmpfs_write() for now,
which brings back zeroing of all new tmpfs data pages.
The existing code that enables this optimization skips the zeroing
in numerous cases where it is needed, resulting in corrupted files
and data leaks from the page's previous identity.
 1.144 05-Sep-2020  riastradh branches: 1.144.2;
Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.143 27-Jun-2020  christos Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.142 24-May-2020  ad tmpfs_write(): use UBC_FAULTBUSY when extending files, if possible, to avoid
zeroing of newly allocated pages & fault processing.
 1.141 19-May-2020  ad PR kern/32166: pgo_get protocol is ambiguous
Also problems with tmpfs+nfs noted by hannken@.

Don't pass PGO_ALLPAGES to pgo_get, and ignore PGO_DONTCARE in the
!PGO_LOCKED case. In uao_get() have uvm_pagealloc() take care of page
zeroing and release busy pages on error.
 1.140 17-May-2020  ad Minor correction to previous.
 1.139 17-May-2020  ad PR kern/55268: tmpfs is slow

tmpfs_getpages(): handle the PGO_LOCKED case and implement lazy update of
atime/mtime.
 1.138 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.137 15-May-2020  ad PR kern/55268: tmpfs is slow

Enter dotdot into the namecache.
 1.136 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.135 14-Mar-2020  ad branches: 1.135.2;
tmpfs_inactive(): do like other file systems and truncate the file if it
has been deleted. Otherwise VFS will try to write cached data "back to
disc", which in the case of a UAO means needless page deactivations and
the resulting TLB shootdowns.
 1.134 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.133 26-May-2017  riastradh branches: 1.133.10; 1.133.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.132 26-Apr-2017  riastradh 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.131 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.130 30-Mar-2017  hannken Protect tmpfs_getpages() against reclaiming vnodes.
 1.129 11-Jan-2017  joerg branches: 1.129.2;
Remove RO check in tmpfs_putpages for now, the syncer doesn't like the
error code.
 1.128 20-Aug-2016  hannken Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.127 12-Mar-2016  martin branches: 1.127.2;
Backout previous - need coffee first
 1.126 12-Mar-2016  martin Mark a variable as __diagused.
 1.125 12-Mar-2016  kardel do no access uninitialized variables in KASSERTs - fixes build
 1.124 12-Mar-2016  joerg Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.
 1.123 06-Jul-2015  hannken Change tmpfs to vcache.
- Use tmpfs node address as key.
- Remove tn_vlock, field tn_vnode now protected by vcache.
- Add a hold count to tmpfs node to prevent nodes from disappearing
while tmpfs_fhtovp() trys to vcache_get() them. Last holder
destroys reclaimed nodes.
- Remove the now unneeded parent unlock/lock for lookup of '..'.
 1.122 20-Apr-2015  riastradh Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.121 08-Sep-2014  gson branches: 1.121.2;
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length. Fixes the tmpfs part of PR kern/48864.
 1.120 25-Jul-2014  dholland branches: 1.120.2;
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.119 26-May-2014  rmind tmpfs_mknod: it is not our responsibility to call vput() on the directory
vnode, so remove it (and ensure *vpp is NULL while here).
 1.118 27-Feb-2014  hannken branches: 1.118.2;
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.117 17-Feb-2014  maxv Adapt my previous patch differently. read(2) wants EISDIR when the
object is a directory. Which also means that tmpfs_read() was returning
a wrong error code when dealing with non-regular vnodes.
 1.116 16-Feb-2014  maxv Fix tmpfs_read()'s return value; it should return EINVAL. Now consistent with
tmpfs_write().

ok christos@
 1.115 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.114 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.113 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.112 10-Jan-2014  pedro Prevent a diagnostic assertion in tmpfs_rmdir() from being triggered
through an rmdir on ".." by moving it so it happens after the check for
empty directories; OK rmind@.
 1.111 03-Jan-2014  hannken Fix a race where thread1 runs VOP_REMOVE() and gets preempted in
tmpfs_reclaim() before the call to tmpfs_free_node(). Thread2
runs VFS_FHTOVP() and gets a new vnode attached to the node thread1
is about to destroy.

Change tmpfs_alloc_node() to always assign non-zero generation number
and tmpfs_inactive() to set the generation number of unlinked nodes
to zero.
 1.110 24-Dec-2013  hannken It is not the task of tmpfs_open() to check for unlinked nodes.

Fix tmpfs_lookup() to always return ENOENT when looking up from
an unlinked directory.
 1.109 24-Nov-2013  rmind - tmpfs_construct_node: prevent from the new node construction if the
directory was removed. Fixes the crash reported by Nicolas Joly.
- tmpfs_reclaim: avoid race by checking tn_links with the vnode locked.
 1.108 23-Nov-2013  rmind Fix previous, add __diagused.
 1.107 23-Nov-2013  rmind - Simplify tmpfs_update(), eliminate tmpfs_note_t::tn_status and deferred
timestamp updates. Fix some incorrect updates and plug some missing ones.
Should fix PR/48385.
- tmpfs_rmdir: avoid O(n) scan when the directory is not empty and whiteout
entries were never added.
 1.106 08-Nov-2013  rmind tmpfs: replace the broken tmpfs_dircookie() logic which uses the node
address truncated to 31 bits (required for 32-bit readdir compatibility,
e.g. linux32). Instead, assign 2^31 range using the following logic:
- The first half of the 2^31 is assigned incrementally (the fast path).
- When exceeded, use the second half of 2^31, but manage with vmem(9).

It will require 2 billion files per-directory to trigger vmem(9) usage.
Also, while here, add some fixes for tmpfs_unmount().

Should fix PR/47739, PR/47480, PR/46088 and PR/41068.
Thanks to wiz@ for stress testing.
 1.105 01-Nov-2013  rmind tmpfs: fix the zero-length symlink target case as NetBSD supports them.
 1.104 31-Oct-2013  rmind tmpfs_alloc_node: it is less error-prone to store the link path with
the NIL terminator included. Adjust tmpfs_readlink() to exclude NIL.
Also, remove the check for zero-length and add some asserts.
 1.103 04-Oct-2013  rmind - tmpfs_remove: check 'appendable' flag for the parent directory as well.
Patch from Pedro Martelletto.
- tmpfs_dir_detach: remove missleading check.
- tmpfs_link: remove unused variable.
 1.102 01-Oct-2013  rmind tmpfs_remove: as per POSIX, "if the file's link count is not 0, the last
file status change timestamp of the file shall be marked for update."

From Pedro Martelletto.
 1.101 18-Mar-2013  plunky branches: 1.101.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.100 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.99 05-Nov-2012  dholland 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.98 22-Jul-2012  rmind branches: 1.98.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.97 09-May-2012  riastradh Adapt tmpfs_rename to use genfs_rename.
 1.96 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.95 27-Feb-2012  chs in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.
 1.94 22-Jan-2012  rmind branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.
 1.93 18-Nov-2011  christos branches: 1.93.4;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.92 27-Sep-2011  christos branches: 1.92.2;
return TMPFS_MAXNAMLEN instead of NAME_MAX
 1.91 27-Sep-2011  christos define and use TMPFS_MAXNAMLEN instead of MAXNAMLEN
 1.90 27-Aug-2011  hannken Finish and enable whiteout support for tmpfs:

- Enable VOP tmpfs_whiteout().
- Support ISWHITEOUT in tmpfs_alloc_file().
- Support DOWHITEOUT in tmpfs_remove() and tmpfs_rmdir().
- Make rmdir on a directory containing whiteouts working.

Should fix PR #35112 (tmpfs doesn't play well with unionfs).
 1.89 18-Aug-2011  riastradh Fix tmpfs_rename locking.

Fixes PR kern/36681. tmpfs now survives dirconc, all our vfs/tmpfs
tests and rename races in atf, and a bunch of hand-written tests
that I'd commit if atf didn't find them highly indigestible.

ok dholland
 1.88 13-Jul-2011  riastradh Fix renaming over mismatched non-directory types in tmpfs.

Renaming a file of any non-directory type over another file of any
other non-directory type is OK -- they need not match as long as
neither is a directory, so loosen the kassert to reflect this.

XXX Need to write test cases for this.

ok dholland, rmind
 1.87 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.86 30-May-2011  rmind branches: 1.86.2;
- tmpfs_getattr: perform tmpfs_update() before fetching the timestamps.
- tmpfs_rmdir: detach after tn_links decrement, so that correct event
i.e. NOTE_DELETE would be trigerred.
 1.85 29-May-2011  rmind - Rework and document inode reference counting. Also document inode life
cycle (destruction part). Perform link counting in tmpfs_dir_attach()
and tmpfs_dir_detach(), instead of alloc/free and arbitrary places.
Fixes PR/44285, PR/44288, PR/44657 and likely PR/42484.

- Fix the race between the lookup and inode destruction. Fixes PR/43167
and its duplicates PR/40088, PR/40757.

- Improve tmpfs_rename() locking a little, fix kqueue event notifications
and also fix PR/43617. Add simplistic tmpfs_parentcheck_p(); to be
expanded and used for further rename() locking fixes.

- Cache directory entry "hint" in the tmpfs node, add tmpfs_dir_cached(),
and thus avoid unnecessary lookup in tmpfs_remove() and tmpfs_rmdir().

- Set correct _PC_FILESIZEBITS value in tmpfs_pathconf(). Fixes PR/43576.

- Few minor fixes.
 1.84 24-May-2011  rmind - tmpfs_lookup: cache (cnp->cn_flags & ISLASTCN) in const bool; de-indent.
- Group tmpfs_{alloc,free}_dirent() with other dirent routines.

No functional changes.
 1.83 24-May-2011  rmind - Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.82 19-May-2011  rmind Add comments, clean up.
 1.81 19-May-2011  rmind Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.80 10-May-2011  matt yes, more C99 please (back out previous change).
 1.79 08-May-2011  christos no c99 please.
 1.78 02-May-2011  rmind Constify, update some comments, use memset() to clear pgs.
 1.77 24-Apr-2011  rmind sys_link: prevent hard links on directories (cross-mount operations are
already prevented). File systems are no longer responsible to check this.
Clean up and add asserts (note that dvp == vp cannot happen in vop_link).

OK dholland@
 1.76 13-Jan-2011  pooka branches: 1.76.2;
Add some support for unionfs (not built by default). It's still
missing at least opaque directory support, but until someone figures
out how that should work on ffs (see PR kern/kern/44383), there's
no point in trying to figure out how it should work here.
 1.75 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.74 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.73 14-Jul-2010  pooka return same errno as ffs
 1.72 02-Jul-2010  rmind tmpfs_lookup: add comment, de-ident main path. No functional change.
tmpfs_dir_attach: add assert.
 1.71 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.70 22-Jun-2010  rmind Replace tmpfs_pool custom allocator code with a simpler layer for memory
accounting. Use wired memory (which can be limited) for meta-data, and
kmem(9) for string allocations.

Close PR/31944. Fix PR/38361 while here. OK ad@.
 1.69 23-Apr-2010  pooka Enforce RLIMIT_FSIZE before VOP_WRITE. This adds support to file
system drivers where it was missing from and fixes one buggy
implementation. The arguably weird semantics of the check are
maintained (v_size vs. va_bytes, overwrite).
 1.68 29-Mar-2010  pooka Stop exposing fifofs internals and leave only fifo_vnodeop_p visible.
 1.67 27-Mar-2010  pooka \n, police!
 1.66 08-Jan-2010  pooka branches: 1.66.2; 1.66.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.65 22-Nov-2009  jmmv Fix panic when trying to delete a directory entry (hi yamt!) by not
attempting to release a pnbuf that does not exist.

I.e. fixes "mkdir a ; unlink a/.". And actually, this was caught by the
automated tests.
 1.64 17-Oct-2009  njoly Make tmpfs write fail when process file size limit is reached.
 1.63 06-Oct-2009  rmind tmpfs_rename: handle hard-links correctly. Fixes PR/41236.
 1.62 03-Sep-2009  elad Implement the vnode scope and adapt tmpfs to use it.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/07/04/msg005404.html
 1.61 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.60 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.59 29-Apr-2009  pooka replace outdated comment. no functional change
 1.58 15-Apr-2009  yamt plug some pnbuf leaks.
 1.57 11-Apr-2009  perry SAVENAME was not set for rename and delete as required

Patch from christos, fixes pr 41183
 1.56 05-Apr-2009  pooka Invariants should be tested for with KASSERT instead of semi-pretending
that them not holding is an acceptable error condition.
 1.55 03-Apr-2009  pooka Fix yet another recent crashy bug in tmpfs rename: since the source
dirent is no longer cached in lookup and we do the lookup ourselves
in rename, we are most definitely not allowed to assert that it
matches the source vnode passed as an argument. In case the source
node does not exist or has been replaced, punt with ENOENT.

Also, nuke some misleading prehistoric comments which haven't been
valid in over a year.

Fixes PR kern/41128 by Nicolas Joly
 1.54 19-Mar-2009  pooka Release dvp in mknod error branch.

Nicolas Joly, PR kern/41006
 1.53 07-Feb-2009  pooka branches: 1.53.2;
If fdvp is tvp, do nothing. Prevents local DoS panic described in
PR kern/38219... maybe. This is hastily concocted fix for 5.0 and
I'm not sure if it has side-effects.
 1.52 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.51 19-Jun-2008  christos branches: 1.51.2; 1.51.4; 1.51.6;
- setting the birthdate is valid in setattr.
- don't call nanotime if not needed.
- don't call tempfs_update() if tempfs_chtimes succeeded, because it just did.
 1.50 28-Apr-2008  martin branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses
 1.49 06-Feb-2008  jmmv branches: 1.49.6; 1.49.8; 1.49.10;
Drop trailing whitespace.
 1.48 31-Jan-2008  ad Remove debugging code that's no longer needed.
 1.47 30-Jan-2008  ad Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.46 25-Jan-2008  ad Remove VOP_LEASE. Discussed on tech-kern.
 1.45 02-Jan-2008  ad Merge vmlocking2 to head.
 1.44 26-Nov-2007  pooka branches: 1.44.2; 1.44.6;
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.43 23-Nov-2007  pooka Fix a race condition: in case two source paths hardlinked to the
same file were renamed simultaneously, there was a window where
directory entry cached in the vnode during lookup would be replaced
before calling rename. This lead to one directory entry getting
renamed twice and the other one getting zero renames. Do a relookup
in rename to make sure we have the correct directory entry.

Thanks go to Greg Oster for reporting the problem, helping with
debugging and thoroughly testing the patch.
 1.42 10-Nov-2007  ad Back out the tmpfs changes; there appears to be a bug lurking.
 1.41 06-Nov-2007  ad Merge from vmlocking.
 1.40 23-Oct-2007  dyoung branches: 1.40.2;
Borrow a clue from the vmlocking branch, and consolidate all of
the vput(9)ing in tmpfs_rmdir() in one place. No functional change
intended.
 1.39 23-Jul-2007  jmmv branches: 1.39.4; 1.39.6; 1.39.10; 1.39.12;
Multiple fixes for tmpfs' rename operation:

- Raise an error if renaming a file to a directory.
- Raise an error if renaming a directory to a file.
- Raise an error if renaming a directory to a non-empty directory.
- Properly allow renaming a directory to an empty directory.
The system could previously crash if the kernel had DIAGNOSTIC enabled,
as this triggered a bogus assertion.

Problem found by Geoff Wing.
 1.38 09-Jul-2007  ad branches: 1.38.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.37 22-Feb-2007  thorpej branches: 1.37.4; 1.37.6;
TRUE -> true, FALSE -> false
 1.36 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.35 04-Jan-2007  elad branches: 1.35.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.34 02-Jan-2007  pooka * fix locking gotchas when trying to unlink "."
* return standard EPERM when trying to unlink a directory
* reorder some checks in rmdir avoid problems if trying to rmdir ".."

jmmv ok
 1.33 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.32 09-Nov-2006  jmmv branches: 1.32.2;
Opening a file after it has been removed (e.g. rmdir $(pwd)) has to fail.
 1.31 09-Nov-2006  jmmv Audit kqueue notifications. The reference behavior is taken from MFS and
is represented in the regression tests.
 1.30 07-Nov-2006  jmmv tmpfs_open cannot assume that the node to be open is still linked to a
directory, so remove an invalid assertion. Otherwise the kernel incorrectly
panics when accessing the current directory after it has been removed.
 1.29 05-Nov-2006  jmmv Truncate directory cookies to 31 bits to avoid problems exposed in Linux
binaries which cast the returned values to 64-bits and fail due to sign
expansion. More details are provided in the big comment in tmpfs.h that
describes how the new tmpfs_dircookie works.

This is a rather ugly hack that shall be fixed with a cleaner solution,
but this resolves the problem in an effective way.

Fixes kern PR/32034.
 1.28 02-Nov-2006  jmmv Make tmpfs_getpages behave as genfs_getpages by ignoring the input pages
array's contents and returning all the requested pages. Otherwise there
are problems (accessing invalid memory) when the a_m vector is passed
uninitialized as the NFS server code does. Fixes PR kern/34959.

Note that this is not a "real" fix. While this makes tmpfs's getpages
operation consistent with the behavior of other file systems, it does
not resolve the different semantics between uvn_get and uao_get as
described in PR kern/32166. I'm adding a comment in the code mentioning
exactly this so that it can be reviewed when this last problem is
addressed.
 1.27 30-Oct-2006  jmmv Update the file's ctime after a rename. Thanks to pooka@.
 1.26 30-Oct-2006  jmmv When renaming a file, we have to modify the mtime of the directory holding
it, not the mtime of the file itself. This fixes the problems exposed when
unpacking software under a tmpfs and trying to build it because dependencies
were not calculated properly (e.g. autoconf 2.60 as reported by tls@).
 1.25 23-Jul-2006  ad branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.
 1.24 15-May-2006  christos branches: 1.24.6;
kauth fallout
 1.23 14-May-2006  elad integrate kauth.
 1.22 21-Feb-2006  christos branches: 1.22.2; 1.22.4; 1.22.6;
PR/31850: Geoff Wing: tmpfs does not honor sticky directories.
 1.21 16-Feb-2006  jmmv Do not use unnamed structures/unions without instances; they break the
build under vax because of gcc 2.95. Found by he@.
 1.20 26-Jan-2006  jmmv branches: 1.20.2; 1.20.4;
Cut a too long line introduced during the conversion to lwps.
 1.19 11-Dec-2005  christos branches: 1.19.2;
merge ktrace-lwp.
 1.18 29-Nov-2005  yamt merge yamt-readahead branch.
 1.17 02-Nov-2005  yamt branches: 1.17.2; 1.17.4;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.16 03-Oct-2005  jmmv branches: 1.16.2;
Follow symlinks during lookup (i.e., don't stop too early) so that symlinks
to directories work as expected. Diagnosed by Greg Oster.
 1.15 29-Sep-2005  jmmv Implement the tmpfs_advlock operation. Makes "user-level" file locking
work (aka lockf(3)).
 1.14 28-Sep-2005  yamt tmpfs_getattr: return up-to-date timestamps.
 1.13 26-Sep-2005  yamt tmpfs_rename: fix lock/unlock mismatch.
 1.12 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.11 23-Sep-2005  jmmv Lock the source directory during the rename operation so that we are safe
to modify it (I hope this is the correct way to go). Avoids triggering an
assertion in the tmpfs_dir_detach function, shown by the t_rename
regression test.
 1.10 15-Sep-2005  yamt change the way to handle directory "offsets" so that
they won't be changed when removing entries in the directory.
some applications like cvs rely on this.
 1.9 14-Sep-2005  yamt tmpfs_getpages: don't create pages past eof.
 1.8 14-Sep-2005  yamt tmpfs_read: handle requests past EOF.
 1.7 13-Sep-2005  jmmv Adapt recent changes to the style of the rest of the file.
 1.6 13-Sep-2005  yamt - don't waste/leak kva.
- implement getpages/putpages. support mmap.
- eliminate meaningless memcpy.
- ubcify.
 1.5 13-Sep-2005  yamt tmpfs_read: return EISDIR rather than EINVAL for non-VREG files.
XXX should we follow nfs, which uses EPERM?
 1.4 13-Sep-2005  yamt tmpfs_link: always free pnbuf.
 1.3 12-Sep-2005  christos convert to use it nanotime, but don't call it unless it is necessary.
 1.2 10-Sep-2005  jmmv wiz@ remembers that the preferred way to spell file-system in NetBSD is
file system.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.16.2.2 29-Oct-2005  yamt as tmpfs_update never fails, make it return void.
suggested by Chuck Silvers.
 1.16.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.17.4.1 19-Nov-2005  yamt - as read-ahead context is per-vnode now,
there are less reasons to make VOP_READ call uvm_ra_request explicitly.
move it to pager (uvn_get) so that it can handle accesses via mmap as well.
- pass advice to pager via ubc.
- tweak DPRINTF.

XXX can be disturbed by PGO_LOCKED.

XXX it's controversial where it should be done.
(uvm_fault, uvn_get or genfs_getpages.)
 1.17.2.4 11-Dec-2005  christos Sync with head.
 1.17.2.3 12-Nov-2005  skrll Adapt to branch
 1.17.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.1 02-Nov-2005  skrll file tmpfs_vnops.c was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.19.2.3 01-Mar-2006  yamt sync with head.
 1.19.2.2 18-Feb-2006  yamt sync with head.
 1.19.2.1 01-Feb-2006  yamt sync with head.
 1.20.4.2 01-Jun-2006  kardel Sync with head.
 1.20.4.1 22-Apr-2006  simonb Sync with head.
 1.20.2.1 09-Sep-2006  rpaulo sync with head
 1.22.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.22.4.2 18-Apr-2006  elad adapt to kauth, pointed out by yamt@, thanks!
 1.22.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.22.2.2 11-Aug-2006  yamt sync with head
 1.22.2.1 24-May-2006  yamt sync with head.
 1.24.6.10 11-Feb-2008  yamt sync with head.
 1.24.6.9 04-Feb-2008  yamt sync with head.
 1.24.6.8 21-Jan-2008  yamt sync with head
 1.24.6.7 07-Dec-2007  yamt sync with head
 1.24.6.6 27-Oct-2007  yamt sync with head.
 1.24.6.5 03-Sep-2007  yamt sync with head.
 1.24.6.4 26-Feb-2007  yamt sync with head.
 1.24.6.3 30-Dec-2006  yamt sync with head.
 1.24.6.2 21-Jun-2006  yamt sync with head.
 1.24.6.1 15-May-2006  yamt file tmpfs_vnops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.25.6.1 10-Dec-2006  yamt sync with head.
 1.25.4.2 12-Jan-2007  ad Sync with head.
 1.25.4.1 18-Nov-2006  ad Sync with head.
 1.32.2.4 01-Feb-2008  riz Pull up following revision(s) (requested by pooka in ticket #1010):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.43
Fix a race condition: in case two source paths hardlinked to the
same file were renamed simultaneously, there was a window where
directory entry cached in the vnode during lookup would be replaced
before calling rename. This lead to one directory entry getting
renamed twice and the other one getting zero renames. Do a relookup
in rename to make sure we have the correct directory entry.
Thanks go to Greg Oster for reporting the problem, helping with
debugging and thoroughly testing the patch.
 1.32.2.3 24-Jul-2007  liamjfoy Pull up following revision(s) (requested by jmmv in ticket #786):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.39
regress/sys/fs/tmpfs/h_tools.c: revision 1.8
regress/sys/fs/tmpfs/t_rename: revision 1.6
regress/sys/fs/tmpfs/t_rename: revision 1.7
Add test cases to ensure that:
1) Renaming a directory to an empty directory works by replacing
the target directory.
2) Renaming a directory to a non-empty directory fails.
This is all by calling rename(2) directly, not mv(1).

tmpfs currently fails those tests, raising an assertion if
DIAGNOSTIC is
enabled. A fix will hopefully follow soon.
Found by pooka@.

Add some more tests to ensure that renaming a file to a directory
and a directory to a file fails with the appropriate error codes.
tmpfs still fails these tests, but the fix is almost ready to go in.

Multiple fixes for tmpfs' rename operation:
- Raise an error if renaming a file to a directory.
- Raise an error if renaming a directory to a file.
- Raise an error if renaming a directory to a non-empty directory.
- Properly allow renaming a directory to an empty directory.

The system could previously crash if the kernel had DIAGNOSTIC
enabled, as this triggered a bogus assertion.
Problem found by Geoff Wing.
 1.32.2.2 17-Feb-2007  tron branches: 1.32.2.2.2;
Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.32.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by pooka in ticket #324):
regress/sys/fs/tmpfs/t_remove: revision 1.8
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.34
* fix locking gotchas when trying to unlink "."
* return standard EPERM when trying to unlink a directory
* reorder some checks in rmdir avoid problems if trying to rmdir ".."
* add a test to check that unlink of "." is not succesful
 1.32.2.2.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.32.2.2.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.35.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.37.6.1 11-Jul-2007  mjf Sync with head.
 1.37.4.8 01-Nov-2007  ad Disable the leaked node KASSERT in tmpfs_rmdir for the time being.
 1.37.4.7 18-Oct-2007  ad tmpfs_rmdir: move assertion to catch leaked tmpfs_nodes to the correct
spot.
 1.37.4.6 08-Oct-2007  ad - Don't leave nodes dangling in order to keep track of the inode generation
number. Free them back to the pool as soon as the referenced file becomes
unused. Using arc4random() for the generation and ino_t based off the
node's in-core address is just about as as good as a disk-based file
system is going to give.
- Add assertion to catch empty directories with linkcount > 1 being freed.
This fires frequently but I haven't tracked the bug down yet..
- Use kmem_alloc.
 1.37.4.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.37.4.4 22-Aug-2007  ad Fix some more concurrency problems.
 1.37.4.3 20-Aug-2007  ad Sync with HEAD.
 1.37.4.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.37.4.1 21-Mar-2007  ad GC the simplelock/spinlock debugging stuff.
 1.38.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.39.12.2 23-Jul-2007  jmmv Multiple fixes for tmpfs' rename operation:

- Raise an error if renaming a file to a directory.
- Raise an error if renaming a directory to a file.
- Raise an error if renaming a directory to a non-empty directory.
- Properly allow renaming a directory to an empty directory.
The system could previously crash if the kernel had DIAGNOSTIC enabled,
as this triggered a bogus assertion.

Problem found by Geoff Wing.
 1.39.12.1 23-Jul-2007  jmmv file tmpfs_vnops.c was added on branch matt-mips64 on 2007-07-23 15:41:02 +0000
 1.39.10.1 13-Nov-2007  bouyer Sync with HEAD
 1.39.6.4 23-Mar-2008  matt sync with HEAD
 1.39.6.3 09-Jan-2008  matt sync with HEAD
 1.39.6.2 08-Nov-2007  matt sync with -HEAD
 1.39.6.1 06-Nov-2007  matt sync with HEAD
 1.39.4.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.39.4.3 11-Nov-2007  joerg Sync with HEAD.
 1.39.4.2 06-Nov-2007  joerg Sync with HEAD.
 1.39.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.40.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.40.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.40.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.44.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.44.2.11 27-Dec-2007  ad Uninit variable warning
 1.44.2.10 27-Dec-2007  ad tmpfs_rename: don't free garbage if failing a cross-device rename.
 1.44.2.9 27-Dec-2007  ad tmpfs_rename: reject cross-mount renames before doing anything else.
 1.44.2.8 22-Dec-2007  ad Fix error in previous.
 1.44.2.7 22-Dec-2007  ad tmpfs_rename: fix a couple more problems.
 1.44.2.6 13-Dec-2007  ad Kill tn_lookup_dirent and find the correct node using the supplied
componentname.
 1.44.2.5 13-Dec-2007  yamt tmpfs_lookup: don't bother to cache dotdot entry. fixes rename.
 1.44.2.4 13-Dec-2007  yamt tmpfs_rmdir: fix an assertion.
 1.44.2.3 12-Dec-2007  ad Minor corrections to previous.
 1.44.2.2 12-Dec-2007  ad - Don't use LK_RETRY in tmpfs_alloc_vp().
- Reduce cosmetic diffs to head.
 1.44.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.49.10.6 11-Aug-2010  yamt sync with head.
 1.49.10.5 11-Mar-2010  yamt sync with head
 1.49.10.4 16-Sep-2009  yamt sync with head
 1.49.10.3 18-Jul-2009  yamt sync with head.
 1.49.10.2 04-May-2009  yamt sync with head.
 1.49.10.1 16-May-2008  yamt sync with head.
 1.49.8.1 18-May-2008  yamt sync with head.
 1.49.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.49.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.49.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.50.4.1 27-Jun-2008  simonb Sync with head.
 1.50.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.6.6 07-Dec-2009  snj Pull up following revision(s) (requested by rmind in ticket #1072):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.63
tmpfs_rename: handle hard-links correctly. Fixes PR/41236.
 1.51.6.5 19-Apr-2009  snj branches: 1.51.6.5.4;
Pull up following revision(s) (requested by ad in ticket #690):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.58
plug some pnbuf leaks.
 1.51.6.4 19-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #690):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.57
SAVENAME was not set for rename and delete as required
Patch from christos, fixes pr 41183
 1.51.6.3 08-Apr-2009  snj Pull up following revision(s) (requested by tron in ticket #680):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.55
Fix yet another recent crashy bug in tmpfs rename: since the source
dirent is no longer cached in lookup and we do the lookup ourselves
in rename, we are most definitely not allowed to assert that it
matches the source vnode passed as an argument. In case the source
node does not exist or has been replaced, punt with ENOENT.
Also, nuke some misleading prehistoric comments which haven't been
valid in over a year.
Fixes PR kern/41128 by Nicolas Joly
 1.51.6.2 24-Mar-2009  snj Pull up following revision(s) (requested by pooka in ticket #590):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.54
Release dvp in mknod error branch.
Nicolas Joly, PR kern/41006
 1.51.6.1 16-Feb-2009  snj Pull up following revision(s) (requested by pooka in ticket #432):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.53
If fdvp is tvp, do nothing. Prevents local DoS panic described in
PR kern/38219... maybe. This is hastily concocted fix for 5.0 and
I'm not sure if it has side-effects.
 1.51.6.5.4.1 21-Apr-2010  matt sync to netbsd-5
 1.51.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.51.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.51.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.51.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.53.2.2 23-Jul-2009  jym Sync with HEAD.
 1.53.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.66.4.6 31-May-2011  rmind sync with head
 1.66.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.66.4.4 05-Mar-2011  rmind sync with head
 1.66.4.3 03-Jul-2010  rmind sync with head
 1.66.4.2 30-May-2010  rmind sync with head
 1.66.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.66.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.66.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.76.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.86.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.92.2.7 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.92.2.6 16-Jan-2013  yamt sync with (a bit old) head
 1.92.2.5 30-Oct-2012  yamt sync with head
 1.92.2.4 23-May-2012  yamt sync with head.
 1.92.2.3 17-Apr-2012  yamt sync with head
 1.92.2.2 25-Jan-2012  yamt uvm_loanabj: take an access pattern hint.
 1.92.2.1 04-Jan-2012  yamt enable O->A loaning read for a few filesystems.
 1.93.4.6 02-Jun-2012  mrg sync to latest -current.
 1.93.4.5 05-Apr-2012  mrg sync to latest -current.
 1.93.4.4 06-Mar-2012  mrg sync to -current
 1.93.4.3 06-Mar-2012  mrg sync to -current
 1.93.4.2 04-Mar-2012  mrg sync to latest -current.
 1.93.4.1 18-Feb-2012  mrg merge to -current.
 1.94.2.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.94.2.1 27-Feb-2012  riz Pull up following revision(s) (requested by chs in ticket #58):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.95
in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.
 1.98.2.4 03-Dec-2017  jdolecek update from HEAD
 1.98.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.98.2.2 23-Jun-2013  tls resync from head
 1.98.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.101.6.1 18-May-2014  rmind sync with head
 1.118.2.1 10-Aug-2014  tls Rebase.
 1.120.2.3 10-May-2016  snj Pull up following revision(s) (requested by joerg in ticket #1163):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.125
do not access uninitialized variables in KASSERTs - fixes build
 1.120.2.2 09-May-2016  snj Pull up following revision(s) (requested by joerg in ticket #1163):
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.66, 1.67
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.124
Only recheck size/node limits on update mounts, if there actually have
been specified.
--
Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.
 1.120.2.1 22-Dec-2014  msaitoh Pull up following revision(s) (requested by gson in ticket #344):
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.121
sys/fs/tmpfs/tmpfs_subr.c: revision 1.97
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length. Fixes the tmpfs part of PR kern/48864.
 1.121.2.6 28-Aug-2017  skrll Sync with HEAD
 1.121.2.5 05-Feb-2017  skrll Sync with HEAD
 1.121.2.4 05-Oct-2016  skrll Sync with HEAD
 1.121.2.3 19-Mar-2016  skrll Sync with HEAD
 1.121.2.2 22-Sep-2015  skrll Sync with HEAD
 1.121.2.1 06-Jun-2015  skrll Sync with HEAD
 1.127.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.127.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.129.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.133.16.1 29-Feb-2020  ad Sync with head.
 1.133.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.135.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.144.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.145.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.14 18-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.
 1.13 24-May-2011  rmind branches: 1.13.72;
- Describe some locking.
- Add VOP argument comments, add some asserts.
- Update/fix/remove outdated/missleading comments.
- Clean up, de-indent, KNF, misc.

No functional changes intended.
 1.12 13-Jan-2011  pooka branches: 1.12.2;
Add some support for unionfs (not built by default). It's still
missing at least opaque directory support, but until someone figures
out how that should work on ffs (see PR kern/kern/44383), there's
no point in trying to figure out how it should work here.
 1.11 28-Apr-2008  martin branches: 1.11.22;
Remove clause 3 and 4 from TNF licenses
 1.10 25-Jan-2008  ad branches: 1.10.6; 1.10.8; 1.10.10;
Remove VOP_LEASE. Discussed on tech-kern.
 1.9 09-Nov-2006  jmmv branches: 1.9.24; 1.9.30;
Add 2006 to the copyright notice; should have done this when touching the
files before.
 1.8 09-Nov-2006  jmmv Audit kqueue notifications. The reference behavior is taken from MFS and
is represented in the regression tests.
 1.7 03-Dec-2005  christos branches: 1.7.18; 1.7.22; 1.7.24;
- 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.6 02-Nov-2005  yamt branches: 1.6.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.5 29-Sep-2005  jmmv branches: 1.5.2;
Implement the tmpfs_advlock operation. Makes "user-level" file locking
work (aka lockf(3)).
 1.4 23-Sep-2005  jmmv Kill the tmpfs(9) manual page; it was just documenting internal details of
tmpfs' "API" and was already rotting.

Instead, merge all the relevant comments into the code. This includes
acknowledgements to Google's Summer of Code 2005 program (they were in the
AUTHORS section of tmpfs(9) before), so all the files need to be changed
to include this sentence alongside the title. (Note that this was not a
requirement of the program.)
 1.3 13-Sep-2005  yamt - don't waste/leak kva.
- implement getpages/putpages. support mmap.
- eliminate meaningless memcpy.
- ubcify.
 1.2 12-Sep-2005  yamt fix lock/unlock mismatch. XXX this is not a real fix.
 1.1 10-Sep-2005  jmmv Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.5.2.1 20-Oct-2005  yamt adapt tmpfs.
 1.6.2.3 11-Dec-2005  christos Sync with head.
 1.6.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.1 02-Nov-2005  skrll file tmpfs_vnops.h was added on branch ktrace-lwp on 2005-11-10 14:09:44 +0000
 1.7.24.1 10-Dec-2006  yamt sync with head.
 1.7.22.1 18-Nov-2006  ad Sync with head.
 1.7.18.4 04-Feb-2008  yamt sync with head.
 1.7.18.3 30-Dec-2006  yamt sync with head.
 1.7.18.2 21-Jun-2006  yamt sync with head.
 1.7.18.1 03-Dec-2005  yamt file tmpfs_vnops.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.9.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.24.1 23-Mar-2008  matt sync with HEAD
 1.10.10.1 16-May-2008  yamt sync with head.
 1.10.8.1 18-May-2008  yamt sync with head.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.22.2 31-May-2011  rmind sync with head
 1.11.22.1 05-Mar-2011  rmind sync with head
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.72.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 02-Feb-2006  reinoud branches: 1.1.4; 1.1.16; 1.1.22;
Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 02-Feb-2006  rpaulo file Makefile was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 02-Feb-2006  yamt file Makefile was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.1.4.2 18-Feb-2006  yamt sync with head.
 1.1.4.1 02-Feb-2006  yamt file Makefile was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.17 18-Mar-2022  reinoud Replace the variable field data[0] to data[1] to avoid undefined behaviour.
 1.16 09-Aug-2018  reinoud Sync with UDFclient
 1.15 25-Jul-2018  kamil Avoid undefined behavior in ecma167-udf.h

Define the UDF_EXT_* symbols as unsigned values.
This prevents undefined behavior of altering the signedness bit in a part
of them. Swap the remaining symbols to unsigned values to keep the
consistency.

Required by GCC when building with Undefined Behavior Sanitizer.
 1.14 07-Jul-2011  reinoud branches: 1.14.52; 1.14.54;
English checked and corrected, courtisy of
Igor Sobrado <sobrado@orion.ciencias.uniovi.es> as noted in OpenBSD that has a
copy of this file.
 1.13 23-Dec-2009  mbalmer Fix typo in comments, no code change.
 1.12 18-May-2009  reinoud Make ecma167 header file compilable by pcc
 1.11 25-Jul-2008  reinoud branches: 1.11.4; 1.11.8; 1.11.12;
Add metadata bitmap ICB file type
 1.10 24-Jun-2008  reinoud branches: 1.10.2;
Fix attribute length calculation and fix naming convention.
 1.9 21-Jun-2008  reinoud Elaborate file times extension times definition.
 1.8 14-May-2008  reinoud branches: 1.8.2;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.7 25-Dec-2007  perry branches: 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.6 04-Jan-2007  reinoud branches: 1.6.20; 1.6.26; 1.6.28; 1.6.32;
Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
 1.5 22-Oct-2006  reinoud branches: 1.5.2;
Add extended attribute numbers associated with the two defined structures
for times and device specification.
 1.4 31-Aug-2006  reinoud branches: 1.4.2; 1.4.4; 1.4.6;
Add shortcut for struct long_ad 's Unique ID hint that covers the lower 32
bits of the targeted files 64 bits Unique ID for recovery purposes.
 1.3 25-Aug-2006  reinoud Fix small though important errors in the Ecma-167 structure definitions.
 1.2 02-Feb-2006  reinoud branches: 1.2.4; 1.2.6; 1.2.16; 1.2.18;
Replace reinclude protection names with less generic versions.
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.2.18.2 08-Sep-2006  rpaulo Pull up following revision(s) (requested by reinoud in ticket #125):
sys/fs/udf/udf_subr.c: revision 1.15
sys/fs/udf/udf_vfsops.c: revision 1.13
sys/fs/udf/ecma167-udf.h: revision 1.4
Add shortcut for struct long_ad 's Unique ID hint that covers the lower 32
bits of the targeted files 64 bits Unique ID for recovery purposes.
Fix locking scheme in udf_mount() to follow more the other filingsystems.
For yet unknown reasons passing the LOCKLEAF flag to namei() did return a
locked vnode as was meant but would panic when a raw device was passed.
Fix copying too much space from a small buffer. The chances of it actually
happening are small but corrupt media could trigger it.
 1.2.18.1 27-Aug-2006  riz Pull up following revision(s) (requested by reinoud in ticket #66):
sys/fs/udf/ecma167-udf.h: revision 1.3
Fix small though important errors in the Ecma-167 structure definitions.
 1.2.16.5 21-Jan-2008  yamt sync with head
 1.2.16.4 26-Feb-2007  yamt sync with head.
 1.2.16.3 30-Dec-2006  yamt sync with head.
 1.2.16.2 21-Jun-2006  yamt sync with head.
 1.2.16.1 02-Feb-2006  yamt file ecma167-udf.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.2.6.1 03-Sep-2006  yamt sync with head.
 1.2.4.2 18-Feb-2006  yamt sync with head.
 1.2.4.1 02-Feb-2006  yamt file ecma167-udf.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.4.6.1 22-Oct-2006  yamt sync with head
 1.4.4.2 09-Sep-2006  rpaulo sync with head
 1.4.4.1 31-Aug-2006  rpaulo file ecma167-udf.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.4.2.2 12-Jan-2007  ad Sync with head.
 1.4.2.1 18-Nov-2006  ad Sync with head.
 1.5.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #333):
sys/fs/udf/udf_subr.c: revision 1.27-1.29
sys/fs/udf/udf_vnops.c: revision 1.9
sys/fs/udf/ecma167-udf.h: revision 1.6
Fix compilation issue when specifying different flags or compiling with a
different compiler. Thanks to Jared for noting.
Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
Forgot one place for UDF_ICB_FILETYPE_RANDOMACCESS.
 1.6.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.28.1 26-Dec-2007  ad Sync with head.
 1.6.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.20.1 09-Jan-2008  matt sync with HEAD
 1.7.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.10.4 11-Mar-2010  yamt sync with head
 1.7.10.3 20-Jun-2009  yamt sync with head
 1.7.10.2 04-May-2009  yamt sync with head.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.7.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.2.2 28-Jul-2008  simonb Sync with head.
 1.8.2.1 27-Jun-2008  simonb Sync with head.
 1.10.2.1 19-Oct-2008  haad Sync with HEAD.
 1.11.12.1 21-Apr-2010  matt sync to netbsd-5
 1.11.8.1 23-Jul-2009  jym Sync with HEAD.
 1.11.4.1 06-Jun-2009  bouyer Pull up following revision(s) (requested by reinoud in ticket #769):
sys/fs/udf/ecma167-udf.h: revision 1.12
Make ecma167 header file compilable by pcc
 1.14.54.1 10-Jun-2019  christos Sync with HEAD
 1.14.52.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.14.52.1 28-Jul-2018  pgoyette Sync with HEAD
 1.6 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.5 10-Jul-2013  reinoud Implement udf_rename() using the new genfs_rename() framework.

Fixes PR kern/47986
 1.4 02-Mar-2010  pooka branches: 1.4.10; 1.4.20; 1.4.24;
Don't generate unused fs_thefs.h headers.
 1.3 29-Aug-2008  reinoud branches: 1.3.14;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.2 14-May-2008  reinoud branches: 1.2.4;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1 02-Feb-2006  reinoud branches: 1.1.4; 1.1.16; 1.1.22; 1.1.72; 1.1.74; 1.1.76; 1.1.78;
Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.1.78.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.78.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.1.76.3 11-Mar-2010  yamt sync with head
 1.1.76.2 04-May-2009  yamt sync with head.
 1.1.76.1 16-May-2008  yamt sync with head.
 1.1.74.1 18-May-2008  yamt sync with head.
 1.1.72.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 02-Feb-2006  rpaulo file files.udf was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 02-Feb-2006  yamt file files.udf was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.1.4.2 18-Feb-2006  yamt sync with head.
 1.1.4.1 02-Feb-2006  yamt file files.udf was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.2.4.1 19-Oct-2008  haad Sync with HEAD.
 1.3.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.24.1 28-Aug-2013  rmind sync with head
 1.4.20.2 03-Dec-2017  jdolecek update from HEAD
 1.4.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.10.1 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.56 18-May-2024  thorpej Move the include of <sys/malloc.h> to where it's truly needed.
 1.55 27-Jun-2023  reinoud Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
 1.54 07-Aug-2022  andvar fix various typos in comments, documentation and messages.
mainly s/paramater/parameter/ and s/reduntant/redundant/.
 1.53 16-Apr-2022  andvar fix various typos in comments and log messages.
 1.52 24-May-2016  reinoud Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.51 10-May-2016  reinoud Rework VAT searching on recordable media. It is now a lot more resilliant to
errors and it allows for VAT searching on crashed writeouts.

While here, make sure the node pointer is always initialised in
udf_get_node().
 1.50 24-Aug-2015  hannken Use vfs_vnode_iterator for udf_do_sync.

- Build rb_tree to get an ordered list of nodes, sync them and
clean the tree.

- Stop abusing mntvnode_lock to serialize udf_do_sync, use new
mutex ump->sync_lock instead.
 1.49 24-Aug-2015  hannken Remove dirtynodes_cv, it is only used for timed waits without any signals.

Replace the cv_timedwait with kpause.
 1.48 06-Apr-2015  hannken Change udf to vcache, keyed on udf_node->loc.loc.
 1.47 17-Sep-2014  reinoud branches: 1.47.2;
As pointed out by wiz@ prevent a possible attack or corruption that results in
an endless loop of indirect descriptors being processed.

The number of indirect descriptors followed is now maximized.
While here, also fix a use-after-free bug!
 1.46 18-Oct-2013  christos fix unused variable warnings
 1.45 27-Jul-2012  drochner branches: 1.45.2; 1.45.4;
gcc -fno-common fallout
 1.44 27-Sep-2011  christos branches: 1.44.2;
- rename UDF_MAX_NAMELEN -> UDF_MAXNAMLEN
- use NAME_MAX instead of MAXNAMLEN
 1.43 25-Sep-2010  matt Rename rb.h to rbtree.h, as it is more appropriate (c.f. ptree.h). Also
helps find code that hasn't been updated to use the new rbtree API.
 1.42 24-Sep-2010  rmind Fixes/improvements to RB-tree implementation:
1. Fix inverted node order, so that negative value from comparison operator
would represent lower (left) node, and positive - higher (right) node.
2. Add an argument (i.e. "context"), passed to comparison operators.
3. Change rb_tree_insert_node() to return a node - either inserted one or
already existing one.
4. Amend the interface to manipulate the actual object, instead of the
rb_node (in a similar way as Patricia-tree interface does).
5. Update all RB-tree users accordingly.

XXX: Perhaps rename rb.h to rbtree.h, since cleaning-up..

1-3 address the PR/43488 by Jeremy Huddleston.

Passes RB-tree regression tests.
Reviewed by: matt@, christos@
 1.41 25-Feb-2010  reinoud branches: 1.41.2;
First part of shrinking/growing metadata partition support:

- extending the metadata partition

Still to follow:
- sparsify metadata partition
- growing the metadata partition
- unsparsifying metadata partition
 1.40 24-Feb-2010  reinoud Rename metadata partition parameters to be less generic and add the flags.
 1.39 24-Feb-2010  reinoud Extract UDF metadata partition parameters as already done for VAT and sparable
partitions.
 1.38 05-Aug-2009  reinoud branches: 1.38.2;
Typo fix
 1.37 08-Jul-2009  reinoud Remove unused LIST_ENTRY()'s now replaced by the rbtree.
 1.36 07-Jul-2009  reinoud Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.
 1.35 06-Jul-2009  reinoud Reduce the number of active ecclines; low memory systems could get into
trouble otherwise.

XXX this value should be computed eventually.
 1.34 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.33 23-Jun-2009  reinoud Bump the NetBSD kernel UDF id to version 0.5
 1.32 18-Jun-2009  reinoud Add RESERVE bitmask flag to DEBUG print constants adding another 0 prefix to
the constants already defined.
 1.31 18-Jun-2009  reinoud Remove now unused UDF_DIRHASH constants
 1.30 08-Feb-2009  reinoud branches: 1.30.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.29 09-Dec-2008  reinoud Fix two buf_init()'s that are not needed since they were already initialised
by getiobuf().

Also remove ancient IPL_BIO reference from the time it was called from
interrupt context instead of the current soft interrupt.
 1.28 05-Dec-2008  reinoud Two fold commit:

1) Enhance write speed significantly on RMW media like CD-RW, DVD-RW but also
on the DVD+RW and all other ECC blocked media. Significant speedups of access
to the device for say compilation on the DVD. Streaming copy is also still at
maximum speed though vast amounts of directory copy work can show side effects
that appear it to slow down but are actually logical when you consider that
most small files are embedded into the descriptors itself.

2) explicit wait for the created RMW thread to spinup
 1.27 27-Sep-2008  reinoud branches: 1.27.2; 1.27.4;
Switch UDF over to the vfs_dirhash.c dirhash code.
 1.26 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.25 29-Jul-2008  reinoud Remove comments on `need to read in'; they are read in.
 1.24 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.23 27-Jul-2008  reinoud Unify naming scheme and source code beautify for better readablility.
 1.22 26-Jul-2008  reinoud Clarify the current spacemap read/write code is reading/writing physical
partition space maps. This in preperation of Metadata spacetable
reading/writeout work.
 1.21 22-Jul-2008  reinoud Limit the UDF dirhash to a configurable amount of memory. The performance
penalty even with a limited dirhash of 128kb is acceptable but it should be
set by machine memory size though.
 1.20 19-Jul-2008  reinoud Use ecma-167 constants instead of homegrown to prevent double mapping.
 1.19 19-Jul-2008  reinoud Choose which time of allocation descriptors to use on new nodes based on
the number of partition mappings.
 1.18 17-Jul-2008  reinoud Implement directory hashing to speed up directory traversals. Speed
improvements of at least 4 times in untarring and roughly 100 to 500 times
on file creation in big directories. Lookup of files was O(n*n) and is now
O(1) even for file creation. Free spaces in the directory are kept in a
seperate list for fast file creation.

The postmark benchmark gives:

UDF old:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
1593 seconds total
681 seconds of transactions (2 per second)

Files:
3956 created (2 per second)
Creation alone: 3000 files (4 per second)
Mixed with transactions: 956 files (1 per second)
990 read (1 per second)
1010 appended (1 per second)
3956 deleted (2 per second)
Deletion alone: 2912 files (9 per second)
Mixed with transactions: 1044 files (1 per second)

Data:
5.26 megabytes read (3.38 kilobytes per second)
21.93 megabytes written (14.10 kilobytes per second)
pm>



UDF new:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
19 seconds total
3 seconds of transactions (666 per second)

Files:
3956 created (208 per second)
Creation alone: 3000 files (230 per second)
Mixed with transactions: 956 files (318 per second)
990 read (330 per second)
1010 appended (336 per second)
3956 deleted (208 per second)
Deletion alone: 2912 files (970 per second)
Mixed with transactions: 1044 files (348 per second)

Data:
5.26 megabytes read (283.66 kilobytes per second)
21.93 megabytes written (1.15 megabytes per second)
 1.17 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.16 03-Jul-2008  reinoud branches: 1.16.2;
Add node-rebuild flag to indicate that the node was rebuild up and thus the
allocation extents have changed.
 1.15 03-Jul-2008  reinoud Create new udf_verbose class.
 1.14 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.13 25-Jun-2008  reinoud Bump maximum number of allocation extents descriptors in a file/directory;
10 did seem far too many, but aparently ``640 kb should be enough for
everyone''.
 1.12 15-May-2008  reinoud branches: 1.12.2;
Introduce new UDF debug class and split rmw strategy debugging prints.
 1.11 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.10 10-Oct-2007  ad branches: 1.10.18; 1.10.20; 1.10.22; 1.10.24;
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.9 04-Jan-2007  reinoud branches: 1.9.6; 1.9.18; 1.9.20; 1.9.22;
Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.8 29-Sep-2006  reinoud branches: 1.8.2;
Add `vfs.udf.verbose' sysctl when running a DEBUG kernel to dynamically set
the udf_verbose variable. So when something goes wrong, it can be examined
on the spot without needing to reboot a new kernel and possibly loosing
state.
 1.7 19-Sep-2006  reinoud Make VOP_LOOKUP's O(1) instead of O(n log(n)) giving a speedup of 7500% on
a 1400 file directory.
 1.6 22-Aug-2006  reinoud branches: 1.6.2; 1.6.4; 1.6.6;
Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.5 21-Aug-2006  reinoud Make a better guess on VAT locations so discs that are semi-standard
formatted can be recognised. This also fixes the bug that prevented UDF to
mount an empty CD-R/DVD*R disc.
 1.4 02-Feb-2006  christos branches: 1.4.4; 1.4.6; 1.4.16; 1.4.18;
protect the whole file, not parts of it.
 1.3 02-Feb-2006  reinoud Fix header re-inclusion protection defines to a less generic naming
scheme.
 1.2 02-Feb-2006  reinoud Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.4.18.3 25-Sep-2006  riz Pull up following revision(s) (requested by reinoud in ticket #185):
sys/fs/udf/udf_subr.c: revision 1.18
sys/fs/udf/udf.h: revision 1.7
Make VOP_LOOKUP's O(1) instead of O(n log(n)) giving a speedup of 7500% on
a 1400 file directory.
 1.4.18.2 27-Aug-2006  riz Pull up following revision(s) (requested by reinoud in ticket #50):
sys/fs/udf/udf_subr.c: revision 1.14
sys/fs/udf/udf.h: revision 1.6
sys/fs/udf/udf_vfsops.c: revision 1.11
Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.4.18.1 24-Aug-2006  tron Pull up following revision(s) (requested by reinoud in ticket #46):
sys/fs/udf/udf_subr.c: revision 1.13
sys/fs/udf/udf.h: revision 1.5
Make a better guess on VAT locations so discs that are semi-standard
formatted can be recognised. This also fixes the bug that prevented UDF to
mount an empty CD-R/DVD*R disc.
 1.4.16.5 27-Oct-2007  yamt sync with head.
 1.4.16.4 26-Feb-2007  yamt sync with head.
 1.4.16.3 30-Dec-2006  yamt sync with head.
 1.4.16.2 21-Jun-2006  yamt sync with head.
 1.4.16.1 02-Feb-2006  yamt file udf.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.4.6.1 03-Sep-2006  yamt sync with head.
 1.4.4.2 18-Feb-2006  yamt sync with head.
 1.4.4.1 02-Feb-2006  yamt file udf.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.6.6.1 22-Oct-2006  yamt sync with head
 1.6.4.2 09-Sep-2006  rpaulo sync with head
 1.6.4.1 22-Aug-2006  rpaulo file udf.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.6.2.2 12-Jan-2007  ad Sync with head.
 1.6.2.1 18-Nov-2006  ad Sync with head.
 1.8.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #332):
sys/fs/udf/udf_subr.c: revision 1.26
sys/fs/udf/udf.h: revision 1.9
sys/fs/udf/udf_vfsops.c: revision 1.19
Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.9.22.1 14-Oct-2007  yamt sync with head.
 1.9.20.1 06-Nov-2007  matt sync with HEAD
 1.9.18.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.9.6.1 05-Apr-2007  ad Compile fixes.
 1.10.24.3 10-Oct-2008  skrll Sync with HEAD.
 1.10.24.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.24.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.22.6 09-Oct-2010  yamt sync with head
 1.10.22.5 11-Mar-2010  yamt sync with head
 1.10.22.4 19-Aug-2009  yamt sync with head.
 1.10.22.3 18-Jul-2009  yamt sync with head.
 1.10.22.2 04-May-2009  yamt sync with head.
 1.10.22.1 16-May-2008  yamt sync with head.
 1.10.20.1 18-May-2008  yamt sync with head.
 1.10.18.5 17-Jan-2009  mjf Sync with HEAD.
 1.10.18.4 05-Oct-2008  mjf Sync with HEAD.
 1.10.18.3 28-Sep-2008  mjf Sync with HEAD.
 1.10.18.2 29-Jun-2008  mjf Sync with HEAD.
 1.10.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.2.6 31-Jul-2008  simonb Sync with head.
 1.12.2.5 28-Jul-2008  simonb Sync with head.
 1.12.2.4 22-Jul-2008  simonb Sync with head.
 1.12.2.3 18-Jul-2008  simonb Sync with head.
 1.12.2.2 03-Jul-2008  simonb Sync with head.
 1.12.2.1 27-Jun-2008  simonb Sync with head.
 1.16.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.2.1 19-Oct-2008  haad Sync with HEAD.
 1.27.4.4 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.27.4.3 18-Feb-2009  snj branches: 1.27.4.3.4;
Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.27.4.2 10-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #174):
sys/fs/udf/udf_strat_rmw.c: revision 1.15
sys/fs/udf/udf.h: revision 1.29
Fix two buf_init()'s that are not needed since they were already initialised
by getiobuf().
Also remove ancient IPL_BIO reference from the time it was called from
interrupt context instead of the current soft interrupt.
 1.27.4.1 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf.h: revision 1.28
sys/fs/udf/udf_strat_rmw.c: revision 1.13
Two fold commit:
1) Enhance write speed significantly on RMW media like CD-RW, DVD-RW but also
on the DVD+RW and all other ECC blocked media. Significant speedups of access
to the device for say compilation on the DVD. Streaming copy is also still at
maximum speed though vast amounts of directory copy work can show side effects
that appear it to slow down but are actually logical when you consider that
most small files are embedded into the descriptors itself.
2) explicit wait for the created RMW thread to spinup
 1.27.4.3.4.1 21-Apr-2010  matt sync to netbsd-5
 1.27.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.27.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.2.1 23-Jul-2009  jym Sync with HEAD.
 1.38.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.38.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.41.2.1 05-Mar-2011  rmind sync with head
 1.44.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.44.2.1 30-Oct-2012  yamt sync with head
 1.45.4.1 18-May-2014  rmind sync with head
 1.45.2.2 03-Dec-2017  jdolecek update from HEAD
 1.45.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.2.3 29-May-2016  skrll Sync with HEAD
 1.47.2.2 22-Sep-2015  skrll Sync with HEAD
 1.47.2.1 06-Apr-2015  skrll Sync with HEAD
 1.48 05-Jan-2025  andvar fix various typos in comments.
 1.47 22-May-2022  andvar branches: 1.47.10;
fix various small typos, mainly in comments.
 1.46 03-Feb-2022  reinoud Revere modification of initializer; it can lead to race conditions where two
allocation would pick the `empty' space causing a panic later on.
 1.45 28-Jan-2022  reinoud On freeing a virtual address in the VAT, use the correct value; this might
confuse other implementations who can reject the VAT on this.
 1.44 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.43 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.42 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.41 23-Apr-2020  ad branches: 1.41.6;
PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.40 14-Oct-2018  jdolecek branches: 1.40.4; 1.40.10;
remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect
 1.39 04-Jan-2017  christos branches: 1.39.14; 1.39.16;
PR/51777: David Binderman: Remove unused computation
 1.38 24-Aug-2015  hannken branches: 1.38.2;
Remove dirtynodes_cv, it is only used for timed waits without any signals.

Replace the cv_timedwait with kpause.
 1.37 03-Dec-2014  reinoud Relax the KASSERT since an equal size is no issue
 1.36 30-Oct-2013  mrg branches: 1.36.6;
used __diagused where appropriate.
 1.35 18-Oct-2013  christos fix unused variable warnings
 1.34 09-Aug-2013  reinoud Fix 32 bit issue in main file read-in function. On both 32 bit and 64 bit
hosts a missing cast would result in `garbage' after the 4Gbyte limit.
 1.33 03-Jul-2013  reinoud On growing a node that was recorded inside the (E)FE, don't forget to set the
size of the node to the NEW size. This was reported by the `t_io
udf_shrinkfile' testcase.

Fixes PR kern/47985
 1.32 16-Jun-2011  hannken branches: 1.32.2; 1.32.8; 1.32.12; 1.32.14; 1.32.16; 1.32.22;
Rename uvm_vnp_zerorange(struct vnode *, off_t, size_t) to
ubc_zerorange(struct uvm_object *, off_t, size_t, int) changing
the first argument to an uvm_object and adding a flags argument.

Modify tmpfs_reg_resize() to zero the backing store (aobj) instead
of the vnode. Ubc_purge() no longer panics when unmounting tmpfs.

Keep uvm_vnp_zerorange() until the next kernel version bump.
 1.31 14-Jan-2011  reinoud branches: 1.31.6;
Metadata partition (v2.50+) bugfix commit :

* fix copying of the extents of the metadata node to the metadatamirror node;
it was not copying all extents.

* fix truncing metadata partition:
* fix endian conversions
* fix information length calculation so its truncated to the right length!

* allow for setting maximum extent length in extent merging. This is needed
since extents in the metadata partition files are only to be in allocation
unit sizes.

* adjust grow and shrink node to set the granularity of the maximum length of
an extent when encountering a metadatafile or metadatamirror file.
 1.30 22-Dec-2010  reinoud Growing the metadata partition is not yet implemented. Be so kind to report
this as unimplemented when the debug flag asks for it!
 1.29 26-Feb-2010  reinoud branches: 1.29.2;
Typo and style
 1.28 25-Feb-2010  reinoud First part of shrinking/growing metadata partition support:

- extending the metadata partition

Still to follow:
- sparsify metadata partition
- growing the metadata partition
- unsparsifying metadata partition
 1.27 27-Jun-2009  reinoud branches: 1.27.2;
Fix corner-case in truncing files. It could forget to free the last block.
This would result in a free-space map with one block orphaned.
 1.26 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.25 18-Jun-2009  reinoud Fix nitpicky spacing and debug printout
 1.24 18-Jun-2009  reinoud Remove unneeded (and unused) inclusion of "opt_quota.h"
 1.23 19-May-2009  reinoud Account for the logical blocks recorded by the extent in the right endian!
 1.22 19-May-2009  reinoud A descriptor's CRC lenth is 16 bit so use udf_rw16() on tag.desc_crc_len.
 1.21 21-Apr-2009  reinoud Fix endian related bug when using discs with a meta-data partition on
big-endian machines.
 1.20 25-Mar-2009  reinoud Fix possible overshoot when allocating from a space bitmap when ffs(3) returns
a too big offset for the bitmap.
 1.19 16-Dec-2008  pooka branches: 1.19.2;
The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.18 29-Aug-2008  reinoud branches: 1.18.2; 1.18.4;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.17 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.16 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.15 26-Jul-2008  reinoud Clarify not implemented allocation schemes; mostly UDF 2.50
HD-DVD/BluRay-RE and UDF 2.60 for BluRay-R
 1.14 19-Jul-2008  reinoud Use the allocation descriptor types selected on mount when growing from an
internal to an extent recording.
 1.13 18-Jul-2008  reinoud Hopefully fix gcc type puned warning.
 1.12 16-Jul-2008  reinoud Make UDF allocation-sanity check optional even if the DEBUG flag is
specified. This should be sysctl-able when compiled with the DEBUG flag
eventually.
 1.11 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.10 03-Jul-2008  reinoud branches: 1.10.2;
Fix rare allocation problem when a fragmented file is truncated to a
non-zero length and the last extent was allocated.
 1.9 02-Jul-2008  reinoud Update node sanity check system and redo allocation recording fixing
corruptions that could take place when overwriting sparse files.

Still one rare corruption possible where blocks are accidentally marked
free, but the cause is not yet found and looking at the pattern it won't
happen in every day use.
 1.8 30-Jun-2008  reinoud Fix serious allocation recording bug if overwriting piece that was
allocated before. Fixes regression test on random overwriting data.

Also fix endian issues and add extra documentation to variables.
 1.7 28-Jun-2008  reinoud When shrinking the file, do clean the freed part in the descriptor; all
unused space need to be zero filled.
 1.6 26-Jun-2008  reinoud Count the length correctly when encountering an allocation extension
redirect in the sanity checking.
 1.5 25-Jun-2008  reinoud Fix lookup problems in very fragmented metadata partitions that use
allocation extent descriptors.
 1.4 25-Jun-2008  reinoud Fix extended allocation descriptor handling in translate file extent
 1.3 25-Jun-2008  reinoud Fix allocation extensions descriptor reading and do free them on node
destruction!
 1.2 20-May-2008  reinoud branches: 1.2.2; 1.2.4; 1.2.6;
Remove bogus KASSERT(); if we shrink the file, the number of allocated
blocsk are of course not the same... duh!
 1.1 14-May-2008  reinoud branches: 1.1.2; 1.1.4;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1.4.3 04-Jun-2008  yamt sync with head
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 14-May-2008  yamt file udf_allocation.c was added on branch yamt-pf42 on 2008-05-18 12:35:05 +0000
 1.1.2.6 11-Mar-2010  yamt sync with head
 1.1.2.5 18-Jul-2009  yamt sync with head.
 1.1.2.4 20-Jun-2009  yamt sync with head
 1.1.2.3 04-May-2009  yamt sync with head.
 1.1.2.2 16-May-2008  yamt sync with head.
 1.1.2.1 14-May-2008  yamt file udf_allocation.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.2.6.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.6.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.2.6.1 20-May-2008  wrstuden file udf_allocation.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.2.4.6 31-Jul-2008  simonb Sync with head.
 1.2.4.5 28-Jul-2008  simonb Sync with head.
 1.2.4.4 22-Jul-2008  simonb Sync with head.
 1.2.4.3 18-Jul-2008  simonb Sync with head.
 1.2.4.2 03-Jul-2008  simonb Sync with head.
 1.2.4.1 27-Jun-2008  simonb Sync with head.
 1.2.2.6 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.5 28-Sep-2008  mjf Sync with HEAD.
 1.2.2.4 02-Jul-2008  mjf Sync with HEAD.
 1.2.2.3 29-Jun-2008  mjf Sync with HEAD.
 1.2.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.2.1 20-May-2008  mjf file udf_allocation.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.10.2.1 19-Oct-2008  haad Sync with HEAD.
 1.18.4.4 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.18.4.3 06-Jun-2009  bouyer Pull up following revision(s) (requested by reinoud in ticket #770):
sys/fs/udf/udf_subr.c: revision 1.88, 1.89
sys/fs/udf/udf_bswap.h: revision 1.6, 1.7
sys/fs/udf/udf_allocation.c: revision 1.22, 1.23
sbin/newfs_udf/udf_create.c: revision 1.16
Fix *serious* bug in bswapping definitions for big endian machines.
ANSI-fy. No idea why they weren't so in the first place.
Fix newfs_udf to create a valid disc images on bigendian machines.
A descriptor's CRC lenth is 16 bit so use udf_rw16() on tag.desc_crc_len.
Forgot to use the udf_rw16() on the descriptor crc lengths of FID's!
Also fix a few dubiously formatted checks.
On creation of a new node, don't forget to set the length of the allocated
space in the right endian!
Account for the logical blocks recorded by the extent in the right endian!
 1.18.4.2 23-Apr-2009  snj branches: 1.18.4.2.4;
Pull up following revision(s) (requested by reinoud in ticket #716):
sys/fs/udf/udf_allocation.c: revision 1.21
Fix endian related bug when using discs with a meta-data partition on
big-endian machines.
 1.18.4.1 31-Mar-2009  snj Pull up following revision(s) (requested by reinoud in ticket #610):
sys/fs/udf/udf_allocation.c: revision 1.20
Fix possible overshoot when allocating from a space bitmap when ffs(3) returns
a too big offset for the bitmap.
 1.18.4.2.4.1 21-Apr-2010  matt sync to netbsd-5
 1.18.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.18.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.2.2 23-Jul-2009  jym Sync with HEAD.
 1.19.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.29.2.1 05-Mar-2011  rmind sync with head
 1.31.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.32.22.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by reinoud in ticket #930):
sys/fs/udf/udf_allocation.c: revision 1.34
Fix 32 bit issue in main file read-in function. On both 32 bit and 64 bit
hosts a missing cast would result in `garbage' after the 4Gbyte limit.
 1.32.16.2 18-May-2014  rmind sync with head
 1.32.16.1 28-Aug-2013  rmind sync with head
 1.32.14.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by reinoud in ticket #930):
sys/fs/udf/udf_allocation.c: revision 1.34
Fix 32 bit issue in main file read-in function. On both 32 bit and 64 bit
hosts a missing cast would result in `garbage' after the 4Gbyte limit.
 1.32.12.2 03-Dec-2017  jdolecek update from HEAD
 1.32.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.8.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by reinoud in ticket #930):
sys/fs/udf/udf_allocation.c: revision 1.34
Fix 32 bit issue in main file read-in function. On both 32 bit and 64 bit
hosts a missing cast would result in `garbage' after the 4Gbyte limit.
 1.32.2.1 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.36.6.3 05-Feb-2017  skrll Sync with HEAD
 1.36.6.2 22-Sep-2015  skrll Sync with HEAD
 1.36.6.1 06-Apr-2015  skrll Sync with HEAD
 1.38.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.39.16.1 10-Jun-2019  christos Sync with HEAD
 1.39.14.1 20-Oct-2018  pgoyette Sync with head
 1.40.10.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.40.4.2 18-Apr-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1437):

sys/fs/udf/udf_allocation.c: revision 1.46

Revere modification of initializer; it can lead to race conditions where two
allocation would pick the `empty' space causing a panic later on.
 1.40.4.1 13-Mar-2022  martin Pull up following revision(s), all via patch,
requested by reinoud in ticket #1432:

sys/fs/udf/udf_vfsops.c: revision 1.83
sys/fs/udf/udf_allocation.c: revision 1.45
sys/fs/udf/udf_subr.c: revision 1.160
sys/fs/udf/udf_subr.c: revision 1.161

While searching the VAT on recordable media, search the last sector too!
This fixes Win10 formatted discs from being mounted incorrectly.

Make sysctl udf.verbose dependent on UDF_DEBUG instead of DEBUG

Fix serious issue with recordable media formatted with Win10. When closing it
after modification the VAT was written out corrupted making the disc
unreadable anymore on remount. Thanks for ig@ for spotting it in the wild!

On freeing a virtual address in the VAT, use the correct value; this might
confuse other implementations who can reject the VAT on this.
 1.41.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.47.10.1 02-Aug-2025  perseant Sync with HEAD
 1.8 22-Oct-2009  bouyer Remove closes 3 and 4 from my copyright.
 1.7 18-May-2009  reinoud ANSI-fy. No idea why they weren't so in the first place.
 1.6 18-May-2009  reinoud Fix *serious* bug in bswapping definitions for big endian machines.
 1.5 14-May-2008  reinoud branches: 1.5.8; 1.5.12; 1.5.16;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.4 05-Mar-2006  christos branches: 1.4.10; 1.4.16; 1.4.66; 1.4.68; 1.4.70; 1.4.72;
remove trailing newlines
 1.3 02-Feb-2006  reinoud branches: 1.3.2; 1.3.4; 1.3.6;
De __P() prototypes.
 1.2 02-Feb-2006  reinoud Fix header re-inclusion protection defines to a less generic naming
scheme.
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.3.6.1 13-Mar-2006  yamt sync with head.
 1.3.4.2 18-Feb-2006  yamt sync with head.
 1.3.4.1 02-Feb-2006  yamt file udf_bswap.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.3.2.1 22-Apr-2006  simonb Sync with head.
 1.4.72.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.70.3 11-Mar-2010  yamt sync with head
 1.4.70.2 20-Jun-2009  yamt sync with head
 1.4.70.1 16-May-2008  yamt sync with head.
 1.4.68.1 18-May-2008  yamt sync with head.
 1.4.66.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.16.2 09-Sep-2006  rpaulo sync with head
 1.4.16.1 05-Mar-2006  rpaulo file udf_bswap.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.4.10.2 21-Jun-2006  yamt sync with head.
 1.4.10.1 05-Mar-2006  yamt file udf_bswap.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.5.16.1 21-Apr-2010  matt sync to netbsd-5
 1.5.12.1 23-Jul-2009  jym Sync with HEAD.
 1.5.8.1 06-Jun-2009  bouyer Pull up following revision(s) (requested by reinoud in ticket #770):
sys/fs/udf/udf_subr.c: revision 1.88, 1.89
sys/fs/udf/udf_bswap.h: revision 1.6, 1.7
sys/fs/udf/udf_allocation.c: revision 1.22, 1.23
sbin/newfs_udf/udf_create.c: revision 1.16
Fix *serious* bug in bswapping definitions for big endian machines.
ANSI-fy. No idea why they weren't so in the first place.
Fix newfs_udf to create a valid disc images on bigendian machines.
A descriptor's CRC lenth is 16 bit so use udf_rw16() on tag.desc_crc_len.
Forgot to use the udf_rw16() on the descriptor crc lengths of FID's!
Also fix a few dubiously formatted checks.
On creation of a new node, don't forget to set the length of the allocated
space in the right endian!
Account for the logical blocks recorded by the extent in the right endian!
 1.4 16-Oct-2019  maya Switch files copyright Reinoud Zandijk from BSD 4 clause to BSD 2 clause.

OK'd by reinoud in email (from 4 Feb 2019).
 1.3 02-Feb-2006  reinoud branches: 1.3.4; 1.3.16; 1.3.22; 1.3.166;
Fix header re-inclusion protection defines to a less generic naming
scheme.
 1.2 02-Feb-2006  reinoud Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.3.166.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.22.2 09-Sep-2006  rpaulo sync with head
 1.3.22.1 02-Feb-2006  rpaulo file udf_mount.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 02-Feb-2006  yamt file udf_mount.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.3.4.2 18-Feb-2006  yamt sync with head.
 1.3.4.1 02-Feb-2006  yamt file udf_mount.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.11 11-Feb-2022  reinoud Translate 254/255 compID values used for deleted entries as per UDF spec. This
allows the printing of the names of deleted file entries.
 1.10 05-Aug-2013  joerg Support tools build.
 1.9 18-Mar-2009  cegger branches: 1.9.12; 1.9.22; 1.9.26;
Ansify function definitions w/o arguments. Generated with sed.
 1.8 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.7 19-May-2008  reinoud branches: 1.7.6; 1.7.8; 1.7.12; 1.7.16;
Implement wide char support for UDF by properly implementing unicode-16 to
UTF-8 like cd9660 and ntfs already do.
 1.6 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.5 11-Dec-2007  lukem branches: 1.5.8; 1.5.10; 1.5.12; 1.5.14;
use __KERNEL_RCSID() instead of __RCSID()
 1.4 22-Feb-2007  thorpej branches: 1.4.18; 1.4.26; 1.4.28; 1.4.30;
TRUE -> true, FALSE -> false
 1.3 10-Aug-2006  reinoud branches: 1.3.4; 1.3.10;
The local variable `index' seems shadowing an inbuild gcc variable (???)
when compiling from userland (kernel ok) so rename the variable to Index to
avoid the confusing warning.
 1.2 12-Jun-2006  christos branches: 1.2.4;
remove ; from };
 1.1 02-Feb-2006  reinoud branches: 1.1.4; 1.1.6; 1.1.12;
Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.1.12.1 19-Jun-2006  chap Sync with head.
 1.1.6.2 11-Aug-2006  yamt sync with head
 1.1.6.1 26-Jun-2006  yamt sync with head.
 1.1.4.2 18-Feb-2006  yamt sync with head.
 1.1.4.1 02-Feb-2006  yamt file udf_osta.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.2.4.5 21-Jan-2008  yamt sync with head
 1.2.4.4 26-Feb-2007  yamt sync with head.
 1.2.4.3 30-Dec-2006  yamt sync with head.
 1.2.4.2 21-Jun-2006  yamt sync with head.
 1.2.4.1 12-Jun-2006  yamt file udf_osta.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.3.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 10-Aug-2006  rpaulo file udf_osta.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.4.30.1 13-Dec-2007  bouyer Sync with HEAD
 1.4.28.1 11-Dec-2007  yamt sync with head.
 1.4.26.1 26-Dec-2007  ad Sync with head.
 1.4.18.1 09-Jan-2008  matt sync with HEAD
 1.5.14.2 24-Jun-2008  wrstuden Hand-merge files that didn't merge right in recent sync w/ current.
 1.5.14.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.12.2 04-May-2009  yamt sync with head.
 1.5.12.1 16-May-2008  yamt sync with head.
 1.5.10.2 04-Jun-2008  yamt sync with head
 1.5.10.1 18-May-2008  yamt sync with head.
 1.5.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.16.1 21-Apr-2010  matt sync to netbsd-5
 1.7.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.8.1 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.7.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.26.1 28-Aug-2013  rmind sync with head
 1.9.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.12.1 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.5 05-Feb-2024  andvar s/dependancies/dependencies/ and s/independantly/independently/ in comments and
distrib notes.
 1.4 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.3 05-Mar-2006  christos branches: 1.3.10; 1.3.16; 1.3.66; 1.3.68; 1.3.70; 1.3.72;
remove trailing newlines
 1.2 02-Feb-2006  reinoud branches: 1.2.2; 1.2.4; 1.2.6;
Replace reinclude protection names with less generic versions.
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.2.6.1 13-Mar-2006  yamt sync with head.
 1.2.4.2 18-Feb-2006  yamt sync with head.
 1.2.4.1 02-Feb-2006  yamt file udf_osta.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.2.2.1 22-Apr-2006  simonb Sync with head.
 1.3.72.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.70.1 16-May-2008  yamt sync with head.
 1.3.68.1 18-May-2008  yamt sync with head.
 1.3.66.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.16.2 09-Sep-2006  rpaulo sync with head
 1.3.16.1 05-Mar-2006  rpaulo file udf_osta.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.3.10.2 21-Jun-2006  yamt sync with head.
 1.3.10.1 05-Mar-2006  yamt file udf_osta.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.14 10-Feb-2024  andvar fix various typos in comments and log messages.
 1.13 05-Dec-2021  msaitoh s/checkum/checksum/ in comment.
 1.12 24-May-2016  reinoud Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.11 12-Jun-2011  rmind branches: 1.11.12; 1.11.30;
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.10 08-Feb-2009  reinoud branches: 1.10.6; 1.10.12;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.9 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.8 29-Aug-2008  reinoud branches: 1.8.2; 1.8.4;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.7 05-Aug-2008  reinoud Fixup important bug in internal recorded data fixup. Although most unlikely
it could result in theory result in descriptor trashing.

On the performance side, it would try to fixup *every* descriptor even if
it wasn't an internally allocated one. Performance loss wasn't that big but
every bit helps.
 1.6 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.5 09-Jul-2008  reinoud Force allocation extent descriptor CRC length to 8 for UDF versions prior
to version 2.01.
 1.4 03-Jul-2008  reinoud branches: 1.4.2;
Avoid panic when trying to mount a non existent block device like a
/dev/vnd0 that is not configured.
 1.3 30-Jun-2008  perry __FUNCTION__ -> __func__
 1.2 24-Jun-2008  reinoud If we're fixing up the internal attributes, is it then wise to check if
they are valid first? Might be on the safe side in the end but disabled for
now.
 1.1 14-May-2008  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1.10.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.10.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.10.1 14-May-2008  wrstuden file udf_readwrite.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:14 +0000
 1.1.8.4 31-Jul-2008  simonb Sync with head.
 1.1.8.3 18-Jul-2008  simonb Sync with head.
 1.1.8.2 03-Jul-2008  simonb Sync with head.
 1.1.8.1 27-Jun-2008  simonb Sync with head.
 1.1.6.6 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.5 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.4 02-Jul-2008  mjf Sync with HEAD.
 1.1.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.1 14-May-2008  mjf file udf_readwrite.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 14-May-2008  yamt file udf_readwrite.c was added on branch yamt-pf42 on 2008-05-18 12:35:06 +0000
 1.1.2.3 04-May-2009  yamt sync with head.
 1.1.2.2 16-May-2008  yamt sync with head.
 1.1.2.1 14-May-2008  yamt file udf_readwrite.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.4.2.1 19-Oct-2008  haad Sync with HEAD.
 1.8.4.2 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.8.4.1 18-Feb-2009  snj branches: 1.8.4.1.4;
Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.8.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.8.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.8.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.6.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.11.30.1 29-May-2016  skrll Sync with HEAD
 1.11.12.1 03-Dec-2017  jdolecek update from HEAD
 1.16 18-May-2024  thorpej Move the include of <sys/malloc.h> to where it's truly needed.
 1.15 02-Jun-2023  andvar follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.
 1.14 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.13 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.12 10-Nov-2014  riz branches: 1.12.20; 1.12.26;
Revert previous, it is actually needed. (builds are failing)
 1.11 10-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.10 16-Jul-2013  reinoud branches: 1.10.4; 1.10.8; 1.10.12;
Remove udf_node * as state variables and add the loop invariants UFS and tmpfs
carry to make it easier to debug.
 1.9 15-Jul-2013  reinoud First step in rewriting the genealogy case
 1.8 13-Jul-2013  reinoud udf_gro_genealogy() : source and destination should never be the same on call,
KASSERT it instead of checking for it.
 1.7 13-Jul-2013  reinoud vp is used, so don't (void) it
 1.6 13-Jul-2013  reinoud Rework udf_gro_rename() to be more linear instead of nesting if/else
branching.
 1.5 12-Jul-2013  reinoud In case there is trouble determining the number of entries in a directory,
return its not empty to be on the safe side.
 1.4 11-Jul-2013  reinoud Resort to the easiest way to check if a directory is deleted: the flag that
tells that there is no FID (dirent) pointing to it anymore.
 1.3 11-Jul-2013  reinoud Small cleanup
 1.2 10-Jul-2013  reinoud Remove the dirent checks and references. UDF doesn't need/use them on rename
so just to make sure, we remove all references/checks to not trigger bugs
thats are not really ours.
 1.1 10-Jul-2013  reinoud Implement udf_rename() using the new genfs_rename() framework.

Fixes PR kern/47986
 1.10.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.12.1 16-Jul-2013  tls file udf_rename.c was added on branch tls-maxphys on 2014-08-20 00:04:28 +0000
 1.10.8.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.10.8.1 16-Jul-2013  yamt file udf_rename.c was added on branch yamt-pagecache on 2014-05-22 11:41:02 +0000
 1.10.4.2 28-Aug-2013  rmind sync with head
 1.10.4.1 16-Jul-2013  rmind file udf_rename.c was added on branch rmind-smpnet on 2013-08-28 23:59:35 +0000
 1.12.26.1 17-Jan-2020  ad Sync with head.
 1.12.20.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5 24-May-2016  reinoud Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.4 10-Nov-2014  maxv branches: 1.4.2;
Do not uselessly include <sys/malloc.h>.
 1.3 16-Dec-2008  pooka branches: 1.3.24; 1.3.40;
The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.2 29-Aug-2008  reinoud branches: 1.2.2; 1.2.4; 1.2.10;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.1 14-May-2008  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; 1.1.12;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1.12.1 19-Oct-2008  haad Sync with HEAD.
 1.1.10.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.10.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.10.1 14-May-2008  wrstuden file udf_strat_bootstrap.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:14 +0000
 1.1.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.1 14-May-2008  mjf file udf_strat_bootstrap.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 14-May-2008  yamt file udf_strat_bootstrap.c was added on branch yamt-pf42 on 2008-05-18 12:35:06 +0000
 1.1.2.3 04-May-2009  yamt sync with head.
 1.1.2.2 16-May-2008  yamt sync with head.
 1.1.2.1 14-May-2008  yamt file udf_strat_bootstrap.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.2.10.1 21-Apr-2010  matt sync to netbsd-5
 1.2.4.1 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.2.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.40.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.3.24.1 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 29-May-2016  skrll Sync with HEAD
 1.17 10-Feb-2024  andvar fix various typos in comments and log messages.
 1.16 27-Jun-2023  reinoud Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
 1.15 15-Jan-2022  msaitoh s/adressing/addressing/
 1.14 24-May-2016  reinoud Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.13 06-Oct-2015  hannken Remove dubious vhold()/holdrele() from write_logvol_dscr strategies.

The udf_node already gets locked with UDF_LOCK_NODE() and udf_reclaim()
will wait for the lock to clear.
 1.12 30-Oct-2013  mrg branches: 1.12.6;
used __diagused where appropriate.
 1.11 18-Oct-2013  christos fix unused variable warnings
 1.10 20-May-2009  reinoud branches: 1.10.12; 1.10.22; 1.10.26;
Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.9 10-Feb-2009  reinoud Remove dead code and double check if its allowed to write out non-sequential
there.
 1.8 08-Feb-2009  reinoud branches: 1.8.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.7 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.6 28-Nov-2008  reinoud Allow for the exclusive selection of `direct' for rdonly mounts; its disabled
for now since its a lot slower than `rmw' access.

For archs that have trouble with `rmw' for whatever reason can so use it as a
scapegoat to allways mount savely rdonly though slower.
 1.5 29-Aug-2008  reinoud branches: 1.5.2; 1.5.4;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.4 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.3 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.2 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.1 14-May-2008  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1.12.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.12.1 19-Oct-2008  haad Sync with HEAD.
 1.1.10.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.10.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.10.1 14-May-2008  wrstuden file udf_strat_direct.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:14 +0000
 1.1.8.2 31-Jul-2008  simonb Sync with head.
 1.1.8.1 18-Jul-2008  simonb Sync with head.
 1.1.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.1 14-May-2008  mjf file udf_strat_direct.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 14-May-2008  yamt file udf_strat_direct.c was added on branch yamt-pf42 on 2008-05-18 12:35:06 +0000
 1.1.2.4 20-Jun-2009  yamt sync with head
 1.1.2.3 04-May-2009  yamt sync with head.
 1.1.2.2 16-May-2008  yamt sync with head.
 1.1.2.1 14-May-2008  yamt file udf_strat_direct.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.5.4.5 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.5.4.4 01-Jun-2009  liamjfoy Pull up following revision(s) (requested by reinoud in ticket #772):
sys/fs/udf/udf_strat_rmw.c: revision 1.19
sys/fs/udf/udf_strat_sequential.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.10
sys/fs/udf/udf_subr.c: revision 1.90
sys/fs/udf/udf_subr.c: revision 1.91
Descriptor version is 16 bit and not 8 so use udf_rw16() to access them.
UniqueID was written in the logical volume integrity without byteswapping for
bigendian machines.

Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.5.4.3 18-Mar-2009  snj branches: 1.5.4.3.4;
Apply patch (requested by reinoud in ticket #569):
Remove dead code and double check if it's allowed to write out
non-sequential there.
--
Sequential writing goes before normal write. Its not likely to ever go
wrong but there could be a race otherwise.
--
Add simplistic UBC async flushing as other FS's seem to do. Its a clutch
and needs to be addressed in UBC properly.
Improve write throttling by doing it on page-size basis. The `standard'
solution would cut up files unnessisary during allocation. It also made
assumptions about ucb wich were propably right but still.
 1.5.4.2 18-Feb-2009  snj Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.5.4.1 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf_strat_direct.c: revision 1.6
sys/fs/udf/udf_subr.c: revision 1.75
Allow for the exclusive selection of `direct' for rdonly mounts; its disabled
for now since its a lot slower than `rmw' access.
For archs that have trouble with `rmw' for whatever reason can so use it as a
scapegoat to allways mount savely rdonly though slower.
 1.5.4.3.4.1 21-Apr-2010  matt sync to netbsd-5
 1.5.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.5.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.2.2 23-Jul-2009  jym Sync with HEAD.
 1.8.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.26.1 18-May-2014  rmind sync with head
 1.10.22.2 03-Dec-2017  jdolecek update from HEAD
 1.10.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.12.1 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.12.6.2 29-May-2016  skrll Sync with HEAD
 1.12.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.31 27-Jun-2023  reinoud Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
 1.30 15-Jan-2022  msaitoh s/adressing/addressing/
 1.29 21-Aug-2021  andvar s/helt/held+s/eroneously/erroneously/+s/splitted/split/+s/recommented/recommended/
 1.28 24-May-2016  reinoud Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.27 06-Oct-2015  hannken Remove dubious vhold()/holdrele() from write_logvol_dscr strategies.

The udf_node already gets locked with UDF_LOCK_NODE() and udf_reclaim()
will wait for the lock to clear.
 1.26 12-Sep-2015  christos diagused some variables.
 1.25 12-Sep-2015  christos remove identity assignment, found by brainy.
 1.24 30-Oct-2013  mrg branches: 1.24.6;
used __diagused where appropriate.
 1.23 18-Oct-2013  christos fix unused variable warnings
 1.22 08-Jul-2009  reinoud branches: 1.22.12; 1.22.22; 1.22.26;
Fix alternating oddity in RMW strategy. Even when in the reading state it
would push out elements to fillup-read only when the time had come for them.
This could then trickle feed the read queue slowly, but fast enough to prevent
it from switching state.
 1.21 06-Jul-2009  reinoud Re-implement read-modify-write backend strategy. This version is a lot more
clean locking-wise and will consume less CPU power on needless moving-around.
 1.20 02-Jul-2009  reinoud Enhance dumping on buffer screwup. Also prevent races or invalid combinations
to exist for ecclines.
 1.19 20-May-2009  reinoud Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.18 08-Feb-2009  reinoud branches: 1.18.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.17 13-Jan-2009  yamt g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.16 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.15 09-Dec-2008  reinoud Fix two buf_init()'s that are not needed since they were already initialised
by getiobuf().

Also remove ancient IPL_BIO reference from the time it was called from
interrupt context instead of the current soft interrupt.
 1.14 06-Dec-2008  reinoud UDF_SHED_FREE state is now also handled by the state machine, so DO signal it.
Free'd up ecclines can now far more quicker be recycled.
 1.13 05-Dec-2008  reinoud Two fold commit:

1) Enhance write speed significantly on RMW media like CD-RW, DVD-RW but also
on the DVD+RW and all other ECC blocked media. Significant speedups of access
to the device for say compilation on the DVD. Streaming copy is also still at
maximum speed though vast amounts of directory copy work can show side effects
that appear it to slow down but are actually logical when you consider that
most small files are embedded into the descriptors itself.

2) explicit wait for the created RMW thread to spinup
 1.12 15-Nov-2008  reinoud Specify blobsize as the `pagingsize' of the eccline blob pool. This will relax
the requirements of the pagingsize.
 1.11 01-Nov-2008  reinoud Introduce an extra state to wich all pushed ecclines are pushed on. This
extra state has a holding time in wich no writeouts will be done
effectively collecting more sectors before its even sheduled for writing.
 1.10 01-Nov-2008  reinoud Explicitly set buffer's block numbers. Blocks were always read/written
correctly only the sheduling could go less than optimal.
 1.9 29-Aug-2008  reinoud branches: 1.9.2; 1.9.4;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.8 07-Aug-2008  reinoud Don't panic on read-errors but set flag that the packet is doomed. Its not
clear if i could read the individual sectors correctly since the entire
read packet is also one big ECC block.
 1.7 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.6 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.5 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.4 17-Jun-2008  reinoud branches: 1.4.2; 1.4.4;
Change comments on marking buffer busy.
 1.3 15-May-2008  reinoud branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
Introduce new UDF debug class and split rmw strategy debugging prints.
 1.2 15-May-2008  reinoud Add accidently removed lines when i pruned the code for release. Important
update.
 1.1 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.3.8.3 31-Jul-2008  simonb Sync with head.
 1.3.8.2 18-Jul-2008  simonb Sync with head.
 1.3.8.1 18-Jun-2008  simonb Sync with head.
 1.3.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.3.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.3.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.3.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.6.1 15-May-2008  mjf file udf_strat_rmw.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.3.4.2 18-May-2008  yamt sync with head.
 1.3.4.1 15-May-2008  yamt file udf_strat_rmw.c was added on branch yamt-pf42 on 2008-05-18 12:35:06 +0000
 1.3.2.5 18-Jul-2009  yamt sync with head.
 1.3.2.4 20-Jun-2009  yamt sync with head
 1.3.2.3 04-May-2009  yamt sync with head.
 1.3.2.2 16-May-2008  yamt sync with head.
 1.3.2.1 15-May-2008  yamt file udf_strat_rmw.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.4.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.4.1 19-Oct-2008  haad Sync with HEAD.
 1.4.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.2.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.4.2.1 17-Jun-2008  wrstuden file udf_strat_rmw.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:14 +0000
 1.9.4.10 09-Jul-2009  snj Pull up following revision(s) (requested by reinoud in ticket #853):
sys/fs/udf/udf_strat_rmw.c: revision 1.22
Fix alternating oddity in RMW strategy. Even when in the reading state it
would push out elements to fillup-read only when the time had come for them.
This could then trickle feed the read queue slowly, but fast enough to prevent
it from switching state.
 1.9.4.9 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.9.4.8 01-Jun-2009  liamjfoy Pull up following revision(s) (requested by reinoud in ticket #772):
sys/fs/udf/udf_strat_rmw.c: revision 1.19
sys/fs/udf/udf_strat_sequential.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.10
sys/fs/udf/udf_subr.c: revision 1.90
sys/fs/udf/udf_subr.c: revision 1.91
Descriptor version is 16 bit and not 8 so use udf_rw16() to access them.
UniqueID was written in the logical volume integrity without byteswapping for
bigendian machines.

Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.9.4.7 18-Feb-2009  snj branches: 1.9.4.7.4;
Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.9.4.6 10-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #174):
sys/fs/udf/udf_strat_rmw.c: revision 1.15
sys/fs/udf/udf.h: revision 1.29
Fix two buf_init()'s that are not needed since they were already initialised
by getiobuf().
Also remove ancient IPL_BIO reference from the time it was called from
interrupt context instead of the current soft interrupt.
 1.9.4.5 10-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #174):
sys/fs/udf/udf_strat_rmw.c: revision 1.14
UDF_SHED_FREE state is now also handled by the state machine, so DO signal it.
Free'd up ecclines can now far more quicker be recycled.
 1.9.4.4 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf.h: revision 1.28
sys/fs/udf/udf_strat_rmw.c: revision 1.13
Two fold commit:
1) Enhance write speed significantly on RMW media like CD-RW, DVD-RW but also
on the DVD+RW and all other ECC blocked media. Significant speedups of access
to the device for say compilation on the DVD. Streaming copy is also still at
maximum speed though vast amounts of directory copy work can show side effects
that appear it to slow down but are actually logical when you consider that
most small files are embedded into the descriptors itself.
2) explicit wait for the created RMW thread to spinup
 1.9.4.3 27-Nov-2008  snj Pull up following revision(s) (requested by reinoud in ticket #133):
sys/fs/udf/udf_strat_rmw.c: revision 1.12
Specify blobsize as the `pagingsize' of the eccline blob pool. This will relax
the requirements of the pagingsize.
 1.9.4.2 02-Nov-2008  snj Pull up following revision(s) (requested by reinoud in ticket #8):
sys/fs/udf/udf_strat_rmw.c: revision 1.11
Introduce an extra state to wich all pushed ecclines are pushed on. This
extra state has a holding time in wich no writeouts will be done
effectively collecting more sectors before its even sheduled for writing.
 1.9.4.1 02-Nov-2008  snj Pull up following revision(s) (requested by reinoud in ticket #6):
sys/fs/udf/udf_strat_rmw.c: revision 1.10
Explicitly set buffer's block numbers. Blocks were always read/written
correctly only the sheduling could go less than optimal.
 1.9.4.7.4.1 21-Apr-2010  matt sync to netbsd-5
 1.9.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.9.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.2.1 23-Jul-2009  jym Sync with HEAD.
 1.22.26.1 18-May-2014  rmind sync with head
 1.22.22.2 03-Dec-2017  jdolecek update from HEAD
 1.22.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.12.1 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.24.6.3 29-May-2016  skrll Sync with HEAD
 1.24.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.24.6.1 22-Sep-2015  skrll Sync with HEAD
 1.20 27-Jun-2023  reinoud Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
 1.19 27-Aug-2022  skrll Spell approximately correctly.
 1.18 27-Aug-2022  skrll Trailing whitespace
 1.17 16-Apr-2022  andvar fix various typos in comments and log messages.
 1.16 08-Mar-2022  reinoud On switching from writing to reading explicitly synchronize the caches. It
isn't strictly needed but some devices in the wild will otherwise bluntly
ignore all reading commands resulting in a kernel and device lockup.
 1.15 24-May-2016  reinoud branches: 1.15.22;
Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.14 06-Oct-2015  hannken Remove dubious vhold()/holdrele() from write_logvol_dscr strategies.

The udf_node already gets locked with UDF_LOCK_NODE() and udf_reclaim()
will wait for the lock to clear.
 1.13 23-Mar-2014  christos branches: 1.13.6;
fix unused
 1.12 18-Oct-2013  christos fix unused variable warnings
 1.11 03-Jan-2011  drochner branches: 1.11.8; 1.11.18; 1.11.22;
destroy mutex/cv before freeing the struct holding them, fixes
LOCKDEBUG panic
 1.10 20-May-2009  reinoud branches: 1.10.4;
Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.9 10-Feb-2009  reinoud Sequential writing goes before normal write. Its not likely to ever go wrong
but there could be a race otherwise.
 1.8 08-Feb-2009  reinoud branches: 1.8.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.7 13-Jan-2009  yamt g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.6 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.5 29-Aug-2008  reinoud branches: 1.5.2; 1.5.4;
Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.4 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.3 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.2 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.1 14-May-2008  reinoud branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.1.12.1 19-Oct-2008  haad Sync with HEAD.
 1.1.10.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.10.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.10.1 14-May-2008  wrstuden file udf_strat_sequential.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:14 +0000
 1.1.8.2 31-Jul-2008  simonb Sync with head.
 1.1.8.1 18-Jul-2008  simonb Sync with head.
 1.1.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.1 14-May-2008  mjf file udf_strat_sequential.c was added on branch mjf-devfs2 on 2008-06-02 13:24:06 +0000
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 14-May-2008  yamt file udf_strat_sequential.c was added on branch yamt-pf42 on 2008-05-18 12:35:06 +0000
 1.1.2.4 20-Jun-2009  yamt sync with head
 1.1.2.3 04-May-2009  yamt sync with head.
 1.1.2.2 16-May-2008  yamt sync with head.
 1.1.2.1 14-May-2008  yamt file udf_strat_sequential.c was added on branch yamt-nfs-mp on 2008-05-16 02:25:21 +0000
 1.5.4.4 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.5.4.3 01-Jun-2009  liamjfoy Pull up following revision(s) (requested by reinoud in ticket #772):
sys/fs/udf/udf_strat_rmw.c: revision 1.19
sys/fs/udf/udf_strat_sequential.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.10
sys/fs/udf/udf_subr.c: revision 1.90
sys/fs/udf/udf_subr.c: revision 1.91
Descriptor version is 16 bit and not 8 so use udf_rw16() to access them.
UniqueID was written in the logical volume integrity without byteswapping for
bigendian machines.

Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.5.4.2 18-Mar-2009  snj branches: 1.5.4.2.4;
Apply patch (requested by reinoud in ticket #569):
Remove dead code and double check if it's allowed to write out
non-sequential there.
--
Sequential writing goes before normal write. Its not likely to ever go
wrong but there could be a race otherwise.
--
Add simplistic UBC async flushing as other FS's seem to do. Its a clutch
and needs to be addressed in UBC properly.
Improve write throttling by doing it on page-size basis. The `standard'
solution would cut up files unnessisary during allocation. It also made
assumptions about ucb wich were propably right but still.
 1.5.4.1 18-Feb-2009  snj Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.5.4.2.4.1 21-Apr-2010  matt sync to netbsd-5
 1.5.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.5.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.2.2 23-Jul-2009  jym Sync with HEAD.
 1.8.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.11.22.1 18-May-2014  rmind sync with head
 1.11.18.2 03-Dec-2017  jdolecek update from HEAD
 1.11.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.8.1 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.13.6.2 29-May-2016  skrll Sync with HEAD
 1.13.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.15.22.1 13-Mar-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1431):

sys/fs/udf/udf_strat_sequential.c: revision 1.16
sys/fs/udf/udf_subr.c: revision 1.167

On switching from writing to reading explicitly synchronize the caches. It
isn't strictly needed but some devices in the wild will otherwise bluntly
ignore all reading commands resulting in a kernel and device lockup.

For bug-compatibility with Windows, the last VAT sector must be a multiple of
16/32 from the start of the track. To allow for scratches, write out at least
a 32 pieces.
 1.177 28-Mar-2025  andvar s/beyong/beyond/ in comment.
 1.176 10-Feb-2024  andvar branches: 1.176.2;
fix various typos in comments and log messages.
 1.175 04-Feb-2024  andvar s/substract/subtract/ in comments.
 1.174 03-Jun-2023  andvar fix various typos in comments and messages.
 1.173 03-Apr-2023  gutteridge Fix typos: s/trough/through/
 1.172 31-Oct-2022  andvar fix various typos in comments and one output message.
 1.171 28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.170 15-May-2022  andvar s/wich/which in comments.
 1.169 22-Apr-2022  reinoud Fix endian issue with UDF extended attribute handling
 1.168 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.167 08-Mar-2022  reinoud For bug-compatibility with Windows, the last VAT sector must be a multiple of
16/32 from the start of the track. To allow for scratches, write out at least
a 32 pieces.
 1.166 06-Feb-2022  andvar fix various typos in comments, log messages and documentation.
mainly s/aparently/apparently/ and s/implmented/implemented/.
 1.165 25-Jan-2022  andvar fix various typos in comments.
 1.164 24-Jan-2022  andvar remove double "with" in comments and usage text. Also fix one typo.
 1.163 01-Jan-2022  msaitoh s/implemenation/implementation/ in comment.
 1.162 16-Dec-2021  reinoud Fix typo: reader -> header
 1.161 16-Dec-2021  reinoud Fix serious issue with recordable media formatted with Win10. When closing it
after modification the VAT was written out corrupted making the disc
unreadable anymore on remount. Thanks for ig@ for spotting it in the wild!
 1.160 15-Dec-2021  reinoud While searching the VAT on recordable media, search the last sector too!
This fixes Win10 formatted discs from being mounted incorrectly.
 1.159 05-Dec-2021  msaitoh s/alloction/allocation/
 1.158 16-Sep-2021  andvar fix typos in word "successful".
 1.157 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.156 21-Aug-2021  andvar s/helt/held+s/eroneously/erroneously/+s/splitted/split/+s/recommented/recommended/
 1.155 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.154 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.153 13-Apr-2021  mrg branches: 1.153.2;
more GCC 10 fixes.

mDNSResponder: another wrong return local address

dhcp: ignore a seemingly impossible stringop overflow

hpacel: avoid maybe uninitialised error that is wrong.

rsh: avoid impossible malloc(0)

udf: cast pointers through (uintptr_t) to fool invalid boundary checks
 1.152 11-Jan-2021  skrll branches: 1.152.2;
Trailing whitespace
 1.151 11-Jan-2021  skrll Fix spelling of preferred in comments. While here improve grammar in
one of the comments.
 1.150 06-Apr-2020  hannken branches: 1.150.4;
udf_get_node(): fix typo and honor "lktype" argument.
 1.149 27-Feb-2020  ad Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.
 1.148 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.147 18-Sep-2019  christos branches: 1.147.2;
Add newly created vnodes to the namei cache. The rest of the filesystems
already did that (or they don't support writing). Discussed in tech-kern.
 1.146 03-Jun-2019  msaitoh branches: 1.146.2;
Fix typo in comment (s/seperate/separate/).
 1.145 01-Jan-2019  hannken Add "void *extra" argument to vcache_new() so a file system may
pass more information about the file to create.

Welcome to 8.99.30
 1.144 14-Oct-2018  jdolecek remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect
 1.143 09-Aug-2018  reinoud Fix length calculation
 1.142 25-Jul-2018  reinoud Enhance logical volume integrity descriptor handling and provide
bug-compatibility for Linux mkudffs 1.3 images.
 1.141 06-Jun-2018  maya branches: 1.141.2;
Remove duplicate ;
 1.140 28-May-2018  chs add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.139 01-Apr-2017  riastradh branches: 1.139.6; 1.139.12;
KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.138 24-May-2016  reinoud branches: 1.138.2; 1.138.4;
Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.137 10-May-2016  reinoud Rework VAT searching on recordable media. It is now a lot more resilliant to
errors and it allows for VAT searching on crashed writeouts.

While here, make sure the node pointer is always initialised in
udf_get_node().
 1.136 27-Jan-2016  reinoud Fix filename creation and deleting with illegal file names. UDF has a
machanism for it but it allowed to create a file with a name it considered
illegal that then couldn't be deleted with the same name.

Fixes PR kern/50608. When confirmed, it can be closed.
 1.135 19-Dec-2015  dholland Improve misleading variable name. Related to PR 50571.

XXX: also there should be real bounds-check logic in here.
XXX: if the on-disk data structure contains rubbish this code will
XXX: leak or trample arbitrary kernel memory.
 1.134 19-Dec-2015  christos add missing ,
 1.133 19-Dec-2015  christos PR/50571: David Binderman: src/sys/fs/udf/udf_subr.c:6465: obvious
performance tidyup
 1.132 24-Aug-2015  hannken Use vfs_vnode_iterator for udf_do_sync.

- Build rb_tree to get an ordered list of nodes, sync them and
clean the tree.

- Stop abusing mntvnode_lock to serialize udf_do_sync, use new
mutex ump->sync_lock instead.
 1.131 24-Aug-2015  hannken Remove dirtynodes_cv, it is only used for timed waits without any signals.

Replace the cv_timedwait with kpause.
 1.130 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.129 06-Apr-2015  hannken Change udf to vcache, keyed on udf_node->loc.loc.
 1.128 07-Feb-2015  christos fix udf_node leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4
 1.127 17-Sep-2014  reinoud branches: 1.127.2;
Fix bug introduced in last patch
 1.126 17-Sep-2014  reinoud As pointed out by wiz@ prevent a possible attack or corruption that results in
an endless loop of indirect descriptors being processed.

The number of indirect descriptors followed is now maximized.
While here, also fix a use-after-free bug!
 1.125 29-Jul-2014  reinoud branches: 1.125.2;
Fix debug printout of udf_write_metadata_partition_spacetable(), it referred
to an old variable.
 1.124 23-Mar-2014  christos branches: 1.124.2;
fix unused
 1.123 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.122 21-Nov-2013  riz Don't create a variable just to assert() on it - assert on the
thing the variable got assigned.
 1.121 18-Oct-2013  christos fix unused variable warnings
 1.120 07-Jul-2013  reinoud Implement a real empty-directory checking for rmdir().

Should should fix the other part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_notempty
 1.119 29-Apr-2012  chs branches: 1.119.2; 1.119.4;
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.118 13-Nov-2011  christos branches: 1.118.4; 1.118.6;
use getdisksize()
 1.117 27-Sep-2011  christos branches: 1.117.2;
- rename UDF_MAX_NAMELEN -> UDF_MAXNAMLEN
- use NAME_MAX instead of MAXNAMLEN
 1.116 16-Aug-2011  mbalmer Fix some typos.
 1.115 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.114 26-Apr-2011  hannken branches: 1.114.2;
Change vflushbuf() to return an error if a synchronous write fails.

Welcome to 5.99.51.
 1.113 22-Jan-2011  reinoud A not rewritable disc can be pseudo-overwritable. A pseudo-overwritable disc
can overwrite its logical volume integrity sequence so no need to make it
append-only for this class of discs.
 1.112 22-Jan-2011  reinoud Lookup the physical partition backing up the logical one when searching for the
metadata partition overlap for BD-R.

Fixes a kernel panic on mounting a BD-R formatted with UDF 2.60
 1.111 21-Jan-2011  reinoud Split out the raw to indexed partitioning code protecting against roque
implementations that use `ramdom' numbers for the physical partitions breaking
lots of implementations. Known curlpit is MicroSoft Windows 7.

Not only the partition mappings need to be protected against this but also the metadata partition files.
 1.110 13-Jan-2011  reinoud branches: 1.110.2; 1.110.4;
Fix the case in where a file with a latin1 file name was created. It was then
erronously entered as thelatin1 file name in the dirhash whereas the matching
routing assumes both UTF-8. This would result in a file being created but not
stat-able since the dirhash couldn't find the entry unless it was remounted.
 1.109 22-Dec-2010  reinoud Running with DEBUG again revealed locking errors previously undetected. The
VAT writeout was done locked while marked locked as were the readin and
writeout of the metadata partition space table.

While here, also protect the (vp) argument of the UDF_SET_SYSTEMFILE() macro.

Tested on UDF 1.50 sequential, UDF 2.01 RW and UDF 2.50 metadata RW meda.
 1.108 24-Sep-2010  rmind Fixes/improvements to RB-tree implementation:
1. Fix inverted node order, so that negative value from comparison operator
would represent lower (left) node, and positive - higher (right) node.
2. Add an argument (i.e. "context"), passed to comparison operators.
3. Change rb_tree_insert_node() to return a node - either inserted one or
already existing one.
4. Amend the interface to manipulate the actual object, instead of the
rb_node (in a similar way as Patricia-tree interface does).
5. Update all RB-tree users accordingly.

XXX: Perhaps rename rb.h to rbtree.h, since cleaning-up..

1-3 address the PR/43488 by Jeremy Huddleston.

Passes RB-tree regression tests.
Reviewed by: matt@, christos@
 1.107 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.106 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.105 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.104 25-Feb-2010  reinoud branches: 1.104.2;
First part of shrinking/growing metadata partition support:

- extending the metadata partition

Still to follow:
- sparsify metadata partition
- growing the metadata partition
- unsparsifying metadata partition
 1.103 24-Feb-2010  reinoud Rename metadata partition parameters to be less generic and add the flags.
 1.102 24-Feb-2010  reinoud Extract UDF metadata partition parameters as already done for VAT and sparable
partitions.
 1.101 05-Jan-2010  mbalmer branches: 1.101.2;
Remove extra semicolons.
 1.100 23-Dec-2009  mbalmer Fix typo in comments, no code change.
 1.99 27-Jul-2009  reinoud Issue extra synchronise caches before closing tracks or sessions. It shouldn't
be needed as the caches should already be synchronised, but better be safe.
 1.98 07-Jul-2009  reinoud Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.
 1.97 06-Jul-2009  reinoud Make source prettier
 1.96 25-Jun-2009  reinoud Rewrite of udf_on_rootpath(), and vop_rename() code that calls it, after the
UFS way. The tree walking is now done the same and the code hasn't locked up
on examples that made it lockup before.
 1.95 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.94 23-Jun-2009  reinoud Renaming in UDF was already possible but directories could only be renamed in
the same directory.

This patch finally allows a directory to be moved between parent directories.
 1.93 18-Jun-2009  reinoud Enhance comment on node locking when writing out a node's descriptors.
 1.92 18-Jun-2009  reinoud Remove unneeded wait for SYNC being finished on node disposal of deleted node;
this could interfere and lockup.
 1.91 20-May-2009  reinoud Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.90 20-May-2009  reinoud Descriptor version is 16 bit and not 8 so use udf_rw16() to access them.
UniqueID was written in the logical volume integrity without byteswapping for
bigendian machines.
 1.89 19-May-2009  reinoud On creation of a new node, don't forget to set the length of the allocated
space in the right endian!
 1.88 19-May-2009  reinoud Forgot to use the udf_rw16() on the descriptor crc lengths of FID's!
Also fix a few dubiously formatted checks.
 1.87 18-Mar-2009  cegger bzero -> memset
 1.86 22-Feb-2009  yamt udf_write_filebuf: remove an write-only variable
 1.85 08-Feb-2009  reinoud branches: 1.85.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.84 05-Feb-2009  pooka Specify BROKEN DIRECTORY ENTRY printf comes from udf
(can happen e.g. with medium error)
 1.83 19-Dec-2008  cegger use M_ZERO on malloc() and remove subsequent bzero().
 1.82 18-Dec-2008  reinoud Implement auto-track repair on tracks marked damaged when searching for
writable tracks on session opening. Note that this an optionally implemented
feature and thus no error will be generated if it fails; the drive will most
likely autorepair it.
 1.81 18-Dec-2008  reinoud Fix critital panic when mounting a CD-R/DVD*R disc. The check for VV_ROOT was
not done correctly and could panic when requested to load a VAT descriptor
since the fileset was not yet fetched.
 1.80 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.79 16-Dec-2008  reinoud Check for a node being root on node creation so when the root node is disposed
of when working deep into the directory tree it can reliably be reget and
marked correctly as the FS root.

Fixed pwd(1) lock panic and possible endless loop in other tools.
 1.78 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.77 16-Dec-2008  reinoud Elaborate SYNC debug messages and rename some debug messages to a more
proper category.
 1.76 01-Dec-2008  reinoud Split uid/gid remapping code to be independent of eachother.
 1.75 28-Nov-2008  reinoud Allow for the exclusive selection of `direct' for rdonly mounts; its disabled
for now since its a lot slower than `rmw' access.

For archs that have trouble with `rmw' for whatever reason can so use it as a
scapegoat to allways mount savely rdonly though slower.
 1.74 28-Nov-2008  reinoud Remove old comment and remove unused calculated variable
 1.73 27-Sep-2008  reinoud branches: 1.73.2; 1.73.4;
Switch UDF over to the vfs_dirhash.c dirhash code.
 1.72 29-Aug-2008  reinoud Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.71 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.70 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.69 27-Jul-2008  reinoud Delay physical partition spacebitmaps from volume-descriptor-checking until
the other supporting structures are read in.
 1.68 26-Jul-2008  reinoud Clarify the current spacemap read/write code is reading/writing physical
partition space maps. This in preperation of Metadata spacetable
reading/writeout work.
 1.67 22-Jul-2008  reinoud No use walking empty hashtables when purging.
 1.66 22-Jul-2008  reinoud Limit the UDF dirhash to a configurable amount of memory. The performance
penalty even with a limited dirhash of 128kb is acceptable but it should be
set by machine memory size though.
 1.65 19-Jul-2008  reinoud Use ecma-167 constants instead of homegrown to prevent double mapping.
 1.64 19-Jul-2008  reinoud Choose which time of allocation descriptors to use on new nodes based on
the number of partition mappings.
 1.63 18-Jul-2008  reinoud fix comment
 1.62 18-Jul-2008  reinoud On dirhash lookup, don't retrieve info you already have.
 1.61 18-Jul-2008  reinoud Remove double check
 1.60 18-Jul-2008  reinoud First retrieve length and hash values *before* advancing to the next entry.
On hashline collision it would check a random one next.
 1.59 17-Jul-2008  reinoud Implement directory hashing to speed up directory traversals. Speed
improvements of at least 4 times in untarring and roughly 100 to 500 times
on file creation in big directories. Lookup of files was O(n*n) and is now
O(1) even for file creation. Free spaces in the directory are kept in a
seperate list for fast file creation.

The postmark benchmark gives:

UDF old:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
1593 seconds total
681 seconds of transactions (2 per second)

Files:
3956 created (2 per second)
Creation alone: 3000 files (4 per second)
Mixed with transactions: 956 files (1 per second)
990 read (1 per second)
1010 appended (1 per second)
3956 deleted (2 per second)
Deletion alone: 2912 files (9 per second)
Mixed with transactions: 1044 files (1 per second)

Data:
5.26 megabytes read (3.38 kilobytes per second)
21.93 megabytes written (14.10 kilobytes per second)
pm>



UDF new:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
19 seconds total
3 seconds of transactions (666 per second)

Files:
3956 created (208 per second)
Creation alone: 3000 files (230 per second)
Mixed with transactions: 956 files (318 per second)
990 read (330 per second)
1010 appended (336 per second)
3956 deleted (208 per second)
Deletion alone: 2912 files (970 per second)
Mixed with transactions: 1044 files (348 per second)

Data:
5.26 megabytes read (283.66 kilobytes per second)
21.93 megabytes written (1.15 megabytes per second)
 1.58 17-Jul-2008  reinoud Dont round up nanosecond count; if its nearing wrap one could get a count
of >1 second resulting in invalid time stamps on disc.
 1.57 11-Jul-2008  reinoud Fix spelling in comment
 1.56 10-Jul-2008  reinoud On node creation, follow tmpfs and UFS by generating the uid/gid pair. This
fixes the lack of file ownership preservation on file/directory creation.

See PR kern/39124
 1.55 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.54 25-Jun-2008  reinoud branches: 1.54.2;
Disable read/write mounting for metadatapartition since attempts to delete
files now corrupt the image due to the lack of allocation scheme support.
 1.53 25-Jun-2008  reinoud Allow metadata partitioned discs to be mounted read-write even though its
allocation scheme is not implemented yet. Creating new files or deleting
anything is thus not possible.
 1.52 25-Jun-2008  reinoud Fix allocation extensions descriptor reading and do free them on node
destruction!
 1.51 24-Jun-2008  reinoud Support the creation of extended attributes for file creation in the
kernel and check and update them when found.

Note that it won't *insert* an extended attribute yet if it hasn't found it
while updating the birthtime.
 1.50 18-Jun-2008  reinoud Cleanup file access,modification,attribute and birthtime setting of files
and make the modification time when set never older than the creation time.
 1.49 19-May-2008  christos branches: 1.49.2;
fix argument type.
 1.48 19-May-2008  reinoud Implement wide char support for UDF by properly implementing unicode-16 to
UTF-8 like cd9660 and ntfs already do.
 1.47 17-May-2008  reinoud Cleaner gcc initialisation detection failure notice.
 1.46 17-May-2008  reinoud Fix `uninitialised variable' warning issued by the sh3 compiler. gcc can't
detect that the `last_node' variable will be set before used since it can't
parse the semantics of `TAILQ_EMPTY()' that is used as a guard first.

Thanks for H?rvard for finding and reporting it :)
 1.45 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.44 02-Jan-2008  ad branches: 1.44.6; 1.44.8; 1.44.10; 1.44.12;
Merge vmlocking2 to head.
 1.43 11-Dec-2007  lukem use __KERNEL_RCSID() instead of __RCSID()
 1.42 27-Nov-2007  reinoud branches: 1.42.2; 1.42.4; 1.42.6;
Pullup fixes from UDF RW support project. This commit fixes the
mmc_discinfo conceptional bug and also vastly improves VAT searching.
 1.41 26-Nov-2007  pooka 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.40 31-Oct-2007  reinoud branches: 1.40.2;
Fix panic when the VAT couldn't be found. It would refer an stale
udf_node->vnode.
 1.39 10-Oct-2007  ad branches: 1.39.2;
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.38 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.37 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.36 29-Jul-2007  ad branches: 1.36.4; 1.36.6; 1.36.8; 1.36.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.35 23-Jul-2007  pooka Initialize size and/or writesize when creating a vnode.
 1.34 29-Apr-2007  msaitoh branches: 1.34.2;
fix typos
 1.33 12-Apr-2007  reinoud Some rogue implementations use random physical partion numbers just to
break other implementations so lookup the physical number instead of
indexing it. Choosing random numbers here is legal according to the specs,
but not a logical choice and most likely done as a wierd kind of copy
protection.

Rogue implementation found to use this
*Microsoft CDIMAGE UDF
 1.32 20-Feb-2007  ad branches: 1.32.4; 1.32.6;
Call genfs_node_destroy() where appropriate.
 1.31 17-Jan-2007  reinoud branches: 1.31.2;
Fix important directory lookup bug that could result in an endless loop. It
fixes the case where a directory lookup is done in a directory has never
been visted/listed; the search optimalisation that searches the directory
from where it left behind the last time would never reach the initial
offset of zero since it would always have at least processed one entry.
 1.30 17-Jan-2007  reinoud Use the generic clock_ymdhms_to_secs() instead of home-brewn version to
translate UDF timestamps to timespec.
 1.29 04-Jan-2007  reinoud Forgot one place for UDF_ICB_FILETYPE_RANDOMACCESS.
 1.28 04-Jan-2007  reinoud Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
 1.27 04-Jan-2007  reinoud Fix compilation issue when specifying different flags or compiling with a
different compiler. Thanks to Jared for noting.
 1.26 04-Jan-2007  reinoud Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.25 25-Dec-2006  wiz Spell "separate" correctly. From Zafer Aydogan.
 1.24 25-Dec-2006  wiz Spell "schedule" correctly. From Zafer Aydogan.
 1.23 16-Nov-2006  christos branches: 1.23.2;
__unused removal on arguments; approved by core.
 1.22 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21 04-Oct-2006  reinoud Fix panic on unmounting VAT file systems. The VAT table was allocated and
freed on the wrong malloc type.
 1.20 03-Oct-2006  reinoud Fix memory leaks on mounting and dismounting UDF volumes.
 1.19 28-Sep-2006  reinoud Fix lookup bug that could result in not finding the last entry. The check
for the cycling was too early. Also fix potential endless loop when the
last entry was deleted.
 1.18 19-Sep-2006  reinoud Make VOP_LOOKUP's O(1) instead of O(n log(n)) giving a speedup of 7500% on
a 1400 file directory.
 1.17 19-Sep-2006  reinoud Fix serious file-corruption issue on sparable partitions.
 1.16 19-Sep-2006  reinoud Fix panic when the sparable table didn't read in correctly.
 1.15 05-Sep-2006  reinoud branches: 1.15.2; 1.15.4; 1.15.6;
Fix copying too much space from a small buffer. The chances of it actually
happening are small but corrupt media could trigger it.
 1.14 22-Aug-2006  reinoud Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.13 21-Aug-2006  reinoud Make a better guess on VAT locations so discs that are semi-standard
formatted can be recognised. This also fixes the bug that prevented UDF to
mount an empty CD-R/DVD*R disc.
 1.12 11-Aug-2006  reinoud Fix comment; it stated a mimimum of 128 translations duh! a maximum it is!
 1.11 09-Jul-2006  reinoud branches: 1.11.2;
Fixing a bad case of walking/writing out of allocated space.... the
allocated space was 2048 bytes, but when adding 1024 to the variable
`unix_name' to split the allocated space in half it effectively starts just
OUTSIDE the allocated space. This ought to fix memory corruption bugs when
using UDF.

This is a routine to revisit one day.
 1.10 20-Jun-2006  christos branches: 1.10.2;
Don't allocate too much stuff on the stack.
 1.9 12-Jun-2006  christos branches: 1.9.2;
stack polics: Don't allocate 4K on the stack.
remove ; from };
 1.8 15-May-2006  christos branches: 1.8.2;
kauth fallout
 1.7 14-May-2006  elad integrate kauth.
 1.6 25-Apr-2006  snj s/allready/already/
 1.5 01-Mar-2006  yamt branches: 1.5.2; 1.5.4; 1.5.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.4 04-Feb-2006  reinoud branches: 1.4.2;
VND and harddiscs have their own defect free space management.
 1.3 04-Feb-2006  reinoud Change a comment into a TODO and fix up case where we could return an
illegal allready-freed memory space.
 1.2 02-Feb-2006  reinoud branches: 1.2.2;
Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.2.2.2 01-Jun-2006  kardel Sync with head.
 1.2.2.1 22-Apr-2006  simonb Sync with head.
 1.4.2.3 01-Mar-2006  yamt adapt udf.
 1.4.2.2 18-Feb-2006  yamt sync with head.
 1.4.2.1 04-Feb-2006  yamt file udf_subr.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.5.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.4.2 11-May-2006  elad sync with head
 1.5.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.5.2.5 14-Sep-2006  yamt sync with head.
 1.5.2.4 03-Sep-2006  yamt sync with head.
 1.5.2.3 11-Aug-2006  yamt sync with head
 1.5.2.2 26-Jun-2006  yamt sync with head.
 1.5.2.1 24-May-2006  yamt sync with head.
 1.8.2.1 19-Jun-2006  chap Sync with head.
 1.9.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.10.2.9 21-Jan-2008  yamt sync with head
 1.10.2.8 07-Dec-2007  yamt sync with head
 1.10.2.7 15-Nov-2007  yamt sync with head.
 1.10.2.6 27-Oct-2007  yamt sync with head.
 1.10.2.5 03-Sep-2007  yamt sync with head.
 1.10.2.4 26-Feb-2007  yamt sync with head.
 1.10.2.3 30-Dec-2006  yamt sync with head.
 1.10.2.2 21-Jun-2006  yamt sync with head.
 1.10.2.1 20-Jun-2006  yamt file udf_subr.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:36 +0000
 1.11.2.6 25-Sep-2006  riz Pull up following revision(s) (requested by reinoud in ticket #185):
sys/fs/udf/udf_subr.c: revision 1.18
sys/fs/udf/udf.h: revision 1.7
Make VOP_LOOKUP's O(1) instead of O(n log(n)) giving a speedup of 7500% on
a 1400 file directory.
 1.11.2.5 25-Sep-2006  riz Pull up following revision(s) (requested by reinoud in ticket #184):
sys/fs/udf/udf_subr.c: revision 1.17
Fix serious file-corruption issue on sparable partitions.
 1.11.2.4 25-Sep-2006  riz Pull up following revision(s) (requested by reinoud in ticket #181):
sys/fs/udf/udf_subr.c: revision 1.16
Fix panic when the sparable table didn't read in correctly.
 1.11.2.3 08-Sep-2006  rpaulo Pull up following revision(s) (requested by reinoud in ticket #125):
sys/fs/udf/udf_subr.c: revision 1.15
sys/fs/udf/udf_vfsops.c: revision 1.13
sys/fs/udf/ecma167-udf.h: revision 1.4
Add shortcut for struct long_ad 's Unique ID hint that covers the lower 32
bits of the targeted files 64 bits Unique ID for recovery purposes.
Fix locking scheme in udf_mount() to follow more the other filingsystems.
For yet unknown reasons passing the LOCKLEAF flag to namei() did return a
locked vnode as was meant but would panic when a raw device was passed.
Fix copying too much space from a small buffer. The chances of it actually
happening are small but corrupt media could trigger it.
 1.11.2.2 27-Aug-2006  riz Pull up following revision(s) (requested by reinoud in ticket #50):
sys/fs/udf/udf_subr.c: revision 1.14
sys/fs/udf/udf.h: revision 1.6
sys/fs/udf/udf_vfsops.c: revision 1.11
Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.11.2.1 24-Aug-2006  tron Pull up following revision(s) (requested by reinoud in ticket #46):
sys/fs/udf/udf_subr.c: revision 1.13
sys/fs/udf/udf.h: revision 1.5
Make a better guess on VAT locations so discs that are semi-standard
formatted can be recognised. This also fixes the bug that prevented UDF to
mount an empty CD-R/DVD*R disc.
 1.15.6.2 10-Dec-2006  yamt sync with head.
 1.15.6.1 22-Oct-2006  yamt sync with head
 1.15.4.2 09-Sep-2006  rpaulo sync with head
 1.15.4.1 05-Sep-2006  rpaulo file udf_subr.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.15.2.3 01-Feb-2007  ad Sync with head.
 1.15.2.2 12-Jan-2007  ad Sync with head.
 1.15.2.1 18-Nov-2006  ad Sync with head.
 1.23.2.6 01-Feb-2008  riz Pull up following revision(s) (requested by reinoud in ticket #1004):
sys/dev/scsipi/cd.c: revision 1.270
sys/sys/cdio.h: revision 1.29
sys/fs/udf/udf_subr.c: revision 1.42
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.
Pullup fixes from UDF RW support project. This commit fixes the
mmc_discinfo conceptional bug and also vastly improves VAT searching.
 1.23.2.5 04-Nov-2007  xtraeme Pull up following revision(s) (requested by reinoud in ticket #966):
sys/fs/udf/udf_subr.c: revision 1.40

Fix panic when the VAT couldn't be found. It would refer an stale
udf_node->vnode.
 1.23.2.4 12-Apr-2007  bouyer branches: 1.23.2.4.2;
Pull up following revision(s) (requested by reinoud in ticket #567):
sys/fs/udf/udf_subr.c: revision 1.33
Some rogue implementations use random physical partion numbers just to
break other implementations so lookup the physical number instead of
indexing it. Choosing random numbers here is legal according to the specs,
but not a logical choice and most likely done as a wierd kind of copy
protection.
Rogue implementation found to use this
*Microsoft CDIMAGE UDF
 1.23.2.3 21-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #376):
sys/fs/udf/udf_subr.c: revisions 1.30 - 1.31
sys/fs/udf/udf_subr.c: revision 1.31
Use the generic clock_ymdhms_to_secs() instead of home-brewn version to
translate UDF timestamps to timespec.
Fix important directory lookup bug that could result in an endless loop. It
fixes the case where a directory lookup is done in a directory has never
been visted/listed; the search optimalisation that searches the directory
from where it left behind the last time would never reach the initial
offset of zero since it would always have at least processed one entry.
 1.23.2.2 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #333):
sys/fs/udf/udf_subr.c: revision 1.27-1.29
sys/fs/udf/udf_vnops.c: revision 1.9
sys/fs/udf/ecma167-udf.h: revision 1.6
Fix compilation issue when specifying different flags or compiling with a
different compiler. Thanks to Jared for noting.
Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
Forgot one place for UDF_ICB_FILETYPE_RANDOMACCESS.
 1.23.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #332):
sys/fs/udf/udf_subr.c: revision 1.26
sys/fs/udf/udf.h: revision 1.9
sys/fs/udf/udf_vfsops.c: revision 1.19
Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.23.2.4.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.23.2.4.2.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.31.2.3 07-May-2007  yamt sync with head.
 1.31.2.2 15-Apr-2007  yamt sync with head.
 1.31.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.32.6.1 11-Jul-2007  mjf Sync with head.
 1.32.4.8 09-Oct-2007  ad Sync with head.
 1.32.4.7 24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.32.4.6 20-Aug-2007  ad Sync with HEAD.
 1.32.4.5 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.32.4.4 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.32.4.3 09-Jun-2007  ad Sync with head.
 1.32.4.2 08-Jun-2007  ad Sync with head.
 1.32.4.1 05-Apr-2007  ad Compile fixes.
 1.34.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.36.10.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.36.10.1 29-Jul-2007  ad file udf_subr.c was added on branch matt-mips64 on 2007-07-29 13:31:12 +0000
 1.36.8.2 14-Oct-2007  yamt sync with head.
 1.36.8.1 06-Oct-2007  yamt sync with head.
 1.36.6.2 09-Jan-2008  matt sync with HEAD
 1.36.6.1 06-Nov-2007  matt sync with HEAD
 1.36.4.5 03-Dec-2007  joerg Sync with HEAD.
 1.36.4.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.36.4.3 31-Oct-2007  joerg Sync with HEAD.
 1.36.4.2 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.36.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.39.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.40.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.40.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.40.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.42.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.42.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.42.4.1 11-Dec-2007  yamt sync with head.
 1.42.2.2 26-Dec-2007  ad Sync with head.
 1.42.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.44.12.3 10-Oct-2008  skrll Sync with HEAD.
 1.44.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.44.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.44.10.8 09-Oct-2010  yamt sync with head
 1.44.10.7 11-Aug-2010  yamt sync with head.
 1.44.10.6 11-Mar-2010  yamt sync with head
 1.44.10.5 19-Aug-2009  yamt sync with head.
 1.44.10.4 18-Jul-2009  yamt sync with head.
 1.44.10.3 20-Jun-2009  yamt sync with head
 1.44.10.2 04-May-2009  yamt sync with head.
 1.44.10.1 16-May-2008  yamt sync with head.
 1.44.8.2 04-Jun-2008  yamt sync with head
 1.44.8.1 18-May-2008  yamt sync with head.
 1.44.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.44.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.44.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.44.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.44.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.49.2.5 31-Jul-2008  simonb Sync with head.
 1.49.2.4 28-Jul-2008  simonb Sync with head.
 1.49.2.3 22-Jul-2008  simonb Sync with head.
 1.49.2.2 18-Jul-2008  simonb Sync with head.
 1.49.2.1 27-Jun-2008  simonb Sync with head.
 1.54.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.54.2.1 19-Oct-2008  haad Sync with HEAD.
 1.73.4.12 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.73.4.11 06-Jun-2009  bouyer Pull up following revision(s) (requested by reinoud in ticket #770):
sys/fs/udf/udf_subr.c: revision 1.88, 1.89
sys/fs/udf/udf_bswap.h: revision 1.6, 1.7
sys/fs/udf/udf_allocation.c: revision 1.22, 1.23
sbin/newfs_udf/udf_create.c: revision 1.16
Fix *serious* bug in bswapping definitions for big endian machines.
ANSI-fy. No idea why they weren't so in the first place.
Fix newfs_udf to create a valid disc images on bigendian machines.
A descriptor's CRC lenth is 16 bit so use udf_rw16() on tag.desc_crc_len.
Forgot to use the udf_rw16() on the descriptor crc lengths of FID's!
Also fix a few dubiously formatted checks.
On creation of a new node, don't forget to set the length of the allocated
space in the right endian!
Account for the logical blocks recorded by the extent in the right endian!
 1.73.4.10 01-Jun-2009  liamjfoy Pull up following revision(s) (requested by reinoud in ticket #772):
sys/fs/udf/udf_strat_rmw.c: revision 1.19
sys/fs/udf/udf_strat_sequential.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.10
sys/fs/udf/udf_subr.c: revision 1.90
sys/fs/udf/udf_subr.c: revision 1.91
Descriptor version is 16 bit and not 8 so use udf_rw16() to access them.
UniqueID was written in the logical volume integrity without byteswapping for
bigendian machines.

Retire IN_CALLBACK_ULK flagging since its not used anymore and the old
assertions on it would trigger without cause.
 1.73.4.9 19-Feb-2009  snj branches: 1.73.4.9.4;
Apply patch (requested by plunky in ticket #447):
Use bitmask_snprintf instead of snprintb.
 1.73.4.8 18-Feb-2009  snj Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.73.4.7 22-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #194):
sys/fs/udf/udf_subr.c: revision 1.82
Implement auto-track repair on tracks marked damaged when searching for
writable tracks on session opening. Note that this an optionally implemented
feature and thus no error will be generated if it fails; the drive will most
likely autorepair it.
 1.73.4.6 22-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #194):
sys/fs/udf/udf_subr.c: revision 1.81
Fix critital panic when mounting a CD-R/DVD*R disc. The check for VV_ROOT was
not done correctly and could panic when requested to load a VAT descriptor
since the fileset was not yet fetched.
 1.73.4.5 18-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #192):
sys/fs/udf/udf_subr.c: revision 1.79
sys/fs/udf/udf_vfsops.c: revision 1.54
Check for a node being root on node creation so when the root node is disposed
of when working deep into the directory tree it can reliably be reget and
marked correctly as the FS root.
Fixed pwd(1) lock panic and possible endless loop in other tools.
 1.73.4.4 18-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #192):
sys/fs/udf/udf_subr.c: revision 1.77
sys/fs/udf/udf_vnops.c: revision 1.33
Elaborate SYNC debug messages and rename some debug messages to a more
proper category.
 1.73.4.3 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf_subr.c: revision 1.76
sys/fs/udf/udf_vnops.c: revision 1.32
Split uid/gid remapping code to be independent of eachother.
 1.73.4.2 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf_strat_direct.c: revision 1.6
sys/fs/udf/udf_subr.c: revision 1.75
Allow for the exclusive selection of `direct' for rdonly mounts; its disabled
for now since its a lot slower than `rmw' access.
For archs that have trouble with `rmw' for whatever reason can so use it as a
scapegoat to allways mount savely rdonly though slower.
 1.73.4.1 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf_subr.c: revision 1.74
Remove old comment and remove unused calculated variable
 1.73.4.9.4.1 21-Apr-2010  matt sync to netbsd-5
 1.73.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.73.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.73.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.85.2.2 23-Jul-2009  jym Sync with HEAD.
 1.85.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.101.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.101.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.101.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.104.2.5 31-May-2011  rmind sync with head
 1.104.2.4 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.104.2.3 05-Mar-2011  rmind sync with head
 1.104.2.2 03-Jul-2010  rmind sync with head
 1.104.2.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.110.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.110.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.114.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.117.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.117.2.2 23-May-2012  yamt sync with head.
 1.117.2.1 17-Apr-2012  yamt sync with head
 1.118.6.1 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.118.4.1 02-Jun-2012  mrg sync to latest -current.
 1.119.4.2 18-May-2014  rmind sync with head
 1.119.4.1 28-Aug-2013  rmind sync with head
 1.119.2.2 03-Dec-2017  jdolecek update from HEAD
 1.119.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.124.2.1 10-Aug-2014  tls Rebase.
 1.125.2.2 27-Jul-2018  martin Pull up following revision(s) (requested by reinoud in ticket #1622):

sys/fs/udf/udf_subr.c: revision 1.142

Enhance logical volume integrity descriptor handling and provide
bug-compatibility for Linux mkudffs 1.3 images.
 1.125.2.1 16-Feb-2015  martin Pull up following revision(s) (requested by maxv in ticket #520):
sys/ufs/chfs/ebh.c: revision 1.6
sys/dev/sdmmc/sdmmc_mem.c: revision 1.33
sys/dev/ic/aic7xxx.c: revision 1.132
sys/fs/nfs/common/krpc_subr.c: revision 1.2
sys/modules/lua/lua.c: revision 1.16
sys/fs/udf/udf_subr.c: revision 1.128
sys/ufs/chfs/chfs_scan.c: revision 1.6
sys/dev/ic/an.c: revision 1.62

Fix six memory leaks and two inconsistencies.
 1.127.2.7 28-Aug-2017  skrll Sync with HEAD
 1.127.2.6 29-May-2016  skrll Sync with HEAD
 1.127.2.5 19-Mar-2016  skrll Sync with HEAD
 1.127.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.127.2.3 22-Sep-2015  skrll Sync with HEAD
 1.127.2.2 06-Jun-2015  skrll Sync with HEAD
 1.127.2.1 06-Apr-2015  skrll Sync with HEAD
 1.138.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.138.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.139.12.5 18-Jan-2019  pgoyette Synch with HEAD
 1.139.12.4 20-Oct-2018  pgoyette Sync with head
 1.139.12.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.139.12.2 28-Jul-2018  pgoyette Sync with HEAD
 1.139.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.139.6.1 27-Jul-2018  martin Pull up following revision(s) (requested by reinoud in ticket #942):

sys/fs/udf/udf_subr.c: revision 1.142

Enhance logical volume integrity descriptor handling and provide
bug-compatibility for Linux mkudffs 1.3 images.
 1.141.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.141.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.141.2.1 10-Jun-2019  christos Sync with HEAD
 1.146.2.3 24-Apr-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1438):

sys/compat/netbsd32/netbsd32.h: revision 1.140
sys/compat/netbsd32/netbsd32_fs.c: revision 1.95
sys/fs/udf/udf_subr.c: revision 1.169

Fix endian issue with UDF extended attribute handling

Implement support for mounting UDF in compat32
Fixes PR#56801
 1.146.2.2 13-Mar-2022  martin Pull up following revision(s), all via patch,
requested by reinoud in ticket #1432:

sys/fs/udf/udf_vfsops.c: revision 1.83
sys/fs/udf/udf_allocation.c: revision 1.45
sys/fs/udf/udf_subr.c: revision 1.160
sys/fs/udf/udf_subr.c: revision 1.161

While searching the VAT on recordable media, search the last sector too!
This fixes Win10 formatted discs from being mounted incorrectly.

Make sysctl udf.verbose dependent on UDF_DEBUG instead of DEBUG

Fix serious issue with recordable media formatted with Win10. When closing it
after modification the VAT was written out corrupted making the disc
unreadable anymore on remount. Thanks for ig@ for spotting it in the wild!

On freeing a virtual address in the VAT, use the correct value; this might
confuse other implementations who can reject the VAT on this.
 1.146.2.1 13-Mar-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1431):

sys/fs/udf/udf_strat_sequential.c: revision 1.16
sys/fs/udf/udf_subr.c: revision 1.167

On switching from writing to reading explicitly synchronize the caches. It
isn't strictly needed but some devices in the wild will otherwise bluntly
ignore all reading commands resulting in a kernel and device lockup.

For bug-compatibility with Windows, the last VAT sector must be a multiple of
16/32 from the start of the track. To allow for scratches, write out at least
a 32 pieces.
 1.147.2.2 29-Feb-2020  ad Sync with head.
 1.147.2.1 17-Jan-2020  ad Sync with head.
 1.150.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.152.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.153.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.176.2.1 02-Aug-2025  perseant Sync with HEAD
 1.21 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.20 24-May-2016  reinoud branches: 1.20.18; 1.20.24;
Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
 1.19 07-Jul-2013  reinoud branches: 1.19.8;
Implement a real empty-directory checking for rmdir().

Should should fix the other part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_notempty
 1.18 25-Feb-2010  reinoud branches: 1.18.10; 1.18.20; 1.18.24;
First part of shrinking/growing metadata partition support:

- extending the metadata partition

Still to follow:
- sparsify metadata partition
- growing the metadata partition
- unsparsifying metadata partition
 1.17 07-Jul-2009  reinoud branches: 1.17.2;
Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.
 1.16 25-Jun-2009  reinoud Rewrite of udf_on_rootpath(), and vop_rename() code that calls it, after the
UFS way. The tree walking is now done the same and the code hasn't locked up
on examples that made it lockup before.
 1.15 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.14 23-Jun-2009  reinoud Renaming in UDF was already possible but directories could only be renamed in
the same directory.

This patch finally allows a directory to be moved between parent directories.
 1.13 08-Feb-2009  reinoud branches: 1.13.2;
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.12 06-Aug-2008  reinoud branches: 1.12.2; 1.12.4;
Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.11 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.10 26-Jul-2008  reinoud Forgot to rename those two references to write_space_bitmap too.
 1.9 17-Jul-2008  reinoud Implement directory hashing to speed up directory traversals. Speed
improvements of at least 4 times in untarring and roughly 100 to 500 times
on file creation in big directories. Lookup of files was O(n*n) and is now
O(1) even for file creation. Free spaces in the directory are kept in a
seperate list for fast file creation.

The postmark benchmark gives:

UDF old:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
1593 seconds total
681 seconds of transactions (2 per second)

Files:
3956 created (2 per second)
Creation alone: 3000 files (4 per second)
Mixed with transactions: 956 files (1 per second)
990 read (1 per second)
1010 appended (1 per second)
3956 deleted (2 per second)
Deletion alone: 2912 files (9 per second)
Mixed with transactions: 1044 files (1 per second)

Data:
5.26 megabytes read (3.38 kilobytes per second)
21.93 megabytes written (14.10 kilobytes per second)
pm>



UDF new:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
19 seconds total
3 seconds of transactions (666 per second)

Files:
3956 created (208 per second)
Creation alone: 3000 files (230 per second)
Mixed with transactions: 956 files (318 per second)
990 read (330 per second)
1010 appended (336 per second)
3956 deleted (208 per second)
Deletion alone: 2912 files (970 per second)
Mixed with transactions: 1044 files (348 per second)

Data:
5.26 megabytes read (283.66 kilobytes per second)
21.93 megabytes written (1.15 megabytes per second)
 1.8 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.7 18-Jun-2008  reinoud branches: 1.7.2;
Cleanup file access,modification,attribute and birthtime setting of files
and make the modification time when set never older than the creation time.
 1.6 19-May-2008  reinoud branches: 1.6.2;
Implement wide char support for UDF by properly implementing unicode-16 to
UTF-8 like cd9660 and ntfs already do.
 1.5 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.4 05-Mar-2006  christos branches: 1.4.10; 1.4.16; 1.4.66; 1.4.68; 1.4.70; 1.4.72;
remove trailing newlines
 1.3 02-Feb-2006  reinoud branches: 1.3.2; 1.3.4; 1.3.6;
Fix header re-inclusion protection defines to a less generic naming
scheme.
 1.2 02-Feb-2006  reinoud Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.3.6.1 13-Mar-2006  yamt sync with head.
 1.3.4.2 18-Feb-2006  yamt sync with head.
 1.3.4.1 02-Feb-2006  yamt file udf_subr.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.3.2.1 22-Apr-2006  simonb Sync with head.
 1.4.72.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.72.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.70.4 11-Mar-2010  yamt sync with head
 1.4.70.3 18-Jul-2009  yamt sync with head.
 1.4.70.2 04-May-2009  yamt sync with head.
 1.4.70.1 16-May-2008  yamt sync with head.
 1.4.68.2 04-Jun-2008  yamt sync with head
 1.4.68.1 18-May-2008  yamt sync with head.
 1.4.66.3 28-Sep-2008  mjf Sync with HEAD.
 1.4.66.2 29-Jun-2008  mjf Sync with HEAD.
 1.4.66.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.16.2 09-Sep-2006  rpaulo sync with head
 1.4.16.1 05-Mar-2006  rpaulo file udf_subr.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.4.10.2 21-Jun-2006  yamt sync with head.
 1.4.10.1 05-Mar-2006  yamt file udf_subr.h was added on branch yamt-lazymbuf on 2006-06-21 15:09:37 +0000
 1.6.2.4 31-Jul-2008  simonb Sync with head.
 1.6.2.3 28-Jul-2008  simonb Sync with head.
 1.6.2.2 18-Jul-2008  simonb Sync with head.
 1.6.2.1 27-Jun-2008  simonb Sync with head.
 1.7.2.1 19-Oct-2008  haad Sync with HEAD.
 1.12.4.2 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.12.4.1 18-Feb-2009  snj branches: 1.12.4.1.4;
Pull up following revision(s) (requested by reinoud in ticket #447):
sys/fs/udf/udf.h: revision 1.30
sys/fs/udf/udf_readwrite.c: revision 1.10
sys/fs/udf/udf_strat_direct.c: revision 1.8
sys/fs/udf/udf_strat_rmw.c: revision 1.18
sys/fs/udf/udf_strat_sequential.c: revision 1.8
sys/fs/udf/udf_subr.c: revision 1.85
sys/fs/udf/udf_subr.h: revision 1.13
Implement session closure on sequential media when requested on mount. It will
allow CD-ROM/DVD-ROM/DB-ROM drives to read the media while still allowing them
to be appended later. It can also be seen as a way to make mountable
snapshots.
 1.12.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.12.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.13.2.1 23-Jul-2009  jym Sync with HEAD.
 1.17.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.24.1 28-Aug-2013  rmind sync with head
 1.18.20.2 03-Dec-2017  jdolecek update from HEAD
 1.18.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.10.1 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.19.8.1 29-May-2016  skrll Sync with HEAD
 1.20.24.1 17-Jan-2020  ad Sync with head.
 1.20.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.86 25-Aug-2025  reinoud Assert that udf_get_node()/udf_loadvnode() returns a valid root node when it doesn't return an error.
 1.85 03-May-2022  hannken Lock devvp for vinvalbuf().
 1.84 23-Mar-2022  andvar fix few typos for word "previous(ly)" in comments.
 1.83 16-Dec-2021  reinoud Make sysctl udf.verbose dependent on UDF_DEBUG instead of DEBUG
 1.82 16-Sep-2021  andvar fix typos in word "successful".
 1.81 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.80 14-Apr-2020  reinoud branches: 1.80.6;
Move comment related to the sysctl_createv() in SYSCTL_SETUP() from the old
place to the new place too.
 1.79 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.78 16-Mar-2020  pgoyette branches: 1.78.2;
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.77 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.76 24-Jun-2017  hannken branches: 1.76.6; 1.76.10; 1.76.12;
No need to call vflush from failing udf_mount(). If the system nodes
really have to disappear we should change vrele() to vrecycle() here.
 1.75 01-Apr-2017  riastradh branches: 1.75.4; 1.75.6;
KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.74 17-Feb-2017  hannken Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.73 07-Jul-2016  msaitoh branches: 1.73.2; 1.73.4;
KNF. Remove extra spaces. No functional change.
 1.72 29-Jan-2016  christos It is meaningless to check the root node if there was an error.
 1.71 24-Aug-2015  hannken Use vfs_vnode_iterator for udf_do_sync.

- Build rb_tree to get an ordered list of nodes, sync them and
clean the tree.

- Stop abusing mntvnode_lock to serialize udf_do_sync, use new
mutex ump->sync_lock instead.
 1.70 24-Aug-2015  hannken Use vfs_vnode_iterator for udf_unmount_sanity_check.
 1.69 24-Aug-2015  hannken Remove dirtynodes_cv, it is only used for timed waits without any signals.

Replace the cv_timedwait with kpause.
 1.68 06-Apr-2015  hannken Change udf to vcache, keyed on udf_node->loc.loc.
 1.67 16-Apr-2014  maxv branches: 1.67.4;
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.66 23-Mar-2014  hannken branches: 1.66.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.65 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.64 30-Sep-2013  hannken Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
 1.63 13-Mar-2012  elad branches: 1.63.2; 1.63.4;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.62 14-Nov-2011  hannken branches: 1.62.4; 1.62.6; 1.62.10; 1.62.12;
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
 1.61 27-Sep-2011  christos branches: 1.61.2;
- rename UDF_MAX_NAMELEN -> UDF_MAXNAMLEN
- use NAME_MAX instead of MAXNAMLEN
 1.60 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.59 07-Jul-2009  reinoud branches: 1.59.2; 1.59.4;
Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.
 1.58 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.57 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.56 25-Apr-2009  elad Add genfs_can_mount() and use it to prevent some more code duplication of
the security checks when mounting a device (VOP_ACCESS() + kauth(9) call)).

Proposed with no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/20/msg004859.html

The vnode is always expected to be locked, so no locking is done outside
the file-system code.
 1.55 08-Feb-2009  reinoud branches: 1.55.2;
If mounting for read-write dont allow a session number to be specified since
its currently still misbehaving. If supported later, it would allow one or a
series of sessions on a sequential recordable media to be ignored as if they
never were created.

Also fix a small comment: its not the direct but the bootstrap disc strategy
that we close down.
 1.54 16-Dec-2008  reinoud Check for a node being root on node creation so when the root node is disposed
of when working deep into the directory tree it can reliably be reget and
marked correctly as the FS root.

Fixed pwd(1) lock panic and possible endless loop in other tools.
 1.53 16-Dec-2008  pooka The great QUOTA purge of '08: get rid of those #ifdef QUOTA and
#include "opt_quota.h" which do exactly nothing. Speeds up kernel
compilation by 1.375*10^-20001 seconds. But leave the most moxious
comment in msdosfs_vfsops untouched.
 1.52 29-Oct-2008  reinoud branches: 1.52.2;
Fix to prevent a closed sequential media to be opened for read/write.
 1.51 27-Sep-2008  reinoud branches: 1.51.2;
Switch UDF over to the vfs_dirhash.c dirhash code.
 1.50 29-Aug-2008  reinoud Remove all remaining traces of UDF_READWRITE since it has been removed as
option.
 1.49 29-Aug-2008  reinoud forgot to destroy an additional mutex and an condition variable.
 1.48 08-Aug-2008  reinoud Remove the need for the kernel option UDF_READWRITE to be able to write to
discs since writing is mature enough.
 1.47 06-Aug-2008  reinoud Rewrite allocation scheme's determination and implementation replacing the
old somewhat naive selection scheme that didn't allow different allocation
settings for nodes, directory information (FIDs) and data.

Also fix some curious side-effects of atime updates on RMW devices.
 1.46 28-Jul-2008  reinoud Streamline allocation to prepare it for metadata partition. Also add
preliminary Metadata partition write support but its disabled still since
its not finished yet and not functioning correctly. All other formats are
checked and should work fine.
 1.45 27-Jul-2008  reinoud Unify naming scheme and source code beautify for better readablility.
 1.44 26-Jul-2008  reinoud Forgot to rename those two references to write_space_bitmap too.
 1.43 22-Jul-2008  reinoud Limit the UDF dirhash to a configurable amount of memory. The performance
penalty even with a limited dirhash of 128kb is acceptable but it should be
set by machine memory size though.
 1.42 19-Jul-2008  reinoud Limit sectorsize to max. 4096 bytes. This prevents a panic when declaring
the node pool since standard pools are limited upto 4096 aparently.
Pagesize limit even?
 1.41 18-Jul-2008  reinoud Instead of bombing out when trying to mount a disc RW when UDF_READWRITE is
not defined, downgrade it to a read-only mount.
 1.40 17-Jul-2008  reinoud Implement directory hashing to speed up directory traversals. Speed
improvements of at least 4 times in untarring and roughly 100 to 500 times
on file creation in big directories. Lookup of files was O(n*n) and is now
O(1) even for file creation. Free spaces in the directory are kept in a
seperate list for fast file creation.

The postmark benchmark gives:

UDF old:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
1593 seconds total
681 seconds of transactions (2 per second)

Files:
3956 created (2 per second)
Creation alone: 3000 files (4 per second)
Mixed with transactions: 956 files (1 per second)
990 read (1 per second)
1010 appended (1 per second)
3956 deleted (2 per second)
Deletion alone: 2912 files (9 per second)
Mixed with transactions: 1044 files (1 per second)

Data:
5.26 megabytes read (3.38 kilobytes per second)
21.93 megabytes written (14.10 kilobytes per second)
pm>



UDF new:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
19 seconds total
3 seconds of transactions (666 per second)

Files:
3956 created (208 per second)
Creation alone: 3000 files (230 per second)
Mixed with transactions: 956 files (318 per second)
990 read (330 per second)
1010 appended (336 per second)
3956 deleted (208 per second)
Deletion alone: 2912 files (970 per second)
Mixed with transactions: 1044 files (348 per second)

Data:
5.26 megabytes read (283.66 kilobytes per second)
21.93 megabytes written (1.15 megabytes per second)
 1.39 28-Jun-2008  rumble branches: 1.39.2;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.38 14-May-2008  reinoud branches: 1.38.2;
Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.37 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.36 29-Apr-2008  ad branches: 1.36.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.35 28-Jan-2008  dholland branches: 1.35.6; 1.35.8; 1.35.10;
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.34 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.33 11-Dec-2007  lukem use __KERNEL_RCSID() instead of __RCSID()
 1.32 08-Dec-2007  pooka branches: 1.32.2; 1.32.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.31 26-Nov-2007  pooka branches: 1.31.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.30 10-Oct-2007  ad branches: 1.30.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.29 31-Jul-2007  pooka branches: 1.29.2; 1.29.4; 1.29.6; 1.29.8;
* 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.28 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.27 17-Jul-2007  pooka branches: 1.27.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.26 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.25 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.24 29-Apr-2007  msaitoh fix typos
 1.23 12-Mar-2007  ad branches: 1.23.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.22 29-Jan-2007  hubertf branches: 1.22.2; 1.22.6;
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.21 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.20 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.19 04-Jan-2007  reinoud Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.18 16-Nov-2006  christos branches: 1.18.2;
__unused removal on arguments; approved by core.
 1.17 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.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 03-Oct-2006  reinoud Fix memory leaks on mounting and dismounting UDF volumes.
 1.14 29-Sep-2006  reinoud Add `vfs.udf.verbose' sysctl when running a DEBUG kernel to dynamically set
the udf_verbose variable. So when something goes wrong, it can be examined
on the spot without needing to reboot a new kernel and possibly loosing
state.
 1.13 05-Sep-2006  reinoud branches: 1.13.2; 1.13.4; 1.13.6;
Fix locking scheme in udf_mount() to follow more the other filingsystems.

For yet unknown reasons passing the LOCKLEAF flag to namei() did return a
locked vnode as was meant but would panic when a raw device was passed.
 1.12 03-Sep-2006  christos add missing initializers
 1.11 22-Aug-2006  reinoud Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.10 21-Aug-2006  reinoud Fix spurious panic when twice remounting a bad filingsystem. It then gets
the same memory block allocated as before and it bombs out on its
descriptor pool allready being initialised. It turns out that the pool was
not allways destroyed. This fix ought to clean it up whatever the cause of
the mishap that results in a reject.
 1.9 10-Aug-2006  reinoud Fix panic on badly or curruptly formatted discs due to an oddity in the
error handling chain.

If NetBSD 4.0 is allready branched at this time this ought to be pulled up.
 1.8 23-Jul-2006  ad branches: 1.8.2;
Use the LWP cached credentials where sane.
 1.7 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.6 12-Jun-2006  christos branches: 1.6.2; 1.6.4;
remove ; from };
 1.5 15-May-2006  christos branches: 1.5.2;
kauth fallout
 1.4 14-May-2006  elad integrate kauth.
 1.3 25-Apr-2006  snj s/allready/already/
 1.2 02-Feb-2006  reinoud branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10;
Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.2.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.8.2 11-May-2006  elad sync with head
 1.2.8.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.2.6.5 14-Sep-2006  yamt sync with head.
 1.2.6.4 03-Sep-2006  yamt sync with head.
 1.2.6.3 11-Aug-2006  yamt sync with head
 1.2.6.2 26-Jun-2006  yamt sync with head.
 1.2.6.1 24-May-2006  yamt sync with head.
 1.2.4.2 18-Feb-2006  yamt sync with head.
 1.2.4.1 02-Feb-2006  yamt file udf_vfsops.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.2.2.1 01-Jun-2006  kardel Sync with head.
 1.5.2.1 19-Jun-2006  chap Sync with head.
 1.6.4.9 04-Feb-2008  yamt sync with head.
 1.6.4.8 21-Jan-2008  yamt sync with head
 1.6.4.7 07-Dec-2007  yamt sync with head
 1.6.4.6 27-Oct-2007  yamt sync with head.
 1.6.4.5 03-Sep-2007  yamt sync with head.
 1.6.4.4 26-Feb-2007  yamt sync with head.
 1.6.4.3 30-Dec-2006  yamt sync with head.
 1.6.4.2 21-Jun-2006  yamt sync with head.
 1.6.4.1 12-Jun-2006  yamt file udf_vfsops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:37 +0000
 1.6.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.8.2.4 08-Sep-2006  rpaulo Pull up following revision(s) (requested by reinoud in ticket #125):
sys/fs/udf/udf_subr.c: revision 1.15
sys/fs/udf/udf_vfsops.c: revision 1.13
sys/fs/udf/ecma167-udf.h: revision 1.4
Add shortcut for struct long_ad 's Unique ID hint that covers the lower 32
bits of the targeted files 64 bits Unique ID for recovery purposes.
Fix locking scheme in udf_mount() to follow more the other filingsystems.
For yet unknown reasons passing the LOCKLEAF flag to namei() did return a
locked vnode as was meant but would panic when a raw device was passed.
Fix copying too much space from a small buffer. The chances of it actually
happening are small but corrupt media could trigger it.
 1.8.2.3 27-Aug-2006  riz Pull up following revision(s) (requested by reinoud in ticket #50):
sys/fs/udf/udf_subr.c: revision 1.14
sys/fs/udf/udf.h: revision 1.6
sys/fs/udf/udf_vfsops.c: revision 1.11
Fix pool allocation/freeing problem for once and for all correctly. Since
it was initialised quite late due to its reliance on disc data the mount
process could have stopped before initialising and thus could panic again
only now for uninitialising an not initialised pool! *sigh*
 1.8.2.2 23-Aug-2006  tron Pull up following revision(s) (requested by reinoud in ticket #45):
sys/fs/udf/udf_vfsops.c: revision 1.10
Fix spurious panic when twice remounting a bad filingsystem. It then gets
the same memory block allocated as before and it bombs out on its
descriptor pool allready being initialised. It turns out that the pool was
not allways destroyed. This fix ought to clean it up whatever the cause of
the mishap that results in a reject.
 1.8.2.1 12-Aug-2006  riz Pull up following revision(s) (requested by reinoud in ticket #12):
sys/fs/udf/udf_vfsops.c: revision 1.9
sys/dev/scsipi/cd.c: revision 1.243
Fix panic on badly or curruptly formatted discs due to an oddity in the
error handling chain.
If NetBSD 4.0 is allready branched at this time this ought to be pulled up.
Fix incorrect `last possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.
 1.13.6.2 10-Dec-2006  yamt sync with head.
 1.13.6.1 22-Oct-2006  yamt sync with head
 1.13.4.2 09-Sep-2006  rpaulo sync with head
 1.13.4.1 05-Sep-2006  rpaulo file udf_vfsops.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.13.2.3 01-Feb-2007  ad Sync with head.
 1.13.2.2 12-Jan-2007  ad Sync with head.
 1.13.2.1 18-Nov-2006  ad Sync with head.
 1.18.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #332):
sys/fs/udf/udf_subr.c: revision 1.26
sys/fs/udf/udf.h: revision 1.9
sys/fs/udf/udf_vfsops.c: revision 1.19
Implement read-only access to UDF 2.50 and UDF 2.60 discs that use metadata
partition mappings. This brings the NetBSD implementation to read all discs
upto date and will read all discs currently defined by OSTA.
 1.22.6.7 20-Aug-2007  ad Sync with HEAD.
 1.22.6.6 15-Jul-2007  ad Sync with head.
 1.22.6.5 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.22.6.4 09-Jun-2007  ad Sync with head.
 1.22.6.3 08-Jun-2007  ad Sync with head.
 1.22.6.2 05-Apr-2007  ad Compile fixes.
 1.22.6.1 13-Mar-2007  ad Sync with head.
 1.22.2.2 07-May-2007  yamt sync with head.
 1.22.2.1 24-Mar-2007  yamt sync with head.
 1.23.2.1 11-Jul-2007  mjf Sync with head.
 1.27.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.29.8.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.29.8.1 31-Jul-2007  pooka file udf_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:20 +0000
 1.29.6.1 14-Oct-2007  yamt sync with head.
 1.29.4.3 23-Mar-2008  matt sync with HEAD
 1.29.4.2 09-Jan-2008  matt sync with HEAD
 1.29.4.1 06-Nov-2007  matt sync with HEAD
 1.29.2.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.29.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.29.2.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.30.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.30.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.30.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.31.2.1 26-Dec-2007  ad Sync with head.
 1.32.4.1 13-Dec-2007  bouyer Sync with HEAD
 1.32.2.1 11-Dec-2007  yamt sync with head.
 1.35.10.4 11-Aug-2010  yamt sync with head.
 1.35.10.3 18-Jul-2009  yamt sync with head.
 1.35.10.2 04-May-2009  yamt sync with head.
 1.35.10.1 16-May-2008  yamt sync with head.
 1.35.8.1 18-May-2008  yamt sync with head.
 1.35.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.35.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.35.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.35.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.35.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.36.2.3 10-Oct-2008  skrll Sync with HEAD.
 1.36.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.38.2.5 31-Jul-2008  simonb Sync with head.
 1.38.2.4 28-Jul-2008  simonb Sync with head.
 1.38.2.3 22-Jul-2008  simonb Sync with head.
 1.38.2.2 18-Jul-2008  simonb Sync with head.
 1.38.2.1 03-Jul-2008  simonb Sync with head.
 1.39.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.39.2.1 19-Oct-2008  haad Sync with HEAD.
 1.51.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.51.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.51.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.52.2.4 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.52.2.3 09-Jul-2009  snj branches: 1.52.2.3.2; 1.52.2.3.6;
Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.52.2.2 18-Feb-2009  snj branches: 1.52.2.2.4;
Pull up following revision(s) (requested by reinoud in ticket #446):
sys/fs/udf/udf_vfsops.c: revision 1.55
If mounting for read-write dont allow a session number to be specified since
its currently still misbehaving. If supported later, it would allow one or a
series of sessions on a sequential recordable media to be ignored as if they
never were created.
Also fix a small comment: its not the direct but the bootstrap disc strategy
that we close down.
 1.52.2.1 18-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #192):
sys/fs/udf/udf_subr.c: revision 1.79
sys/fs/udf/udf_vfsops.c: revision 1.54
Check for a node being root on node creation so when the root node is disposed
of when working deep into the directory tree it can reliably be reget and
marked correctly as the FS root.
Fixed pwd(1) lock panic and possible endless loop in other tools.
 1.52.2.3.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.52.2.3.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.52.2.2.4.1 21-Apr-2010  matt sync to netbsd-5
 1.55.2.2 23-Jul-2009  jym Sync with HEAD.
 1.55.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.59.4.1 03-Jul-2010  rmind sync with head
 1.59.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.61.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.61.2.1 17-Apr-2012  yamt sync with head
 1.62.12.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.62.10.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.62.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.62.4.1 05-Apr-2012  mrg sync to latest -current.
 1.63.4.1 18-May-2014  rmind sync with head
 1.63.2.2 03-Dec-2017  jdolecek update from HEAD
 1.63.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.66.2.1 10-Aug-2014  tls Rebase.
 1.67.4.4 28-Aug-2017  skrll Sync with HEAD
 1.67.4.3 19-Mar-2016  skrll Sync with HEAD
 1.67.4.2 22-Sep-2015  skrll Sync with HEAD
 1.67.4.1 06-Apr-2015  skrll Sync with HEAD
 1.73.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.73.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.73.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.73.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.75.6.1 01-Jul-2017  snj Pull up following revision(s) (requested by hannken in ticket #75):
sys/fs/udf/udf_vfsops.c: revision 1.76
No need to call vflush from failing udf_mount(). If the system nodes
really have to disappear we should change vrele() to vrecycle() here.
 1.75.4.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.76.12.1 17-Jan-2020  ad Sync with head.
 1.76.10.1 13-Mar-2022  martin Pull up following revision(s), all via patch,
requested by reinoud in ticket #1432:

sys/fs/udf/udf_vfsops.c: revision 1.83
sys/fs/udf/udf_allocation.c: revision 1.45
sys/fs/udf/udf_subr.c: revision 1.160
sys/fs/udf/udf_subr.c: revision 1.161

While searching the VAT on recordable media, search the last sector too!
This fixes Win10 formatted discs from being mounted incorrectly.

Make sysctl udf.verbose dependent on UDF_DEBUG instead of DEBUG

Fix serious issue with recordable media formatted with Win10. When closing it
after modification the VAT was written out corrupted making the disc
unreadable anymore on remount. Thanks for ig@ for spotting it in the wild!

On freeing a virtual address in the VAT, use the correct value; this might
confuse other implementations who can reject the VAT on this.
 1.76.6.2 21-Apr-2020  martin Sync with HEAD
 1.76.6.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.78.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.80.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.127 27-Jun-2023  reinoud Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
 1.126 28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.125 03-May-2022  andvar fix various typos, mainly s/trasfering/transferring/ and s/theese/these/.
 1.124 03-May-2022  hannken No IO_NODELOCKED for unlocked vnode.
 1.123 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.122 01-Apr-2022  reinoud Fix malformed DPRINTF() macro
 1.121 30-Mar-2022  christos Fix locking in udf_link(). XXX: udf_symlink is prolly similarly broken.
 1.120 27-Mar-2022  christos add a kauth vnode check for creating links
 1.119 16-Feb-2022  andvar fix various typos, mainly in comments.
 1.118 06-Feb-2022  andvar fix various typos in comments, log messages and documentation.
mainly s/aparently/apparently/ and s/implmented/implemented/.
 1.117 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.116 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.115 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.114 27-Jun-2020  christos branches: 1.114.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.113 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.112 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.111 14-Apr-2020  reinoud fix debug print flag
 1.110 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.109 23-Feb-2020  ad branches: 1.109.4;
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.108 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.107 27-Dec-2019  msaitoh branches: 1.107.2;
s/transfered/transferred/
 1.106 26-May-2017  riastradh branches: 1.106.10;
Eliminate crusty debugging sludge.

We have a mostly sane vnode lifecycle now. If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
 1.105 26-May-2017  riastradh 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.104 26-Apr-2017  riastradh 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.103 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.102 20-Aug-2016  hannken branches: 1.102.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.101 20-Apr-2015  riastradh branches: 1.101.2;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.100 06-Apr-2015  hannken Change udf to vcache, keyed on udf_node->loc.loc.
 1.99 06-Apr-2015  hannken Move the removal of unlinked nodes from udf_inactive() to udf_reclaim().
 1.98 04-Apr-2015  riastradh Fix remaining read(fd, NULL, 1) cases.
 1.97 28-Jan-2015  martin When udf_symlink() fails, do not explicitly call udf_delete_node(), as
vrele() called next will do that again - avoids a double free of the
bitmap, leading to a KASSERT failure (or worse in real life) in the
udf_symlink_long in the fs/vfs::t_vnops test.
 1.96 04-Jan-2015  reinoud Add missing vrele() as found by the testsuite.

Thanks Jurgen Hannken for the patch.
 1.95 03-Dec-2014  reinoud Explicitly delete the failing node; it would be killed with the unlink too but
explicitly deleting it is better than just setting the file size to zero.
 1.94 29-Jul-2014  reinoud branches: 1.94.4;
Posix requires the va_size of a symlink to be pathlength for symbolic links.
This fixes yet another atf case.
 1.93 29-Jul-2014  reinoud Access time should only be set on accessing the data or messing with the
contents, not on inode access rights and ownership changes. Should address
PR kern/49033 for UDF.

Test results now come clean for bugs related to this issue in the ATF.
 1.92 25-Jul-2014  dholland 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.91 23-Mar-2014  christos branches: 1.91.2;
fix unused
 1.90 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.89 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.88 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.87 18-Oct-2013  christos fix unused variable warnings
 1.86 04-Oct-2013  hannken Remove a bogus vrecycle() from udf_inactive(). Vrecycle() works on inactive
vnodes while VOP_INACTIVE() should never be called on an inactive vnode.

Ok: Reinoud Zandijk <reinoud@netbsd.org>
 1.85 10-Jul-2013  reinoud Implement udf_rename() using the new genfs_rename() framework.

Fixes PR kern/47986
 1.84 08-Jul-2013  reinoud Clarify the sticky-bit check
 1.83 07-Jul-2013  reinoud Pull forward the node creation returned from the lookup call. Its vnode is
used in the access determination on delete/rename of TXT files.

Thanks for joerg@ and clang for detecting this!
 1.82 07-Jul-2013  reinoud Implement a real empty-directory checking for rmdir().

Should should fix the other part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_notempty
 1.81 05-Jul-2013  reinoud Fixes chflags. They were silently rejected before but the VFS standard demands
it complains with EOPNOTSUPP.

Fixes chflags test case.
 1.80 05-Jul-2013  reinoud Provide additional checks to udf_lookup and restructure it a bit.

Should fix PR 47988
 1.79 03-Jul-2013  reinoud Remove spurious empty line
 1.78 03-Jul-2013  reinoud On removing a directory make sure the leaf directory doesn't have a valid '..'
link anymore. In a corner case this leaf can be held by a process as a CWD. It
is guaranteed to be empty at this stage so we trunc it removing the only valid
FID, being the '..' entry.

Solves part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_rmdirdotdot
 1.77 03-Jul-2013  reinoud Typo in debug message: we are removing a directory and not a file.
 1.76 27-Jun-2013  reinoud branches: 1.76.2;
Since UDF volumes are always mounted async, the simple UBC purging with
VOP_PUTPAGES() was never triggered resulting in far too much data in the UBC
that needed to be written out. This could result in instability on small
memory machines.
 1.75 18-Mar-2013  plunky C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.74 05-Nov-2012  dholland Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.73 05-Nov-2012  dholland 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.72 22-Jul-2012  rmind branches: 1.72.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.71 29-Apr-2012  chs change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.70 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.69 18-Nov-2011  christos branches: 1.69.4; 1.69.6;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.68 18-Oct-2011  hannken branches: 1.68.2;
VOP_GETATTR() needs a shared lock at least.

While here fix a typo (fvp -> tvp).
 1.67 27-Sep-2011  christos return UDF_MAXNAMLEN instead of NAME_MAX
 1.66 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.65 19-May-2011  rmind branches: 1.65.2;
Remove cache_purge(9) calls from reclamation routines in the file systems,
as vclean(9) performs it for us since Lite2 merge.
 1.64 26-Apr-2011  hannken Change vflushbuf() to return an error if a synchronous write fails.

Welcome to 5.99.51.
 1.63 24-Apr-2011  rmind sys_link: prevent hard links on directories (cross-mount operations are
already prevented). File systems are no longer responsible to check this.
Clean up and add asserts (note that dvp == vp cannot happen in vop_link).

OK dholland@
 1.62 02-Jan-2011  dholland branches: 1.62.2;
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.61 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.60 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.59 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.58 24-Jun-2010  hannken Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.
 1.57 08-Jan-2010  pooka branches: 1.57.2; 1.57.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.56 05-Jan-2010  mbalmer Remove extra semicolons.
 1.55 14-Sep-2009  reinoud Rework simplistic UBC flushing. Recent changes to genfs made the old flush
system generate heaps of odd allocations since the end of write request was
overwritten by the start of the second resulting in another relocation.

Also added a full flush of the file on a VOP_CLOSE(). This automatically
flushes file tails to disc.
 1.54 30-Jul-2009  reinoud Fix uid/gid check; it was checking if the old values would fit in 32 bits
instead of checking if the new values would.
 1.53 27-Jul-2009  reinoud System nodes are not written out on becomming inactive; they should be written
out before automatically.

However, when dealing with faulty discs that fail to mount, system nodes are
of course not written out and thus may still be marked dirty, if only due to
access. Especially on sequential media this gave rise to panics on reading
trackinfo since the write track section had not yet been initialised.
 1.52 08-Jul-2009  reinoud Since OSTA has not defined a good set of flags to cover our flags, its not
usefull to implement chflags(). Instead ignore it for now since the error
codes might confuse esp. gui's.
 1.51 07-Jul-2009  reinoud Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.
 1.50 06-Jul-2009  reinoud Make source prettier
 1.49 03-Jul-2009  pgoyette Pass the vp arg to udf_check_possible() so we can access its v_mount
member.

XXX No idea if this is the right solution to this problem, but it does
XXX at least allow thebuild to continue. The original committed should
XXX verify that this does what was intended!

(Hello again, Elad)
 1.48 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.47 25-Jun-2009  reinoud Rewrite of udf_on_rootpath(), and vop_rename() code that calls it, after the
UFS way. The tree walking is now done the same and the code hasn't locked up
on examples that made it lockup before.
 1.46 24-Jun-2009  reinoud Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.
 1.45 23-Jun-2009  reinoud Renaming in UDF was already possible but directories could only be renamed in
the same directory.

This patch finally allows a directory to be moved between parent directories.
 1.44 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.43 18-Jun-2009  reinoud Add overlooked `cred' declaration in udf_write() when i committed the catchup
patches.
 1.42 18-Jun-2009  reinoud Pass-on credentials to size reversal on aborted write due to error. It could
be that in the future this credentials need to be changed to allways-allow
since its an reverting-on-error behaviour.
 1.41 07-May-2009  elad Extract the open-coded authorization logic for chtimes() from various
file-systems and put it in a single function, genfs_can_chtimes().

This also makes UDF follow the same policy as all other file-systems.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004951.html
 1.40 22-Apr-2009  elad Per discussion on tech-kern@:

- Replace use of label/goto with returns

- Rename, change prototype of, and move functions from vfs_subr.c to
genfs_vnops.c
 1.39 20-Apr-2009  elad Refactor some duplicated file-system code.

Proposed and received no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
 1.38 20-Mar-2009  reinoud Fix panic due to memory leak on symlink creation. A test copy with 3000+
symlinks could get the machine down.
 1.37 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.36 11-Feb-2009  reinoud Improve write throttling by doing it on page-size basis. The `standard'
solution would cut up files unnessisary during allocation. It also made
assumptions about ucb wich were propably right but still.
 1.35 10-Feb-2009  reinoud Add simplistic UBC async flushing as other FS's seem to do. Its a clutch and
needs to be addressed in UBC properly.
 1.34 16-Dec-2008  reinoud branches: 1.34.2;
Fix endless loop occuring on empty directories listing on 512 bytes/sector
media like harddiscs. Also provide provide a `safety net' on readdir so it
will signal EOF when its requested an entry outside the directory.
 1.33 16-Dec-2008  reinoud Elaborate SYNC debug messages and rename some debug messages to a more
proper category.
 1.32 01-Dec-2008  reinoud Split uid/gid remapping code to be independent of eachother.
 1.31 26-Nov-2008  pooka Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.
 1.30 17-Jul-2008  reinoud branches: 1.30.2; 1.30.4;
Implement directory hashing to speed up directory traversals. Speed
improvements of at least 4 times in untarring and roughly 100 to 500 times
on file creation in big directories. Lookup of files was O(n*n) and is now
O(1) even for file creation. Free spaces in the directory are kept in a
seperate list for fast file creation.

The postmark benchmark gives:

UDF old:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
1593 seconds total
681 seconds of transactions (2 per second)

Files:
3956 created (2 per second)
Creation alone: 3000 files (4 per second)
Mixed with transactions: 956 files (1 per second)
990 read (1 per second)
1010 appended (1 per second)
3956 deleted (2 per second)
Deletion alone: 2912 files (9 per second)
Mixed with transactions: 1044 files (1 per second)

Data:
5.26 megabytes read (3.38 kilobytes per second)
21.93 megabytes written (14.10 kilobytes per second)
pm>



UDF new:
pm>set transactions 2000
pm>set number 3000
pm>run
Creating files...Done
Performing transactions..........Done
Deleting files...Done
Time:
19 seconds total
3 seconds of transactions (666 per second)

Files:
3956 created (208 per second)
Creation alone: 3000 files (230 per second)
Mixed with transactions: 956 files (318 per second)
990 read (330 per second)
1010 appended (336 per second)
3956 deleted (208 per second)
Deletion alone: 2912 files (970 per second)
Mixed with transactions: 1044 files (348 per second)

Data:
5.26 megabytes read (283.66 kilobytes per second)
21.93 megabytes written (1.15 megabytes per second)
 1.29 17-Jul-2008  reinoud Since the rename logic now locks its source directory too, we ought to
unlock the source directory again on exit. The stub that doesn't allow
cross directory renames for now jumped to the wrong exit point and thus
left a locked directory node that paniced on next locking.
 1.28 15-Jul-2008  reinoud Keep the directory to read '..' from locked until its dirent is read and
its location is extracted.

Also lock the source directory so its contents can safely be changed...
patch from tmpfs.
 1.27 10-Jul-2008  reinoud Fix chtimes permission checking. This sanitised version is hopefully DTRT.
 1.26 10-Jul-2008  reinoud Allow the renaming of directories *within* their current directory. No
cross-directory renaming is allowed yet.
 1.25 10-Jul-2008  reinoud Clarifying comments
 1.24 07-Jul-2008  reinoud Support for allocation extents descriptor writing to allow for arbitrary
heavily fragmented files.

Also fixing some (rare) allocation bugs and function name streamlining.

Tested on harddisc, CD-RW and CD-R i.e. all three basic backend classes.
 1.23 24-Jun-2008  reinoud branches: 1.23.2;
Make readsymlink bug-tolerant to MacOS X symlink construction bug. It puts
the name ".." on a parent path component. To prevent other similar errors,
name length checking is not done but the passed name that shouldn't be
passed is ignored.
 1.22 24-Jun-2008  reinoud We are not allowed zero length names in softlinks.
 1.21 24-Jun-2008  reinoud Support the creation of extended attributes for file creation in the
kernel and check and update them when found.

Note that it won't *insert* an extended attribute yet if it hasn't found it
while updating the birthtime.
 1.20 18-Jun-2008  reinoud Cleanup file access,modification,attribute and birthtime setting of files
and make the modification time when set never older than the creation time.
 1.19 19-May-2008  reinoud branches: 1.19.2;
Implement wide char support for UDF by properly implementing unicode-16 to
UTF-8 like cd9660 and ntfs already do.
 1.18 14-May-2008  reinoud Import writing part of the UDF file system making optical media like CD's
and DVD's behave like floppy discs. Writing is supported upto and including
version 2.01; version 2.50 and 2.60 will follow.

Also extending the UDF implementation to support symbolic links and
hardlinks.

Added are the mmcformat(8) tool to format rewritable CD/DVD discs and
newfs_udf(8).

Limitations:
all operations can be performed on the file system though the
sheduling is currently optimised for archiving workloads.

mv(1)/rename(2) is currently only implemented for non-directories.
 1.17 25-Jan-2008  ad branches: 1.17.6; 1.17.8; 1.17.10; 1.17.12;
Remove VOP_LEASE. Discussed on tech-kern.
 1.16 17-Jan-2008  ad Fix dodgy tests of v_usecount.
 1.15 02-Jan-2008  ad Merge vmlocking2 to head.
 1.14 11-Dec-2007  lukem use __KERNEL_RCSID() instead of __RCSID()
 1.13 26-Nov-2007  pooka branches: 1.13.2; 1.13.4; 1.13.6;
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.12 08-Oct-2007  ad branches: 1.12.4;
Merge from vmlocking: fix dodgy use of VOP_ISLOCKED().
 1.11 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.10 29-Apr-2007  msaitoh branches: 1.10.6; 1.10.8; 1.10.10;
fix typos
 1.9 04-Jan-2007  reinoud branches: 1.9.2; 1.9.6; 1.9.8;
Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
 1.8 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.7 12-Oct-2006  christos branches: 1.7.2;
- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.6 12-Jun-2006  christos branches: 1.6.4; 1.6.8; 1.6.10; 1.6.12;
remove ; from };
 1.5 14-May-2006  elad branches: 1.5.2;
integrate kauth.
 1.4 11-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.

XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
 1.3 25-Apr-2006  snj s/allready/already/
 1.2 02-Feb-2006  reinoud branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10;
Fix $NetBSD$ tags. (sorry)
 1.1 02-Feb-2006  reinoud Initial import of a UDF file system implementation for NetBSD.

The code supports read access to all media types that CD/DVD type drives
can recognize including DVD-RAM and BD- drives as well as harddisc partions
and vnd devices. UDF versions upto the latest 2.60 are to be supported
though due to lack of test media version 2.50 and 2.60 are not implemented
yet though easy to add. Both open and closed media are supported.

Write access is planned and in preparation. To facilitate this some hooks
are present in the code that are not strictly needed in a read-only
implementation but which allow writing to be added more easily.

Implemented and tested media types are CD-ROM, CD-R, CD-RW, CD-MRW,
DVD-ROM, DVD*R, DVD*RW, DVD+MRW but the same code can also read DVD-RAM,
HD-DVD and BluRay discs. Also vnd devices have been tested with several
sector sizes.

Discs created and written by UDFclient, Nero's InCD and Roxio's
DirectCD/Drag2Disc read fine.
 1.2.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.8.2 11-May-2006  elad sync with head
 1.2.8.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.2.6.2 26-Jun-2006  yamt sync with head.
 1.2.6.1 24-May-2006  yamt sync with head.
 1.2.4.2 18-Feb-2006  yamt sync with head.
 1.2.4.1 02-Feb-2006  yamt file udf_vnops.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:18 +0000
 1.2.2.1 01-Jun-2006  kardel Sync with head.
 1.5.2.1 19-Jun-2006  chap Sync with head.
 1.6.12.2 10-Dec-2006  yamt sync with head.
 1.6.12.1 22-Oct-2006  yamt sync with head
 1.6.10.2 09-Sep-2006  rpaulo sync with head
 1.6.10.1 12-Jun-2006  rpaulo file udf_vnops.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:06 +0000
 1.6.8.2 12-Jan-2007  ad Sync with head.
 1.6.8.1 18-Nov-2006  ad Sync with head.
 1.6.4.9 04-Feb-2008  yamt sync with head.
 1.6.4.8 21-Jan-2008  yamt sync with head
 1.6.4.7 07-Dec-2007  yamt sync with head
 1.6.4.6 27-Oct-2007  yamt sync with head.
 1.6.4.5 03-Sep-2007  yamt sync with head.
 1.6.4.4 26-Feb-2007  yamt sync with head.
 1.6.4.3 30-Dec-2006  yamt sync with head.
 1.6.4.2 21-Jun-2006  yamt sync with head.
 1.6.4.1 12-Jun-2006  yamt file udf_vnops.c was added on branch yamt-lazymbuf on 2006-06-21 15:09:37 +0000
 1.7.2.2 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.7.2.1 04-Jan-2007  bouyer Pull up following revision(s) (requested by reinoud in ticket #333):
sys/fs/udf/udf_subr.c: revision 1.27-1.29
sys/fs/udf/udf_vnops.c: revision 1.9
sys/fs/udf/ecma167-udf.h: revision 1.6
Fix compilation issue when specifying different flags or compiling with a
different compiler. Thanks to Jared for noting.
Add UDF_ICB_FILETYPE_REALTIME type as found on UDF 2.50 discs. Also revert
a multiplication order to enforce 64 bit math.
Forgot one place for UDF_ICB_FILETYPE_RANDOMACCESS.
 1.9.8.1 11-Jul-2007  mjf Sync with head.
 1.9.6.4 09-Oct-2007  ad Sync with head.
 1.9.6.3 22-Aug-2007  ad Fix dodgy use of VOP_ISLOCKED().
 1.9.6.2 08-Jun-2007  ad Sync with head.
 1.9.6.1 05-Apr-2007  ad Compile fixes.
 1.9.2.1 07-May-2007  yamt sync with head.
 1.10.10.2 14-Oct-2007  yamt sync with head.
 1.10.10.1 06-Oct-2007  yamt sync with head.
 1.10.8.3 23-Mar-2008  matt sync with HEAD
 1.10.8.2 09-Jan-2008  matt sync with HEAD
 1.10.8.1 06-Nov-2007  matt sync with HEAD
 1.10.6.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.6.2 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.10.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.12.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.12.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.12.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.13.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.13.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.13.4.1 11-Dec-2007  yamt sync with head.
 1.13.2.2 26-Dec-2007  ad Sync with head.
 1.13.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.17.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.17.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.10.8 11-Aug-2010  yamt sync with head.
 1.17.10.7 11-Mar-2010  yamt sync with head
 1.17.10.6 16-Sep-2009  yamt sync with head
 1.17.10.5 19-Aug-2009  yamt sync with head.
 1.17.10.4 18-Jul-2009  yamt sync with head.
 1.17.10.3 16-May-2009  yamt sync with head
 1.17.10.2 04-May-2009  yamt sync with head.
 1.17.10.1 16-May-2008  yamt sync with head.
 1.17.8.2 04-Jun-2008  yamt sync with head
 1.17.8.1 18-May-2008  yamt sync with head.
 1.17.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.17.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.17.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.2.2 18-Jul-2008  simonb Sync with head.
 1.19.2.1 27-Jun-2008  simonb Sync with head.
 1.23.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.2.1 19-Oct-2008  haad Sync with HEAD.
 1.30.4.8 26-Sep-2009  snj Apply patch (requested by reinoud in ticket #959):
UDF's flushing algorithm was susceptible to interference with genfs.
This patch fixes that and also ensures that there aren't tails around
being allocated later.
 1.30.4.7 09-Jul-2009  snj Apply patch (requested by reinoud in ticket #852):
Numerous UDF improvements:
- a much saner rmw backend
- free space management done right
- the high system time usage when encountering huge numbers of nodes
are a thing of the past due to refactoring
- various small fixes
 1.30.4.6 24-Mar-2009  snj branches: 1.30.4.6.4;
Pull up following revision(s) (requested by reinoud in ticket #592):
sys/fs/udf/udf_vnops.c: revision 1.38
Fix panic due to memory leak on symlink creation. A test copy with 3000+
symlinks could get the machine down.
 1.30.4.5 18-Mar-2009  snj Apply patch (requested by reinoud in ticket #585):
Fix build by bringing in part of 1.35 that was left out.
 1.30.4.4 18-Mar-2009  snj Apply patch (requested by reinoud in ticket #569):
Remove dead code and double check if it's allowed to write out
non-sequential there.
--
Sequential writing goes before normal write. Its not likely to ever go
wrong but there could be a race otherwise.
--
Add simplistic UBC async flushing as other FS's seem to do. Its a clutch
and needs to be addressed in UBC properly.
Improve write throttling by doing it on page-size basis. The `standard'
solution would cut up files unnessisary during allocation. It also made
assumptions about ucb wich were propably right but still.
 1.30.4.3 18-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #192):
sys/fs/udf/udf_vnops.c: revision 1.34
Fix endless loop occuring on empty directories listing on 512 bytes/sector
media like harddiscs. Also provide provide a `safety net' on readdir so it
will signal EOF when its requested an entry outside the directory.
 1.30.4.2 18-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #192):
sys/fs/udf/udf_subr.c: revision 1.77
sys/fs/udf/udf_vnops.c: revision 1.33
Elaborate SYNC debug messages and rename some debug messages to a more
proper category.
 1.30.4.1 06-Dec-2008  snj Pull up following revision(s) (requested by reinoud in ticket #167):
sys/fs/udf/udf_subr.c: revision 1.76
sys/fs/udf/udf_vnops.c: revision 1.32
Split uid/gid remapping code to be independent of eachother.
 1.30.4.6.4.1 21-Apr-2010  matt sync to netbsd-5
 1.30.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.30.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.30.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.2.2 23-Jul-2009  jym Sync with HEAD.
 1.34.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.4.4 31-May-2011  rmind sync with head
 1.57.4.3 05-Mar-2011  rmind sync with head
 1.57.4.2 03-Jul-2010  rmind sync with head
 1.57.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.57.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.62.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.65.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.68.2.5 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.68.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.68.2.3 30-Oct-2012  yamt sync with head
 1.68.2.2 23-May-2012  yamt sync with head.
 1.68.2.1 17-Apr-2012  yamt sync with head
 1.69.6.2 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.69.6.1 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.69.4.2 02-Jun-2012  mrg sync to latest -current.
 1.69.4.1 05-Apr-2012  mrg sync to latest -current.
 1.72.2.4 03-Dec-2017  jdolecek update from HEAD
 1.72.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.72.2.2 23-Jun-2013  tls resync from head
 1.72.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.76.2.2 18-May-2014  rmind sync with head
 1.76.2.1 28-Aug-2013  rmind sync with head
 1.91.2.1 10-Aug-2014  tls Rebase.
 1.94.4.4 28-Aug-2017  skrll Sync with HEAD
 1.94.4.3 05-Oct-2016  skrll Sync with HEAD
 1.94.4.2 06-Jun-2015  skrll Sync with HEAD
 1.94.4.1 06-Apr-2015  skrll Sync with HEAD
 1.101.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.102.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.106.10.2 21-Apr-2020  martin Sync with HEAD
 1.106.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.2.2 29-Feb-2020  ad Sync with head.
 1.107.2.1 17-Jan-2020  ad Sync with head.
 1.109.4.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.109.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.114.6.1 01-Aug-2021  thorpej Sync with HEAD.
 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.
 1.1 18-Feb-2008  ad branches: 1.1.2; 1.1.10; 1.1.12;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file Makefile was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file Makefile was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file Makefile was added on branch mjf-devfs on 2008-02-18 21:06:44 +0000
 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 18-Feb-2008  ad branches: 1.1.2; 1.1.10; 1.1.12; 1.1.16; 1.1.36;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.36.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.16.1 11-Mar-2010  yamt sync with head
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file files.unionfs was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file files.unionfs was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file files.unionfs was added on branch mjf-devfs on 2008-02-18 21:06:44 +0000
 1.2.20.1 03-Dec-2017  jdolecek update from HEAD
 1.4 05-Mar-2020  riastradh Revert "Include opt_diagnostic.h for DIAGNOSTIC."

This did not do what I thought it did. opt_diagnostic.h is only for
the unused _DIAGNOSTIC, which seems like an abortive attempt to
incrementally convert DIAGNOSTIC to an opt_*.h option rather than a
command-line option.
 1.3 05-Mar-2020  riastradh Include opt_diagnostic.h for DIAGNOSTIC.

...at least, in header files, which may not have already included
libkern.h.
 1.2 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.1 18-Feb-2008  ad branches: 1.1.2; 1.1.8; 1.1.10; 1.1.12; 1.1.16; 1.1.18; 1.1.20;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.20.1 03-Jul-2008  simonb Sync with head.
 1.1.18.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.16.1 04-May-2009  yamt sync with head.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file unionfs.h was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file unionfs.h was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.8.1 29-Jun-2008  mjf Sync with HEAD.
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file unionfs.h was added on branch mjf-devfs on 2008-02-18 21:06:44 +0000
 1.16 11-Sep-2022  christos catch up; make this compile again.
 1.15 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.14 01-Jun-2017  chs branches: 1.14.26;
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.13 12-Jun-2011  rmind branches: 1.13.12; 1.13.30;
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.12 02-Jan-2011  dholland branches: 1.12.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.11 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.10 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.9 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.8 24-Jun-2010  hannken Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.
 1.7 18-Jun-2010  hannken Remove the concept of recursive vnode locks by eliminating
vn_setrecurse(), vn_restorerecurse() and LK_CANRECURSE.
Welcome to 5.99.31

Discussed on tech-kern.
 1.6 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.5 08-Jan-2010  pooka branches: 1.5.2; 1.5.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.4 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.3 18-Mar-2009  cegger bcopy -> memcpy
 1.2 18-Mar-2009  cegger bcmp -> memcmp
 1.1 18-Feb-2008  ad branches: 1.1.2; 1.1.10; 1.1.12; 1.1.16; 1.1.24; 1.1.30;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.30.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.24.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.16.3 11-Aug-2010  yamt sync with head.
 1.1.16.2 11-Mar-2010  yamt sync with head
 1.1.16.1 04-May-2009  yamt sync with head.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file unionfs_subr.c was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file unionfs_subr.c was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file unionfs_subr.c was added on branch mjf-devfs on 2008-02-18 21:06:44 +0000
 1.5.4.6 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.5.4.5 21-May-2011  rmind Finish v_interlock sharing bits for union/unionfs.
 1.5.4.4 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.5.4.3 05-Mar-2011  rmind sync with head
 1.5.4.2 03-Jul-2010  rmind sync with head
 1.5.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.5.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.12.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.30.1 28-Aug-2017  skrll Sync with HEAD
 1.13.12.1 03-Dec-2017  jdolecek update from HEAD
 1.14.26.1 01-Aug-2021  thorpej Sync with HEAD.
 1.17 18-May-2024  thorpej Remove unecessary include of <sys/malloc.h>.
 1.16 12-Sep-2022  christos kmem_alloc -> kmem_zalloc, thanks Rin.
 1.15 11-Sep-2022  christos catch up; make this compile again.
 1.14 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.13 16-Apr-2014  maxv branches: 1.13.28; 1.13.34;
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.12 23-Mar-2014  hannken branches: 1.12.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.11 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.10 05-Nov-2012  dholland branches: 1.10.2;
Fix build of fs/unionfs (the extra unused copy of onionfs) for the
quota changes.
 1.9 06-Mar-2011  bouyer branches: 1.9.4; 1.9.10; 1.9.14; 1.9.16; 1.9.18;
merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.8 19-Nov-2010  dholland branches: 1.8.2; 1.8.4;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.7 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.6 05-Dec-2008  ad branches: 1.6.6; 1.6.8;
PR kern/40110: null, overlay and umap modules loading -> panic (layerfs symbols not there)

Add a layerfs module.
 1.5 28-Jun-2008  rumble branches: 1.5.2; 1.5.4; 1.5.6; 1.5.12; 1.5.16;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.4 13-May-2008  simonb branches: 1.4.2;
mnt_data is a pointer, set it to NULL not 0 when we're finished with it.
 1.3 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.2 29-Apr-2008  ad branches: 1.2.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.1 18-Feb-2008  ad branches: 1.1.2; 1.1.8; 1.1.10; 1.1.12; 1.1.14; 1.1.16;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.16.3 11-Aug-2010  yamt sync with head.
 1.1.16.2 04-May-2009  yamt sync with head.
 1.1.16.1 16-May-2008  yamt sync with head.
 1.1.14.1 18-May-2008  yamt sync with head.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file unionfs_vfsops.c was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file unionfs_vfsops.c was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.8.3 17-Jan-2009  mjf Sync with HEAD.
 1.1.8.2 29-Jun-2008  mjf Sync with HEAD.
 1.1.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file unionfs_vfsops.c was added on branch mjf-devfs on 2008-02-18 21:06:44 +0000
 1.2.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.2.1 03-Jul-2008  simonb Sync with head.
 1.5.16.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.5.12.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.5.6.1 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.5.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.8.3 21-Apr-2011  rmind sync with head
 1.6.8.2 05-Mar-2011  rmind sync with head
 1.6.8.1 03-Jul-2010  rmind sync with head
 1.6.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.4.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.18.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.9.16.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.9.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.10.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.9.4.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.9.4.1 16-Jan-2013  yamt sync with (a bit old) head
 1.10.2.1 18-May-2014  rmind sync with head
 1.12.2.1 10-Aug-2014  tls Rebase.
 1.13.34.1 17-Jan-2020  ad Sync with head.
 1.13.28.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.19 11-Sep-2022  christos catch up; make this compile again.
 1.18 27-Mar-2022  christos Expose groupmember as kauth_cred_groupmember and use it.
 1.17 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.16 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.15 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.14 16-May-2020  christos branches: 1.14.6;
Add ACL support for FFS. From FreeBSD.
 1.13 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.12 26-May-2017  riastradh branches: 1.12.10; 1.12.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.11 26-Apr-2017  riastradh 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.10 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.9 20-Apr-2015  riastradh branches: 1.9.2; 1.9.4;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.8 25-Jul-2014  dholland branches: 1.8.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.7 05-Nov-2012  dholland branches: 1.7.10;
Excise struct componentname from the namecache.

This uglifies the interface, because several operations need to be
passed the namei flags and cache_lookup also needs for the time being
to be passed cnp->cn_nameiop. Nonetheless, it's a net benefit.

The glop should be able to go away eventually but requires structural
cleanup elsewhere first.

This change requires a kernel bump.
 1.6 22-Jul-2012  rmind branches: 1.6.2;
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.
 1.5 12-Jun-2011  rmind branches: 1.5.2; 1.5.8;
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.4 30-Nov-2010  dholland branches: 1.4.6;
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.3 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.2 24-Jun-2010  hannken Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.
 1.1 18-Feb-2008  ad branches: 1.1.2; 1.1.10; 1.1.12; 1.1.16; 1.1.36; 1.1.38;
A port of FreeBSD's updated unionfs. This is a work in progress. In
particular, unionfs_lookup() needs a lot of attention.
 1.1.38.4 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.1.38.3 05-Mar-2011  rmind sync with head
 1.1.38.2 03-Jul-2010  rmind sync with head
 1.1.38.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.1.36.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.16.1 11-Aug-2010  yamt sync with head.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 18-Feb-2008  matt file unionfs_vnops.c was added on branch matt-armv6 on 2008-03-23 02:04:57 +0000
 1.1.10.2 27-Feb-2008  yamt sync with head.
 1.1.10.1 18-Feb-2008  yamt file unionfs_vnops.c was added on branch yamt-lazymbuf on 2008-02-27 08:36:54 +0000
 1.1.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.2.1 18-Feb-2008  mjf file unionfs_vnops.c was added on branch mjf-devfs on 2008-02-18 21:06:45 +0000
 1.4.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.8.1 12-Aug-2012  martin Pull up following revision(s) (requested by manu in ticket #484):
sys/fs/nilfs/nilfs_vnops.c: revision 1.18
sys/ufs/ufs/ufs_lookup.c: revision 1.117
sys/nfs/nfs_vnops.c: revision 1.295
sys/ufs/chfs/chfs_vnops.c: revision 1.8
sys/ufs/ext2fs/ext2fs_lookup.c: revision 1.70
sys/fs/unionfs/unionfs_vnops.c: revision 1.6
sys/kern/vfs_cache.c: revision 1.89
sys/fs/efs/efs_vnops.c: revision 1.26
sys/fs/hfs/hfs_vnops.c: revision 1.26
sys/fs/adosfs/adlookup.c: revision 1.16
sys/fs/puffs/puffs_vnops.c: revision 1.168
sys/fs/tmpfs/tmpfs_vnops.c: revision 1.98
sys/fs/ntfs/ntfs_vnops.c: revision 1.52
sys/fs/cd9660/cd9660_lookup.c: revision 1.20
sys/fs/msdosfs/msdosfs_lookup.c: revision 1.24
sys/fs/smbfs/smbfs_vnops.c: revision 1.80
sys/fs/udf/udf_vnops.c: revision 1.72
sys/fs/filecorefs/filecore_lookup.c: revision 1.14
sys/fs/puffs/puffs_node.c: revision 1.25
Move some the test for MAKEENTRY into the cache_enter(9). Make some
variables in vfs_cache.c static, __read_mostly, etc.
No objection on tech-kern@.
 1.5.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.5.2.1 30-Oct-2012  yamt sync with head
 1.6.2.3 03-Dec-2017  jdolecek update from HEAD
 1.6.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.7.10.1 10-Aug-2014  tls Rebase.
 1.8.4.2 28-Aug-2017  skrll Sync with HEAD
 1.8.4.1 06-Jun-2015  skrll Sync with HEAD
 1.9.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.9.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.12.16.1 29-Feb-2020  ad Sync with head.
 1.12.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.1 27-Jun-2011  uch branches: 1.1.12;
7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.4 24-May-2022  andvar fix various typos in comments, docs and log messages.
 1.3 22-May-2022  andvar fix various small typos, mainly in comments.
 1.2 16-Jul-2011  uch core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.5 14-Aug-2011  apb Rename all static functions to have "v7fs_" prefix. Fixes a problem
in the tools build, where the static link() and unlink() functions
conflicted with those declared in <unistd.h>.
 1.4 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.3 16-Jul-2011  uch export v7fs_datablock_addr for makefs
 1.2 13-Jul-2011  uch When filesize is zero, correctly return V7FS_ITERATOR_END
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 16-Jul-2011  uch export v7fs_datablock_addr for makefs
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.3 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.9 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.8 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.7 16-May-2020  christos branches: 1.7.6;
Add ACL support for FFS. From FreeBSD.
 1.6 28-May-2018  chs add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
 1.5 17-Feb-2017  hannken branches: 1.5.12;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.4 29-Dec-2014  hannken branches: 1.4.2; 1.4.4;
Change v7fs to vcache.
 1.3 25-Jul-2014  dholland branches: 1.3.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.2 23-Mar-2014  hannken branches: 1.2.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.1 27-Jun-2011  uch branches: 1.1.2; 1.1.12; 1.1.16;
7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 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.2.2.1 10-Aug-2014  tls Rebase.
 1.3.4.2 28-Aug-2017  skrll Sync with HEAD
 1.3.4.1 06-Apr-2015  skrll Sync with HEAD
 1.4.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.7.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 29-Dec-2014  hannken Change v7fs to vcache.
 1.1 27-Jun-2011  uch branches: 1.1.12; 1.1.30;
7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.7 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.6 29-Dec-2014  hannken Defer deallocating unlinked inodes to v7fs_reclaim().

Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.5 07-Dec-2012  msaitoh branches: 1.5.12; 1.5.14;
Fix off by one error.
 1.4 21-Mar-2012  christos branches: 1.4.2;
don't re-define MIN
 1.3 30-Jul-2011  uch branches: 1.3.2; 1.3.6; 1.3.8; 1.3.12;
Fix return vaule. Pass t_vnops:rename_dotdot, dir_noempty, rename_dir(6)
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.3.12.1 16-Dec-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #748):
sys/fs/v7fs/v7fs_file.c: revision 1.5
Fix off by one error.
 1.3.8.1 16-Dec-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #748):
sys/fs/v7fs/v7fs_file.c: revision 1.5
Fix off by one error.
 1.3.6.1 05-Apr-2012  mrg sync to latest -current.
 1.3.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 25-Feb-2013  tls resync with head
 1.5.14.1 06-Apr-2015  skrll Sync with HEAD
 1.5.12.1 07-Jan-2015  martin Pull up following revision(s) (requested by hannken in ticket #386):
sys/fs/v7fs/v7fs_file.c: revision 1.6
sys/fs/v7fs/v7fs_vnops.c: revision 1.18
sys/fs/v7fs/v7fs_vnops.c: revision 1.19
sys/fs/v7fs/v7fs_vfsops.c: revision 1.11
v7fs_getattr: adjust size of symlinks by -1 to compensate the trailing NUL.
Should fix the v7fs part of PR kern/48864.
Defer deallocating unlinked inodes to v7fs_reclaim().
Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.3 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.2 16-Jul-2011  uch core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.5 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.4 30-Jul-2011  uch When rename directory, check hierarchy. Pass t_vnops rename_dir(5)
 1.3 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.2 16-Jul-2011  uch core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.3 25-Sep-2024  andvar s/corupt/corrupt/ in debug message.
 1.2 18-Jul-2011  apb branches: 1.2.90;
In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2.90.1 02-Aug-2025  perseant Sync with HEAD
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.3 28-Jun-2013  christos prevent memory leak on error
http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html
 1.2 18-Jul-2011  apb branches: 1.2.2; 1.2.12;
In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.1 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.5 27-Aug-2017  skrll Remove some unnecessary duplicatioN
 1.4 01-Jun-2017  chs 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.3 28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.2 20-Nov-2013  rmind branches: 1.2.6;
v7fs: replace malloc(9) with kmem(9), fix a memory leak and few missing
mutex destruction cases in the error path.
 1.1 27-Jun-2011  uch branches: 1.1.2; 1.1.12; 1.1.16;
7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 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.2.6.2 28-Aug-2017  skrll Sync with HEAD
 1.2.6.1 06-Apr-2015  skrll Sync with HEAD
 1.4 08-Aug-2011  uch Remove suspicious warning message.
 1.3 03-Aug-2011  dholland Insert casts to off_t to avoid 32-bit multiplication overflow when
computing device offsets on 32-bit platforms. Should fix PR 45191.
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.2 18-Jul-2011  apb In sources that get compiled into the tools version of makefs, add:

#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.19 03-May-2022  hannken Lock devvp for kauth KAUTH_REQ_SYSTEM_MOUNT_DEVICE.
 1.18 05-Feb-2022  zafer fix membername in dprintf
 1.17 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.16 01-Jun-2017  chs branches: 1.16.10; 1.16.16;
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.15 17-Apr-2017  hannken branches: 1.15.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
 1.14 17-Apr-2017  hannken Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
 1.13 01-Apr-2017  riastradh KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.
 1.12 29-Dec-2014  hannken branches: 1.12.2; 1.12.4;
Change v7fs to vcache.
 1.11 29-Dec-2014  hannken Defer deallocating unlinked inodes to v7fs_reclaim().

Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.10 16-Apr-2014  maxv branches: 1.10.2; 1.10.4;
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.9 23-Nov-2013  christos branches: 1.9.2;
change the mountlist CIRCLEQ into a TAILQ
 1.8 20-Nov-2013  rmind v7fs: replace malloc(9) with kmem(9), fix a memory leak and few missing
mutex destruction cases in the error path.
 1.7 13-Jun-2012  joerg branches: 1.7.2; 1.7.4;
Ensure that error is initialized in all code paths.
 1.6 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.5 13-Nov-2011  christos branches: 1.5.4; 1.5.6;
use getdisksize()
 1.4 30-Jul-2011  uch branches: 1.4.2;
v7fs_lookup() fix return value. Pass t_vnops rename_dir(3)
v7fs_setttr() check credential. Pass t_unpriv owner
v7fs_rename() reload inode(v7fs_vnode_reload). Pass t_vnops rename_reg_nodir
 1.3 23-Jul-2011  uch remove partition check from v7fs_mount. problem on rump implementation.
 1.2 02-Jul-2011  uch Set missing error number
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.4.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.4.2.2 30-Oct-2012  yamt sync with head
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.5.6.2 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.5.6.1 24-Jun-2012  jdc branches: 1.5.6.1.4; 1.5.6.1.6;
Pull up revisions:
src/sys/fs/hfs/hfs_vfsops.c revision 1.29
src/sys/fs/sysvbfs/sysvbfs_vfsops.c revision 1.40
src/sys/fs/v7fs/v7fs_vfsops.c revision 1.7
(requested by joerg in ticket #344).
 1.5.6.1.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.5.6.1.4.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.5.4.1 05-Apr-2012  mrg sync to latest -current.
 1.7.4.1 18-May-2014  rmind sync with head
 1.7.2.2 03-Dec-2017  jdolecek update from HEAD
 1.7.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 10-Aug-2014  tls Rebase.
 1.10.4.2 28-Aug-2017  skrll Sync with HEAD
 1.10.4.1 06-Apr-2015  skrll Sync with HEAD
 1.10.2.1 07-Jan-2015  martin Pull up following revision(s) (requested by hannken in ticket #386):
sys/fs/v7fs/v7fs_file.c: revision 1.6
sys/fs/v7fs/v7fs_vnops.c: revision 1.18
sys/fs/v7fs/v7fs_vnops.c: revision 1.19
sys/fs/v7fs/v7fs_vfsops.c: revision 1.11
v7fs_getattr: adjust size of symlinks by -1 to compensate the trailing NUL.
Should fix the v7fs part of PR kern/48864.
Defer deallocating unlinked inodes to v7fs_reclaim().
Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.12.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.12.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.12.2.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.15.2.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.16.16.1 17-Jan-2020  ad Sync with head.
 1.16.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38 31-Jul-2022  mlelstv Don't panic for a negative offset, just fail the operation with EINVAL.
 1.37 22-May-2022  andvar fix various small typos, mainly in comments.
 1.36 30-Mar-2022  christos fix unlock on error.
 1.35 27-Mar-2022  christos add a kauth vnode check for creating links
 1.34 11-Feb-2022  hannken A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
 1.33 01-Feb-2022  jakllsch fix spelling of "regular" in comment
 1.32 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.31 27-Jun-2020  christos Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.30 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.29 23-Apr-2020  ad PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
somewhere. Use it to decide whether to do direct-mapped copy, rather than
poking around directly in the vnode in ubc_uiomove(), which is ugly and
doesn't work for tmpfs. It would be nicer to contain all this in UVM but
the filesystem provides the needed locking here (VV_MAPPED) and to
reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS(). Pass in UBC_ISMAPPED where
appropriate.
 1.28 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.27 17-Jan-2020  ad branches: 1.27.4;
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.26 26-May-2017  riastradh branches: 1.26.10; 1.26.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.25 26-Apr-2017  riastradh 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.24 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.23 08-Apr-2017  hannken Update mtime when updating file size.

PR kern/51762 (mtime not updated by open(O_TRUNC))
 1.22 20-Aug-2016  hannken branches: 1.22.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.21 20-Apr-2015  riastradh branches: 1.21.2;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.20 29-Dec-2014  hannken Change v7fs to vcache.
 1.19 29-Dec-2014  hannken Defer deallocating unlinked inodes to v7fs_reclaim().

Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.18 29-Dec-2014  hannken v7fs_getattr: adjust size of symlinks by -1 to compensate the trailing NUL.

Should fix the v7fs part of PR kern/48864.
 1.17 08-Aug-2014  gson branches: 1.17.2; 1.17.4;
Whitespace fix
 1.16 07-Feb-2014  hannken branches: 1.16.2;
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.15 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.14 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.13 20-Nov-2013  rmind v7fs: replace malloc(9) with kmem(9), fix a memory leak and few missing
mutex destruction cases in the error path.
 1.12 18-Mar-2013  plunky branches: 1.12.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.11 29-Apr-2012  chs branches: 1.11.2;
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
 1.10 31-Mar-2012  njoly Make v7fs_getattr() report file flags, and adjust v7fs_setattr() to
allow unsetting SF_APPEND flag.
 1.9 22-Mar-2012  njoly Pass operations flags to genfs_can_chtimes(), not file ones.
 1.8 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.7 27-Jan-2012  njoly branches: 1.7.2;
Check parent directory write permission for DELETE operation.

ok uch@.
 1.6 30-Jul-2011  uch branches: 1.6.2; 1.6.6;
v7fs_lookup() fix return value. Pass t_vnops rename_dir(3)
v7fs_setttr() check credential. Pass t_unpriv owner
v7fs_rename() reload inode(v7fs_vnode_reload). Pass t_vnops rename_reg_nodir
 1.5 24-Jul-2011  uch Existing inode don't recycle. rump works.
 1.4 16-Jul-2011  uch core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs
 1.3 13-Jul-2011  uch Fix readdir eofflag(bogus eofflags was setted). getcwd works.
 1.2 13-Jul-2011  uch Fix inode update method. chown and chmod works.
 1.1 27-Jun-2011  uch 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8).
 1.6.6.3 02-Jun-2012  mrg sync to latest -current.
 1.6.6.2 05-Apr-2012  mrg sync to latest -current.
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.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.6.2.2 23-May-2012  yamt sync with head.
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.7.2.1 07-May-2012  riz Pull up following revision(s) (requested by chs in ticket #204):
sys/fs/sysvbfs/sysvbfs_vnops.c: revision 1.44
sys/ufs/ffs/ffs_vfsops.c: revision 1.277
sys/fs/v7fs/v7fs_vnops.c: revision 1.11
sys/ufs/chfs/chfs_vnops.c: revision 1.7
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.61
sys/miscfs/genfs/genfs_io.c: revision 1.54
sys/kern/vfs_wapbl.c: revision 1.52
sys/uvm/uvm_pager.h: revision 1.43
sys/ufs/ffs/ffs_vnops.c: revision 1.121
sys/kern/vfs_subr.c: revision 1.434
sys/fs/msdosfs/msdosfs_vnops.c: revision 1.83
sys/fs/ntfs/ntfs_vnops.c: revision 1.51
sys/fs/udf/udf_subr.c: revision 1.119
sys/miscfs/specfs/spec_vnops.c: revision 1.135
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.103
sys/fs/udf/udf_vnops.c: revision 1.71
sys/ufs/ufs/ufs_readwrite.c: revision 1.104
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
mark all wapbl I/O as BPRIO_TIMECRITICAL.
this is the second part of addressing PR 46325.
 1.11.2.3 03-Dec-2017  jdolecek update from HEAD
 1.11.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.1 23-Jun-2013  tls resync from head
 1.12.6.1 18-May-2014  rmind sync with head
 1.16.2.1 10-Aug-2014  tls Rebase.
 1.17.4.4 28-Aug-2017  skrll Sync with HEAD
 1.17.4.3 05-Oct-2016  skrll Sync with HEAD
 1.17.4.2 06-Jun-2015  skrll Sync with HEAD
 1.17.4.1 06-Apr-2015  skrll Sync with HEAD
 1.17.2.1 07-Jan-2015  martin Pull up following revision(s) (requested by hannken in ticket #386):
sys/fs/v7fs/v7fs_file.c: revision 1.6
sys/fs/v7fs/v7fs_vnops.c: revision 1.18
sys/fs/v7fs/v7fs_vnops.c: revision 1.19
sys/fs/v7fs/v7fs_vfsops.c: revision 1.11
v7fs_getattr: adjust size of symlinks by -1 to compensate the trailing NUL.
Should fix the v7fs part of PR kern/48864.
Defer deallocating unlinked inodes to v7fs_reclaim().
Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
 1.21.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.22.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.26.16.1 17-Jan-2020  ad Sync with head.
 1.26.10.2 21-Apr-2020  martin Sync with HEAD
 1.26.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.27.4.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.27.4.1 20-Apr-2020  bouyer Sync with HEAD

RSS XML Feed