Home | History | Annotate | only in /src/sys/fs/tmpfs
History log of /src/sys/fs/tmpfs
RevisionDateAuthorComments
 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.

RSS XML Feed