xref: /csrg-svn/sys/nfs/nfs.h (revision 43345)
138414Smckusick /*
238414Smckusick  * Copyright (c) 1989 The Regents of the University of California.
338414Smckusick  * All rights reserved.
438414Smckusick  *
538414Smckusick  * This code is derived from software contributed to Berkeley by
638414Smckusick  * Rick Macklem at The University of Guelph.
738414Smckusick  *
838414Smckusick  * Redistribution and use in source and binary forms are permitted
938414Smckusick  * provided that the above copyright notice and this paragraph are
1038414Smckusick  * duplicated in all such forms and that any documentation,
1138414Smckusick  * advertising materials, and other materials related to such
1238414Smckusick  * distribution and use acknowledge that the software was developed
1338414Smckusick  * by the University of California, Berkeley.  The name of the
1438414Smckusick  * University may not be used to endorse or promote products derived
1538414Smckusick  * from this software without specific prior written permission.
1638414Smckusick  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1738414Smckusick  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1838414Smckusick  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1938414Smckusick  *
20*43345Smckusick  *	@(#)nfs.h	7.8 (Berkeley) 06/21/90
2138414Smckusick  */
2238414Smckusick 
2338414Smckusick /*
2438414Smckusick  * Tunable constants for nfs
2538414Smckusick  */
2640116Smckusick 
27*43345Smckusick #define	NFS_MAXIOVEC	34
2840116Smckusick #define NFS_HZ		10		/* Ticks per second for NFS timeouts */
2940116Smckusick #define	NFS_TIMEO	(1*NFS_HZ)	/* Default timeout = 1 second */
30*43345Smckusick #define	NFS_MINTIMEO	(NFS_HZ)	/* Min timeout to use */
3140116Smckusick #define	NFS_MAXTIMEO	(60*NFS_HZ)	/* Max timeout to backoff to */
3241906Smckusick #define	NFS_MINIDEMTIMEO (2*NFS_HZ)	/* Min timeout for non-idempotent ops*/
33*43345Smckusick #define	NFS_RELIABLETIMEO (5*NFS_HZ)	/* Min timeout on reliable sockets */
3440116Smckusick #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
3540116Smckusick #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
3640116Smckusick #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
37*43345Smckusick #define NFS_FISHY	8		/* Host not responding at this count */
3840116Smckusick #define	NFS_ATTRTIMEO	5		/* Attribute cache timeout in sec */
39*43345Smckusick #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
40*43345Smckusick #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
41*43345Smckusick #define	NFS_MAXREADDIR	NFS_MAXDATA	/* Max. size of directory read */
4241906Smckusick #define	NFS_MAXASYNCDAEMON 20	/* Max. number async_daemons runable */
4339339Smckusick #define	NMOD(a)		((a) % nfs_asyncdaemons)
4438414Smckusick 
4541906Smckusick /*
4641906Smckusick  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
4741906Smckusick  * What should be in this set is open to debate, but I believe that since
4841906Smckusick  * I/O system calls on ufs are never interrupted by signals the set should
4941906Smckusick  * be minimal. My reasoning is that many current programs that use signals
5041906Smckusick  * such as SIGALRM will not expect file I/O system calls to be interrupted
5141906Smckusick  * by them and break.
5241906Smckusick  */
5341906Smckusick #define	NFSINT_SIGMASK	(sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
5441906Smckusick 			 sigmask(SIGHUP)|sigmask(SIGQUIT))
5540116Smckusick 
5638414Smckusick /*
5741906Smckusick  * Socket errors ignored for connectionless sockets??
5841906Smckusick  * For now, ignore them all
5941906Smckusick  */
6041906Smckusick #define	NFSIGNORE_SOERROR(s, e) \
6141906Smckusick 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
6241906Smckusick 		((s) & PR_CONNREQUIRED) == 0)
6341906Smckusick 
6441906Smckusick /*
6538414Smckusick  * Nfs outstanding request list element
6638414Smckusick  */
6738414Smckusick struct nfsreq {
6838414Smckusick 	struct nfsreq	*r_next;
6938414Smckusick 	struct nfsreq	*r_prev;
7038414Smckusick 	struct mbuf	*r_mreq;
7138414Smckusick 	struct mbuf	*r_mrep;
7241906Smckusick 	struct nfsmount *r_nmp;
7338414Smckusick 	struct vnode	*r_vp;
7438414Smckusick 	u_long		r_xid;
7540116Smckusick 	short		r_flags;	/* flags on request, see below */
7640116Smckusick 	short		r_retry;	/* max retransmission count */
7740116Smckusick 	short		r_rexmit;	/* current retrans count */
7840116Smckusick 	short		r_timer;	/* tick counter on reply */
7940116Smckusick 	short		r_timerinit;	/* reinit tick counter on reply */
8041906Smckusick 	struct proc	*r_procp;	/* Proc that did I/O system call */
8138414Smckusick };
8238414Smckusick 
8340116Smckusick /* Flag values for r_flags */
8440116Smckusick #define R_TIMING	0x01		/* timing request (in mntp) */
8540116Smckusick #define R_SENT		0x02		/* request has been sent */
8641906Smckusick #define	R_SOFTTERM	0x04		/* soft mnt, too many retries */
8741906Smckusick #define	R_INTR		0x08		/* intr mnt, signal pending */
8841906Smckusick #define	R_SOCKERR	0x10		/* Fatal error on socket */
8941906Smckusick #define	R_TPRINTFMSG	0x20		/* Did a tprintf msg. */
9041906Smckusick #define	R_MUSTRESEND	0x40		/* Must resend request */
9140116Smckusick 
9240116Smckusick #ifdef	KERNEL
9338414Smckusick /*
9438414Smckusick  * Silly rename structure that hangs off the nfsnode until the name
9538414Smckusick  * can be removed by nfs_inactive()
9638414Smckusick  */
9738414Smckusick struct sillyrename {
9838414Smckusick 	int	s_flag;
9938414Smckusick 	nfsv2fh_t s_fh;
10038414Smckusick 	struct nameidata s_namei;
10138414Smckusick };
10238414Smckusick 
10338414Smckusick /* And its flag values */
10438414Smckusick #define REMOVE		0
10538414Smckusick #define	RMDIR		1
10640116Smckusick #endif	/* KERNEL */
10738414Smckusick 
10838414Smckusick /*
10938414Smckusick  * Stats structure
11038414Smckusick  */
11138414Smckusick struct nfsstats {
11238414Smckusick 	int	attrcache_hits;
11338414Smckusick 	int	attrcache_misses;
11438414Smckusick 	int	lookupcache_hits;
11538414Smckusick 	int	lookupcache_misses;
11640296Smckusick 	int	direofcache_hits;
11740296Smckusick 	int	direofcache_misses;
11839744Smckusick 	int	biocache_reads;
11939744Smckusick 	int	read_bios;
12039744Smckusick 	int	read_physios;
12139744Smckusick 	int	biocache_writes;
12239744Smckusick 	int	write_bios;
12339744Smckusick 	int	write_physios;
12441906Smckusick 	int	biocache_readlinks;
12541906Smckusick 	int	readlink_bios;
12641906Smckusick 	int	biocache_readdirs;
12741906Smckusick 	int	readdir_bios;
12838414Smckusick 	int	rpccnt[NFS_NPROCS];
12938414Smckusick 	int	rpcretries;
13038414Smckusick 	int	srvrpccnt[NFS_NPROCS];
13138414Smckusick 	int	srvrpc_errs;
13238414Smckusick 	int	srv_errs;
13340116Smckusick 	int	rpcrequests;
13440116Smckusick 	int	rpctimeouts;
13540116Smckusick 	int	rpcunexpected;
13640116Smckusick 	int	rpcinvalid;
13739744Smckusick 	int	srvcache_inproghits;
13839744Smckusick 	int	srvcache_idemdonehits;
13939744Smckusick 	int	srvcache_nonidemdonehits;
14039744Smckusick 	int	srvcache_misses;
14138414Smckusick };
14238414Smckusick 
14338414Smckusick #ifdef KERNEL
14438414Smckusick struct nfsstats nfsstats;
14540116Smckusick #endif /* KERNEL */
146