Home | History | Annotate | Line # | Download | only in nfs
nfs.h revision 1.1
      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, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by the University of
     19  *	California, Berkeley and its contributors.
     20  * 4. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  *	@(#)nfs.h	7.11 (Berkeley) 4/19/91
     37  */
     38 
     39 #ifndef _NFS_NFS_H_
     40 #define _NFS_NFS_H_
     41 
     42 /*
     43  * Tunable constants for nfs
     44  */
     45 
     46 #define	NFS_MAXIOVEC	34
     47 #define NFS_HZ		10		/* Ticks per second for NFS timeouts */
     48 #define	NFS_TIMEO	(1*NFS_HZ)	/* Default timeout = 1 second */
     49 #define	NFS_MINTIMEO	(NFS_HZ)	/* Min timeout to use */
     50 #define	NFS_MAXTIMEO	(60*NFS_HZ)	/* Max timeout to backoff to */
     51 #define	NFS_MINIDEMTIMEO (2*NFS_HZ)	/* Min timeout for non-idempotent ops*/
     52 #define	NFS_RELIABLETIMEO (5*NFS_HZ)	/* Min timeout on reliable sockets */
     53 #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
     54 #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
     55 #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
     56 #define NFS_FISHY	8		/* Host not responding at this count */
     57 #define	NFS_ATTRTIMEO	5		/* Attribute cache timeout in sec */
     58 #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
     59 #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
     60 #define	NFS_MAXREADDIR	NFS_MAXDATA	/* Max. size of directory read */
     61 #define	NFS_MAXASYNCDAEMON 20		/* Max. number async_daemons runable */
     62 #define	NFS_DIRBLKSIZ	1024		/* Size of an NFS directory block */
     63 #define	NMOD(a)		((a) % nfs_asyncdaemons)
     64 
     65 /*
     66  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
     67  * What should be in this set is open to debate, but I believe that since
     68  * I/O system calls on ufs are never interrupted by signals the set should
     69  * be minimal. My reasoning is that many current programs that use signals
     70  * such as SIGALRM will not expect file I/O system calls to be interrupted
     71  * by them and break.
     72  */
     73 #define	NFSINT_SIGMASK	(sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
     74 			 sigmask(SIGHUP)|sigmask(SIGQUIT))
     75 
     76 /*
     77  * Socket errors ignored for connectionless sockets??
     78  * For now, ignore them all
     79  */
     80 #define	NFSIGNORE_SOERROR(s, e) \
     81 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
     82 		((s) & PR_CONNREQUIRED) == 0)
     83 
     84 /*
     85  * Nfs outstanding request list element
     86  */
     87 struct nfsreq {
     88 	struct nfsreq	*r_next;
     89 	struct nfsreq	*r_prev;
     90 	struct mbuf	*r_mreq;
     91 	struct mbuf	*r_mrep;
     92 	struct nfsmount *r_nmp;
     93 	struct vnode	*r_vp;
     94 	u_long		r_xid;
     95 	short		r_flags;	/* flags on request, see below */
     96 	short		r_retry;	/* max retransmission count */
     97 	short		r_rexmit;	/* current retrans count */
     98 	short		r_timer;	/* tick counter on reply */
     99 	short		r_timerinit;	/* reinit tick counter on reply */
    100 	struct proc	*r_procp;	/* Proc that did I/O system call */
    101 };
    102 
    103 /* Flag values for r_flags */
    104 #define R_TIMING	0x01		/* timing request (in mntp) */
    105 #define R_SENT		0x02		/* request has been sent */
    106 #define	R_SOFTTERM	0x04		/* soft mnt, too many retries */
    107 #define	R_INTR		0x08		/* intr mnt, signal pending */
    108 #define	R_SOCKERR	0x10		/* Fatal error on socket */
    109 #define	R_TPRINTFMSG	0x20		/* Did a tprintf msg. */
    110 #define	R_MUSTRESEND	0x40		/* Must resend request */
    111 
    112 #ifdef	KERNEL
    113 /*
    114  * Silly rename structure that hangs off the nfsnode until the name
    115  * can be removed by nfs_inactive()
    116  */
    117 struct sillyrename {
    118 	nfsv2fh_t s_fh;
    119 	struct	ucred *s_cred;
    120 	struct	vnode *s_dvp;
    121 	u_short	s_namlen;
    122 	char	s_name[20];
    123 };
    124 
    125 /* And its flag values */
    126 #define REMOVE		0
    127 #define	RMDIR		1
    128 #endif	/* KERNEL */
    129 
    130 /*
    131  * Stats structure
    132  */
    133 struct nfsstats {
    134 	int	attrcache_hits;
    135 	int	attrcache_misses;
    136 	int	lookupcache_hits;
    137 	int	lookupcache_misses;
    138 	int	direofcache_hits;
    139 	int	direofcache_misses;
    140 	int	biocache_reads;
    141 	int	read_bios;
    142 	int	read_physios;
    143 	int	biocache_writes;
    144 	int	write_bios;
    145 	int	write_physios;
    146 	int	biocache_readlinks;
    147 	int	readlink_bios;
    148 	int	biocache_readdirs;
    149 	int	readdir_bios;
    150 	int	rpccnt[NFS_NPROCS];
    151 	int	rpcretries;
    152 	int	srvrpccnt[NFS_NPROCS];
    153 	int	srvrpc_errs;
    154 	int	srv_errs;
    155 	int	rpcrequests;
    156 	int	rpctimeouts;
    157 	int	rpcunexpected;
    158 	int	rpcinvalid;
    159 	int	srvcache_inproghits;
    160 	int	srvcache_idemdonehits;
    161 	int	srvcache_nonidemdonehits;
    162 	int	srvcache_misses;
    163 };
    164 
    165 #ifdef KERNEL
    166 struct nfsstats nfsstats;
    167 #endif /* KERNEL */
    168 
    169 #endif /* !_NFS_NFS_H_ */
    170