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 * %sccs.include.redist.c% 9 * 10 * @(#)nfs.h 7.16 (Berkeley) 03/16/92 11 */ 12 13 /* 14 * Tunable constants for nfs 15 */ 16 17 #define NFS_MAXIOVEC 34 18 #define NFS_HZ 25 /* Ticks per second for NFS timeouts */ 19 #define NFS_TIMEO (1*NFS_HZ) /* Default timeout = 1 second */ 20 #define NFS_MINTIMEO (1*NFS_HZ) /* Min timeout to use */ 21 #define NFS_MAXTIMEO (60*NFS_HZ) /* Max timeout to backoff to */ 22 #define NFS_MINIDEMTIMEO (5*NFS_HZ) /* Min timeout for non-idempotent ops*/ 23 #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 24 #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 25 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 26 #define NFS_MAXGRPS 16 /* Max. size of groups list */ 27 #define NFS_ATTRTIMEO 5 /* Attribute cache timeout in sec */ 28 #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 29 #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 30 #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 31 #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 32 #define NFS_MAXREADDIR NFS_MAXDATA /* Max. size of directory read */ 33 #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 34 #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ 35 #define NFS_DIRBLKSIZ 1024 /* Size of an NFS directory block */ 36 #define NMOD(a) ((a) % nfs_asyncdaemons) 37 38 /* 39 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 40 * should ever try and use it. 41 */ 42 struct nfsd_args { 43 int sock; /* Socket to serve */ 44 caddr_t name; /* Client address for connection based sockets */ 45 int namelen; /* Length of name */ 46 }; 47 48 struct nfsd_srvargs { 49 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 50 uid_t nsd_uid; /* Effective uid mapped to cred */ 51 u_long nsd_haddr; /* Ip address of client */ 52 struct ucred nsd_cr; /* Cred. uid maps to */ 53 int nsd_authlen; /* Length of auth string (ret) */ 54 char *nsd_authstr; /* Auth string (ret) */ 55 }; 56 57 struct nfsd_cargs { 58 char *ncd_dirp; /* Mount dir path */ 59 uid_t ncd_authuid; /* Effective uid */ 60 int ncd_authtype; /* Type of authenticator */ 61 int ncd_authlen; /* Length of authenticator string */ 62 char *ncd_authstr; /* Authenticator string */ 63 }; 64 65 /* 66 * Stats structure 67 */ 68 struct nfsstats { 69 int attrcache_hits; 70 int attrcache_misses; 71 int lookupcache_hits; 72 int lookupcache_misses; 73 int direofcache_hits; 74 int direofcache_misses; 75 int biocache_reads; 76 int read_bios; 77 int read_physios; 78 int biocache_writes; 79 int write_bios; 80 int write_physios; 81 int biocache_readlinks; 82 int readlink_bios; 83 int biocache_readdirs; 84 int readdir_bios; 85 int rpccnt[NFS_NPROCS]; 86 int rpcretries; 87 int srvrpccnt[NFS_NPROCS]; 88 int srvrpc_errs; 89 int srv_errs; 90 int rpcrequests; 91 int rpctimeouts; 92 int rpcunexpected; 93 int rpcinvalid; 94 int srvcache_inproghits; 95 int srvcache_idemdonehits; 96 int srvcache_nonidemdonehits; 97 int srvcache_misses; 98 int srvnqnfs_leases; 99 int srvnqnfs_maxleases; 100 int srvnqnfs_getleases; 101 }; 102 103 /* 104 * Flags for nfssvc() system call. 105 */ 106 #define NFSSVC_BIOD 0x002 107 #define NFSSVC_NFSD 0x004 108 #define NFSSVC_ADDSOCK 0x008 109 #define NFSSVC_AUTHIN 0x010 110 #define NFSSVC_GOTAUTH 0x040 111 #define NFSSVC_AUTHINFAIL 0x080 112 #define NFSSVC_MNTD 0x100 113 114 /* 115 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 116 * What should be in this set is open to debate, but I believe that since 117 * I/O system calls on ufs are never interrupted by signals the set should 118 * be minimal. My reasoning is that many current programs that use signals 119 * such as SIGALRM will not expect file I/O system calls to be interrupted 120 * by them and break. 121 */ 122 #ifdef KERNEL 123 #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 124 sigmask(SIGHUP)|sigmask(SIGQUIT)) 125 126 /* 127 * Socket errors ignored for connectionless sockets?? 128 * For now, ignore them all 129 */ 130 #define NFSIGNORE_SOERROR(s, e) \ 131 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 132 ((s) & PR_CONNREQUIRED) == 0) 133 134 /* 135 * Nfs outstanding request list element 136 */ 137 struct nfsreq { 138 struct nfsreq *r_next; 139 struct nfsreq *r_prev; 140 struct mbuf *r_mreq; 141 struct mbuf *r_mrep; 142 struct mbuf *r_md; 143 caddr_t r_dpos; 144 struct nfsmount *r_nmp; 145 struct vnode *r_vp; 146 u_long r_xid; 147 int r_flags; /* flags on request, see below */ 148 int r_retry; /* max retransmission count */ 149 int r_rexmit; /* current retrans count */ 150 int r_timer; /* tick counter on reply */ 151 int r_procnum; /* NFS procedure number */ 152 int r_rtt; /* RTT for rpc */ 153 struct proc *r_procp; /* Proc that did I/O system call */ 154 }; 155 156 /* Flag values for r_flags */ 157 #define R_TIMING 0x01 /* timing request (in mntp) */ 158 #define R_SENT 0x02 /* request has been sent */ 159 #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 160 #define R_INTR 0x08 /* intr mnt, signal pending */ 161 #define R_SOCKERR 0x10 /* Fatal error on socket */ 162 #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 163 #define R_MUSTRESEND 0x40 /* Must resend request */ 164 165 struct nfsstats nfsstats; 166 167 /* 168 * A list of nfssvc_sock structures is maintained with all the sockets 169 * that require service by the nfsd. 170 * The nfsuid structs hang off of the nfssvc_sock structs in both lru 171 * and uid hash lists. 172 */ 173 #define NUIDHASHSIZ 32 174 #define NUIDHASH(uid) ((uid) & (NUIDHASHSIZ - 1)) 175 176 struct nfsuid { 177 struct nfsuid *nu_lrunext; /* MUST be first */ 178 struct nfsuid *nu_lruprev; 179 struct nfsuid *nu_hnext; 180 struct nfsuid *nu_hprev; 181 int nu_flag; /* Flags */ 182 uid_t nu_uid; /* Uid mapped by this entry */ 183 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 184 struct ucred nu_cr; /* Cred uid mapped to */ 185 }; 186 187 #define nu_inetaddr nu_haddr.had_inetaddr 188 #define nu_nam nu_haddr.had_nam 189 /* Bits for nu_flag */ 190 #define NU_INETADDR 0x1 191 192 struct nfssvc_sock { 193 struct nfsuid *ns_lrunext; /* MUST be first */ 194 struct nfsuid *ns_lruprev; 195 struct nfssvc_sock *ns_next; 196 struct nfssvc_sock *ns_prev; 197 int ns_flag; 198 u_long ns_sref; 199 struct file *ns_fp; 200 struct socket *ns_so; 201 int ns_solock; 202 struct mbuf *ns_nam; 203 int ns_cc; 204 struct mbuf *ns_raw; 205 struct mbuf *ns_rawend; 206 int ns_reclen; 207 struct mbuf *ns_rec; 208 struct mbuf *ns_recend; 209 int ns_numuids; 210 struct nfsuid *ns_uidh[NUIDHASHSIZ]; 211 }; 212 213 /* Bits for "ns_flag" */ 214 #define SLP_VALID 0x01 215 #define SLP_DOREC 0x02 216 #define SLP_NEEDQ 0x04 217 #define SLP_DISCONN 0x08 218 #define SLP_GETSTREAM 0x10 219 #define SLP_INIT 0x20 220 #define SLP_WANTINIT 0x40 221 222 #define SLP_ALLFLAGS 0xff 223 224 /* 225 * One of these structures is allocated for each nfsd. 226 */ 227 struct nfsd { 228 struct nfsd *nd_next; /* Must be first */ 229 struct nfsd *nd_prev; 230 int nd_flag; /* NFSD_ flags */ 231 struct nfssvc_sock *nd_slp; /* Current socket */ 232 struct mbuf *nd_nam; /* Client addr for datagram req. */ 233 struct mbuf *nd_mrep; /* Req. mbuf list */ 234 struct mbuf *nd_md; 235 caddr_t nd_dpos; /* Position in list */ 236 int nd_procnum; /* RPC procedure number */ 237 u_long nd_retxid; /* RPC xid */ 238 int nd_repstat; /* Reply status value */ 239 struct ucred nd_cr; /* Credentials for req. */ 240 int nd_nqlflag; /* Leasing flag */ 241 int nd_duration; /* Lease duration */ 242 int nd_authlen; /* Authenticator len */ 243 u_char nd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 244 struct proc *nd_procp; /* Proc ptr */ 245 }; 246 247 #define NFSD_WAITING 0x01 248 #define NFSD_CHECKSLP 0x02 249 #define NFSD_REQINPROG 0x04 250 #define NFSD_NEEDAUTH 0x08 251 #define NFSD_AUTHFAIL 0x10 252 #endif /* KERNEL */ 253