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.17 (Berkeley) 08/11/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 /* 177 * Network address hash list element 178 */ 179 union nethostaddr { 180 u_long had_inetaddr; 181 struct mbuf *had_nam; 182 }; 183 184 struct nfsuid { 185 struct nfsuid *nu_lrunext; /* MUST be first */ 186 struct nfsuid *nu_lruprev; 187 struct nfsuid *nu_hnext; 188 struct nfsuid *nu_hprev; 189 int nu_flag; /* Flags */ 190 uid_t nu_uid; /* Uid mapped by this entry */ 191 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 192 struct ucred nu_cr; /* Cred uid mapped to */ 193 }; 194 195 #define nu_inetaddr nu_haddr.had_inetaddr 196 #define nu_nam nu_haddr.had_nam 197 /* Bits for nu_flag */ 198 #define NU_INETADDR 0x1 199 200 struct nfssvc_sock { 201 struct nfsuid *ns_lrunext; /* MUST be first */ 202 struct nfsuid *ns_lruprev; 203 struct nfssvc_sock *ns_next; 204 struct nfssvc_sock *ns_prev; 205 int ns_flag; 206 u_long ns_sref; 207 struct file *ns_fp; 208 struct socket *ns_so; 209 int ns_solock; 210 struct mbuf *ns_nam; 211 int ns_cc; 212 struct mbuf *ns_raw; 213 struct mbuf *ns_rawend; 214 int ns_reclen; 215 struct mbuf *ns_rec; 216 struct mbuf *ns_recend; 217 int ns_numuids; 218 struct nfsuid *ns_uidh[NUIDHASHSIZ]; 219 }; 220 221 /* Bits for "ns_flag" */ 222 #define SLP_VALID 0x01 223 #define SLP_DOREC 0x02 224 #define SLP_NEEDQ 0x04 225 #define SLP_DISCONN 0x08 226 #define SLP_GETSTREAM 0x10 227 #define SLP_INIT 0x20 228 #define SLP_WANTINIT 0x40 229 230 #define SLP_ALLFLAGS 0xff 231 232 /* 233 * One of these structures is allocated for each nfsd. 234 */ 235 struct nfsd { 236 struct nfsd *nd_next; /* Must be first */ 237 struct nfsd *nd_prev; 238 int nd_flag; /* NFSD_ flags */ 239 struct nfssvc_sock *nd_slp; /* Current socket */ 240 struct mbuf *nd_nam; /* Client addr for datagram req. */ 241 struct mbuf *nd_mrep; /* Req. mbuf list */ 242 struct mbuf *nd_md; 243 caddr_t nd_dpos; /* Position in list */ 244 int nd_procnum; /* RPC procedure number */ 245 u_long nd_retxid; /* RPC xid */ 246 int nd_repstat; /* Reply status value */ 247 struct ucred nd_cr; /* Credentials for req. */ 248 int nd_nqlflag; /* Leasing flag */ 249 int nd_duration; /* Lease duration */ 250 int nd_authlen; /* Authenticator len */ 251 u_char nd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 252 struct proc *nd_procp; /* Proc ptr */ 253 }; 254 255 #define NFSD_WAITING 0x01 256 #define NFSD_CHECKSLP 0x02 257 #define NFSD_REQINPROG 0x04 258 #define NFSD_NEEDAUTH 0x08 259 #define NFSD_AUTHFAIL 0x10 260 #endif /* KERNEL */ 261