nfsargs.h revision 19449
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * This code is derived from software contributed to Berkeley by
61541Srgrimes * Rick Macklem at The University of Guelph.
71541Srgrimes *
81541Srgrimes * Redistribution and use in source and binary forms, with or without
91541Srgrimes * modification, are permitted provided that the following conditions
101541Srgrimes * are met:
111541Srgrimes * 1. Redistributions of source code must retain the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer.
131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer in the
151541Srgrimes *    documentation and/or other materials provided with the distribution.
161541Srgrimes * 3. All advertising materials mentioning features or use of this software
171541Srgrimes *    must display the following acknowledgement:
181541Srgrimes *	This product includes software developed by the University of
191541Srgrimes *	California, Berkeley and its contributors.
201541Srgrimes * 4. Neither the name of the University nor the names of its contributors
211541Srgrimes *    may be used to endorse or promote products derived from this software
221541Srgrimes *    without specific prior written permission.
231541Srgrimes *
241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341541Srgrimes * SUCH DAMAGE.
351541Srgrimes *
361541Srgrimes *	@(#)nfs.h	8.1 (Berkeley) 6/10/93
3719449Sdfr * $Id: nfs.h,v 1.18 1996/08/21 21:55:44 dyson Exp $
381541Srgrimes */
391541Srgrimes
402175Spaul#ifndef _NFS_NFS_H_
412175Spaul#define _NFS_NFS_H_
422175Spaul
4311982Sjoerg#include <nfs/rpcv2.h>
4411982Sjoerg
451541Srgrimes/*
461541Srgrimes * Tunable constants for nfs
471541Srgrimes */
481541Srgrimes
491541Srgrimes#define	NFS_MAXIOVEC	34
509336Sdfr#define NFS_TICKINTVL	5		/* Desired time for a tick (msec) */
519336Sdfr#define NFS_HZ		(hz / nfs_ticks) /* Ticks/sec */
529336Sdfr#define	NFS_TIMEO	(1 * NFS_HZ)	/* Default timeout = 1 second */
539336Sdfr#define	NFS_MINTIMEO	(1 * NFS_HZ)	/* Min timeout to use */
549336Sdfr#define	NFS_MAXTIMEO	(60 * NFS_HZ)	/* Max timeout to backoff to */
559336Sdfr#define	NFS_MINIDEMTIMEO (5 * NFS_HZ)	/* Min timeout for non-idempotent ops*/
561541Srgrimes#define	NFS_MAXREXMIT	100		/* Stop counting after this many */
571541Srgrimes#define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
581541Srgrimes#define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
591541Srgrimes#define	NFS_MAXGRPS	16		/* Max. size of groups list */
601828Sdg#ifndef NFS_MINATTRTIMO
611541Srgrimes#define	NFS_MINATTRTIMO 5		/* Attribute cache timeout in sec */
621828Sdg#endif
631828Sdg#ifndef NFS_MAXATTRTIMO
641541Srgrimes#define	NFS_MAXATTRTIMO 60
651828Sdg#endif
661541Srgrimes#define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
671541Srgrimes#define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
689336Sdfr#define NFS_READDIRSIZE	8192		/* Def. readdir size */
691541Srgrimes#define	NFS_DEFRAHEAD	1		/* Def. read ahead # blocks */
701541Srgrimes#define	NFS_MAXRAHEAD	4		/* Max. read ahead # blocks */
711541Srgrimes#define	NFS_MAXUIDHASH	64		/* Max. # of hashed uid entries/mp */
7213765Smpp#define	NFS_MAXASYNCDAEMON 	20	/* Max. number async_daemons runnable */
739336Sdfr#define NFS_MAXGATHERDELAY	100	/* Max. write gather delay (msec) */
749336Sdfr#ifndef NFS_GATHERDELAY
759336Sdfr#define NFS_GATHERDELAY		10	/* Default write gather delay (msec) */
769336Sdfr#endif
779336Sdfr#define	NFS_DIRBLKSIZ	4096		/* Must be a multiple of DIRBLKSIZ */
789336Sdfr
799336Sdfr/*
809336Sdfr * Oddballs
819336Sdfr */
821541Srgrimes#define	NMOD(a)		((a) % nfs_asyncdaemons)
839336Sdfr#define NFS_CMPFH(n, f, s) \
849336Sdfr	((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
859336Sdfr#define NFS_ISV3(v)	(VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
869336Sdfr#define NFS_SRVMAXDATA(n) \
879336Sdfr		(((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
889336Sdfr		 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
891541Srgrimes
901541Srgrimes/*
919336Sdfr * XXX
9213765Smpp * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but
939336Sdfr * until then...
949336Sdfr * Same goes for sys/malloc.h, which needs M_NFSDIROFF,
959336Sdfr * M_NFSRVDESC and M_NFSBIGFH added.
969336Sdfr * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an
979336Sdfr * exclusive create.
989336Sdfr * The B_INVAFTERWRITE flag should be set to whatever is required by the
999336Sdfr * buffer cache code to say "Invalidate the block after it is written back".
1009336Sdfr */
1019336Sdfr#ifndef B_NEEDCOMMIT
1029336Sdfr#define B_NEEDCOMMIT	B_APPENDWRITE
1039336Sdfr#endif
1049336Sdfr#ifndef M_NFSRVDESC
1059336Sdfr#define M_NFSRVDESC	M_TEMP
1069336Sdfr#endif
1079336Sdfr#ifndef M_NFSDIROFF
1089336Sdfr#define M_NFSDIROFF	M_TEMP
1099336Sdfr#endif
1109336Sdfr#ifndef M_NFSBIGFH
1119336Sdfr#define M_NFSBIGFH	M_TEMP
1129336Sdfr#endif
1139336Sdfr#ifndef VA_EXCLUSIVE
1149336Sdfr#define VA_EXCLUSIVE	0
1159336Sdfr#endif
1169336Sdfr#ifdef __FreeBSD__
1179336Sdfr#define	B_INVAFTERWRITE	B_NOCACHE
1189336Sdfr#else
1199336Sdfr#define	B_INVAFTERWRITE	B_INVAL
1209336Sdfr#endif
1219336Sdfr
1229336Sdfr/*
1239336Sdfr * These ifdefs try to handle the differences between the various 4.4BSD-Lite
1249336Sdfr * based vfs interfaces.
1259336Sdfr * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to
1269336Sdfr * differentiate between NetBSD-1.0 and NetBSD-current, so..
1279336Sdfr * I also don't know about BSDi's 2.0 release.
1289336Sdfr */
1299336Sdfr#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
1309336Sdfr#define	HAS_VOPLEASE	1
1319336Sdfr#endif
1329336Sdfr#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
1339336Sdfr#define HAS_VOPREVOKE	1
1349336Sdfr#endif
1359336Sdfr
1369336Sdfr/*
1379336Sdfr * The IO_METASYNC flag should be implemented for local file systems.
1389336Sdfr * (Until then, it is nothin at all.)
1399336Sdfr */
1409336Sdfr#ifndef IO_METASYNC
1419336Sdfr#define IO_METASYNC	0
1429336Sdfr#endif
1439336Sdfr
1449336Sdfr/*
1451541Srgrimes * Set the attribute timeout based on how recently the file has been modified.
1461541Srgrimes */
1471541Srgrimes#define	NFS_ATTRTIMEO(np) \
1481541Srgrimes	((((np)->n_flag & NMODIFIED) || \
1491541Srgrimes	 (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
1501541Srgrimes	 ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
1511541Srgrimes	  (time.tv_sec - (np)->n_mtime) / 10))
1521541Srgrimes
1531541Srgrimes/*
1549336Sdfr * Expected allocation sizes for major data structures. If the actual size
1559336Sdfr * of the structure exceeds these sizes, then malloc() will be allocating
1569336Sdfr * almost twice the memory required. This is used in nfs_init() to warn
1579336Sdfr * the sysadmin that the size of a structure should be reduced.
1589336Sdfr * (These sizes are always a power of 2. If the kernel malloc() changes
1599336Sdfr *  to one that does not allocate space in powers of 2 size, then this all
1609336Sdfr *  becomes bunk!)
1619336Sdfr */
1629336Sdfr#define NFS_NODEALLOC	256
1639336Sdfr#define NFS_MNTALLOC	512
1649336Sdfr#define NFS_SVCALLOC	256
1659336Sdfr#define NFS_UIDALLOC	128
1669336Sdfr
1679336Sdfr/*
1681541Srgrimes * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
1691541Srgrimes * should ever try and use it.
1701541Srgrimes */
1711541Srgrimesstruct nfsd_args {
1721541Srgrimes	int	sock;		/* Socket to serve */
1731541Srgrimes	caddr_t	name;		/* Client address for connection based sockets */
1741541Srgrimes	int	namelen;	/* Length of name */
1751541Srgrimes};
1761541Srgrimes
1771541Srgrimesstruct nfsd_srvargs {
1781541Srgrimes	struct nfsd	*nsd_nfsd;	/* Pointer to in kernel nfsd struct */
1791541Srgrimes	uid_t		nsd_uid;	/* Effective uid mapped to cred */
1801541Srgrimes	u_long		nsd_haddr;	/* Ip address of client */
1811541Srgrimes	struct ucred	nsd_cr;		/* Cred. uid maps to */
1821541Srgrimes	int		nsd_authlen;	/* Length of auth string (ret) */
1839336Sdfr	u_char		*nsd_authstr;	/* Auth string (ret) */
1849336Sdfr	int		nsd_verflen;	/* and the verfier */
1859336Sdfr	u_char		*nsd_verfstr;
1869336Sdfr	struct timeval	nsd_timestamp;	/* timestamp from verifier */
1879336Sdfr	u_long		nsd_ttl;	/* credential ttl (sec) */
1889336Sdfr	NFSKERBKEY_T	nsd_key;	/* Session key */
1891541Srgrimes};
1901541Srgrimes
1911541Srgrimesstruct nfsd_cargs {
1921541Srgrimes	char		*ncd_dirp;	/* Mount dir path */
1931541Srgrimes	uid_t		ncd_authuid;	/* Effective uid */
1941541Srgrimes	int		ncd_authtype;	/* Type of authenticator */
1951541Srgrimes	int		ncd_authlen;	/* Length of authenticator string */
1969336Sdfr	u_char		*ncd_authstr;	/* Authenticator string */
1979336Sdfr	int		ncd_verflen;	/* and the verifier */
1989336Sdfr	u_char		*ncd_verfstr;
1999336Sdfr	NFSKERBKEY_T	ncd_key;	/* Session key */
2001541Srgrimes};
2011541Srgrimes
2021541Srgrimes/*
2031541Srgrimes * Stats structure
2041541Srgrimes */
2051541Srgrimesstruct nfsstats {
2061541Srgrimes	int	attrcache_hits;
2071541Srgrimes	int	attrcache_misses;
2081541Srgrimes	int	lookupcache_hits;
2091541Srgrimes	int	lookupcache_misses;
2101541Srgrimes	int	direofcache_hits;
2111541Srgrimes	int	direofcache_misses;
2121541Srgrimes	int	biocache_reads;
2131541Srgrimes	int	read_bios;
2141541Srgrimes	int	read_physios;
2151541Srgrimes	int	biocache_writes;
2161541Srgrimes	int	write_bios;
2171541Srgrimes	int	write_physios;
2181541Srgrimes	int	biocache_readlinks;
2191541Srgrimes	int	readlink_bios;
2201541Srgrimes	int	biocache_readdirs;
2211541Srgrimes	int	readdir_bios;
2221541Srgrimes	int	rpccnt[NFS_NPROCS];
2231541Srgrimes	int	rpcretries;
2241541Srgrimes	int	srvrpccnt[NFS_NPROCS];
2251541Srgrimes	int	srvrpc_errs;
2261541Srgrimes	int	srv_errs;
2271541Srgrimes	int	rpcrequests;
2281541Srgrimes	int	rpctimeouts;
2291541Srgrimes	int	rpcunexpected;
2301541Srgrimes	int	rpcinvalid;
2311541Srgrimes	int	srvcache_inproghits;
2321541Srgrimes	int	srvcache_idemdonehits;
2331541Srgrimes	int	srvcache_nonidemdonehits;
2341541Srgrimes	int	srvcache_misses;
2351541Srgrimes	int	srvnqnfs_leases;
2361541Srgrimes	int	srvnqnfs_maxleases;
2371541Srgrimes	int	srvnqnfs_getleases;
2389336Sdfr	int	srvvop_writes;
2391541Srgrimes};
2401541Srgrimes
2411541Srgrimes/*
2421541Srgrimes * Flags for nfssvc() system call.
2431541Srgrimes */
2441541Srgrimes#define	NFSSVC_BIOD	0x002
2451541Srgrimes#define	NFSSVC_NFSD	0x004
2461541Srgrimes#define	NFSSVC_ADDSOCK	0x008
2471541Srgrimes#define	NFSSVC_AUTHIN	0x010
2481541Srgrimes#define	NFSSVC_GOTAUTH	0x040
2491541Srgrimes#define	NFSSVC_AUTHINFAIL 0x080
2501541Srgrimes#define	NFSSVC_MNTD	0x100
2511541Srgrimes
2521541Srgrimes/*
2533820Swollman * fs.nfs sysctl(3) identifiers
2543820Swollman */
2553820Swollman#define NFS_NFSSTATS	1		/* struct: struct nfsstats */
2563820Swollman
2573820Swollman#define FS_NFS_NAMES { \
2583820Swollman		       { 0, 0 }, \
2593820Swollman		       { "nfsstats", CTLTYPE_STRUCT }, \
2603820Swollman}
2613820Swollman
2623820Swollman/*
2631541Srgrimes * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
2641541Srgrimes * What should be in this set is open to debate, but I believe that since
2651541Srgrimes * I/O system calls on ufs are never interrupted by signals the set should
2661541Srgrimes * be minimal. My reasoning is that many current programs that use signals
2671541Srgrimes * such as SIGALRM will not expect file I/O system calls to be interrupted
2681541Srgrimes * by them and break.
2691541Srgrimes */
2709336Sdfr#if defined(KERNEL) || defined(_KERNEL)
2714067Swollman
2724067Swollmanstruct uio; struct buf; struct vattr; struct nameidata;	/* XXX */
2734067Swollman
2741541Srgrimes#define	NFSINT_SIGMASK	(sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
2751541Srgrimes			 sigmask(SIGHUP)|sigmask(SIGQUIT))
2761541Srgrimes
2771541Srgrimes/*
2781541Srgrimes * Socket errors ignored for connectionless sockets??
2791541Srgrimes * For now, ignore them all
2801541Srgrimes */
2811541Srgrimes#define	NFSIGNORE_SOERROR(s, e) \
2821541Srgrimes		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
2831541Srgrimes		((s) & PR_CONNREQUIRED) == 0)
2841541Srgrimes
2851541Srgrimes/*
2861541Srgrimes * Nfs outstanding request list element
2871541Srgrimes */
2881541Srgrimesstruct nfsreq {
2893664Sphk	TAILQ_ENTRY(nfsreq) r_chain;
2901541Srgrimes	struct mbuf	*r_mreq;
2911541Srgrimes	struct mbuf	*r_mrep;
2921541Srgrimes	struct mbuf	*r_md;
2931541Srgrimes	caddr_t		r_dpos;
2941541Srgrimes	struct nfsmount *r_nmp;
2951541Srgrimes	struct vnode	*r_vp;
2961541Srgrimes	u_long		r_xid;
2971541Srgrimes	int		r_flags;	/* flags on request, see below */
2981541Srgrimes	int		r_retry;	/* max retransmission count */
2991541Srgrimes	int		r_rexmit;	/* current retrans count */
3001541Srgrimes	int		r_timer;	/* tick counter on reply */
3011541Srgrimes	int		r_procnum;	/* NFS procedure number */
3021541Srgrimes	int		r_rtt;		/* RTT for rpc */
3031541Srgrimes	struct proc	*r_procp;	/* Proc that did I/O system call */
3041541Srgrimes};
3051541Srgrimes
3063664Sphk/*
3073664Sphk * Queue head for nfsreq's
3083664Sphk */
3099759Sbdeextern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
3103664Sphk
3111541Srgrimes/* Flag values for r_flags */
3121541Srgrimes#define R_TIMING	0x01		/* timing request (in mntp) */
3131541Srgrimes#define R_SENT		0x02		/* request has been sent */
3141541Srgrimes#define	R_SOFTTERM	0x04		/* soft mnt, too many retries */
3151541Srgrimes#define	R_INTR		0x08		/* intr mnt, signal pending */
3161541Srgrimes#define	R_SOCKERR	0x10		/* Fatal error on socket */
3171541Srgrimes#define	R_TPRINTFMSG	0x20		/* Did a tprintf msg. */
3181541Srgrimes#define	R_MUSTRESEND	0x40		/* Must resend request */
3191541Srgrimes#define	R_GETONEREP	0x80		/* Probe for one reply only */
3201541Srgrimes
3211541Srgrimes/*
3221541Srgrimes * A list of nfssvc_sock structures is maintained with all the sockets
3231541Srgrimes * that require service by the nfsd.
3241541Srgrimes * The nfsuid structs hang off of the nfssvc_sock structs in both lru
3251541Srgrimes * and uid hash lists.
3261541Srgrimes */
3279336Sdfr#ifndef NFS_UIDHASHSIZ
3289336Sdfr#define	NFS_UIDHASHSIZ	29	/* Tune the size of nfssvc_sock with this */
3299336Sdfr#endif
3303664Sphk#define	NUIDHASH(sock, uid) \
3319336Sdfr	(&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
3329336Sdfr#ifndef NFS_WDELAYHASHSIZ
3339336Sdfr#define	NFS_WDELAYHASHSIZ 16	/* and with this */
3349336Sdfr#endif
3359336Sdfr#define	NWDELAYHASH(sock, f) \
3369336Sdfr	(&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
3379336Sdfr#ifndef NFS_MUIDHASHSIZ
33819449Sdfr#define NFS_MUIDHASHSIZ	63	/* Tune the size of nfsmount with this */
3399336Sdfr#endif
3409336Sdfr#define	NMUIDHASH(nmp, uid) \
3419336Sdfr	(&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
3429336Sdfr#define	NFSNOHASH(fhsum) \
3439336Sdfr	(&nfsnodehashtbl[(fhsum) & nfsnodehash])
3441541Srgrimes
3451541Srgrimes/*
3461541Srgrimes * Network address hash list element
3471541Srgrimes */
3481541Srgrimesunion nethostaddr {
3491541Srgrimes	u_long had_inetaddr;
3501541Srgrimes	struct mbuf *had_nam;
3511541Srgrimes};
3521541Srgrimes
3531541Srgrimesstruct nfsuid {
3543664Sphk	TAILQ_ENTRY(nfsuid) nu_lru;	/* LRU chain */
3553664Sphk	LIST_ENTRY(nfsuid) nu_hash;	/* Hash list */
3561541Srgrimes	int		nu_flag;	/* Flags */
3571541Srgrimes	union nethostaddr nu_haddr;	/* Host addr. for dgram sockets */
3581541Srgrimes	struct ucred	nu_cr;		/* Cred uid mapped to */
3599336Sdfr	int		nu_expire;	/* Expiry time (sec) */
3609336Sdfr	struct timeval	nu_timestamp;	/* Kerb. timestamp */
3619336Sdfr	u_long		nu_nickname;	/* Nickname on server */
3629336Sdfr	NFSKERBKEY_T	nu_key;		/* and session key */
3631541Srgrimes};
3641541Srgrimes
3651541Srgrimes#define	nu_inetaddr	nu_haddr.had_inetaddr
3661541Srgrimes#define	nu_nam		nu_haddr.had_nam
3671541Srgrimes/* Bits for nu_flag */
3681541Srgrimes#define	NU_INETADDR	0x1
3699336Sdfr#define NU_NAM		0x2
3709336Sdfr#define NU_NETFAM(u)	(((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
3711541Srgrimes
3721541Srgrimesstruct nfssvc_sock {
3733664Sphk	TAILQ_ENTRY(nfssvc_sock) ns_chain;	/* List of all nfssvc_sock's */
3743664Sphk	TAILQ_HEAD(, nfsuid) ns_uidlruhead;
3751541Srgrimes	struct file	*ns_fp;
3761541Srgrimes	struct socket	*ns_so;
3771541Srgrimes	struct mbuf	*ns_nam;
3781541Srgrimes	struct mbuf	*ns_raw;
3791541Srgrimes	struct mbuf	*ns_rawend;
3801541Srgrimes	struct mbuf	*ns_rec;
3811541Srgrimes	struct mbuf	*ns_recend;
3829336Sdfr	struct mbuf	*ns_frag;
3839336Sdfr	int		ns_flag;
3849336Sdfr	int		ns_solock;
3859336Sdfr	int		ns_cc;
3869336Sdfr	int		ns_reclen;
3871541Srgrimes	int		ns_numuids;
3889336Sdfr	u_long		ns_sref;
3899336Sdfr	LIST_HEAD(, nfsrv_descript) ns_tq;	/* Write gather lists */
3909336Sdfr	LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
3919336Sdfr	LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
3921541Srgrimes};
3931541Srgrimes
3941541Srgrimes/* Bits for "ns_flag" */
3951541Srgrimes#define	SLP_VALID	0x01
3961541Srgrimes#define	SLP_DOREC	0x02
3971541Srgrimes#define	SLP_NEEDQ	0x04
3981541Srgrimes#define	SLP_DISCONN	0x08
3991541Srgrimes#define	SLP_GETSTREAM	0x10
4009336Sdfr#define	SLP_LASTFRAG	0x20
4011541Srgrimes#define SLP_ALLFLAGS	0xff
4021541Srgrimes
4039759Sbdeextern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
4049759Sbdeextern int nfssvc_sockhead_flag;
4053664Sphk#define	SLP_INIT	0x01
4063664Sphk#define	SLP_WANTINIT	0x02
4073664Sphk
4081541Srgrimes/*
4091541Srgrimes * One of these structures is allocated for each nfsd.
4101541Srgrimes */
4111541Srgrimesstruct nfsd {
4129336Sdfr	TAILQ_ENTRY(nfsd) nfsd_chain;	/* List of all nfsd's */
4139336Sdfr	int		nfsd_flag;	/* NFSD_ flags */
4149336Sdfr	struct nfssvc_sock *nfsd_slp;	/* Current socket */
4159336Sdfr	int		nfsd_authlen;	/* Authenticator len */
4169336Sdfr	u_char		nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
4179336Sdfr	int		nfsd_verflen;	/* and the Verifier */
4189336Sdfr	u_char		nfsd_verfstr[RPCVERF_MAXSIZ];
4199336Sdfr	struct proc	*nfsd_procp;	/* Proc ptr */
4209336Sdfr	struct nfsrv_descript *nfsd_nd;	/* Associated nfsrv_descript */
4211541Srgrimes};
4221541Srgrimes
4239336Sdfr/* Bits for "nfsd_flag" */
4241541Srgrimes#define	NFSD_WAITING	0x01
4253664Sphk#define	NFSD_REQINPROG	0x02
4263664Sphk#define	NFSD_NEEDAUTH	0x04
4273664Sphk#define	NFSD_AUTHFAIL	0x08
4283305Sphk
4299336Sdfr/*
4309336Sdfr * This structure is used by the server for describing each request.
4319336Sdfr * Some fields are used only when write request gathering is performed.
4329336Sdfr */
4339336Sdfrstruct nfsrv_descript {
4349336Sdfr	u_quad_t		nd_time;	/* Write deadline (usec) */
4359336Sdfr	off_t			nd_off;		/* Start byte offset */
4369336Sdfr	off_t			nd_eoff;	/* and end byte offset */
4379336Sdfr	LIST_ENTRY(nfsrv_descript) nd_hash;	/* Hash list */
4389336Sdfr	LIST_ENTRY(nfsrv_descript) nd_tq;		/* and timer list */
4399336Sdfr	LIST_HEAD(,nfsrv_descript) nd_coalesce;	/* coalesced writes */
4409336Sdfr	struct mbuf		*nd_mrep;	/* Request mbuf list */
4419336Sdfr	struct mbuf		*nd_md;		/* Current dissect mbuf */
4429336Sdfr	struct mbuf		*nd_mreq;	/* Reply mbuf list */
4439336Sdfr	struct mbuf		*nd_nam;	/* and socket addr */
4449336Sdfr	struct mbuf		*nd_nam2;	/* return socket addr */
4459336Sdfr	caddr_t			nd_dpos;	/* Current dissect pos */
4469336Sdfr	int			nd_procnum;	/* RPC # */
4479336Sdfr	int			nd_stable;	/* storage type */
4489336Sdfr	int			nd_flag;	/* nd_flag */
4499336Sdfr	int			nd_len;		/* Length of this write */
4509336Sdfr	int			nd_repstat;	/* Reply status */
4519336Sdfr	u_long			nd_retxid;	/* Reply xid */
4529336Sdfr	u_long			nd_duration;	/* Lease duration */
4539336Sdfr	struct timeval		nd_starttime;	/* Time RPC initiated */
4549336Sdfr	fhandle_t		nd_fh;		/* File handle */
4559336Sdfr	struct ucred		nd_cr;		/* Credentials */
4569336Sdfr};
4579336Sdfr
4589336Sdfr/* Bits for "nd_flag" */
4599336Sdfr#define	ND_READ		LEASE_READ
4609336Sdfr#define ND_WRITE	LEASE_WRITE
4619336Sdfr#define ND_CHECK	0x04
4629336Sdfr#define ND_LEASE	(ND_READ | ND_WRITE | ND_CHECK)
4639336Sdfr#define ND_NFSV3	0x08
4649336Sdfr#define ND_NQNFS	0x10
4659336Sdfr#define ND_KERBNICK	0x20
4669336Sdfr#define ND_KERBFULL	0x40
4679336Sdfr#define ND_KERBAUTH	(ND_KERBNICK | ND_KERBFULL)
4689336Sdfr
4699759Sbdeextern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
4709759Sbdeextern int nfsd_head_flag;
4713664Sphk#define	NFSD_CHECKSLP	0x01
4723664Sphk
4739336Sdfr/*
4749336Sdfr * These macros compare nfsrv_descript structures.
4759336Sdfr */
4769336Sdfr#define NFSW_CONTIG(o, n) \
4779336Sdfr		((o)->nd_eoff >= (n)->nd_off && \
4789336Sdfr		 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
4799336Sdfr
4809336Sdfr#define NFSW_SAMECRED(o, n) \
4819336Sdfr	(((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
4829336Sdfr 	 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
4839336Sdfr		sizeof (struct ucred)))
4849336Sdfr
4853305Sphkint	nfs_reply __P((struct nfsreq *));
4869336Sdfrint	nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
4873305Sphkint	nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *));
4889336Sdfrint	nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));
4893305Sphkint	nfs_sndlock __P((int *,struct nfsreq *));
49012453Sbdevoid	nfs_sndunlock __P((int *flagp));
4913305Sphkint	nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
4923305Sphkint	nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int));
4933305Sphkint	nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *));
4949336Sdfrint	nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *));
4953305Sphkint	nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *));
4963305Sphkint	nfs_asyncio __P((struct buf *,struct ucred *));
4973305Sphkint	nfs_doio __P((struct buf *,struct ucred *,struct proc *));
4983305Sphkint	nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *));
4993305Sphkint	nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *));
5009336Sdfrint	nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *));
5013305Sphkint	nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
5029336Sdfrvoid	nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *));
5039336Sdfrvoid	nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **));
5049336Sdfrvoid	nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **));
5053305Sphkint	netaddr_match __P((int,union nethostaddr *,struct mbuf *));
5063305Sphkint	nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *));
5073305Sphkint	nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *));
5089336Sdfrint	nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int));
5093305Sphkvoid	nfsm_adj __P((struct mbuf *,int,int));
5103305Sphkint	nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *));
5113305Sphkvoid	nfsrv_initcache __P((void));
5129336Sdfrint	nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T));
5139336Sdfrint	nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int));
5149336Sdfrint	nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *));
5153305Sphkint	nfs_adv __P((struct mbuf **,caddr_t *,int,int));
5163305Sphkvoid	nfs_nhinit __P((void));
5173305Sphkvoid	nfs_timer __P((void*));
5189336Sdfru_long nfs_hash __P((nfsfh_t *,int));
51912453Sbdevoid	nfsrv_slpderef __P((struct nfssvc_sock *slp));
5209336Sdfrint	nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **));
52112588Sbdevoid	nfsrv_cleancache __P((void));
5229336Sdfrint	nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **));
52312911Sphkint	nfs_init __P((void));
5249336Sdfrvoid	nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *));
5253305Sphkint	nfs_connect __P((struct nfsmount *,struct nfsreq *));
52612588Sbdevoid	nfs_disconnect __P((struct nfsmount *nmp));
5273305Sphkint	nfs_getattrcache __P((struct vnode *,struct vattr *));
5283305Sphkint	nfsm_strtmbuf __P((struct mbuf **,char **,char *,long));
5293305Sphkint	nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *));
5303305Sphkint	nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *));
5313305Sphkvoid	nfsrv_init __P((int));
5329336Sdfrvoid	nfs_clearcommit __P((struct mount *));
5339336Sdfrint	nfsrv_errmap __P((struct nfsrv_descript *, int));
53412588Sbdevoid	nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
5359336Sdfrvoid	nfsrvw_sort __P((gid_t [],int));
5369336Sdfrvoid	nfsrv_setcred __P((struct ucred *,struct ucred *));
5379336Sdfrint	nfs_writebp __P((struct buf *,int));
53817761Sdysonint	nfsrv_object_create __P(( struct vnode * ));
53912588Sbdevoid	nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
5409336Sdfrint	nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
5419336Sdfr			       struct proc *, struct mbuf **));
5429336Sdfrint	nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
5439336Sdfr			struct proc *p));
5446361Sphk
54512588Sbdeint	nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
54612588Sbde			   struct proc *procp, struct mbuf **mrq));
54712588Sbdeint	nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
54812588Sbde			  struct proc *procp, struct mbuf **mrq));
54912588Sbdeint	nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
55012588Sbde			  struct proc *procp, struct mbuf **mrq));
55112911Sphkint	nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,
55212911Sphk			struct ucred *,struct nfssvc_sock *,struct mbuf *,
55312911Sphk			int *,int));
55412588Sbdeint	nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
55512588Sbde			  struct proc *procp, struct mbuf **mrq));
55612588Sbdeint	nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
55712588Sbde			   struct proc *procp, struct mbuf **mrq));
55812588Sbdeint	nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
55912588Sbde			struct proc *procp, struct mbuf **mrq));
56012588Sbdeint	nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
56112588Sbde			  struct proc *procp, struct mbuf **mrq));
56212588Sbdeint	nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
56312588Sbde			 struct proc *procp, struct mbuf **mrq));
56412588Sbdeint	nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
56512588Sbde			 struct proc *procp, struct mbuf **mrq));
56612588Sbdeint	nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
56712588Sbde			struct proc *procp, struct mbuf **mrq));
56812588Sbdeint	nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
56912588Sbde			struct proc *procp, struct mbuf **mrq));
57012588Sbdeint	nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
57112588Sbde			    struct nfssvc_sock *slp, struct proc *procp,
57212588Sbde			    struct mbuf **mrq));
57312588Sbdeint	nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
57412588Sbde			struct proc *procp, struct mbuf **mrq));
57512588Sbdeint	nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
57612588Sbde			   struct proc *procp, struct mbuf **mrq));
57712588Sbdeint	nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
57812588Sbde			       struct nfssvc_sock *slp, struct proc *procp,
57912588Sbde			       struct mbuf **mrq));
58012588Sbdeint	nfsrv_readlink __P((struct nfsrv_descript *nfsd,
58112588Sbde			    struct nfssvc_sock *slp, struct proc *procp,
58212588Sbde			    struct mbuf **mrq));
58312588Sbdeint	nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
58412588Sbde			  struct proc *procp, struct mbuf **mrq));
58512588Sbdeint	nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
58612588Sbde			  struct proc *procp, struct mbuf **mrq));
58712588Sbdeint	nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
58812588Sbde			 struct proc *procp, struct mbuf **mrq));
58912588Sbdeint	nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
59012588Sbde			   struct proc *procp, struct mbuf **mrq));
59112588Sbdeint	nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
59212588Sbde			  struct proc *procp, struct mbuf **mrq));
59312588Sbdeint	nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
59412588Sbde			   struct proc *procp, struct mbuf **mrq));
59512588Sbdeint	nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
59612588Sbde			 struct proc *procp, struct mbuf **mrq));
59712588Sbde
59812911Sphk
5991541Srgrimes#endif	/* KERNEL */
6002175Spaul
6012175Spaul#endif
602