diff options
author | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
commit | 10f666af84d48e89e4e2960415c9b616fce4077f (patch) | |
tree | 88a944de263165091f0a18abeedbaaccec532407 /sys/nfsserver | |
parent | 0960d7e91af3428ffba89b42228d82d8afaa0389 (diff) | |
download | FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.zip FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.tar.gz |
This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.
The system boots and can mount UFS filesystems.
Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
Mount_std mounts will not work until the getfsent
library routine is changed.
Reviewed by: various people
Submitted by: Jeffery Hsu <hsu@freebsd.org>
Diffstat (limited to 'sys/nfsserver')
-rw-r--r-- | sys/nfsserver/nfs.h | 168 | ||||
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 32 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvcache.c | 2 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsock.c | 7 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 26 | ||||
-rw-r--r-- | sys/nfsserver/nfs_syscalls.c | 4 | ||||
-rw-r--r-- | sys/nfsserver/nfsm_subs.h | 3 | ||||
-rw-r--r-- | sys/nfsserver/nfsrvcache.h | 3 | ||||
-rw-r--r-- | sys/nfsserver/nfsrvstats.h | 168 |
9 files changed, 276 insertions, 137 deletions
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h index db41859..73a018c 100644 --- a/sys/nfsserver/nfs.h +++ b/sys/nfsserver/nfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1989, 1993 + * Copyright (c) 1989, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -33,19 +33,19 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs.h 8.1 (Berkeley) 6/10/93 + * @(#)nfs.h 8.4 (Berkeley) 5/1/95 * $FreeBSD$ */ #ifndef _NFS_NFS_H_ #define _NFS_NFS_H_ -#include <nfs/rpcv2.h> - /* * Tunable constants for nfs */ +#ifdef KERNEL + #define NFS_MAXIOVEC 34 #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ @@ -69,7 +69,7 @@ #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ -#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ +#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ #ifndef NFS_GATHERDELAY #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ @@ -89,30 +89,9 @@ /* * XXX - * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but - * until then... - * Same goes for sys/malloc.h, which needs M_NFSDIROFF, - * M_NFSRVDESC and M_NFSBIGFH added. - * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an - * exclusive create. * The B_INVAFTERWRITE flag should be set to whatever is required by the * buffer cache code to say "Invalidate the block after it is written back". */ -#ifndef B_NEEDCOMMIT -#define B_NEEDCOMMIT B_APPENDWRITE -#endif -#ifndef M_NFSRVDESC -#define M_NFSRVDESC M_TEMP -#endif -#ifndef M_NFSDIROFF -#define M_NFSDIROFF M_TEMP -#endif -#ifndef M_NFSBIGFH -#define M_NFSBIGFH M_TEMP -#endif -#ifndef VA_EXCLUSIVE -#define VA_EXCLUSIVE 0 -#endif #ifdef __FreeBSD__ #define B_INVAFTERWRITE B_NOCACHE #else @@ -120,20 +99,6 @@ #endif /* - * These ifdefs try to handle the differences between the various 4.4BSD-Lite - * based vfs interfaces. - * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to - * differentiate between NetBSD-1.0 and NetBSD-current, so.. - * I also don't know about BSDi's 2.0 release. - */ -#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPLEASE 1 -#endif -#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPREVOKE 1 -#endif - -/* * The IO_METASYNC flag should be implemented for local file systems. * (Until then, it is nothin at all.) */ @@ -164,13 +129,114 @@ #define NFS_SVCALLOC 256 #define NFS_UIDALLOC 128 +#endif /* KERNEL */ + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ +#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ +#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ +#define NFSMNT_DISMNT 0x00800000 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ +#define NFSMNT_WANTSND 0x02000000 /* Want above */ +#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x08000000 /* Want above */ +#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ + +/* + * Arguments to mount NFS + */ +#define NFS_ARGSVERSION 3 /* change when nfs_args changes */ +struct nfs_args { + int version; /* args structure version number */ + struct sockaddr *addr; /* file server address */ + int addrlen; /* length of address */ + int sotype; /* Socket type */ + int proto; /* and Protocol */ + u_char *fh; /* File handle to be mounted */ + int fhsize; /* Size, in bytes, of fh */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int readdirsize; /* readdir size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int maxgrouplist; /* Max. size of group list */ + int readahead; /* # of blocks to readahead */ + int leaseterm; /* Term (sec) of lease */ + int deadthresh; /* Retrans threshold */ + char *hostname; /* server's name */ +}; + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ +#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ +#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ +#define NFSMNT_DISMNT 0x00800000 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ +#define NFSMNT_WANTSND 0x02000000 /* Want above */ +#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x08000000 /* Want above */ +#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ + /* * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs * should ever try and use it. */ struct nfsd_args { int sock; /* Socket to serve */ - caddr_t name; /* Client address for connection based sockets */ + caddr_t name; /* Client addr for connection based sockets */ int namelen; /* Length of name */ }; @@ -200,6 +266,10 @@ struct nfsd_cargs { }; /* + * XXX to allow amd to include nfs.h without nfsproto.h + */ +#ifdef NFS_NPROCS +/* * Stats structure */ struct nfsstats { @@ -237,6 +307,7 @@ struct nfsstats { int srvnqnfs_getleases; int srvvop_writes; }; +#endif /* * Flags for nfssvc() system call. @@ -267,7 +338,7 @@ struct nfsstats { * such as SIGALRM will not expect file I/O system calls to be interrupted * by them and break. */ -#if defined(KERNEL) || defined(_KERNEL) +#ifdef KERNEL struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ @@ -482,6 +553,8 @@ extern int nfsd_head_flag; !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ sizeof (struct ucred))) + +int nfs_init __P((struct vfsconf *vfsp)); int nfs_reply __P((struct nfsreq *)); int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); @@ -516,14 +589,12 @@ int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); void nfs_nhinit __P((void)); void nfs_timer __P((void*)); u_long nfs_hash __P((nfsfh_t *,int)); -void nfsrv_slpderef __P((struct nfssvc_sock *slp)); int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); -void nfsrv_cleancache __P((void)); int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); -int nfs_init __P((void)); void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); +void nfsrv_cleancache __P((void)); int nfs_connect __P((struct nfsmount *,struct nfsreq *)); -void nfs_disconnect __P((struct nfsmount *nmp)); +void nfs_disconnect __P((struct nfsmount *)); int nfs_getattrcache __P((struct vnode *,struct vattr *)); int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); @@ -531,7 +602,6 @@ int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); void nfsrv_init __P((int)); void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); -void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); void nfsrvw_sort __P((gid_t [],int)); void nfsrv_setcred __P((struct ucred *,struct ucred *)); int nfs_writebp __P((struct buf *,int)); @@ -594,8 +664,8 @@ int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq)); - - +void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); +void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* KERNEL */ #endif diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 3946778..28a705a 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -1723,7 +1723,7 @@ nfsrv_remove(nfsd, slp, procp, mrq) } out: if (!error) { - vnode_pager_uncache(vp); + vnode_pager_uncache(vp, procp); nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); @@ -1900,7 +1900,7 @@ out: nqsrv_getl(tdvp, ND_WRITE); if (tvp) { nqsrv_getl(tvp, ND_WRITE); - (void) vnode_pager_uncache(tvp); + (void) vnode_pager_uncache(tvp, procp); } error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); @@ -2027,11 +2027,7 @@ out: if (!error) { nqsrv_getl(vp, ND_WRITE); nqsrv_getl(xp, ND_WRITE); -#if defined(__NetBSD__) || defined(__FreeBSD__) - error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); -#else error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd); -#endif } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) @@ -2479,7 +2475,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) int siz, cnt, fullsiz, eofflag, rdonly, cache, ncookies; int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t frev, off, toff, verf; - u_int *cookies = NULL, *cookiep; + u_long *cookies = NULL, *cookiep; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2520,7 +2516,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(getret, &at); return (0); } - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, procp); MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); #ifdef __NetBSD__ ncookies = siz / (5 * NFSX_UNSIGNED); /*7 for V3, but it's an est. so*/ @@ -2538,16 +2534,12 @@ again: io.uio_rw = UIO_READ; io.uio_procp = (struct proc *)0; eofflag = 0; - VOP_LOCK(vp); -#ifndef __NetBSD__ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); -#else - error = VOP_READDIR(vp, &io, cred, &eofflag, cookies, ncookies); -#endif off = (off_t)io.uio_offset; if (!cookies && !error) error = NFSERR_PERM; @@ -2556,7 +2548,7 @@ again: if (!error) error = getret; } - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, procp); if (error) { vrele(vp); free((caddr_t)rbuf, M_TEMP); @@ -2751,7 +2743,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache, dirlen, ncookies; u_quad_t frev, off, toff, verf; - u_int *cookies = NULL, *cookiep; + u_long *cookies = NULL, *cookiep; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2787,7 +2779,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(getret, &at); return (0); } - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, procp); MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); #ifdef __NetBSD__ ncookies = siz / (7 * NFSX_UNSIGNED); @@ -2805,19 +2797,15 @@ again: io.uio_rw = UIO_READ; io.uio_procp = (struct proc *)0; eofflag = 0; - VOP_LOCK(vp); -#ifndef __NetBSD__ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); -#else - error = VOP_READDIR(vp, &io, cred, &eofflag, cookies, ncookies); -#endif off = (u_quad_t)io.uio_offset; getret = VOP_GETATTR(vp, &at, cred, procp); - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, procp); if (!cookies && !error) error = NFSERR_PERM; if (!error) diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c index 835ec06..efff221 100644 --- a/sys/nfsserver/nfs_srvcache.c +++ b/sys/nfsserver/nfs_srvcache.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs_srvcache.c 8.1 (Berkeley) 6/10/93 + * @(#)nfs_srvcache.c 8.3 (Berkeley) 3/30/95 * $FreeBSD$ */ diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c index addd59f..ed16333 100644 --- a/sys/nfsserver/nfs_srvsock.c +++ b/sys/nfsserver/nfs_srvsock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1989, 1991, 1993 + * Copyright (c) 1989, 1991, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs_socket.c 8.3 (Berkeley) 1/12/94 + * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 * $FreeBSD$ */ @@ -1925,6 +1925,9 @@ nfs_getreq(nd, nfsd, has_header) struct mbuf *mrep, *md; register struct nfsuid *nuidp; struct timeval tvin, tvout; +#if 0 /* until encrypted keys are implemented */ + NFSKERBKEYSCHED_T keys; /* stores key schedule */ +#endif mrep = nd->nd_mrep; md = nd->nd_md; diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 1feadd6..5f83bf5 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -100,6 +100,7 @@ enum vtype nv3tov_type[8]= { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO }; +int nfs_mount_type; int nfs_ticks; struct nfs_reqq nfs_reqq; @@ -1093,7 +1094,8 @@ nfsm_strtmbuf(mb, bpos, cp, siz) * Called once to initialize data structures... */ int -nfs_init() +nfs_init(vfsp) + struct vfsconf *vfsp; { register int i; @@ -1116,6 +1118,7 @@ nfs_init() printf("struct nfsuid bloated (> %dbytes)\n",NFS_UIDALLOC); printf("Try unionizing the nu_nickname and nu_flag fields\n"); } + nfs_mount_type = vfsp->vfc_typenum; nfsrtt.pos = 0; rpc_vers = txdr_unsigned(RPC_VER2); rpc_call = txdr_unsigned(RPC_CALL); @@ -1170,10 +1173,10 @@ nfs_init() * of the system can call us, if we are loadable. */ #ifndef NFS_NOSERVER - lease_check = nfs_lease_check; + lease_check_hook = nqnfs_vop_lease_check; #endif lease_updatetime = nfs_lease_updatetime; - vfsconf[MOUNT_NFS]->vfc_refcount++; /* make us non-unloadable */ + vfsp->vfc_refcount++; /* make us non-unloadable */ #ifdef VFS_LKM sysent[SYS_nfssvc].sy_narg = 2; sysent[SYS_nfssvc].sy_call = nfssvc; @@ -1212,7 +1215,6 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) register struct vattr *vap; register struct nfs_fattr *fp; register struct nfsnode *np; - register struct nfsnodehashhead *nhpp; register long t1; caddr_t cp2; int error = 0, rdev; @@ -1222,6 +1224,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) struct timespec mtime; struct vnode *nvp; int v3 = NFS_ISV3(vp); + struct proc *p = curproc; md = *mdp; t1 = (mtod(md, caddr_t) + md->m_len) - *dposp; @@ -1284,7 +1287,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) * then release it here. */ if (vtyp != VREG && VOP_ISLOCKED(vp)) - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, p); vp->v_type = vtyp; if (vp->v_type == VFIFO) { vp->v_op = fifo_nfsv2nodeop_p; @@ -1295,8 +1298,11 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) if (nvp) { /* * Discard unneeded vnode, but save its nfsnode. + * Since the nfsnode does not have a lock, its + * vnode lock has to be carried over. */ - LIST_REMOVE(np, n_hash); + nvp->v_vnlock = vp->v_vnlock; + vp->v_vnlock = NULL; nvp->v_data = vp->v_data; vp->v_data = NULL; vp->v_op = spec_vnodeop_p; @@ -1306,8 +1312,6 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) * Reinitialize aliased node. */ np->n_vnode = nvp; - nhpp = NFSNOHASH(nfs_hash(np->n_fhp, np->n_fhsize)); - LIST_INSERT_HEAD(nhpp, np, n_hash); *vpp = vp = nvp; } } @@ -1714,13 +1718,14 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag) int *rdonlyp; int kerbflag; { + struct proc *p = curproc; /* XXX */ register struct mount *mp; register int i; struct ucred *credanon; int error, exflags; *vpp = (struct vnode *)0; - mp = getvfs(&fhp->fh_fsid); + mp = vfs_getvfs(&fhp->fh_fsid); if (!mp) return (ESTALE); error = VFS_FHTOVP(mp, &fhp->fh_fid, nam, vpp, &exflags, &credanon); @@ -1751,7 +1756,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag) nfsrv_object_create(*vpp); if (!lockflag) - VOP_UNLOCK(*vpp); + VOP_UNLOCK(*vpp, 0, p); return (0); } @@ -1947,3 +1952,4 @@ nfsrv_object_create(struct vnode *vp) { return vfs_object_create(vp, curproc, curproc?curproc->p_ucred:NULL, 1); } #endif /* NFS_NOSERVER */ + diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 734fe79..24d4bd6 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs_syscalls.c 8.3 (Berkeley) 1/4/94 + * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 * $FreeBSD$ */ @@ -97,7 +97,6 @@ static int nfssvc_iod __P((struct proc *)); static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON]; - #ifndef NFS_NOSERVER int nfsd_waiting = 0; static struct nfsdrt nfsdrt; @@ -1051,6 +1050,7 @@ nfsmout: } #ifndef NFS_NOSERVER + /* * Derefence a server socket structure. If it has no more references and * is no longer valid, you can throw it away. diff --git a/sys/nfsserver/nfsm_subs.h b/sys/nfsserver/nfsm_subs.h index ac1a159..cd37c59 100644 --- a/sys/nfsserver/nfsm_subs.h +++ b/sys/nfsserver/nfsm_subs.h @@ -33,10 +33,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfsm_subs.h 8.1 (Berkeley) 6/16/93 + * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 * $FreeBSD$ */ + #ifndef _NFS_NFSM_SUBS_H_ #define _NFS_NFSM_SUBS_H_ diff --git a/sys/nfsserver/nfsrvcache.h b/sys/nfsserver/nfsrvcache.h index 38c9657..2cfa694 100644 --- a/sys/nfsserver/nfsrvcache.h +++ b/sys/nfsserver/nfsrvcache.h @@ -33,10 +33,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfsrvcache.h 8.1 (Berkeley) 6/10/93 + * @(#)nfsrvcache.h 8.3 (Berkeley) 3/30/95 * $FreeBSD$ */ + #ifndef _NFS_NFSRVCACHE_H_ #define _NFS_NFSRVCACHE_H_ diff --git a/sys/nfsserver/nfsrvstats.h b/sys/nfsserver/nfsrvstats.h index db41859..73a018c 100644 --- a/sys/nfsserver/nfsrvstats.h +++ b/sys/nfsserver/nfsrvstats.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1989, 1993 + * Copyright (c) 1989, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -33,19 +33,19 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)nfs.h 8.1 (Berkeley) 6/10/93 + * @(#)nfs.h 8.4 (Berkeley) 5/1/95 * $FreeBSD$ */ #ifndef _NFS_NFS_H_ #define _NFS_NFS_H_ -#include <nfs/rpcv2.h> - /* * Tunable constants for nfs */ +#ifdef KERNEL + #define NFS_MAXIOVEC 34 #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ @@ -69,7 +69,7 @@ #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ -#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ +#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ #ifndef NFS_GATHERDELAY #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ @@ -89,30 +89,9 @@ /* * XXX - * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but - * until then... - * Same goes for sys/malloc.h, which needs M_NFSDIROFF, - * M_NFSRVDESC and M_NFSBIGFH added. - * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an - * exclusive create. * The B_INVAFTERWRITE flag should be set to whatever is required by the * buffer cache code to say "Invalidate the block after it is written back". */ -#ifndef B_NEEDCOMMIT -#define B_NEEDCOMMIT B_APPENDWRITE -#endif -#ifndef M_NFSRVDESC -#define M_NFSRVDESC M_TEMP -#endif -#ifndef M_NFSDIROFF -#define M_NFSDIROFF M_TEMP -#endif -#ifndef M_NFSBIGFH -#define M_NFSBIGFH M_TEMP -#endif -#ifndef VA_EXCLUSIVE -#define VA_EXCLUSIVE 0 -#endif #ifdef __FreeBSD__ #define B_INVAFTERWRITE B_NOCACHE #else @@ -120,20 +99,6 @@ #endif /* - * These ifdefs try to handle the differences between the various 4.4BSD-Lite - * based vfs interfaces. - * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to - * differentiate between NetBSD-1.0 and NetBSD-current, so.. - * I also don't know about BSDi's 2.0 release. - */ -#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPLEASE 1 -#endif -#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPREVOKE 1 -#endif - -/* * The IO_METASYNC flag should be implemented for local file systems. * (Until then, it is nothin at all.) */ @@ -164,13 +129,114 @@ #define NFS_SVCALLOC 256 #define NFS_UIDALLOC 128 +#endif /* KERNEL */ + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ +#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ +#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ +#define NFSMNT_DISMNT 0x00800000 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ +#define NFSMNT_WANTSND 0x02000000 /* Want above */ +#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x08000000 /* Want above */ +#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ + +/* + * Arguments to mount NFS + */ +#define NFS_ARGSVERSION 3 /* change when nfs_args changes */ +struct nfs_args { + int version; /* args structure version number */ + struct sockaddr *addr; /* file server address */ + int addrlen; /* length of address */ + int sotype; /* Socket type */ + int proto; /* and Protocol */ + u_char *fh; /* File handle to be mounted */ + int fhsize; /* Size, in bytes, of fh */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int readdirsize; /* readdir size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int maxgrouplist; /* Max. size of group list */ + int readahead; /* # of blocks to readahead */ + int leaseterm; /* Term (sec) of lease */ + int deadthresh; /* Retrans threshold */ + char *hostname; /* server's name */ +}; + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ +#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ +#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ +#define NFSMNT_DISMNT 0x00800000 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ +#define NFSMNT_WANTSND 0x02000000 /* Want above */ +#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x08000000 /* Want above */ +#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ + /* * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs * should ever try and use it. */ struct nfsd_args { int sock; /* Socket to serve */ - caddr_t name; /* Client address for connection based sockets */ + caddr_t name; /* Client addr for connection based sockets */ int namelen; /* Length of name */ }; @@ -200,6 +266,10 @@ struct nfsd_cargs { }; /* + * XXX to allow amd to include nfs.h without nfsproto.h + */ +#ifdef NFS_NPROCS +/* * Stats structure */ struct nfsstats { @@ -237,6 +307,7 @@ struct nfsstats { int srvnqnfs_getleases; int srvvop_writes; }; +#endif /* * Flags for nfssvc() system call. @@ -267,7 +338,7 @@ struct nfsstats { * such as SIGALRM will not expect file I/O system calls to be interrupted * by them and break. */ -#if defined(KERNEL) || defined(_KERNEL) +#ifdef KERNEL struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ @@ -482,6 +553,8 @@ extern int nfsd_head_flag; !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ sizeof (struct ucred))) + +int nfs_init __P((struct vfsconf *vfsp)); int nfs_reply __P((struct nfsreq *)); int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); @@ -516,14 +589,12 @@ int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); void nfs_nhinit __P((void)); void nfs_timer __P((void*)); u_long nfs_hash __P((nfsfh_t *,int)); -void nfsrv_slpderef __P((struct nfssvc_sock *slp)); int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); -void nfsrv_cleancache __P((void)); int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); -int nfs_init __P((void)); void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); +void nfsrv_cleancache __P((void)); int nfs_connect __P((struct nfsmount *,struct nfsreq *)); -void nfs_disconnect __P((struct nfsmount *nmp)); +void nfs_disconnect __P((struct nfsmount *)); int nfs_getattrcache __P((struct vnode *,struct vattr *)); int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); @@ -531,7 +602,6 @@ int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); void nfsrv_init __P((int)); void nfs_clearcommit __P((struct mount *)); int nfsrv_errmap __P((struct nfsrv_descript *, int)); -void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); void nfsrvw_sort __P((gid_t [],int)); void nfsrv_setcred __P((struct ucred *,struct ucred *)); int nfs_writebp __P((struct buf *,int)); @@ -594,8 +664,8 @@ int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq)); int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq)); - - +void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); +void nfsrv_slpderef __P((struct nfssvc_sock *slp)); #endif /* KERNEL */ #endif |