freebsd-skq/sys
Robert Watson 1ee624b31d The socket code upcalls into the NFS server using the so_upcall
mechanism so that early processing on mbufs can be performed before
a context switch to the NFS server threads.  Because of this, if
the socket code is running without Giant, the NFS server also needs
to be able to run the upcall code without relying on the presence on
Giant.  This change modifies the NFS server to run using a "giant
code lock" covering operation of the whole subsystem.  Work is in
progress to move to data-based locking as part of the NFSv4 server
changes.

Introduce an NFS server subsystem lock, 'nfsd_mtx', and a set of
macros to operate on the lock:

  NFSD_LOCK_ASSERT()    Assert nfsd_mtx owned by current thread
  NFSD_UNLOCK_ASSERT()  Assert nfsd_mtx not owned by current thread
  NFSD_LOCK_DONTCARE()  Advisory: this function doesn't care
  NFSD_LOCK()           Lock nfsd_mtx
  NFSD_UNLOCK()         Unlock nfsd_mtx

Constify a number of global variables/structures in the NFS server
code, as they are not modified and contain constants only:

  nfsrvv2_procid       nfsrv_nfsv3_procid      nonidempotent
  nfsv2_repstat        nfsv2_type              nfsrv_nfsv3_procid
  nfsrvv2_procid       nfsrv_v2errmap          nfsv3err_null
  nfsv3err_getattr     nfsv3err_setattr        nfsv3err_lookup
  nfsv3err_access      nfsv3err_readlink       nfsv3err_read
  nfsv3err_write       nfsv3err_create         nfsv3err_mkdir
  nfsv3err_symlink     nfsv3err_mknod          nfsv3err_remove
  nfsv3err_rmdir       nfsv3err_rename         nfsv3err_link
  nfsv3err_readdir     nfsv3err_readdirplus    nfsv3err_fsstat
  nfsv3err_fsinfo      nfsv3err_pathconf       nfsv3err_commit
  nfsrv_v3errmap

There are additional structures that should be constified but due
to their being passed into general purpose functions without const
arguments, I have not yet converted.

In general, acquire nfsd_mtx when accessing any of the global NFS
structures, including struct nfssvc_sock, struct nfsd, struct
nfsrv_descript.

Release nfsd_mtx whenever calling into VFS, and acquire Giant for
calls into VFS.  Giant is not required for any part of the
operation of the NFS server with the exception of calls into VFS.
Giant will never by acquired in the upcall code path.  However, it
may operate entirely covered by Giant, or not.  If debug.mpsafenet
is set to 0, the system calls will acquire Giant across all
operations, and the upcall will assert Giant.  As such, by default,
this enables locking and allows us to test assertions, but should not
cause any substantial new amount of code to be run without Giant.
Bugs should manifest in the form of lock assertion failures for now.

This approach is similar (but not identical) to modifications to the
BSD/OS NFS server code snapshot provided by BSDi as part of their
SMPng snapshot.  The strategy is almost the same (single lock over
the NFS server), but differs in the following ways:

- Our NFS client and server code bases don't overlap, which means
  both fewer bugs and easier locking (thanks Peter!).  Also means
  NFSD_*() as opposed to NFS_*().

- We make broad use of assertions, whereas the BSD/OS code does not.

- Made slightly different choices about how to handle macros building
  packets but operating with side effects.

- We acquire Giant only when entering VFS from the NFS server daemon
  threads.

- Serious bugs in BSD/OS implementation corrected -- the snapshot we
  received was clearly a work in progress.

Based on ideas from:	BSDi SMPng Snapshot
Reviewed by:		rick@snowhite.cis.uoguelph.ca
Extensive testing by:	kris
2004-05-24 04:06:14 +00:00
..
alpha Moved most of the "MI" definitions and declarations from <machine/profile.h> 2004-05-19 15:41:26 +00:00
amd64 Added profiling support for Xint0x80_syscall. 2004-05-23 19:06:15 +00:00
arm Remove two debugging printf(). 2004-05-22 13:15:14 +00:00
boot Markup fixes. 2004-05-16 22:51:36 +00:00
cam Quirk for Neuros USB audio device. 2004-05-02 19:24:23 +00:00
coda Device megapatch 5/6: 2004-02-21 21:32:15 +00:00
compat Small timer cleanups: 2004-04-30 20:51:55 +00:00
conf Build prof_machdep.c if profiling. 2004-05-23 18:38:27 +00:00
contrib This commit was generated by cvs2svn to compensate for changes in r129059, 2004-05-09 03:06:25 +00:00
crypto Fix a reentrancy issue in md5_calc(). 2004-01-27 18:57:21 +00:00
ddb Fixed DDB_NOKLDSYM on amd64's: 2004-05-18 05:30:06 +00:00
dev A handler for ioctl(SIOCSIFCAP) should not alter a bit in 2004-05-23 21:05:08 +00:00
fs Switch from using the vnode interlock to a private mutex in fifo_open() 2004-05-17 20:16:40 +00:00
geom - Change command name from 'config' to 'configure'. 2004-05-21 15:23:48 +00:00
gnu Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
i4b Convert callers to the new bus_alloc_resource_any(9) API. 2004-03-17 17:50:55 +00:00
i386 MFamd64 (1.117: made the FAKE_MCOUNT() in doreti work non-accidentally, 2004-05-23 17:25:46 +00:00
ia64 Moved most of the "MI" definitions and declarations from <machine/profile.h> 2004-05-19 15:41:26 +00:00
isa Move fdc from isa/fd.c to dev/fdc/fdc.c. The old files were 2004-05-17 05:46:16 +00:00
isofs/cd9660 Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
kern Implement the new KERN_PROC_RGID option, and also implement the 2004-05-22 23:11:44 +00:00
libkern Import libkern arm specific bits. 2004-05-14 12:28:31 +00:00
modules - Connect geom(8) and its libraries to the build. 2004-05-20 10:37:13 +00:00
net Consult parent's if_capenable for active VLAN-related capabilities. 2004-05-23 22:32:15 +00:00
net80211 Link state change notification of ethernet media to the routing socket. 2004-05-05 15:48:06 +00:00
netatalk Remove redundant call to soisdisconnected() from ddp_abort(), as it 2004-05-05 03:34:37 +00:00
netatm These are changes to allow to use the Intel C/C++ compiler (lang/icc) 2004-03-12 21:45:33 +00:00
netgraph Whitespace nit. 2004-05-19 11:35:03 +00:00
netinet When checking for possible port theft, skip over a TCP inpcb 2004-05-20 06:35:02 +00:00
netinet6 Fix a bug which I discovered recently while doing IPv6 testing at 2004-05-14 03:57:17 +00:00
netipsec use correct address for SADB_EXT_ADDRESS_DST in key_do_allocsa_policy 2004-05-03 05:15:53 +00:00
netipx Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
netkey avoid duplicate free. 2004-01-25 17:18:12 +00:00
netnatm Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
netncp Make the process_exit eventhandler run without Giant. Add Giant hooks 2004-03-14 02:06:28 +00:00
netsmb Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
nfs Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfs4client Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
nfsclient Make vm_page's PG_ZERO flag immutable between the time of the page's 2004-05-06 05:03:23 +00:00
nfsserver The socket code upcalls into the NFS server using the so_upcall 2004-05-24 04:06:14 +00:00
opencrypto kthread_exit() no longer requires Giant, so don't force callers to acquire 2004-03-05 22:42:17 +00:00
pc98 MFi386: revision 1.1160. 2004-05-18 11:56:56 +00:00
pccard Convert callers to the new bus_alloc_resource_any(9) API. 2004-03-17 17:50:55 +00:00
pci Only initialize the if_sis callout as MPSAFE if debug.mpsafenet is set 2004-05-23 22:22:29 +00:00
posix4 The sem_timedwait() and ksem_timedwait() functions both 2004-02-03 22:27:03 +00:00
powerpc Moved most of the "MI" definitions and declarations from <machine/profile.h> 2004-05-19 15:41:26 +00:00
rpc Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
security Remove dead code. (This loop counted the number of rules, but the count 2004-05-15 20:55:19 +00:00
sparc64 Use unsigned types for the arguments of the atomic(9) operations, 2004-05-22 00:52:16 +00:00
sys Define a KERN_PROC_RGID option for kvm_getprocs(). 2004-05-22 23:08:49 +00:00
tools Correct $FreeBSD$ style. 2004-04-16 05:22:11 +00:00
ufs Upon further review it was decided this piece of the msync(2) 2004-05-21 12:05:48 +00:00
vm To date, unwiring a fictitious page has produced a panic. The reason 2004-05-22 04:53:51 +00:00
Makefile Try harder not to compile anything in sys/boot for arm. 2004-05-16 00:19:12 +00:00