History log of /netbsd-current/sys/nfs/nfs_vfsops.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.246 13-May-2024 msaitoh

ficticious -> fictitious in comment.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.245 21-Mar-2023 christos

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


# 1.244 17-Mar-2023 mlelstv

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.243 13-Jun-2021 mlelstv

Don't pretend that files are limited to 1TB on NFSv3.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.242 02-Apr-2021 christos

branches: 1.242.2;
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.241 13-Apr-2020 ad

branches: 1.241.2; 1.241.4;
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

branches: 1.240.2;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.4; 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.245 21-Mar-2023 christos

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


# 1.244 17-Mar-2023 mlelstv

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.243 13-Jun-2021 mlelstv

Don't pretend that files are limited to 1TB on NFSv3.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.242 02-Apr-2021 christos

branches: 1.242.2;
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.241 13-Apr-2020 ad

branches: 1.241.2; 1.241.4;
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

branches: 1.240.2;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.4; 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.244 17-Mar-2023 mlelstv

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.243 13-Jun-2021 mlelstv

Don't pretend that files are limited to 1TB on NFSv3.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.242 02-Apr-2021 christos

branches: 1.242.2;
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.241 13-Apr-2020 ad

branches: 1.241.2; 1.241.4;
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

branches: 1.240.2;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.4; 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.243 13-Jun-2021 mlelstv

Don't pretend that files are limited to 1TB on NFSv3.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.242 02-Apr-2021 christos

Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.241 13-Apr-2020 ad

branches: 1.241.2; 1.241.4;
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

branches: 1.240.2;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.242 02-Apr-2021 christos

Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


Revision tags: thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.241 13-Apr-2020 ad

Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

branches: 1.240.2;
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.241 13-Apr-2020 ad

Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.240 16-Mar-2020 pgoyette

Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.240 16-Mar-2020 pgoyette

Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.


Revision tags: ad-namecache-base3
# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.239 27-Feb-2020 ad

Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.


Revision tags: ad-namecache-base2 ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: ad-namecache-base1
# 1.238 17-Jan-2020 ad

VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.


Revision tags: ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

branches: 1.237.6;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

branches: 1.236.2;
PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.237 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.236 16-Mar-2018 christos

PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

branches: 1.235.10;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.235 17-Apr-2017 hannken

Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.234 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


Revision tags: jdolecek-ncq-base
# 1.233 01-Apr-2017 riastradh

KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector.


Revision tags: pgoyette-localcount-20170320
# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

branches: 1.231.2; 1.231.4;
Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.232 17-Feb-2017 hannken

Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.231 02-Nov-2015 pgoyette

Don't forget to call nfs_fini() when we're finished. Without this,
we leave a dangling pool nfsrvdescpl around.


Revision tags: nick-nhusb-base-20150921
# 1.230 15-Jul-2015 manu

Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
force unmount is ongoing. This causes timeouts to be reduced and
prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.229 30-May-2014 hannken

branches: 1.229.2; 1.229.4;
Change NFS from rbtree to vcache.


# 1.228 24-May-2014 christos

Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.227 16-Apr-2014 maxv

An (un)privileged user can easily make the kernel dereference a NULL
pointer.

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

ok christos@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.226 23-Mar-2014 hannken

branches: 1.226.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.


Revision tags: riastradh-drm2-base3
# 1.225 17-Mar-2014 hannken

Change nfs_sync() to use vfs_vnode_iterator.


# 1.224 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


# 1.223 23-Nov-2013 christos

change the mountlist CIRCLEQ into a TAILQ


# 1.222 14-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.221 22-Jan-2013 dholland

branches: 1.221.2;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.


Revision tags: netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.220 24-Oct-2011 hannken

branches: 1.220.2; 1.220.8; 1.220.12; 1.220.14; 1.220.16;
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


# 1.219 07-Oct-2011 hannken

As vnalloc() always allocates with PR_WAITOK there is no longer the need
to test its result for NULL.


# 1.218 12-Jun-2011 rmind

Welcome to 5.99.53! Merge rmind-uvmplock branch:

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

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

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

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

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

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 rmind-uvmplock-base
# 1.217 12-Aug-2010 pooka

branches: 1.217.6;
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


Revision tags: yamt-nfs-mp-base10
# 1.216 21-Jul-2010 hannken

Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.


# 1.215 09-Jul-2010 hannken

nfs_unmount(): No need to take a second reference for the root node.

nfs_root(): Replace vget() with vref()/vn_lock(), this node already
has a reference.


# 1.214 24-Jun-2010 hannken

Clean up vnode lock operations pass 2:

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

Welcome to 5.99.32.

Discussed on tech-kern.


# 1.213 24-Jun-2010 hannken

Clean up vnode lock operations:

- VOP_LOCK(vp, flags): Limit the set of allowed flags to LK_EXCLUSIVE,
LK_SHARED and LK_NOWAIT. LK_INTERLOCK is no longer allowed as it
makes no sense here.

- VOP_ISLOCKED(vp): Remove the for some time unused return value
LK_EXCLOTHER. Mark this operation as "diagnostic only".
Making a lock decision based on this operation is no longer allowed.

Discussed on tech-kern.


# 1.212 15-May-2010 dholland

nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.211 02-Mar-2010 pooka

branches: 1.211.2;
Get rid of dependency on fs_nfs.h, i.e. source modules with
conditional content depending on if the NFS client is wanted or
not. The server can now be made an independent module not depending
on the nfs client.

Tested with rump_nfs (standalone client), rump_nfsd (standalone
nfsd) and a qemu installation with both the client and the server.


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.210 15-Mar-2009 cegger

branches: 1.210.2;
ansify function definitions


# 1.209 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.208 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


# 1.207 14-Mar-2009 dsl

Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.206 17-Dec-2008 cegger

branches: 1.206.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.205 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


# 1.204 14-Nov-2008 ad

Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).


Revision tags: netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.203 22-Oct-2008 matt

branches: 1.203.2; 1.203.4; 1.203.10; 1.203.14;
Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.


# 1.202 22-Oct-2008 matt

Change NFS to use a RB-tree for its FH->nfsnode lookups.


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4
# 1.201 30-Sep-2008 pooka

Since the nfs root vnode is eternally constant, fully initialize
it in mountfs instead of deferring part of the initialization to
VFS_ROOT(). Fixes theoretical future bugs for nfs roots.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.200 10-May-2008 rumble

branches: 1.200.4;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

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

Quick sanity check by ad@.


# 1.199 06-May-2008 ad

branches: 1.199.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

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

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

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

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

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


# 1.198 30-Apr-2008 ad

PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.


# 1.197 29-Apr-2008 ad

PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.196 13-Feb-2008 yamt

branches: 1.196.6; 1.196.8; 1.196.10;
reject files larger than nm_maxfilesize.


# 1.195 13-Feb-2008 yamt

nfs_mountroot: kmem_alloc+memset -> kmem_zalloc


# 1.194 30-Jan-2008 ad

PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.


# 1.193 28-Jan-2008 dholland

Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.


Revision tags: bouyer-xeni386-nbase
# 1.192 20-Jan-2008 joerg

Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.


Revision tags: bouyer-xeni386-base matt-armv6-base
# 1.191 03-Jan-2008 pooka

valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok


# 1.190 02-Jan-2008 yamt

use kmem_alloc instead of malloc.


# 1.189 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.188 26-Nov-2007 pooka

branches: 1.188.2; 1.188.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.187 28-Oct-2007 yamt

branches: 1.187.2;
make NFS_ATTRTIMEO a function.


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 vmlocking-base
# 1.186 10-Oct-2007 ad

branches: 1.186.2;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.185 06-Sep-2007 rmind

branches: 1.185.2;
nfs_mount: Plug a possible leaks.
Invented in 1.114 rev.
From CID: 4534


# 1.184 10-Aug-2007 yamt

branches: 1.184.2;
- instead of scanning an array of iods, maintain a list of idle iods.
- make nfs_getset_niothreads MP friendly.


Revision tags: matt-mips64-base
# 1.183 05-Aug-2007 yamt

branches: 1.183.2;
use kpause rather than lbolt.


# 1.182 31-Jul-2007 pooka

branches: 1.182.2;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods


# 1.181 26-Jul-2007 pooka

Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


# 1.180 20-Jul-2007 pooka

In sync, skip over vnodes based on if they are clean rather than
if they have pages.


Revision tags: nick-csl-alignment-base
# 1.179 17-Jul-2007 pooka

branches: 1.179.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok


# 1.178 12-Jul-2007 dsl

Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.


Revision tags: yamt-idlelwp-base8 mjf-ufs-trans-base
# 1.177 29-Apr-2007 yamt

don't forget to destroy mutex and condvar.


# 1.176 29-Apr-2007 yamt

use condvar.


# 1.175 29-Apr-2007 yamt

use mutex and condver.


Revision tags: thorpej-atomic-base
# 1.174 04-Mar-2007 christos

branches: 1.174.2; 1.174.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.173 22-Feb-2007 thorpej

TRUE -> true, FALSE -> false


# 1.172 15-Feb-2007 yamt

branches: 1.172.2;
use mutex and rwlock rather than lockmgr.


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.171 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

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

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

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.170 27-Dec-2006 yamt

- remove the rest of nqnfs.
- reject NFSMNT_MNTD and NFSMNT_KERB. (no users in tree.)


# 1.169 27-Dec-2006 yamt

remove nqnfs.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.168 09-Nov-2006 yamt

remove some __unused in function parameters.


# 1.167 25-Oct-2006 reinoud

Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.


Revision tags: yamt-splraiseipl-base2
# 1.166 20-Oct-2006 reinoud

Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

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

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.


# 1.165 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.164 02-Sep-2006 yamt

branches: 1.164.2; 1.164.4;
nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR.


# 1.163 02-Sep-2006 yamt

implement vptofh and fhtovp for nfs.


# 1.162 02-Sep-2006 christos

fix default type decls
fix incomplete initializer


# 1.161 24-Aug-2006 christos

Don't free what we did not allocate.


# 1.160 23-Aug-2006 christos

Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.159 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.158 13-Jul-2006 martin

Fix alignement problems for fhandle_t, exposed by gcc4.1.

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

Discussed on tech-kern, with lots of help from yamt (thanks!).


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.157 07-Jun-2006 kardel

branches: 1.157.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.156 20-May-2006 yamt

mountnfs: reject wrongly-sized filehandle for nfsv2.


# 1.155 14-May-2006 elad

branches: 1.155.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.154 20-Apr-2006 blymn

Prefix iostat structure elements with io_


# 1.153 14-Apr-2006 blymn

Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.152 21-Feb-2006 thorpej

branches: 1.152.2; 1.152.4; 1.152.6;
Use device_class() instead of accessing dv_class directly.


# 1.151 11-Dec-2005 christos

branches: 1.151.2; 1.151.4; 1.151.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.150 23-Sep-2005 jmmv

Apply the NFS exports list rototill patch:

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

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.


# 1.149 19-Sep-2005 christos

ATTRTIMEO takes 2 args.


# 1.148 09-Jun-2005 atatat

branches: 1.148.2;
Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code. I know it's not the prettiest code, but it seems to work rather
well in spite of itself.


# 1.147 29-May-2005 christos

- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST


Revision tags: kent-audio2-base
# 1.146 29-Mar-2005 thorpej

- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.145 26-Feb-2005 perry

branches: 1.145.2;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge
# 1.144 02-Jan-2005 thorpej

branches: 1.144.2; 1.144.4;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.


Revision tags: kent-audio1-base
# 1.143 15-Aug-2004 mycroft

Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
d_type fields(!), add a new internal flag, IMNT_DTYPE.

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

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

Clean up some crappy pointer frobnication.


# 1.142 12-Jul-2004 yamt

nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync. otherwise genfs_getpages behaves badly.


# 1.141 05-Jul-2004 pk

Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().


# 1.140 25-May-2004 hannken

Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

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

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>


# 1.139 25-May-2004 atatat

Sysctl descriptions under vfs subtree


# 1.138 22-May-2004 jonathan

Eliminate several uses of `curproc' from the socket-layer code and from NFS.

Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.


# 1.137 27-Apr-2004 jrf

First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

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

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.


# 1.136 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


Revision tags: netbsd-2-0-base
# 1.135 24-Mar-2004 atatat

branches: 1.135.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.


# 1.134 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.133 02-Oct-2003 itojun

plug mbuf leak due to manual mbuf handling. PR kern/13807.
(martti confirmed that it stabilizes the situation described in kren/13807)


# 1.132 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.131 29-Jun-2003 fvdl

branches: 1.131.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.130 29-Jun-2003 thorpej

Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.


# 1.129 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.128 21-May-2003 yamt

remove local definitions of TRUE and FALSE.


# 1.127 03-May-2003 yamt

better handling of write verifier change.


# 1.126 24-Apr-2003 drochner

Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.


# 1.125 16-Apr-2003 christos

PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.


# 1.124 02-Apr-2003 yamt

use queue manipulation macros.


# 1.123 28-Mar-2003 yamt

if rsize was explicitly specified by mount_nfs,
prefer it to rtpref from nfsd. the same for wsize and wtpref.

ok'ed by fvdl.


# 1.122 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.121 01-Feb-2003 thorpej

Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.120 24-Nov-2002 scw

Fix an uninitialised variable warning.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.119 21-Oct-2002 yamt

fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.


# 1.118 21-Oct-2002 enami

When printing filesystem specific parameters, also print the address and
port of server numerically.


Revision tags: kqueue-base
# 1.117 01-Oct-2002 christos

forgot to set deadthresh; thanks to YAMAMOTO Takashi.


# 1.116 21-Sep-2002 christos

MNT_GETARGS support


Revision tags: gehenna-devsw-base
# 1.115 30-Jul-2002 soren

Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.


# 1.114 26-Jul-2002 enami

Synchronize code and comment again to prevent mbuf leak. Sprinkle some
KNF while I'm here.


# 1.113 25-Jul-2002 jdolecek

Reduce stack usage on the NFS mount code path. This fixes kernel stack
overflow when using IPsec on vax, as reported by Olaf Seibert on
current-users@.


Revision tags: netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.112 04-Dec-2001 christos

branches: 1.112.8; 1.112.10;
PR/14817: Gregory McGarry: NFS_V2_ONLY doesn't seem to work.


Revision tags: thorpej-mips-cache-base
# 1.111 10-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-devvp-base3
# 1.110 08-Oct-2001 chs

branches: 1.110.2;
revert a change that I accidentally included with ubcperf.


Revision tags: thorpej-devvp-base2
# 1.109 20-Sep-2001 chs

fix nfs_bmap() so that it works for both genfs_{get,put}pages() and swap/vnd.


Revision tags: post-chs-ubcperf
# 1.108 15-Sep-2001 chs

a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.


Revision tags: pre-chs-ubcperf
# 1.107 15-Sep-2001 chs

add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.


Revision tags: thorpej-devvp-base
# 1.106 30-Jul-2001 jdolecek

branches: 1.106.2;
Check the passed file handle length _before_, not _after_ copyin()


# 1.105 30-Jul-2001 fvdl

Check the length of a passed in filehandle to the mount call before
doing a copyin. From Ken Ashcraft @ Stanford via Constantine Sapuntzakis.


# 1.104 01-Jul-2001 gmcgarry

branches: 1.104.2;
Introduce NFS_DEFAULT_NIOTHREADS to define the default number
of nfs_niothreads instead of hard-coding 4.

This change has the advantage that the default can be specified
at compile time. If the root filesystem is mounted over NFS
we don't have an opportunity to use the syscall to limit the
number of threads. Useful on small-memory machines.


# 1.103 30-May-2001 mrg

use _KERNEL_OPT


# 1.102 28-Apr-2001 bjh21

When NFS_V2_ONLY is defined, refuse to mount NFSv3 and NQNFS filesystems,
rather than pretending they're NFSv2 and hoping for the best. Fix based on
that supplied by Christian Groessler.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.101 12-Feb-2001 fvdl

branches: 1.101.2;
Instead of storing the filehandle in the mount structure, store the
vnode pointer. This avoids a locking problem with nfs_nget, and
can be done because we always have a reference on the root vnode
of the filesystem.


# 1.100 06-Feb-2001 fvdl

Do actual vnode locking for NFS.


# 1.99 22-Jan-2001 jdolecek

make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const


# 1.98 10-Dec-2000 chs

in *_sync(), don't skip vnodes which have (potentially dirty) pages.


# 1.97 27-Nov-2000 chs

Initial integration of the Unified Buffer Cache project.


# 1.96 19-Sep-2000 fvdl

Update for VOP_FSYNC parameter change.


# 1.95 19-Sep-2000 bjh21

New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts. Not finished yet, but already
provides some 44k of saving in code size on arm26. More savings, and some
documentation, are still to come.


# 1.94 23-Aug-2000 enami

Update nfs mount flags correctly. Fixes a bug introduced in rev. 1.65.


# 1.93 30-Jul-2000 simonb

Remove inclusion of <uvm/uvm_extern.h> that was there only to keep
<sys/sysctl.h> happy.


# 1.92 27-Jun-2000 mrg

remove include of <vm/vm.h>


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.91 10-Jun-2000 assar

branches: 1.91.2;
make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.


Revision tags: minoura-xpg4dl-base
# 1.90 07-May-2000 tsarna

branches: 1.90.2;
Auto-adjusting vfs.nfs.iothreads: when mounting the first nfs
filesystem, if the number of threads is "-1", meaning it's never been
set, then set it to 4. You can override by setting this to some other
number (including 0) before or after mounting, of course.

Thanks to whoever it was that suggested this on ICB... sorry I don't
remember who.


# 1.89 15-Apr-2000 tsarna

Death to nfsiod!

It is replaced by kernel threads that do the same thing. The number of
kernel threads used is set with the vfs.nfs.iothreads sysctl.


# 1.88 30-Mar-2000 augustss

Remove register declarations.


# 1.87 29-Mar-2000 simonb

Don't need to include <sys/conf.h> here.


# 1.86 16-Mar-2000 jdolecek

Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.85 15-Nov-1999 fvdl

Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O


Revision tags: comdex-fall-1999-base fvdl-softdep-base
# 1.84 29-Aug-1999 sommerfeld

branches: 1.84.2; 1.84.4; 1.84.8;
Once the mount structure is definitely doomed, always set the
NFSMNT_DISMNT bit in it so that any waiters can go away cleanly.
(formerly, we did this only in the NQNFS/KERB cases).


Revision tags: kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.83 06-Mar-1999 fair

branches: 1.83.2; 1.83.4;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.


# 1.82 05-Mar-1999 mycroft

Clean up some sign extension bogosity in statfs, so negative numbers are
actually negative on a LP64 client.


# 1.81 26-Feb-1999 wrstuden

Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.


# 1.80 21-Feb-1999 drochner

-call nfs_boot_cleanup() if mount failed
-g/c diskless swap initialization


Revision tags: kenh-if-detach-base
# 1.79 12-Nov-1998 fvdl

Use different names for the "nfscon" label to tsleep(), so that it can
be seen in which one a process is sleeping.


Revision tags: chs-ubc-base
# 1.78 28-Sep-1998 drochner

Use the "atime" instead of "mtime" of the remote root directory as
base for inittodr() - it is closer to the current time.


# 1.77 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


Revision tags: eeh-paddr_t-base
# 1.76 05-Jul-1998 jonathan

* defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.


# 1.75 24-Jun-1998 sommerfe

Always include fifos; "not an option any more".


# 1.74 22-Jun-1998 sommerfe

defopt for options FIFO


# 1.73 05-Jun-1998 kleink

Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.


# 1.72 24-Mar-1998 fvdl

Re-instate call to "safe" disconnect function that got lost during the
Lite2 merge.


# 1.71 03-Mar-1998 thorpej

Historical practice assumes that NFS root mounts are initially read/write.


# 1.70 03-Mar-1998 fvdl

Don't try to apply the cookie endian heuristic on a mounted file (e.g.
a swapfile). From Matthias Drochner.


# 1.69 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.68 18-Feb-1998 thorpej

Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().


# 1.67 30-Jan-1998 fvdl

Only take the receive lock before disconnecting when doing it from
nfs_decode_args. Otherwise we might just end up locking against ourselves.

XXX workaround, will do ok for now. Proper fix forthcoming.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.66 19-Oct-1997 fvdl

branches: 1.66.2;
* Implement optional 32 <-> 64 bit directory cookie translation. This uses
the directory cache as translation table. See nfs_subs.c for comments.
Makes the code a bit more complex to look at than I would have liked,
but doesn't affect the speed of the default behavior.
* Optimize caching behavior a bit when buffers are invalidated.
* Save some RPCs in readdir operations by not bothering if there is
a small amount left to do to fill the buffer. It'll be done in the
next RPC with a larger chunk anyway. Wastes a bit of buffer space
but is faster.
* Make n_vattr an allocated vattr struct. This avoids nfsnode bloat,
and is friendlier to the malloc routines.


Revision tags: marc-pcmcia-base
# 1.65 10-Oct-1997 fvdl

* New directory entry caching system. Provides full caching of any
directory cookie that may be thrown back at us from userspace, up
to a size limit. Fixes double entry problem.
* Split flags for internal and external use in the NFS mount structure.
* Fix some buffer structure fields that weren're being used correctly.
* Fix missing directory cache inval call in nfs_open.
* Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable
value of 8k.
* Various other things that I forget, all related to the dir caching
somehow, though.


# 1.64 09-Sep-1997 gwr

Move the call to nfs_boot_getfh() from nfs_vfsops.c to nfs_boot.c
(just for better isolation - it can now be static)


Revision tags: thorpej-signal-base
# 1.63 29-Aug-1997 gwr

Supporting changes for the new BOOTP support in nfs_mountroot.


Revision tags: marc-pcmcia-bp
# 1.62 18-Jul-1997 christos

branches: 1.62.2;
Fix reversed test for version 3 that broke nfs version 2 mounts.


# 1.61 17-Jul-1997 fvdl

* Deal with servers that don't give complete FSINFO (like NT)
From Olaf Seibert <rhialto@polder.ubc.kun.nl> (PR 3687)
* Make an attempt to check the maximum filesize before attempting
a write to the server, as write RPCs will typically happen
asynchronously, and the process will not see the error.
Fixes problems with unexpectly truncated files at 4G
* Pass up errors in nfs_writerpc correctly


# 1.60 12-Jun-1997 mrg

remove swap configuration.


# 1.59 27-May-1997 gwr

Minor reorganization of nfs_mountroot code to simplify BOOTP support.
The RPC/bootparamd calls to get the root and swap paths are now done
in nfs_boot_init() instead of nfs_boot_getfh(), so the latter now just
does the RPC/mountd call. Also changed some panics into error returns.


Revision tags: is-newarp-before-merge
# 1.58 22-Feb-1997 fvdl

Silently clear NFSMNT_NOCONN if it's a TCP mount.


Revision tags: is-newarp-base
# 1.57 04-Feb-1997 fvdl

branches: 1.57.2; 1.57.4;
* Make sure a new socket is created when switching to/from NOCONN with
a mount
* Add extra printf statements to hopefully get some more info on lockups,
specifically when a send error is ignored.


# 1.56 31-Jan-1997 thorpej

- Add nfs_mountroot to nfs_vfsops.
- Only attempt to mount NFS root on a DV_IFNET class device.
- If nfs_boot_init() failes, return the error code to the caller.


# 1.55 22-Dec-1996 cgd

branches: 1.55.2;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...


# 1.54 03-Dec-1996 thorpej

Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.


# 1.53 02-Dec-1996 thorpej

NFS performance improvement from Doug Rabson/FreeBSD:

Improve the queuing algorithms used by NFS' asynchronous i/o. The
existing mechanism uses a global queue for some buffers and the
vp->b_dirtyblkhd queue for others. This turns sequential writes into
randomly ordered writes to the server, affecting both read and write
performance. The existing mechanism also copes badly with hung
servers, tending to block accesses to other servers when all the iods
are waiting for a hung server.

The new mechanism uses a queue for each mount point. All asynchronous
i/o goes through this queue which preserves the ordering of requests.
A simple mechanism ensures that the iods are shared out fairly between
active mount points.

Reviewed/integrated/approved by Frank van der Linden <fvdl@netbsd.org>


# 1.52 20-Oct-1996 fvdl

Enhancements from Matthias Drochner:
- Try V3 first for diskless booting. Fall back to V2 if V3 fails.
- optionally (option NFS_BOOT_TCP) try a TCP mount first
for diskless booting. Fall back to UDP if it fails.
- Enable switching between UDP and TCP for remounts.


# 1.51 13-Oct-1996 christos

revert kprintf changes


# 1.50 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.49 24-Jun-1996 pk

Ignore the mountpoint's `v_usecount' in nfs_unmount() if MNT_FORCE is on.
This takes care of two related problems:
- `umount -f' wouldn't work if someone's working directory is
the filesystem root.
- vfs_unmountall() would complain about a busy `/' on a
diskless setup.


# 1.48 14-Jun-1996 cgd

avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.


# 1.47 23-May-1996 fvdl

* Make mounts with symlinks work (needed for direct mounts with amd). PR #1917
* Never change the NQNFS flag and/or version when just doing an update mount.
Fixes a problem that made diskless booting impossible under some
circumstances.


Revision tags: netbsd-1-2-base
# 1.46 24-Mar-1996 fvdl

branches: 1.46.4;
Return earlier on error in nfs_statfs. Should fix problem reported by
both mrg and cgd.


# 1.45 17-Mar-1996 christos

Fix printf format strings.


# 1.44 13-Mar-1996 fvdl

Make readdirsize default to rsize if rsize is explicitly specified,
and readdirsize isn't.


# 1.43 18-Feb-1996 fvdl

Bring in a merge of Rick Macklem's NFSv3 code from Lite2


# 1.42 13-Feb-1996 gwr

Do the RPC to bootparamd a little later (just before the mountd call)
so that we do not ask for the "swap" path when swapping on disk.


# 1.41 09-Feb-1996 christos

nfs prototype changes


# 1.40 01-Feb-1996 jtc

Rename struct timespec fields to conform to POSIX.1b


# 1.39 19-Dec-1995 cgd

changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.38 13-Aug-1995 mycroft

splnet --> splsoftnet


# 1.37 18-Jun-1995 cgd

don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN


# 1.36 02-Jun-1995 mycroft

Fix more off by one errors.


# 1.35 18-Mar-1995 gwr

Print the "root/swap on ..." messages here.
Add NFS_BOOT_OPTIONS for things like NFSMNT_NOCONN.


# 1.34 09-Mar-1995 mycroft

copy*str() should use size_t.


# 1.33 18-Jan-1995 mycroft

Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.32 23-Aug-1994 pk

branches: 1.32.2;
When updating an NFS mountpoint, we cannot just increase `rsize' or `wsize'
without also adjusting the corresponding socket buffers. We could probably
call sbrelease/sbreserve/soreserve ourselves without much harm, but we'd
have to duplicate much of the logic in nfs_connect(). In stead, blow the
socket away entirely and let nfs_connect() do its job again.


# 1.31 18-Aug-1994 mycroft

More LIST/CIRCLEQ migration.


# 1.30 14-Aug-1994 gwr

Add the option NFS_BOOT_RWSIZE to allow diskless boot configuration
to start with a reduced NFS read and write size (need for wd8003).


# 1.29 12-Aug-1994 cgd

kill two errant spaces.


# 1.28 11-Aug-1994 gwr

Diskless boot will now bind the local socket to a reserved port to
satisfy picky servers. Also fix some missing initializations.
(Thanks to Chuck Cranor for PR#394 -- now fixed.)


Revision tags: netbsd-1-0-base
# 1.27 03-Jul-1994 mycroft

branches: 1.27.2;
Save FS type at mount time for some later tests.


# 1.26 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.25 28-Jun-1994 gwr

Minor nits: replace ... with ...
p->p_cred->pc_ucred p->p_ucred
x / DEV_BSIZE x >> DEV_BSHIFT


# 1.24 22-Jun-1994 pk

straighten out diskless swap code somewhat.


# 1.23 14-Jun-1994 gwr

Fix false "hits" in the attribute cache when booting diskless.
(Yet another thing that breaks when time.tv_sec is near zero...)


# 1.22 13-Jun-1994 gwr

New diskless boot code (uses RARP, bootparamd).


# 1.21 08-Jun-1994 mycroft

Update to 4.4-Lite fs code, with local changes.


# 1.20 18-May-1994 cgd

put sync printing in one place


# 1.19 13-May-1994 mycroft

Trivial function name change.


# 1.18 11-May-1994 mycroft

Cast some args to caddr_t.


# 1.17 23-Apr-1994 cgd

make fs types consistent over new kernels. also, some proto foo.


# 1.16 21-Apr-1994 cgd

Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.


# 1.15 18-Apr-1994 glass

revised nfs diskless support. uses bootp+rpc to gather parameters


# 1.14 14-Apr-1994 cgd

fs types are names now.


# 1.13 10-Apr-1994 cgd

make damn sure nothing's holding on the the mount point vnode


# 1.12 31-Mar-1994 glass

make panic string unique


# 1.11 21-Dec-1993 cgd

oops; fix last


# 1.10 21-Dec-1993 cgd

from jsp: Changed to get attributes of root node and
generate correct type, rather than assuming it's a directory.
This allows Amd direct mounts to work correctly.


# 1.9 18-Dec-1993 mycroft

Canonicalize all #includes.


# 1.8 07-Dec-1993 pk

Exclusive access when manipulating flag field in mount structure.


# 1.7 07-Dec-1993 pk

Don't allow the NFS_LOCKBITS to be set or reset from user land.
Allow other flags (SOFT,HARD,SPONGY, etc) to be altered by `mount -u'.


# 1.6 06-Dec-1993 pk

Allow changing of various NFS parameters by using `mount -u ...'.


# 1.5 19-Nov-1993 cgd

patch from Ukai Fumitoshi <ukai@kmc.kyoto-u.ac.jp>
to do the right thing with NFS fsid's and getnewfsid()


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 13-Jul-1993 cgd

branches: 1.4.4;
diskless changes made last time were hosed; were using NULL for
"no credentials" rather than NOCRED.


# 1.3 07-Jul-1993 cgd

changes from ws to support diskless booting... these are "OK" on inspection
and after testing... (actually, currently, none of the changed
code is even used...)


# 1.2 20-May-1993 cgd

more rcs id adding and header cleanup. i like vi macros!


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision