Home | History | Annotate | Line # | Download | only in nfs
nfs.h revision 1.3
      1  1.1  mycroft /*
      2  1.3  mycroft  * Copyright (c) 1989, 1993
      3  1.3  mycroft  *	The Regents of the University of California.  All rights reserved.
      4  1.1  mycroft  *
      5  1.1  mycroft  * This code is derived from software contributed to Berkeley by
      6  1.1  mycroft  * Rick Macklem at The University of Guelph.
      7  1.1  mycroft  *
      8  1.1  mycroft  * Redistribution and use in source and binary forms, with or without
      9  1.1  mycroft  * modification, are permitted provided that the following conditions
     10  1.1  mycroft  * are met:
     11  1.1  mycroft  * 1. Redistributions of source code must retain the above copyright
     12  1.1  mycroft  *    notice, this list of conditions and the following disclaimer.
     13  1.1  mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  mycroft  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  mycroft  *    documentation and/or other materials provided with the distribution.
     16  1.1  mycroft  * 3. All advertising materials mentioning features or use of this software
     17  1.1  mycroft  *    must display the following acknowledgement:
     18  1.1  mycroft  *	This product includes software developed by the University of
     19  1.1  mycroft  *	California, Berkeley and its contributors.
     20  1.1  mycroft  * 4. Neither the name of the University nor the names of its contributors
     21  1.1  mycroft  *    may be used to endorse or promote products derived from this software
     22  1.1  mycroft  *    without specific prior written permission.
     23  1.1  mycroft  *
     24  1.1  mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  1.1  mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  1.1  mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  1.1  mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  1.1  mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  1.1  mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  1.1  mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  1.1  mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  1.1  mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  1.1  mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  1.1  mycroft  * SUCH DAMAGE.
     35  1.1  mycroft  *
     36  1.3  mycroft  *	from: @(#)nfs.h	8.1 (Berkeley) 6/10/93
     37  1.3  mycroft  *	$Id: nfs.h,v 1.3 1994/06/08 11:36:50 mycroft Exp $
     38  1.1  mycroft  */
     39  1.1  mycroft 
     40  1.1  mycroft /*
     41  1.1  mycroft  * Tunable constants for nfs
     42  1.1  mycroft  */
     43  1.1  mycroft 
     44  1.1  mycroft #define	NFS_MAXIOVEC	34
     45  1.3  mycroft #define NFS_HZ		25		/* Ticks per second for NFS timeouts */
     46  1.1  mycroft #define	NFS_TIMEO	(1*NFS_HZ)	/* Default timeout = 1 second */
     47  1.3  mycroft #define	NFS_MINTIMEO	(1*NFS_HZ)	/* Min timeout to use */
     48  1.1  mycroft #define	NFS_MAXTIMEO	(60*NFS_HZ)	/* Max timeout to backoff to */
     49  1.3  mycroft #define	NFS_MINIDEMTIMEO (5*NFS_HZ)	/* Min timeout for non-idempotent ops*/
     50  1.1  mycroft #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
     51  1.1  mycroft #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
     52  1.1  mycroft #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
     53  1.3  mycroft #define	NFS_MAXGRPS	16		/* Max. size of groups list */
     54  1.3  mycroft #define	NFS_MINATTRTIMO 5		/* Attribute cache timeout in sec */
     55  1.3  mycroft #define	NFS_MAXATTRTIMO 60
     56  1.1  mycroft #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
     57  1.1  mycroft #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
     58  1.3  mycroft #define	NFS_DEFRAHEAD	1		/* Def. read ahead # blocks */
     59  1.3  mycroft #define	NFS_MAXRAHEAD	4		/* Max. read ahead # blocks */
     60  1.1  mycroft #define	NFS_MAXREADDIR	NFS_MAXDATA	/* Max. size of directory read */
     61  1.3  mycroft #define	NFS_MAXUIDHASH	64		/* Max. # of hashed uid entries/mp */
     62  1.3  mycroft #define	NFS_MAXASYNCDAEMON 20	/* Max. number async_daemons runable */
     63  1.1  mycroft #define	NFS_DIRBLKSIZ	1024		/* Size of an NFS directory block */
     64  1.1  mycroft #define	NMOD(a)		((a) % nfs_asyncdaemons)
     65  1.1  mycroft 
     66  1.1  mycroft /*
     67  1.3  mycroft  * Set the attribute timeout based on how recently the file has been modified.
     68  1.3  mycroft  */
     69  1.3  mycroft #define	NFS_ATTRTIMEO(np) \
     70  1.3  mycroft 	((((np)->n_flag & NMODIFIED) || \
     71  1.3  mycroft 	 (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
     72  1.3  mycroft 	 ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
     73  1.3  mycroft 	  (time.tv_sec - (np)->n_mtime) / 10))
     74  1.3  mycroft 
     75  1.3  mycroft /*
     76  1.3  mycroft  * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
     77  1.3  mycroft  * should ever try and use it.
     78  1.3  mycroft  */
     79  1.3  mycroft struct nfsd_args {
     80  1.3  mycroft 	int	sock;		/* Socket to serve */
     81  1.3  mycroft 	caddr_t	name;		/* Client address for connection based sockets */
     82  1.3  mycroft 	int	namelen;	/* Length of name */
     83  1.3  mycroft };
     84  1.3  mycroft 
     85  1.3  mycroft struct nfsd_srvargs {
     86  1.3  mycroft 	struct nfsd	*nsd_nfsd;	/* Pointer to in kernel nfsd struct */
     87  1.3  mycroft 	uid_t		nsd_uid;	/* Effective uid mapped to cred */
     88  1.3  mycroft 	u_long		nsd_haddr;	/* Ip address of client */
     89  1.3  mycroft 	struct ucred	nsd_cr;		/* Cred. uid maps to */
     90  1.3  mycroft 	int		nsd_authlen;	/* Length of auth string (ret) */
     91  1.3  mycroft 	char		*nsd_authstr;	/* Auth string (ret) */
     92  1.3  mycroft };
     93  1.3  mycroft 
     94  1.3  mycroft struct nfsd_cargs {
     95  1.3  mycroft 	char		*ncd_dirp;	/* Mount dir path */
     96  1.3  mycroft 	uid_t		ncd_authuid;	/* Effective uid */
     97  1.3  mycroft 	int		ncd_authtype;	/* Type of authenticator */
     98  1.3  mycroft 	int		ncd_authlen;	/* Length of authenticator string */
     99  1.3  mycroft 	char		*ncd_authstr;	/* Authenticator string */
    100  1.3  mycroft };
    101  1.3  mycroft 
    102  1.3  mycroft /*
    103  1.3  mycroft  * Stats structure
    104  1.3  mycroft  */
    105  1.3  mycroft struct nfsstats {
    106  1.3  mycroft 	int	attrcache_hits;
    107  1.3  mycroft 	int	attrcache_misses;
    108  1.3  mycroft 	int	lookupcache_hits;
    109  1.3  mycroft 	int	lookupcache_misses;
    110  1.3  mycroft 	int	direofcache_hits;
    111  1.3  mycroft 	int	direofcache_misses;
    112  1.3  mycroft 	int	biocache_reads;
    113  1.3  mycroft 	int	read_bios;
    114  1.3  mycroft 	int	read_physios;
    115  1.3  mycroft 	int	biocache_writes;
    116  1.3  mycroft 	int	write_bios;
    117  1.3  mycroft 	int	write_physios;
    118  1.3  mycroft 	int	biocache_readlinks;
    119  1.3  mycroft 	int	readlink_bios;
    120  1.3  mycroft 	int	biocache_readdirs;
    121  1.3  mycroft 	int	readdir_bios;
    122  1.3  mycroft 	int	rpccnt[NFS_NPROCS];
    123  1.3  mycroft 	int	rpcretries;
    124  1.3  mycroft 	int	srvrpccnt[NFS_NPROCS];
    125  1.3  mycroft 	int	srvrpc_errs;
    126  1.3  mycroft 	int	srv_errs;
    127  1.3  mycroft 	int	rpcrequests;
    128  1.3  mycroft 	int	rpctimeouts;
    129  1.3  mycroft 	int	rpcunexpected;
    130  1.3  mycroft 	int	rpcinvalid;
    131  1.3  mycroft 	int	srvcache_inproghits;
    132  1.3  mycroft 	int	srvcache_idemdonehits;
    133  1.3  mycroft 	int	srvcache_nonidemdonehits;
    134  1.3  mycroft 	int	srvcache_misses;
    135  1.3  mycroft 	int	srvnqnfs_leases;
    136  1.3  mycroft 	int	srvnqnfs_maxleases;
    137  1.3  mycroft 	int	srvnqnfs_getleases;
    138  1.3  mycroft };
    139  1.3  mycroft 
    140  1.3  mycroft /*
    141  1.3  mycroft  * Flags for nfssvc() system call.
    142  1.3  mycroft  */
    143  1.3  mycroft #define	NFSSVC_BIOD	0x002
    144  1.3  mycroft #define	NFSSVC_NFSD	0x004
    145  1.3  mycroft #define	NFSSVC_ADDSOCK	0x008
    146  1.3  mycroft #define	NFSSVC_AUTHIN	0x010
    147  1.3  mycroft #define	NFSSVC_GOTAUTH	0x040
    148  1.3  mycroft #define	NFSSVC_AUTHINFAIL 0x080
    149  1.3  mycroft #define	NFSSVC_MNTD	0x100
    150  1.3  mycroft 
    151  1.3  mycroft /*
    152  1.1  mycroft  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
    153  1.1  mycroft  * What should be in this set is open to debate, but I believe that since
    154  1.1  mycroft  * I/O system calls on ufs are never interrupted by signals the set should
    155  1.1  mycroft  * be minimal. My reasoning is that many current programs that use signals
    156  1.1  mycroft  * such as SIGALRM will not expect file I/O system calls to be interrupted
    157  1.1  mycroft  * by them and break.
    158  1.1  mycroft  */
    159  1.3  mycroft #ifdef KERNEL
    160  1.1  mycroft #define	NFSINT_SIGMASK	(sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
    161  1.1  mycroft 			 sigmask(SIGHUP)|sigmask(SIGQUIT))
    162  1.1  mycroft 
    163  1.1  mycroft /*
    164  1.1  mycroft  * Socket errors ignored for connectionless sockets??
    165  1.1  mycroft  * For now, ignore them all
    166  1.1  mycroft  */
    167  1.1  mycroft #define	NFSIGNORE_SOERROR(s, e) \
    168  1.1  mycroft 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
    169  1.1  mycroft 		((s) & PR_CONNREQUIRED) == 0)
    170  1.1  mycroft 
    171  1.1  mycroft /*
    172  1.1  mycroft  * Nfs outstanding request list element
    173  1.1  mycroft  */
    174  1.1  mycroft struct nfsreq {
    175  1.1  mycroft 	struct nfsreq	*r_next;
    176  1.1  mycroft 	struct nfsreq	*r_prev;
    177  1.1  mycroft 	struct mbuf	*r_mreq;
    178  1.1  mycroft 	struct mbuf	*r_mrep;
    179  1.3  mycroft 	struct mbuf	*r_md;
    180  1.3  mycroft 	caddr_t		r_dpos;
    181  1.1  mycroft 	struct nfsmount *r_nmp;
    182  1.1  mycroft 	struct vnode	*r_vp;
    183  1.1  mycroft 	u_long		r_xid;
    184  1.3  mycroft 	int		r_flags;	/* flags on request, see below */
    185  1.3  mycroft 	int		r_retry;	/* max retransmission count */
    186  1.3  mycroft 	int		r_rexmit;	/* current retrans count */
    187  1.3  mycroft 	int		r_timer;	/* tick counter on reply */
    188  1.3  mycroft 	int		r_procnum;	/* NFS procedure number */
    189  1.3  mycroft 	int		r_rtt;		/* RTT for rpc */
    190  1.1  mycroft 	struct proc	*r_procp;	/* Proc that did I/O system call */
    191  1.1  mycroft };
    192  1.1  mycroft 
    193  1.1  mycroft /* Flag values for r_flags */
    194  1.1  mycroft #define R_TIMING	0x01		/* timing request (in mntp) */
    195  1.1  mycroft #define R_SENT		0x02		/* request has been sent */
    196  1.1  mycroft #define	R_SOFTTERM	0x04		/* soft mnt, too many retries */
    197  1.1  mycroft #define	R_INTR		0x08		/* intr mnt, signal pending */
    198  1.1  mycroft #define	R_SOCKERR	0x10		/* Fatal error on socket */
    199  1.1  mycroft #define	R_TPRINTFMSG	0x20		/* Did a tprintf msg. */
    200  1.1  mycroft #define	R_MUSTRESEND	0x40		/* Must resend request */
    201  1.3  mycroft #define	R_GETONEREP	0x80		/* Probe for one reply only */
    202  1.3  mycroft 
    203  1.3  mycroft struct nfsstats nfsstats;
    204  1.1  mycroft 
    205  1.1  mycroft /*
    206  1.3  mycroft  * A list of nfssvc_sock structures is maintained with all the sockets
    207  1.3  mycroft  * that require service by the nfsd.
    208  1.3  mycroft  * The nfsuid structs hang off of the nfssvc_sock structs in both lru
    209  1.3  mycroft  * and uid hash lists.
    210  1.1  mycroft  */
    211  1.3  mycroft #define	NUIDHASHSIZ	32
    212  1.3  mycroft #define	NUIDHASH(uid)	((uid) & (NUIDHASHSIZ - 1))
    213  1.1  mycroft 
    214  1.1  mycroft /*
    215  1.3  mycroft  * Network address hash list element
    216  1.1  mycroft  */
    217  1.3  mycroft union nethostaddr {
    218  1.3  mycroft 	u_long had_inetaddr;
    219  1.3  mycroft 	struct mbuf *had_nam;
    220  1.3  mycroft };
    221  1.3  mycroft 
    222  1.3  mycroft struct nfsuid {
    223  1.3  mycroft 	struct nfsuid	*nu_lrunext;	/* MUST be first */
    224  1.3  mycroft 	struct nfsuid	*nu_lruprev;
    225  1.3  mycroft 	struct nfsuid	*nu_hnext;
    226  1.3  mycroft 	struct nfsuid	*nu_hprev;
    227  1.3  mycroft 	int		nu_flag;	/* Flags */
    228  1.3  mycroft 	uid_t		nu_uid;		/* Uid mapped by this entry */
    229  1.3  mycroft 	union nethostaddr nu_haddr;	/* Host addr. for dgram sockets */
    230  1.3  mycroft 	struct ucred	nu_cr;		/* Cred uid mapped to */
    231  1.3  mycroft };
    232  1.3  mycroft 
    233  1.3  mycroft #define	nu_inetaddr	nu_haddr.had_inetaddr
    234  1.3  mycroft #define	nu_nam		nu_haddr.had_nam
    235  1.3  mycroft /* Bits for nu_flag */
    236  1.3  mycroft #define	NU_INETADDR	0x1
    237  1.3  mycroft 
    238  1.3  mycroft struct nfssvc_sock {
    239  1.3  mycroft 	struct nfsuid	*ns_lrunext;	/* MUST be first */
    240  1.3  mycroft 	struct nfsuid	*ns_lruprev;
    241  1.3  mycroft 	struct nfssvc_sock *ns_next;
    242  1.3  mycroft 	struct nfssvc_sock *ns_prev;
    243  1.3  mycroft 	int		ns_flag;
    244  1.3  mycroft 	u_long		ns_sref;
    245  1.3  mycroft 	struct file	*ns_fp;
    246  1.3  mycroft 	struct socket	*ns_so;
    247  1.3  mycroft 	int		ns_solock;
    248  1.3  mycroft 	struct mbuf	*ns_nam;
    249  1.3  mycroft 	int		ns_cc;
    250  1.3  mycroft 	struct mbuf	*ns_raw;
    251  1.3  mycroft 	struct mbuf	*ns_rawend;
    252  1.3  mycroft 	int		ns_reclen;
    253  1.3  mycroft 	struct mbuf	*ns_rec;
    254  1.3  mycroft 	struct mbuf	*ns_recend;
    255  1.3  mycroft 	int		ns_numuids;
    256  1.3  mycroft 	struct nfsuid	*ns_uidh[NUIDHASHSIZ];
    257  1.1  mycroft };
    258  1.1  mycroft 
    259  1.3  mycroft /* Bits for "ns_flag" */
    260  1.3  mycroft #define	SLP_VALID	0x01
    261  1.3  mycroft #define	SLP_DOREC	0x02
    262  1.3  mycroft #define	SLP_NEEDQ	0x04
    263  1.3  mycroft #define	SLP_DISCONN	0x08
    264  1.3  mycroft #define	SLP_GETSTREAM	0x10
    265  1.3  mycroft #define	SLP_INIT	0x20
    266  1.3  mycroft #define	SLP_WANTINIT	0x40
    267  1.3  mycroft 
    268  1.3  mycroft #define SLP_ALLFLAGS	0xff
    269  1.3  mycroft 
    270  1.3  mycroft /*
    271  1.3  mycroft  * One of these structures is allocated for each nfsd.
    272  1.3  mycroft  */
    273  1.3  mycroft struct nfsd {
    274  1.3  mycroft 	struct nfsd	*nd_next;	/* Must be first */
    275  1.3  mycroft 	struct nfsd	*nd_prev;
    276  1.3  mycroft 	int		nd_flag;	/* NFSD_ flags */
    277  1.3  mycroft 	struct nfssvc_sock *nd_slp;	/* Current socket */
    278  1.3  mycroft 	struct mbuf	*nd_nam;	/* Client addr for datagram req. */
    279  1.3  mycroft 	struct mbuf	*nd_mrep;	/* Req. mbuf list */
    280  1.3  mycroft 	struct mbuf	*nd_md;
    281  1.3  mycroft 	caddr_t		nd_dpos;	/* Position in list */
    282  1.3  mycroft 	int		nd_procnum;	/* RPC procedure number */
    283  1.3  mycroft 	u_long		nd_retxid;	/* RPC xid */
    284  1.3  mycroft 	int		nd_repstat;	/* Reply status value */
    285  1.3  mycroft 	struct ucred	nd_cr;		/* Credentials for req. */
    286  1.3  mycroft 	int		nd_nqlflag;	/* Leasing flag */
    287  1.3  mycroft 	int		nd_duration;	/* Lease duration */
    288  1.3  mycroft 	int		nd_authlen;	/* Authenticator len */
    289  1.3  mycroft 	u_char		nd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
    290  1.3  mycroft 	struct proc	*nd_procp;	/* Proc ptr */
    291  1.3  mycroft };
    292  1.1  mycroft 
    293  1.3  mycroft #define	NFSD_WAITING	0x01
    294  1.3  mycroft #define	NFSD_CHECKSLP	0x02
    295  1.3  mycroft #define	NFSD_REQINPROG	0x04
    296  1.3  mycroft #define	NFSD_NEEDAUTH	0x08
    297  1.3  mycroft #define	NFSD_AUTHFAIL	0x10
    298  1.3  mycroft #endif	/* KERNEL */
    299