History log of /netbsd-current/sys/fs/tmpfs/tmpfs_vnops.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.145 13-Dec-2020 chs

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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.145 13-Dec-2020 chs

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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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@).


Revision tags: thorpej-futex-newbase
# 1.145 13-Dec-2020 chs

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.


Revision tags: thorpej-futex-base
# 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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.144 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.137 15-May-2020 ad

PR kern/55268: tmpfs is slow

Enter dotdot into the namecache.


Revision tags: bouyer-xenpvh-base2
# 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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.135 14-Mar-2020 ad

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.


Revision tags: is-mlppp-base ad-namecache-base3
# 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.


Revision tags: netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.135 14-Mar-2020 ad

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.


Revision tags: ad-namecache-base3
# 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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.133 26-May-2017 riastradh

branches: 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.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.133 26-May-2017 riastradh

Make VOP_RECLAIM do the last unlock of the vnode.

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

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.133 26-May-2017 riastradh

Make VOP_RECLAIM do the last unlock of the vnode.

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

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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@).


Revision tags: prg-localcount2-base
# 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


Revision tags: pgoyette-localcount-20170426 bouyer-socketcan-base1
# 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!


Revision tags: jdolecek-ncq-base
# 1.130 30-Mar-2017 hannken

Protect tmpfs_getpages() against reclaiming vnodes.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base
# 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.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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.129 11-Jan-2017 joerg

Remove RO check in tmpfs_putpages for now, the syncer doesn't like the
error code.


Revision tags: pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.127 12-Mar-2016 martin

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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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@).


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914
# 1.128 20-Aug-2016 hannken

Remove now obsolete operation vcache_remove().

Welcome to 7.99.36


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.127 12-Mar-2016 martin

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.


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 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 '..'.


Revision tags: nick-nhusb-base-20150606
# 1.122 20-Apr-2015 riastradh

Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 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.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 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).


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 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@)


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 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.


Revision tags: yamt-pagecache-base6
# 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@.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.97 09-May-2012 riastradh

Adapt tmpfs_rename to use genfs_rename.


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 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.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base4
# 1.95 27-Feb-2012 chs

in tmpfs_readdir(), skip the . and .. processing on removed directories,
since the latter will crash in this case.


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.94 22-Jan-2012 rmind

branches: 1.94.2;
tmpfs_access: simplify, no need to separate the logic.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base
# 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.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 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@


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base
# 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.


Revision tags: matt-mips64-premerge-20101231
# 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.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 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@.


Revision tags: uebayasi-xip-base1
# 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!


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 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


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase
# 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.


Revision tags: yamt-nfs-mp-base8
# 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


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6
# 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


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.59 29-Apr-2009 pooka

replace outdated comment. no functional change


Revision tags: nick-hppapmap-base3 nick-hppapmap-base
# 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


Revision tags: nick-hppapmap-base2
# 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.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.52 26-Nov-2008 pooka

Rototill all remaining file systems to use ubc_uiomove() instead
of the ubc_alloc() - uiomove() - ubc_release() dance.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 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.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.50 28-Apr-2008 martin

branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 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.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.45 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 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.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 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.


Revision tags: jmcneill-base
# 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.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base vmlocking-base
# 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.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 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


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 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.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 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


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3
# 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().


Revision tags: netbsd-4-base
# 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@).


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.25 23-Jul-2006 ad

branches: 1.25.4; 1.25.6;
Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.24 15-May-2006 christos

branches: 1.24.6;
kauth fallout


# 1.23 14-May-2006 elad

integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 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.


Revision tags: ktrace-lwp-base
# 1.18 29-Nov-2005 yamt

merge yamt-readahead branch.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 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


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 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@).