History log of /openbsd-current/sys/nfs/nfs_node.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.76 01-May-2024 jsg

remove unneeded includes
ok miod@ mpi@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.75 27-Jun-2022 visa

Fix lock order reversal in nfs_inactive()

Make the silly file removal happen after the vnode has been unlocked.
This avoids a file-directory reversal in the vnode locking order.

OK jca@


Revision tags: OPENBSD_7_1_BASE
# 1.74 20-Oct-2021 semarie

revert vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop
(both kernel and userland bits)

GENERIC + VFSLCKDEBUG is broken with it.


# 1.73 19-Oct-2021 semarie

vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop

This flag is currently used to mark or unmark a vnode to actively
check vnode locking semantic (when compiled with VFSLCKDEBUG).

Currently, VLOCKSWORK flag isn't properly set for several FS
implementation which have full locking support. This commit enable
proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs).

Instead of using a particular flag, it directly check if
v_op->vop_islocked is nullop or not to activate or not the vnode
locking checks.

ok mpi@


# 1.72 19-Oct-2021 semarie

vnode: do not manipulate vnode lock directly

use VOP_LOCK / VOP_UNLOCK wrappers.

VOP_LOCK() is prefered over vn_lock() here in order to keep equivalent code.

ok mpi@ visa@ (as part of larger diff)


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.71 20-Jan-2020 claudio

struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.75 27-Jun-2022 visa

Fix lock order reversal in nfs_inactive()

Make the silly file removal happen after the vnode has been unlocked.
This avoids a file-directory reversal in the vnode locking order.

OK jca@


Revision tags: OPENBSD_7_1_BASE
# 1.74 20-Oct-2021 semarie

revert vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop
(both kernel and userland bits)

GENERIC + VFSLCKDEBUG is broken with it.


# 1.73 19-Oct-2021 semarie

vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop

This flag is currently used to mark or unmark a vnode to actively
check vnode locking semantic (when compiled with VFSLCKDEBUG).

Currently, VLOCKSWORK flag isn't properly set for several FS
implementation which have full locking support. This commit enable
proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs).

Instead of using a particular flag, it directly check if
v_op->vop_islocked is nullop or not to activate or not the vnode
locking checks.

ok mpi@


# 1.72 19-Oct-2021 semarie

vnode: do not manipulate vnode lock directly

use VOP_LOCK / VOP_UNLOCK wrappers.

VOP_LOCK() is prefered over vn_lock() here in order to keep equivalent code.

ok mpi@ visa@ (as part of larger diff)


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.71 20-Jan-2020 claudio

struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.74 20-Oct-2021 semarie

revert vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop
(both kernel and userland bits)

GENERIC + VFSLCKDEBUG is broken with it.


# 1.73 19-Oct-2021 semarie

vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop

This flag is currently used to mark or unmark a vnode to actively
check vnode locking semantic (when compiled with VFSLCKDEBUG).

Currently, VLOCKSWORK flag isn't properly set for several FS
implementation which have full locking support. This commit enable
proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs).

Instead of using a particular flag, it directly check if
v_op->vop_islocked is nullop or not to activate or not the vnode
locking checks.

ok mpi@


# 1.72 19-Oct-2021 semarie

vnode: do not manipulate vnode lock directly

use VOP_LOCK / VOP_UNLOCK wrappers.

VOP_LOCK() is prefered over vn_lock() here in order to keep equivalent code.

ok mpi@ visa@ (as part of larger diff)


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.71 20-Jan-2020 claudio

struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.73 19-Oct-2021 semarie

vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop

This flag is currently used to mark or unmark a vnode to actively
check vnode locking semantic (when compiled with VFSLCKDEBUG).

Currently, VLOCKSWORK flag isn't properly set for several FS
implementation which have full locking support. This commit enable
proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs).

Instead of using a particular flag, it directly check if
v_op->vop_islocked is nullop or not to activate or not the vnode
locking checks.

ok mpi@


# 1.72 19-Oct-2021 semarie

vnode: do not manipulate vnode lock directly

use VOP_LOCK / VOP_UNLOCK wrappers.

VOP_LOCK() is prefered over vn_lock() here in order to keep equivalent code.

ok mpi@ visa@ (as part of larger diff)


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.71 20-Jan-2020 claudio

struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.71 20-Jan-2020 claudio

struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.70 27-May-2018 visa

Drop unnecessary `p' parameter from vget(9).

OK mpi@


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.69 05-May-2018 mpi

Implement proper locking for NFS nodes.

Tested in bulks by many. ok visa@, beck@


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.68 28-Apr-2018 visa

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@


# 1.67 09-Apr-2018 mpi

Change the representation of an NFS mount point by caching the root
nodes.

nfs_root() now returns a "locked" vnode, so vput(9) must be called to
release it. Note that this has currently no effect as nfs_lock/unlock
are still stubs.

This will prevent some lock odering problems with upcoming NFSnode
locking.

Tested by landry@, sthen@, visa@, naddy@ and myself.

From NetBSD with some tweaks, ok visa@


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.66 28-Mar-2018 mpi

Check for possible race after sleeping instead of using a rwlock to
protect insertions in `nm_ntree'.

This will prevent a future lock ordering problem with NFSnode's lock.

ok tedu@, visa@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.65 27-Sep-2016 dlg

replace the use of RB macros with the RBT functions.


Revision tags: OPENBSD_6_0_BASE
# 1.64 19-Mar-2016 natano

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.63 09-Feb-2016 mmcc

sync a function's comment with its signature

ok tedu@, with a slight tweak


Revision tags: OPENBSD_5_8_BASE
# 1.62 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.61 23-Dec-2014 tedu

to be safe, revert locking change until further tested.


# 1.60 23-Dec-2014 tedu

optimize locking a wee bit by holding it for critical parts only


# 1.59 16-Dec-2014 tedu

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt


# 1.58 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


# 1.57 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.56 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.55 21-Dec-2010 thib

Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@


# 1.54 10-Sep-2010 thib

Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.


# 1.53 06-Sep-2010 thib

End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.


Revision tags: OPENBSD_4_8_BASE
# 1.52 07-Aug-2010 krw

No "\n" needed at the end of panic() strings.

Bogus chunks pointed out by matthew@ and miod@. No cookies for
marco@ and jasper@.

ok deraadt@ miod@ matthew@ jasper@ macro@


Revision tags: OPENBSD_4_7_BASE
# 1.51 17-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

This introduces VLARVAL - so we can indicate in a vnode that the higher
level stuff hiding in v_data is incompletely set up. This flag is then
used by nfs to deal with a halfway set up vnode and release it correctly.

analysis and bogus fix by art@, correct fix by me after serveral failed
attempts and much painful testing by krw@, good suggestions by tedu and miod

ok krw@ oga@ thib@ blambert@ art@


# 1.50 15-Dec-2009 beck

back out previous fix, apparently neither art or i can fix anything right on the first try

vgone doesn't work in other cases of this. I must fix this slightly differntly


# 1.49 15-Dec-2009 beck

This fixes a case where we could panic on a null deref with a bad vnode
in nfs_inactive, on a reboot.

The core of the problem was in nfs_nget, when we lose the race to put a new
nfsnode in the tree, we have previously allocated a vnode, which getnewvnode
has done an insmntque into the nfs mp's mntlist. The problem being we then
try again with a new vnode, abandoning this one on the mntlist, leaving
junk there for us to die on when we unmount.

analysis and bogus fix by art@, correct fix by me. much painful testing by
krw@

ok oga@, art@


# 1.48 14-Aug-2009 thib

Use the nfs_hashlock to protect the nfs_nodetree hanging of the mount.

What can happen is that a recycling of a vnode could pull one from out
under us (since NFS has issues with ref counts...).

Dance around getnewvnode() since we can end up recycling vnodes that
where formerly owned by NFS, causing recursive locking.

We where lucky with the old hashtables has the race was rare but now
with more aggresive recycling we loose, just as theo found out on vax.

help from oga, beck and blambert (beck mostly screamed though).

ok oga@, beck@, blambert@


# 1.47 11-Aug-2009 thib

tiny knf and use curproc directly instead of a setting up a local proc
pointer since its just used in one place.

ok blambert@


# 1.46 10-Aug-2009 thib

Use an RB tree instead of a hashtable for fh/node lookups.

Idea from NetBSD.

OK blambert@


# 1.45 20-Jul-2009 thib

(struct foo *)0 -> NULL, every where I could find it.

OK blambert@


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.44 24-Dec-2008 thib

Replace the TRUE/FALSE defines with 1/0 respectively. This doesn't
hurt readability and it was just plain annoying seeing them defined
in every other .c file.

OK blambert@


# 1.43 23-Dec-2008 thib

small indent fix


# 1.42 09-Aug-2008 thib

o nfs_vinvalbuf() is always called with the intrflag as 1, and then
checks if the mount is actually interrutable, and if not sets it 0.
remove this argument from nfs_vinvalbuf and just do the checking inside
the function.
o give nfs_vinvalbuf() a makeover so it looks nice. (spacing, casts, &c);
o Actually pass PCATCH too tsleep() if the mount it interrutable.

ok art@, blambert@


# 1.41 08-Aug-2008 blambert

Remove code for variable-sized allocations of NFS filehandles by malloc(),
as it was never used because there were 64-bit buffers already allocated
for filehandles in nfsnode structs.

ok thib@


Revision tags: OPENBSD_4_4_BASE
# 1.40 14-Jun-2008 mk

A bunch of pool_get() + bzero() -> pool_get(..., .. | PR_ZERO)
conversions that should shave a few bytes off the kernel.

ok henning, krw, jsing, oga, miod, and thib (``even though i usually prefer
FOO|BAR''; thanks for looking.


# 1.39 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


# 1.38 10-Jun-2008 thib

o Avoid putting duplicate entries into the name cache,
add a function to handle cache_enter()'s for us since
we need to update the appropriate timestamps so we don't
miss on lookup;
o Do not purge the dvp in nfs_rmdir(), since there's no need;
o cache the new entry created in nfs_mkdir();
o Do caching of the access modes, this drastically reduces the
amount of over the wire access RPCs we do in the NFSv3 case.

This diff was written by Pedro Martelletto, sometime in 2004.
A lot of people have been running with it at one time or another,
this includes at least markus and matthieu.

OK deraadt@, blambert@


Revision tags: OPENBSD_4_3_BASE
# 1.37 13-Dec-2007 thib

Garbage collect nfsdmap and leftover code. That structure
was used as a part of the "old-style directory caching"
that was removed in 2001;

ok beck@, blambert@


# 1.36 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.35 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.34 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.33 28-May-2007 thib

lockmgr -> rwlock for the nfs_hashlock.

ok tedu@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 07-May-2006 tedu

add a name to rwlock so that we can tell where procs are getting stuck
without breaking into ddb. doubles the size of rwlock [1], but moving
forward this really helps. ok/tested pedro fgsch millert krw
[1 - next person to add a field to this struct gets whipped with a wet noodle]


Revision tags: OPENBSD_3_9_BASE
# 1.31 09-Jan-2006 pedro

Put vprint() under DIAGNOSTIC, as to save space in generated ramdisks.
Inspiration from miod@, okay deraadt@. Tested on i386, macppc and amd64.


# 1.30 19-Nov-2005 pedro

Use NULL where NULL is meant


# 1.29 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.28 26-Dec-2004 miod

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.


Revision tags: OPENBSD_3_6_BASE
# 1.27 03-Aug-2004 marius

NFS commit coalescion: instead of sending a commit for each block, coalesce
these into larger ranges wherever possible.

this should speed up NFS writes quite a bit.

ok art@ millert@ pedro@ tedu@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.26 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 02-Jul-2002 ericj

use hash.h for nfs_hash as well as namei's hash
ok art@ costa@


Revision tags: OPENBSD_3_1_BASE
# 1.24 14-Mar-2002 millert

First round of __P removal in sys


# 1.23 23-Feb-2002 art

Sigh. The diff is out for testing for three months without a single problem.
Two days after commit people report serious lockups all over the place.
Back out nfs locking changes.


# 1.22 22-Feb-2002 csapuntz

More locking in the NFS code


# 1.21 23-Jan-2002 art

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
- group all information the backend allocator for a pool in a separate
struct. The pool will only have a pointer to that struct.
- change the pool_init API to reflect that.
- link all pools allocating from the same allocator on a linked list.
- Since an allocator is responsible to wait for physical memory it will
only fail (waitok) when it runs out of its backing vm_map, carefully
drain pools using the same allocator so that va space is freed.
(see comments in code for caveats and details).
- change pool_reclaim to return if it actually succeeded to free some
memory, use that information to make draining easier and more efficient.
- get rid of PR_URGENT, noone uses it.


# 1.20 16-Jan-2002 ericj

use queue.h macro's
remove register


# 1.19 19-Dec-2001 art

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.


Revision tags: UBC_BASE
# 1.18 01-Dec-2001 art

branches: 1.18.2;
Unlock and drop vnode if VOP_GETATTR fails.


# 1.17 27-Nov-2001 art

Merge in the unified buffer cache code as found in NetBSD 2001/03/10. The
code is written mostly by Chuck Silvers <chuq@chuq.com>/<chs@netbsd.org>.

Tested for the past few weeks by many developers, should be in a pretty stable
state, but will require optimizations and additional cleanups.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


Revision tags: OPENBSD_3_0_BASE
# 1.15 25-Jun-2001 csapuntz

Remove NQNFS


# 1.14 24-Jun-2001 csapuntz

Change handling of NFS root vnode. Moves recognition of NFS root vnode into
nfs_nget.

Root vnode no longer pinned in inode cache. Also, forceable unmounts of an
nfs file system now work even if there are extra references to the NFS root.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE SMP_BASE kame_19991208
# 1.13 28-Apr-1999 art

branches: 1.13.4;
zap the newhashinit hack.
Add an extra flag to hashinit telling if it should wait in malloc.
update all calls to hashinit.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.12 21-Aug-1998 csapuntz

Fix malloc race in nfs_node.c


# 1.11 06-Aug-1998 csapuntz

Rename vop_revoke, vn_bwrite, vop_noislocked, vop_nolock, vop_nounlock
to be vop_generic_revoke, vop_generic_bwrite, vop_generic_islocked,
vop_generic_lock and vop_generic_unlock.

Create vop_generic_abortop and propogate change to all file systems.

Fix PR/371.

Get rid of locking in NULLFS (should be mostly unnecessary now except for
forced unmounts).


Revision tags: OPENBSD_2_3_BASE
# 1.10 06-Nov-1997 csapuntz

Updates for VFS Lite 2 + soft update.


Revision tags: OPENBSD_2_2_BASE
# 1.9 06-Oct-1997 deraadt

back out vfs lite2 till after 2.2


# 1.8 06-Oct-1997 csapuntz

VFS Lite2 Changes


Revision tags: OPENBSD_2_1_BASE
# 1.7 18-Apr-1997 deraadt

Don't set sillyrename field to 0 for directories, as it's in a union with
the head of the cookie list. Fixes PR 3215, fix supplied by Hiroshi Tezuka
<tezuka@trc.rwcp.or.jp>. Should also fix M_NFSDIROFF memory leak; fvdl


Revision tags: OPENBSD_2_0_BASE
# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 17-Apr-1996 mickey

Minor cleanups. Checked against Lite2.
(NetBSD's was really just a Lite2's, but w/ 64bit support)


# 1.4 31-Mar-1996 mickey

From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon,
is there smth usefull ?..


# 1.3 29-Feb-1996 niklas

From NetBSD: merge with 960217 (still NFSv2)


# 1.2 21-Dec-1995 deraadt

from cgd; handle 64-bit pointers and longs


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision