Commit Graph

1238 Commits

Author SHA1 Message Date
matt 19e6c76b2d Rename rb.h to rbtree.h, as it is more appropriate (c.f. ptree.h). Also
helps find code that hasn't been updated to use the new rbtree API.
2010-09-25 01:42:38 +00:00
rmind 879d5dfb5e Fixes/improvements to RB-tree implementation:
1. Fix inverted node order, so that negative value from comparison operator
   would represent lower (left) node, and positive - higher (right) node.
2. Add an argument (i.e. "context"), passed to comparison operators.
3. Change rb_tree_insert_node() to return a node - either inserted one or
   already existing one.
4. Amend the interface to manipulate the actual object, instead of the
   rb_node (in a similar way as Patricia-tree interface does).
5. Update all RB-tree users accordingly.

XXX: Perhaps rename rb.h to rbtree.h, since cleaning-up..

1-3 address the PR/43488 by Jeremy Huddleston.

Passes RB-tree regression tests.
Reviewed by: matt@, christos@
2010-09-24 22:51:50 +00:00
pooka 6790af89a6 Do not return a garbage vnode in vpp if fhtovp fails.
Fixes PR kern/43745 for nfs.
2010-08-12 09:41:10 +00:00
hannken fb62bef947 Make holding v_interlock mandatory for callers of vget().
Announced some time ago on tech-kern.
2010-07-21 17:52:09 +00:00
hannken 11163f82c2 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.
2010-07-09 08:25:57 +00:00
hannken 245651a23d Remove vlockmgr(). Generic vnode lock operations now use a rwlock located
in the vnode.  All LK_* flags move from sys/lock.h to sys/vnode.h.  Calls
to vlockmgr() in file systems get replaced with VOP_LOCK() or VOP_UNLOCK().

Welcome to 5.99.34.

Discussed on tech-kern.
2010-07-01 13:00:54 +00:00
hannken 1423e65b26 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.
2010-06-24 12:58:48 +00:00
hannken f6c438ba23 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.
2010-06-24 07:54:46 +00:00
jakllsch 4d4f33141e Fix memory leak during some NFS writes. 2010-06-12 21:10:55 +00:00
dholland 15fb978372 nfs_statvfs should return NFS_MAXNAMLEN, not MAXNAMLEN.
(Compile-tested only, but that should be ok)
2010-05-15 20:24:57 +00:00
pooka 0c20c076ce Enforce RLIMIT_FSIZE before VOP_WRITE. This adds support to file
system drivers where it was missing from and fixes one buggy
implementation.  The arguably weird semantics of the check are
maintained (v_size vs. va_bytes, overwrite).
2010-04-23 15:38:46 +00:00
pooka 242bf1c3e7 Stop exposing fifofs internals and leave only fifo_vnodeop_p visible. 2010-03-29 13:11:32 +00:00
chs e23026927c in nfs_bootparam(), set the corresponding flag for each field that we fill in. 2010-03-21 00:10:40 +00:00
pooka b943545a94 don't create unused fs_nfs.h 2010-03-02 23:49:11 +00:00
pooka 77486bda39 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.
2010-03-02 23:19:09 +00:00
yamt b1ff79355f nfs_msg: #if 0 out tprintf for now and comment why. 2010-02-13 11:17:30 +00:00
yamt 5a779e86cd nfs_request: fix races which break congestion window and make nfs client stuck. 2010-01-19 13:39:04 +00:00
yamt b92b080272 remove unused r_timer member. 2010-01-19 13:29:40 +00:00
pooka c3183f3251 The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase).  Plenty of mix'n match upper/lowercase has creeped
into the tree since then.  Nuke the macros and convert all callsites
to lowercase.

no functional change
2010-01-08 11:35:07 +00:00
christos 44768c61d0 put nuidhash_max in a file that is shared between server and client code. 2009-12-31 20:01:33 +00:00
christos 3506b644ed handle the nuidhash_max lossage differently 2009-12-31 19:38:16 +00:00
christos 41b6684af0 appease gcc. 2009-12-31 19:31:31 +00:00
christos 30da2a8fa7 nuidhash_max is needed by sys_nfssvc 2009-12-31 19:30:45 +00:00
pooka 3142d3ac31 Define namei flag INRENAME and set it if a lookup operation is part
of rename.  This helps with building better asserts for rename in
the DELETE lookup ... the RENAME lookup is quite obviously a part
of rename.
2009-12-23 01:09:24 +00:00
dyoung 8641587693 For readability's sake, write NULL instead of (type *)0. 2009-12-06 18:00:15 +00:00
cegger 9480c51b04 Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
2009-11-07 07:27:40 +00:00
bouyer 5dabc83466 Handle EWOULDBLOCK the same way as EPIPE. It seems the TCP socket layer
can return EWOULDBLOCK on some occasion when the connection is broken.
2009-11-05 08:11:24 +00:00
snj 0d31d3264f Remove 3rd and 4th clauses. OK cl@ (copyright holder). 2009-10-23 02:32:33 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
pooka 65aa3ef107 If send fails with EMSGSIZE for whatever reason, it's unlikely to
succeed no matter how hard we retry.  So just fail the request.
2009-10-16 23:36:05 +00:00
dholland 8d36057243 Move a big wodge of symlink-following code from nfsd to inside
lookup_for_nfsd(). This code is, or at least should be, the same as
the regular symlink-following code plus an extra flag nfsd needs.

The two lots of code can/will be merged in the future.
2009-09-27 17:23:53 +00:00
dholland fb458255a3 Rename lookup() to lookup_for_nfsd(), to make it clear just whose
private backdoor entry point this is.

Also, clone the lookup_for_nfsd() entry point as
lookup_for_nfsd_index(), for use by a different call site in nfsd that
does different unclean things with nameidata.
2009-09-27 17:19:07 +00:00
pooka b7f6f78fc9 Remove stale comment about super user. no functional change 2009-09-14 14:37:52 +00:00
tls 8352accb45 ...and one more missed in the earlier commit (sigh). Kernels should build
again now.
2009-09-03 21:06:21 +00:00
tls 41715850eb Missed this file in previous commit, accidentally checked in fix to local
repository copy!  Sorry about that, folks.
2009-09-03 20:59:12 +00:00
apb 72648fe99b Use pid_t, not short, for a pid.
Part of PR 41255 from Kurt Lidl.
2009-07-14 20:59:54 +00:00
roy 5f399f5c68 Use a function to add extra data to the vendor area so that data added
remains constant for both DISCOVER and REQUEST messages.
2009-07-10 12:16:31 +00:00
roy eb66460837 Protect against short IP addresses in the DHCP message. 2009-07-10 02:41:39 +00:00
roy 0aeddffdd4 When using DHCP, request the parameters that we need. Fixes PR kern/38830.
Thanks to Tim McIntosh.
2009-07-10 01:29:54 +00:00
christos e234b387dc The compatibility call to re-export from sys_mount() calls
mountd_set_exports_list, with the mnt_updating mutex held. Account for that
to avoid a locking against myself panic.
2009-07-07 14:09:05 +00:00
elad 870920260d Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

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

No objections on tech-kern@:

	http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
2009-06-23 19:36:38 +00:00
ad fc7505ae27 Broken assertion. 2009-05-23 18:19:19 +00:00
ad a742b7d3d8 - Cosmetic change to previous.
- Add a comment.
2009-05-23 15:59:30 +00:00
ad d4b01cb0fb - Fix a race between umount()/mount() and nfssvc().
- Toss netexport state on nfsserver module unload.
2009-05-23 15:31:21 +00:00
ad abc14f1bc4 Fix a crash when unloading nfsserver module. 2009-05-23 14:45:18 +00:00
ad 7839123ed3 Remove pointless error check. 2009-05-23 14:44:56 +00:00
yamt be2d4d69b3 nfs_clearcommit: fix a race with vnode cleaning. 2009-05-14 15:42:22 +00:00
yamt 8276e4de1a nfs_lookup: vn_lock the vnode returned by cache_lookup_raw
before feeding it to VOP_GETATTR.  it's necessary because the vnode might
be being cleaned by getcleanvnode.

it's an instance of more general races between vnode reclaim and
unlocked VOPs.  however, this one happens somewhat often because it can be
triggered by getnewvnode rather than revoke.
2009-05-10 05:18:26 +00:00
yamt dd0402b09c restore lines, esp. a vrele() call, which i mistakenly removed
in the previous.  (rev.1.276)
2009-05-10 03:51:43 +00:00
cegger a531bda091 correct previous: use %zu for BOOTP_SIZE_(MIN,MAX).
Pointed out by David Holland
2009-05-06 05:34:12 +00:00
cegger 4bbacd3411 buildfix: use %d for BOOTP_SIZE_(MIN,MAX).
Makes i386 ALL kernel build again.
2009-05-05 12:48:31 +00:00
yamt 6f0983460b when freeing cn_pnbuf, make it NULL if DIAGNOSTIC. 2009-05-04 06:05:19 +00:00
yamt fc99505dcc nfs_lookup: handle the case where the vnode returned cache_lookup_raw is
being reclaimed by another thread.  after recent changes in cache_lookup_raw,
there's a race between cache_lookup_raw/vtryget and getcleanvnode/vclean.
PR/41028.
2009-05-04 05:59:35 +00:00
yamt 5f6d027dab nfs_lookup: add an assertion. 2009-05-04 05:50:17 +00:00
yamt ffdcb971f2 nfs_lookup: comments. no functional changes. 2009-05-04 05:49:00 +00:00
manu 20f56b3015 - Silence warning when running with debug enabled
- Remind the administrator about the required DHCP option when some are
  missing, instead of silently failing, you stupid computer!
2009-05-02 21:06:51 +00:00
bouyer 615c2e4e8d PR kern/41154: possible races in NFS server code
Fix some of the races (but probably not all of them) in the NFS server code.
nfssvc_nfsd(): change a splsoftclock()/spx() to mutex_enter/exit(&nfsd_lock)
 (I guess it was forgotten when the nfsd code was made SMP safe)
m_freem(nd_nam) in nfsrv_slpderef() instead of nfsrv_zapsock() to
 avoid possible use after free in nfssvc_nfsd()
Fix nfsrv_slpderef() to not release  nfsd_lock before testing SLP_VALID
 and reaquiring it just after. This could cause a use after free
 of the slp if one thread is in nfsrv_slpderef() and the other one grabs
 slp from nfssvc_sockpending and zap it.
2009-04-10 19:04:14 +00:00
bouyer 2f4b50f71c PR kern/41158: nfs_rename() locking against myself
nfsrv_rename() can exit without calling genfs_renamelock_exit() because
the nfsm_reply() can do return (0) on error.
Change nfsm_reply to use 'error = 0; goto nfsmout' instead.
Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other
macros calling it.
As a side effect it could fix a missing vrele(dirp) in various place where
nfsm_reply could return(0).
2009-04-10 18:58:50 +00:00
cegger b8817e4aed ansify function definitions 2009-03-15 17:14:40 +00:00
dsl 82357f6d42 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.
2009-03-14 21:04:01 +00:00
dsl 454af1c0e8 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.)
2009-03-14 15:35:58 +00:00
dsl 02cdf4d2c8 Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
2009-03-14 14:45:51 +00:00
yamt 6f8f12ad37 nfs_lookup: fix a comment. 2009-03-13 15:01:29 +00:00
yamt d32e59ebfc nfs_bioread: don't truncate values in a debug printf. 2009-03-13 15:00:34 +00:00
nisimura e12e37e63e Update comments to reflect realities; the filenames were changed in 1997
and another one was added years ago.
2009-03-04 06:56:25 +00:00
ad 350a5f88e7 PR kern/40491 5.0: nfs timer can crash/break on smp
Hack around it by acquiring softnet_lock around the client-side timer loop.
2009-02-04 20:36:54 +00:00
yamt 812bb0d164 restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.
2009-01-21 06:59:29 +00:00
mrg f41b56aff5 Actually enforce the maximum timeout (60s by default) rather
than backing off to 256*SRTT.  This is why it sometimes could take
hours for a NFS mount to come back when the server returned.

contributed anonymously.
2009-01-18 09:45:05 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
christos ed795a66a7 protect sillyrename with _KERNEL 2009-01-02 21:06:11 +00:00
ad 27bc6a2391 - Don't vput() a vnode that we do not hold locked.
- Eliminate one of the few remaining uses of LK_CANRECURSE.
2009-01-02 12:57:29 +00:00
cegger 9b87d582bd kill MALLOC and FREE macros. 2008-12-17 20:51:31 +00:00
pooka 4b18ba9da3 nfsd_use_loan: int -> bool 2008-12-03 14:56:05 +00:00
pooka 0fa0158c37 Use kmem instead of malloc to avoid hassle with dynamically attaching
a malloc type.  Makes nfsserver-as-a-module work.

reported on current-users & tested by Geoff Wing
2008-11-28 07:23:22 +00:00
pooka bd6148602f g/c unused malloc types 2008-11-28 06:47:08 +00:00
pooka 83f531e6a8 Use struct nfs_fattr in struct flrep instead of uint32_t array
acrobatics to get rid of type punning warning.
2008-11-27 14:04:58 +00:00
pooka 1ba9363d08 Comment police. No functional or GENERIC size change. 2008-11-25 14:28:42 +00:00
pooka ad71247a89 When testing if a file system handles file handles (ha ha ha), be
content with just the vp-to-fh-size check.
(removes a very weird error path in the code)
2008-11-25 14:04:23 +00:00
mrg d7d9597105 avoid noisy nfs_timer/nfs_reply DEBUG output that occurs when the
NFS server goes away.  use ratelimit(9) and only print the console
error once every 10 seconds.  PR#31562.
2008-11-23 08:22:07 +00:00
ad 92ce8c6a3d 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
2008-11-19 18:35:57 +00:00
ad df8183316d Remove COMPAT ifdefs that might as well be comments (i.e., they cost us
almost nothing).
2008-11-14 13:33:55 +00:00
christos 2a274197af - allocate 8 pointers on the stack to avoid stack overflow in nfs.
- make that 8 a constant
- remove bogus panic
2008-10-31 20:42:41 +00:00
cegger 6b4fb5f4de make this build again without having
NFS_BOOT_BOOTSTATIC, NFS_BOOT_BOOTP, NFS_BOOT_DHCP or NFS_BOOT_BOOTPARAM
defined.

I uncovered this case when compiling rump.
2008-10-27 13:24:01 +00:00
cegger c479884027 change nfs boot behaviour to automatically try next boot method if boot information are incomplete to succeed.
That way, it is possible combine static and dhcp boot:
  For example, to boot diskless you can specify the nfs-server and the rootpath statically. All other information will be taken via dhcp.

Patch has been presented on port-xen, tech-kern and tech-net:
http://mail-index.netbsd.org/port-xen/2008/10/24/msg004488.html
http://mail-index.netbsd.org/tech-kern/2008/10/24/msg003255.html
http://mail-index.netbsd.org/tech-net/2008/10/24/msg000864.html

No comments, no objections.
2008-10-27 10:58:22 +00:00
cegger cac6895435 - ansify function definition
- de- __P
- u_int32_t -> uint32_t

No functional changes.
2008-10-24 17:17:12 +00:00
matt b55adffee3 Don't need nfs_vfs_reinit anymore since we don't resize tables anymore.
Move reinit code to init case.
2008-10-22 12:29:35 +00:00
matt a42078ef92 Change NFS to use a RB-tree for its FH->nfsnode lookups. 2008-10-22 11:36:06 +00:00
christos 02934a6249 Requested by yamt:
- In getpages don't allocate if we are not locked
- Use kmem_alloc instead of malloc and don't sleep

Also provide a 64 entry stack array so we don't have to allocate in the
common case.
2008-10-17 14:24:43 +00:00
dogcow cff6728f44 it appears the previous commit's sacrifice was "successful compilation with
NFS_V2_ONLY defined".
2008-10-17 06:40:21 +00:00
christos a7242b8e23 Another sacrifice to the stack protector gods. 2008-10-16 22:04:22 +00:00
christos 96d7a83037 don't use variable allocation on the stack. 2008-10-16 19:33:48 +00:00
pooka c66ebd3d57 For NFSV3CREATE_EXCLUSIVE verifier, just use arc4random() instead
of the first inet address on INET systems (which is likely to be
localhost).
2008-10-15 14:21:35 +00:00
christos ff1eb234c1 do the proper ifdef dance for non-inet families 2008-10-09 14:38:21 +00:00
pooka ae509fabab Use atomic op to get next xid. Initialize value with arc4random()
at nfs init time instead system time based trickery intermingled
with the runtime code.

le bouef: kills last simple_lock from nfs
2008-10-09 00:11:39 +00:00
pooka d9f75a894c nuke outdated comment 2008-10-07 01:20:37 +00:00
pooka f4da52c698 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.
2008-09-30 21:12:48 +00:00
pooka c7637a677e Initialize nfsnode pools and malloc type dynamically in the
constructor instead of depending on link sets.  Consequently, rename
nfs_nh{init,reinit,done} to nfs_node_{init,reinit,done}, respectively,
to better convey the function.
2008-09-30 14:29:39 +00:00
pooka 7f617ba79e Apply #ifdef modern art to make NFSSERVER-without-NFS possible. 2008-09-30 14:25:15 +00:00
pooka b334ad7b43 Don't free nd_mrep in case of no reply. It is (at least in one
case) freed already within the rpc handler.

XXX: this line and another was originally committed with "don't
leak mbufs", but given that currently it can double-free an mbuf
and essentially crash the system, I'll opt for the leak.  Needless
to say, this needs revisiting, but that requires a large scale
campaign due to the sticky nature of nfsm love.
2008-09-28 00:10:18 +00:00
plunky fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00