xref: /original-bsd/sys/nfs/nfs.h (revision 89363ea9)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rick Macklem at The University of Guelph.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *	@(#)nfs.h	7.7 (Berkeley) 05/14/90
21  */
22 
23 /*
24  * Tunable constants for nfs
25  */
26 
27 #define	NFS_MAXIOVEC	10
28 #define NFS_HZ		10		/* Ticks per second for NFS timeouts */
29 #define	NFS_TIMEO	(1*NFS_HZ)	/* Default timeout = 1 second */
30 #define	NFS_MINTIMEO	(NFS_HZ/2)	/* Min timeout to use */
31 #define	NFS_MAXTIMEO	(60*NFS_HZ)	/* Max timeout to backoff to */
32 #define	NFS_MINIDEMTIMEO (2*NFS_HZ)	/* Min timeout for non-idempotent ops*/
33 #define	NFS_RELIABLETIMEO (300*NFS_HZ)	/* Min timeout on reliable sockets */
34 #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
35 #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
36 #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
37 #define NFS_FISHY	6		/* Host not responding at this count */
38 #define	NFS_ATTRTIMEO	5		/* Attribute cache timeout in sec */
39 #define	NFS_WSIZE	8192		/* Max. write data size <= 8192 */
40 #define	NFS_RSIZE	8192		/* Max. read data size <= 8192 */
41 #define	NFS_MAXREADDIR	NFS_RSIZE	/* Max. size of directory read */
42 #define	NFS_MAXASYNCDAEMON 20	/* Max. number async_daemons runable */
43 #define	NMOD(a)		((a) % nfs_asyncdaemons)
44 
45 /*
46  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
47  * What should be in this set is open to debate, but I believe that since
48  * I/O system calls on ufs are never interrupted by signals the set should
49  * be minimal. My reasoning is that many current programs that use signals
50  * such as SIGALRM will not expect file I/O system calls to be interrupted
51  * by them and break.
52  */
53 #define	NFSINT_SIGMASK	(sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
54 			 sigmask(SIGHUP)|sigmask(SIGQUIT))
55 
56 /*
57  * Socket errors ignored for connectionless sockets??
58  * For now, ignore them all
59  */
60 #define	NFSIGNORE_SOERROR(s, e) \
61 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
62 		((s) & PR_CONNREQUIRED) == 0)
63 
64 /*
65  * Nfs outstanding request list element
66  */
67 struct nfsreq {
68 	struct nfsreq	*r_next;
69 	struct nfsreq	*r_prev;
70 	struct mbuf	*r_mreq;
71 	struct mbuf	*r_mrep;
72 	struct nfsmount *r_nmp;
73 	struct vnode	*r_vp;
74 	u_long		r_xid;
75 	short		r_flags;	/* flags on request, see below */
76 	short		r_retry;	/* max retransmission count */
77 	short		r_rexmit;	/* current retrans count */
78 	short		r_timer;	/* tick counter on reply */
79 	short		r_timerinit;	/* reinit tick counter on reply */
80 	struct proc	*r_procp;	/* Proc that did I/O system call */
81 };
82 
83 /* Flag values for r_flags */
84 #define R_TIMING	0x01		/* timing request (in mntp) */
85 #define R_SENT		0x02		/* request has been sent */
86 #define	R_SOFTTERM	0x04		/* soft mnt, too many retries */
87 #define	R_INTR		0x08		/* intr mnt, signal pending */
88 #define	R_SOCKERR	0x10		/* Fatal error on socket */
89 #define	R_TPRINTFMSG	0x20		/* Did a tprintf msg. */
90 #define	R_MUSTRESEND	0x40		/* Must resend request */
91 
92 #ifdef	KERNEL
93 /*
94  * Silly rename structure that hangs off the nfsnode until the name
95  * can be removed by nfs_inactive()
96  */
97 struct sillyrename {
98 	int	s_flag;
99 	nfsv2fh_t s_fh;
100 	struct nameidata s_namei;
101 };
102 
103 /* And its flag values */
104 #define REMOVE		0
105 #define	RMDIR		1
106 #endif	/* KERNEL */
107 
108 /*
109  * Stats structure
110  */
111 struct nfsstats {
112 	int	attrcache_hits;
113 	int	attrcache_misses;
114 	int	lookupcache_hits;
115 	int	lookupcache_misses;
116 	int	direofcache_hits;
117 	int	direofcache_misses;
118 	int	biocache_reads;
119 	int	read_bios;
120 	int	read_physios;
121 	int	biocache_writes;
122 	int	write_bios;
123 	int	write_physios;
124 	int	biocache_readlinks;
125 	int	readlink_bios;
126 	int	biocache_readdirs;
127 	int	readdir_bios;
128 	int	rpccnt[NFS_NPROCS];
129 	int	rpcretries;
130 	int	srvrpccnt[NFS_NPROCS];
131 	int	srvrpc_errs;
132 	int	srv_errs;
133 	int	rpcrequests;
134 	int	rpctimeouts;
135 	int	rpcunexpected;
136 	int	rpcinvalid;
137 	int	srvcache_inproghits;
138 	int	srvcache_idemdonehits;
139 	int	srvcache_nonidemdonehits;
140 	int	srvcache_misses;
141 };
142 
143 #ifdef KERNEL
144 struct nfsstats nfsstats;
145 #endif /* KERNEL */
146