1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1989, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * This code is derived from software contributed to Berkeley by 6df8bae1dSRodney W. Grimes * Rick Macklem at The University of Guelph. 7df8bae1dSRodney W. Grimes * 8df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 9df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 10df8bae1dSRodney W. Grimes * are met: 11df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 12df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 13df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 14df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 15df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 16df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 17df8bae1dSRodney W. Grimes * must display the following acknowledgement: 18df8bae1dSRodney W. Grimes * This product includes software developed by the University of 19df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 20df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 21df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 22df8bae1dSRodney W. Grimes * without specific prior written permission. 23df8bae1dSRodney W. Grimes * 24df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34df8bae1dSRodney W. Grimes * SUCH DAMAGE. 35df8bae1dSRodney W. Grimes * 36df8bae1dSRodney W. Grimes * @(#)nfs.h 8.1 (Berkeley) 6/10/93 37a62dc406SDoug Rabson * $Id: nfs.h,v 1.9 1995/02/14 06:22:18 phk Exp $ 38df8bae1dSRodney W. Grimes */ 39df8bae1dSRodney W. Grimes 4033420ec6SPaul Richards #ifndef _NFS_NFS_H_ 4133420ec6SPaul Richards #define _NFS_NFS_H_ 4233420ec6SPaul Richards 43df8bae1dSRodney W. Grimes /* 44df8bae1dSRodney W. Grimes * Tunable constants for nfs 45df8bae1dSRodney W. Grimes */ 46df8bae1dSRodney W. Grimes 47df8bae1dSRodney W. Grimes #define NFS_MAXIOVEC 34 48a62dc406SDoug Rabson #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 49a62dc406SDoug Rabson #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 50df8bae1dSRodney W. Grimes #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 51df8bae1dSRodney W. Grimes #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 52df8bae1dSRodney W. Grimes #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 53df8bae1dSRodney W. Grimes #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 54df8bae1dSRodney W. Grimes #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 55df8bae1dSRodney W. Grimes #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 56df8bae1dSRodney W. Grimes #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 57df8bae1dSRodney W. Grimes #define NFS_MAXGRPS 16 /* Max. size of groups list */ 58b1b76581SDavid Greenman #ifndef NFS_MINATTRTIMO 59df8bae1dSRodney W. Grimes #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 60b1b76581SDavid Greenman #endif 61b1b76581SDavid Greenman #ifndef NFS_MAXATTRTIMO 62df8bae1dSRodney W. Grimes #define NFS_MAXATTRTIMO 60 63b1b76581SDavid Greenman #endif 64df8bae1dSRodney W. Grimes #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 65df8bae1dSRodney W. Grimes #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 66a62dc406SDoug Rabson #define NFS_READDIRSIZE 8192 /* Def. readdir size */ 67df8bae1dSRodney W. Grimes #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 68df8bae1dSRodney W. Grimes #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 69df8bae1dSRodney W. Grimes #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 70df8bae1dSRodney W. Grimes #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ 71a62dc406SDoug Rabson #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ 72a62dc406SDoug Rabson #ifndef NFS_GATHERDELAY 73a62dc406SDoug Rabson #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ 74a62dc406SDoug Rabson #endif 75a62dc406SDoug Rabson #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ 76a62dc406SDoug Rabson 77a62dc406SDoug Rabson /* 78a62dc406SDoug Rabson * Oddballs 79a62dc406SDoug Rabson */ 80df8bae1dSRodney W. Grimes #define NMOD(a) ((a) % nfs_asyncdaemons) 81a62dc406SDoug Rabson #define NFS_CMPFH(n, f, s) \ 82a62dc406SDoug Rabson ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 83a62dc406SDoug Rabson #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) 84a62dc406SDoug Rabson #define NFS_SRVMAXDATA(n) \ 85a62dc406SDoug Rabson (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ 86a62dc406SDoug Rabson NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) 87a62dc406SDoug Rabson 88a62dc406SDoug Rabson /* 89a62dc406SDoug Rabson * XXX 90a62dc406SDoug Rabson * sys/buf.h should be editted to change B_APPENDWRITE --> B_NEEDCOMMIT, but 91a62dc406SDoug Rabson * until then... 92a62dc406SDoug Rabson * Same goes for sys/malloc.h, which needs M_NFSDIROFF, 93a62dc406SDoug Rabson * M_NFSRVDESC and M_NFSBIGFH added. 94a62dc406SDoug Rabson * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an 95a62dc406SDoug Rabson * exclusive create. 96a62dc406SDoug Rabson * The B_INVAFTERWRITE flag should be set to whatever is required by the 97a62dc406SDoug Rabson * buffer cache code to say "Invalidate the block after it is written back". 98a62dc406SDoug Rabson */ 99a62dc406SDoug Rabson #ifndef B_NEEDCOMMIT 100a62dc406SDoug Rabson #define B_NEEDCOMMIT B_APPENDWRITE 101a62dc406SDoug Rabson #endif 102a62dc406SDoug Rabson #ifndef M_NFSRVDESC 103a62dc406SDoug Rabson #define M_NFSRVDESC M_TEMP 104a62dc406SDoug Rabson #endif 105a62dc406SDoug Rabson #ifndef M_NFSDIROFF 106a62dc406SDoug Rabson #define M_NFSDIROFF M_TEMP 107a62dc406SDoug Rabson #endif 108a62dc406SDoug Rabson #ifndef M_NFSBIGFH 109a62dc406SDoug Rabson #define M_NFSBIGFH M_TEMP 110a62dc406SDoug Rabson #endif 111a62dc406SDoug Rabson #ifndef VA_EXCLUSIVE 112a62dc406SDoug Rabson #define VA_EXCLUSIVE 0 113a62dc406SDoug Rabson #endif 114a62dc406SDoug Rabson #ifdef __FreeBSD__ 115a62dc406SDoug Rabson #define B_INVAFTERWRITE B_NOCACHE 116a62dc406SDoug Rabson #else 117a62dc406SDoug Rabson #define B_INVAFTERWRITE B_INVAL 118a62dc406SDoug Rabson #endif 119a62dc406SDoug Rabson 120a62dc406SDoug Rabson /* 121a62dc406SDoug Rabson * These ifdefs try to handle the differences between the various 4.4BSD-Lite 122a62dc406SDoug Rabson * based vfs interfaces. 123a62dc406SDoug Rabson * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to 124a62dc406SDoug Rabson * differentiate between NetBSD-1.0 and NetBSD-current, so.. 125a62dc406SDoug Rabson * I also don't know about BSDi's 2.0 release. 126a62dc406SDoug Rabson */ 127a62dc406SDoug Rabson #if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) 128a62dc406SDoug Rabson #define HAS_VOPLEASE 1 129a62dc406SDoug Rabson #endif 130a62dc406SDoug Rabson #if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) 131a62dc406SDoug Rabson #define HAS_VOPREVOKE 1 132a62dc406SDoug Rabson #endif 133a62dc406SDoug Rabson 134a62dc406SDoug Rabson /* 135a62dc406SDoug Rabson * The IO_METASYNC flag should be implemented for local file systems. 136a62dc406SDoug Rabson * (Until then, it is nothin at all.) 137a62dc406SDoug Rabson */ 138a62dc406SDoug Rabson #ifndef IO_METASYNC 139a62dc406SDoug Rabson #define IO_METASYNC 0 140a62dc406SDoug Rabson #endif 141df8bae1dSRodney W. Grimes 142df8bae1dSRodney W. Grimes /* 143df8bae1dSRodney W. Grimes * Set the attribute timeout based on how recently the file has been modified. 144df8bae1dSRodney W. Grimes */ 145df8bae1dSRodney W. Grimes #define NFS_ATTRTIMEO(np) \ 146df8bae1dSRodney W. Grimes ((((np)->n_flag & NMODIFIED) || \ 147df8bae1dSRodney W. Grimes (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ 148df8bae1dSRodney W. Grimes ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ 149df8bae1dSRodney W. Grimes (time.tv_sec - (np)->n_mtime) / 10)) 150df8bae1dSRodney W. Grimes 151df8bae1dSRodney W. Grimes /* 152a62dc406SDoug Rabson * Expected allocation sizes for major data structures. If the actual size 153a62dc406SDoug Rabson * of the structure exceeds these sizes, then malloc() will be allocating 154a62dc406SDoug Rabson * almost twice the memory required. This is used in nfs_init() to warn 155a62dc406SDoug Rabson * the sysadmin that the size of a structure should be reduced. 156a62dc406SDoug Rabson * (These sizes are always a power of 2. If the kernel malloc() changes 157a62dc406SDoug Rabson * to one that does not allocate space in powers of 2 size, then this all 158a62dc406SDoug Rabson * becomes bunk!) 159a62dc406SDoug Rabson */ 160a62dc406SDoug Rabson #define NFS_NODEALLOC 256 161a62dc406SDoug Rabson #define NFS_MNTALLOC 512 162a62dc406SDoug Rabson #define NFS_SVCALLOC 256 163a62dc406SDoug Rabson #define NFS_UIDALLOC 128 164a62dc406SDoug Rabson 165a62dc406SDoug Rabson /* 166df8bae1dSRodney W. Grimes * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 167df8bae1dSRodney W. Grimes * should ever try and use it. 168df8bae1dSRodney W. Grimes */ 169df8bae1dSRodney W. Grimes struct nfsd_args { 170df8bae1dSRodney W. Grimes int sock; /* Socket to serve */ 171df8bae1dSRodney W. Grimes caddr_t name; /* Client address for connection based sockets */ 172df8bae1dSRodney W. Grimes int namelen; /* Length of name */ 173df8bae1dSRodney W. Grimes }; 174df8bae1dSRodney W. Grimes 175df8bae1dSRodney W. Grimes struct nfsd_srvargs { 176df8bae1dSRodney W. Grimes struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 177df8bae1dSRodney W. Grimes uid_t nsd_uid; /* Effective uid mapped to cred */ 178df8bae1dSRodney W. Grimes u_long nsd_haddr; /* Ip address of client */ 179df8bae1dSRodney W. Grimes struct ucred nsd_cr; /* Cred. uid maps to */ 180df8bae1dSRodney W. Grimes int nsd_authlen; /* Length of auth string (ret) */ 181a62dc406SDoug Rabson u_char *nsd_authstr; /* Auth string (ret) */ 182a62dc406SDoug Rabson int nsd_verflen; /* and the verfier */ 183a62dc406SDoug Rabson u_char *nsd_verfstr; 184a62dc406SDoug Rabson struct timeval nsd_timestamp; /* timestamp from verifier */ 185a62dc406SDoug Rabson u_long nsd_ttl; /* credential ttl (sec) */ 186a62dc406SDoug Rabson NFSKERBKEY_T nsd_key; /* Session key */ 187df8bae1dSRodney W. Grimes }; 188df8bae1dSRodney W. Grimes 189df8bae1dSRodney W. Grimes struct nfsd_cargs { 190df8bae1dSRodney W. Grimes char *ncd_dirp; /* Mount dir path */ 191df8bae1dSRodney W. Grimes uid_t ncd_authuid; /* Effective uid */ 192df8bae1dSRodney W. Grimes int ncd_authtype; /* Type of authenticator */ 193df8bae1dSRodney W. Grimes int ncd_authlen; /* Length of authenticator string */ 194a62dc406SDoug Rabson u_char *ncd_authstr; /* Authenticator string */ 195a62dc406SDoug Rabson int ncd_verflen; /* and the verifier */ 196a62dc406SDoug Rabson u_char *ncd_verfstr; 197a62dc406SDoug Rabson NFSKERBKEY_T ncd_key; /* Session key */ 198df8bae1dSRodney W. Grimes }; 199df8bae1dSRodney W. Grimes 200df8bae1dSRodney W. Grimes /* 201df8bae1dSRodney W. Grimes * Stats structure 202df8bae1dSRodney W. Grimes */ 203df8bae1dSRodney W. Grimes struct nfsstats { 204df8bae1dSRodney W. Grimes int attrcache_hits; 205df8bae1dSRodney W. Grimes int attrcache_misses; 206df8bae1dSRodney W. Grimes int lookupcache_hits; 207df8bae1dSRodney W. Grimes int lookupcache_misses; 208df8bae1dSRodney W. Grimes int direofcache_hits; 209df8bae1dSRodney W. Grimes int direofcache_misses; 210df8bae1dSRodney W. Grimes int biocache_reads; 211df8bae1dSRodney W. Grimes int read_bios; 212df8bae1dSRodney W. Grimes int read_physios; 213df8bae1dSRodney W. Grimes int biocache_writes; 214df8bae1dSRodney W. Grimes int write_bios; 215df8bae1dSRodney W. Grimes int write_physios; 216df8bae1dSRodney W. Grimes int biocache_readlinks; 217df8bae1dSRodney W. Grimes int readlink_bios; 218df8bae1dSRodney W. Grimes int biocache_readdirs; 219df8bae1dSRodney W. Grimes int readdir_bios; 220df8bae1dSRodney W. Grimes int rpccnt[NFS_NPROCS]; 221df8bae1dSRodney W. Grimes int rpcretries; 222df8bae1dSRodney W. Grimes int srvrpccnt[NFS_NPROCS]; 223df8bae1dSRodney W. Grimes int srvrpc_errs; 224df8bae1dSRodney W. Grimes int srv_errs; 225df8bae1dSRodney W. Grimes int rpcrequests; 226df8bae1dSRodney W. Grimes int rpctimeouts; 227df8bae1dSRodney W. Grimes int rpcunexpected; 228df8bae1dSRodney W. Grimes int rpcinvalid; 229df8bae1dSRodney W. Grimes int srvcache_inproghits; 230df8bae1dSRodney W. Grimes int srvcache_idemdonehits; 231df8bae1dSRodney W. Grimes int srvcache_nonidemdonehits; 232df8bae1dSRodney W. Grimes int srvcache_misses; 233df8bae1dSRodney W. Grimes int srvnqnfs_leases; 234df8bae1dSRodney W. Grimes int srvnqnfs_maxleases; 235df8bae1dSRodney W. Grimes int srvnqnfs_getleases; 236a62dc406SDoug Rabson int srvvop_writes; 237df8bae1dSRodney W. Grimes }; 238df8bae1dSRodney W. Grimes 239df8bae1dSRodney W. Grimes /* 240df8bae1dSRodney W. Grimes * Flags for nfssvc() system call. 241df8bae1dSRodney W. Grimes */ 242df8bae1dSRodney W. Grimes #define NFSSVC_BIOD 0x002 243df8bae1dSRodney W. Grimes #define NFSSVC_NFSD 0x004 244df8bae1dSRodney W. Grimes #define NFSSVC_ADDSOCK 0x008 245df8bae1dSRodney W. Grimes #define NFSSVC_AUTHIN 0x010 246df8bae1dSRodney W. Grimes #define NFSSVC_GOTAUTH 0x040 247df8bae1dSRodney W. Grimes #define NFSSVC_AUTHINFAIL 0x080 248df8bae1dSRodney W. Grimes #define NFSSVC_MNTD 0x100 249df8bae1dSRodney W. Grimes 250df8bae1dSRodney W. Grimes /* 251b43e29afSGarrett Wollman * fs.nfs sysctl(3) identifiers 252b43e29afSGarrett Wollman */ 253b43e29afSGarrett Wollman #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 254b43e29afSGarrett Wollman 255b43e29afSGarrett Wollman #define FS_NFS_NAMES { \ 256b43e29afSGarrett Wollman { 0, 0 }, \ 257b43e29afSGarrett Wollman { "nfsstats", CTLTYPE_STRUCT }, \ 258b43e29afSGarrett Wollman } 259b43e29afSGarrett Wollman 260b43e29afSGarrett Wollman /* 261df8bae1dSRodney W. Grimes * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 262df8bae1dSRodney W. Grimes * What should be in this set is open to debate, but I believe that since 263df8bae1dSRodney W. Grimes * I/O system calls on ufs are never interrupted by signals the set should 264df8bae1dSRodney W. Grimes * be minimal. My reasoning is that many current programs that use signals 265df8bae1dSRodney W. Grimes * such as SIGALRM will not expect file I/O system calls to be interrupted 266df8bae1dSRodney W. Grimes * by them and break. 267df8bae1dSRodney W. Grimes */ 268a62dc406SDoug Rabson #if defined(KERNEL) || defined(_KERNEL) 269d9e91095SGarrett Wollman 270d9e91095SGarrett Wollman struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 271d9e91095SGarrett Wollman 272df8bae1dSRodney W. Grimes #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 273df8bae1dSRodney W. Grimes sigmask(SIGHUP)|sigmask(SIGQUIT)) 274df8bae1dSRodney W. Grimes 275df8bae1dSRodney W. Grimes /* 276df8bae1dSRodney W. Grimes * Socket errors ignored for connectionless sockets?? 277df8bae1dSRodney W. Grimes * For now, ignore them all 278df8bae1dSRodney W. Grimes */ 279df8bae1dSRodney W. Grimes #define NFSIGNORE_SOERROR(s, e) \ 280df8bae1dSRodney W. Grimes ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 281df8bae1dSRodney W. Grimes ((s) & PR_CONNREQUIRED) == 0) 282df8bae1dSRodney W. Grimes 283df8bae1dSRodney W. Grimes /* 284df8bae1dSRodney W. Grimes * Nfs outstanding request list element 285df8bae1dSRodney W. Grimes */ 286df8bae1dSRodney W. Grimes struct nfsreq { 2876ae32407SPoul-Henning Kamp TAILQ_ENTRY(nfsreq) r_chain; 288df8bae1dSRodney W. Grimes struct mbuf *r_mreq; 289df8bae1dSRodney W. Grimes struct mbuf *r_mrep; 290df8bae1dSRodney W. Grimes struct mbuf *r_md; 291df8bae1dSRodney W. Grimes caddr_t r_dpos; 292df8bae1dSRodney W. Grimes struct nfsmount *r_nmp; 293df8bae1dSRodney W. Grimes struct vnode *r_vp; 294df8bae1dSRodney W. Grimes u_long r_xid; 295df8bae1dSRodney W. Grimes int r_flags; /* flags on request, see below */ 296df8bae1dSRodney W. Grimes int r_retry; /* max retransmission count */ 297df8bae1dSRodney W. Grimes int r_rexmit; /* current retrans count */ 298df8bae1dSRodney W. Grimes int r_timer; /* tick counter on reply */ 299df8bae1dSRodney W. Grimes int r_procnum; /* NFS procedure number */ 300df8bae1dSRodney W. Grimes int r_rtt; /* RTT for rpc */ 301df8bae1dSRodney W. Grimes struct proc *r_procp; /* Proc that did I/O system call */ 302df8bae1dSRodney W. Grimes }; 303df8bae1dSRodney W. Grimes 3046ae32407SPoul-Henning Kamp /* 3056ae32407SPoul-Henning Kamp * Queue head for nfsreq's 3066ae32407SPoul-Henning Kamp */ 3076ae32407SPoul-Henning Kamp TAILQ_HEAD(, nfsreq) nfs_reqq; 3086ae32407SPoul-Henning Kamp 309df8bae1dSRodney W. Grimes /* Flag values for r_flags */ 310df8bae1dSRodney W. Grimes #define R_TIMING 0x01 /* timing request (in mntp) */ 311df8bae1dSRodney W. Grimes #define R_SENT 0x02 /* request has been sent */ 312df8bae1dSRodney W. Grimes #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 313df8bae1dSRodney W. Grimes #define R_INTR 0x08 /* intr mnt, signal pending */ 314df8bae1dSRodney W. Grimes #define R_SOCKERR 0x10 /* Fatal error on socket */ 315df8bae1dSRodney W. Grimes #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 316df8bae1dSRodney W. Grimes #define R_MUSTRESEND 0x40 /* Must resend request */ 317df8bae1dSRodney W. Grimes #define R_GETONEREP 0x80 /* Probe for one reply only */ 318df8bae1dSRodney W. Grimes 319df8bae1dSRodney W. Grimes /* 320df8bae1dSRodney W. Grimes * A list of nfssvc_sock structures is maintained with all the sockets 321df8bae1dSRodney W. Grimes * that require service by the nfsd. 322df8bae1dSRodney W. Grimes * The nfsuid structs hang off of the nfssvc_sock structs in both lru 323df8bae1dSRodney W. Grimes * and uid hash lists. 324df8bae1dSRodney W. Grimes */ 325a62dc406SDoug Rabson #ifndef NFS_UIDHASHSIZ 326a62dc406SDoug Rabson #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 327a62dc406SDoug Rabson #endif 3286ae32407SPoul-Henning Kamp #define NUIDHASH(sock, uid) \ 329a62dc406SDoug Rabson (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 330a62dc406SDoug Rabson #ifndef NFS_WDELAYHASHSIZ 331a62dc406SDoug Rabson #define NFS_WDELAYHASHSIZ 16 /* and with this */ 332a62dc406SDoug Rabson #endif 333a62dc406SDoug Rabson #define NWDELAYHASH(sock, f) \ 334a62dc406SDoug Rabson (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) 335a62dc406SDoug Rabson #ifndef NFS_MUIDHASHSIZ 336a62dc406SDoug Rabson #define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */ 337a62dc406SDoug Rabson #endif 338a62dc406SDoug Rabson #define NMUIDHASH(nmp, uid) \ 339a62dc406SDoug Rabson (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 340a62dc406SDoug Rabson #define NFSNOHASH(fhsum) \ 341a62dc406SDoug Rabson (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 342df8bae1dSRodney W. Grimes 343df8bae1dSRodney W. Grimes /* 344df8bae1dSRodney W. Grimes * Network address hash list element 345df8bae1dSRodney W. Grimes */ 346df8bae1dSRodney W. Grimes union nethostaddr { 347df8bae1dSRodney W. Grimes u_long had_inetaddr; 348df8bae1dSRodney W. Grimes struct mbuf *had_nam; 349df8bae1dSRodney W. Grimes }; 350df8bae1dSRodney W. Grimes 351df8bae1dSRodney W. Grimes struct nfsuid { 3526ae32407SPoul-Henning Kamp TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 3536ae32407SPoul-Henning Kamp LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 354df8bae1dSRodney W. Grimes int nu_flag; /* Flags */ 355df8bae1dSRodney W. Grimes union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 356df8bae1dSRodney W. Grimes struct ucred nu_cr; /* Cred uid mapped to */ 357a62dc406SDoug Rabson int nu_expire; /* Expiry time (sec) */ 358a62dc406SDoug Rabson struct timeval nu_timestamp; /* Kerb. timestamp */ 359a62dc406SDoug Rabson u_long nu_nickname; /* Nickname on server */ 360a62dc406SDoug Rabson NFSKERBKEY_T nu_key; /* and session key */ 361df8bae1dSRodney W. Grimes }; 362df8bae1dSRodney W. Grimes 363df8bae1dSRodney W. Grimes #define nu_inetaddr nu_haddr.had_inetaddr 364df8bae1dSRodney W. Grimes #define nu_nam nu_haddr.had_nam 365df8bae1dSRodney W. Grimes /* Bits for nu_flag */ 366df8bae1dSRodney W. Grimes #define NU_INETADDR 0x1 367a62dc406SDoug Rabson #define NU_NAM 0x2 368a62dc406SDoug Rabson #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 369df8bae1dSRodney W. Grimes 370df8bae1dSRodney W. Grimes struct nfssvc_sock { 3716ae32407SPoul-Henning Kamp TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 3726ae32407SPoul-Henning Kamp TAILQ_HEAD(, nfsuid) ns_uidlruhead; 373df8bae1dSRodney W. Grimes struct file *ns_fp; 374df8bae1dSRodney W. Grimes struct socket *ns_so; 375df8bae1dSRodney W. Grimes struct mbuf *ns_nam; 376df8bae1dSRodney W. Grimes struct mbuf *ns_raw; 377df8bae1dSRodney W. Grimes struct mbuf *ns_rawend; 378df8bae1dSRodney W. Grimes struct mbuf *ns_rec; 379df8bae1dSRodney W. Grimes struct mbuf *ns_recend; 380a62dc406SDoug Rabson struct mbuf *ns_frag; 381a62dc406SDoug Rabson int ns_flag; 382a62dc406SDoug Rabson int ns_solock; 383a62dc406SDoug Rabson int ns_cc; 384a62dc406SDoug Rabson int ns_reclen; 385df8bae1dSRodney W. Grimes int ns_numuids; 386a62dc406SDoug Rabson u_long ns_sref; 387a62dc406SDoug Rabson LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 388a62dc406SDoug Rabson LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 389a62dc406SDoug Rabson LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 390df8bae1dSRodney W. Grimes }; 391df8bae1dSRodney W. Grimes 392df8bae1dSRodney W. Grimes /* Bits for "ns_flag" */ 393df8bae1dSRodney W. Grimes #define SLP_VALID 0x01 394df8bae1dSRodney W. Grimes #define SLP_DOREC 0x02 395df8bae1dSRodney W. Grimes #define SLP_NEEDQ 0x04 396df8bae1dSRodney W. Grimes #define SLP_DISCONN 0x08 397df8bae1dSRodney W. Grimes #define SLP_GETSTREAM 0x10 398a62dc406SDoug Rabson #define SLP_LASTFRAG 0x20 399df8bae1dSRodney W. Grimes #define SLP_ALLFLAGS 0xff 400df8bae1dSRodney W. Grimes 4016ae32407SPoul-Henning Kamp TAILQ_HEAD(, nfssvc_sock) nfssvc_sockhead; 4026ae32407SPoul-Henning Kamp int nfssvc_sockhead_flag; 4036ae32407SPoul-Henning Kamp #define SLP_INIT 0x01 4046ae32407SPoul-Henning Kamp #define SLP_WANTINIT 0x02 4056ae32407SPoul-Henning Kamp 406df8bae1dSRodney W. Grimes /* 407df8bae1dSRodney W. Grimes * One of these structures is allocated for each nfsd. 408df8bae1dSRodney W. Grimes */ 409df8bae1dSRodney W. Grimes struct nfsd { 410a62dc406SDoug Rabson TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 411a62dc406SDoug Rabson int nfsd_flag; /* NFSD_ flags */ 412a62dc406SDoug Rabson struct nfssvc_sock *nfsd_slp; /* Current socket */ 413a62dc406SDoug Rabson int nfsd_authlen; /* Authenticator len */ 414a62dc406SDoug Rabson u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 415a62dc406SDoug Rabson int nfsd_verflen; /* and the Verifier */ 416a62dc406SDoug Rabson u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 417a62dc406SDoug Rabson struct proc *nfsd_procp; /* Proc ptr */ 418a62dc406SDoug Rabson struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 419df8bae1dSRodney W. Grimes }; 420df8bae1dSRodney W. Grimes 421a62dc406SDoug Rabson /* Bits for "nfsd_flag" */ 422df8bae1dSRodney W. Grimes #define NFSD_WAITING 0x01 4236ae32407SPoul-Henning Kamp #define NFSD_REQINPROG 0x02 4246ae32407SPoul-Henning Kamp #define NFSD_NEEDAUTH 0x04 4256ae32407SPoul-Henning Kamp #define NFSD_AUTHFAIL 0x08 4266ae32407SPoul-Henning Kamp 427a62dc406SDoug Rabson /* 428a62dc406SDoug Rabson * This structure is used by the server for describing each request. 429a62dc406SDoug Rabson * Some fields are used only when write request gathering is performed. 430a62dc406SDoug Rabson */ 431a62dc406SDoug Rabson struct nfsrv_descript { 432a62dc406SDoug Rabson u_quad_t nd_time; /* Write deadline (usec) */ 433a62dc406SDoug Rabson off_t nd_off; /* Start byte offset */ 434a62dc406SDoug Rabson off_t nd_eoff; /* and end byte offset */ 435a62dc406SDoug Rabson LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 436a62dc406SDoug Rabson LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 437a62dc406SDoug Rabson LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 438a62dc406SDoug Rabson struct mbuf *nd_mrep; /* Request mbuf list */ 439a62dc406SDoug Rabson struct mbuf *nd_md; /* Current dissect mbuf */ 440a62dc406SDoug Rabson struct mbuf *nd_mreq; /* Reply mbuf list */ 441a62dc406SDoug Rabson struct mbuf *nd_nam; /* and socket addr */ 442a62dc406SDoug Rabson struct mbuf *nd_nam2; /* return socket addr */ 443a62dc406SDoug Rabson caddr_t nd_dpos; /* Current dissect pos */ 444a62dc406SDoug Rabson int nd_procnum; /* RPC # */ 445a62dc406SDoug Rabson int nd_stable; /* storage type */ 446a62dc406SDoug Rabson int nd_flag; /* nd_flag */ 447a62dc406SDoug Rabson int nd_len; /* Length of this write */ 448a62dc406SDoug Rabson int nd_repstat; /* Reply status */ 449a62dc406SDoug Rabson u_long nd_retxid; /* Reply xid */ 450a62dc406SDoug Rabson u_long nd_duration; /* Lease duration */ 451a62dc406SDoug Rabson struct timeval nd_starttime; /* Time RPC initiated */ 452a62dc406SDoug Rabson fhandle_t nd_fh; /* File handle */ 453a62dc406SDoug Rabson struct ucred nd_cr; /* Credentials */ 454a62dc406SDoug Rabson }; 455a62dc406SDoug Rabson 456a62dc406SDoug Rabson /* Bits for "nd_flag" */ 457a62dc406SDoug Rabson #define ND_READ LEASE_READ 458a62dc406SDoug Rabson #define ND_WRITE LEASE_WRITE 459a62dc406SDoug Rabson #define ND_CHECK 0x04 460a62dc406SDoug Rabson #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 461a62dc406SDoug Rabson #define ND_NFSV3 0x08 462a62dc406SDoug Rabson #define ND_NQNFS 0x10 463a62dc406SDoug Rabson #define ND_KERBNICK 0x20 464a62dc406SDoug Rabson #define ND_KERBFULL 0x40 465a62dc406SDoug Rabson #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 466a62dc406SDoug Rabson 4676ae32407SPoul-Henning Kamp TAILQ_HEAD(, nfsd) nfsd_head; 4686ae32407SPoul-Henning Kamp int nfsd_head_flag; 4696ae32407SPoul-Henning Kamp #define NFSD_CHECKSLP 0x01 47048fbb6ccSPoul-Henning Kamp 471a62dc406SDoug Rabson /* 472a62dc406SDoug Rabson * These macros compare nfsrv_descript structures. 473a62dc406SDoug Rabson */ 474a62dc406SDoug Rabson #define NFSW_CONTIG(o, n) \ 475a62dc406SDoug Rabson ((o)->nd_eoff >= (n)->nd_off && \ 476a62dc406SDoug Rabson !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 477a62dc406SDoug Rabson 478a62dc406SDoug Rabson #define NFSW_SAMECRED(o, n) \ 479a62dc406SDoug Rabson (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 480a62dc406SDoug Rabson !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 481a62dc406SDoug Rabson sizeof (struct ucred))) 482a62dc406SDoug Rabson 48348fbb6ccSPoul-Henning Kamp int nfs_reply __P((struct nfsreq *)); 484a62dc406SDoug Rabson int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 48548fbb6ccSPoul-Henning Kamp int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 486a62dc406SDoug Rabson int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 48748fbb6ccSPoul-Henning Kamp int nfs_sndlock __P((int *,struct nfsreq *)); 48848fbb6ccSPoul-Henning Kamp int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 48948fbb6ccSPoul-Henning Kamp int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 49048fbb6ccSPoul-Henning Kamp int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 491a62dc406SDoug Rabson int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 49248fbb6ccSPoul-Henning Kamp int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 493a62dc406SDoug Rabson int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); 49448fbb6ccSPoul-Henning Kamp int nfs_asyncio __P((struct buf *,struct ucred *)); 49548fbb6ccSPoul-Henning Kamp int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 49648fbb6ccSPoul-Henning Kamp int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 49748fbb6ccSPoul-Henning Kamp int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 498a62dc406SDoug Rabson int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 49948fbb6ccSPoul-Henning Kamp int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 500a62dc406SDoug Rabson void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 501a62dc406SDoug Rabson void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 502a62dc406SDoug Rabson void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 503a62dc406SDoug Rabson int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *,int)); 50448fbb6ccSPoul-Henning Kamp int nfsrv_access __P((struct vnode *,int,struct ucred *,int,struct proc *)); 50548fbb6ccSPoul-Henning Kamp int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 50648fbb6ccSPoul-Henning Kamp int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 50748fbb6ccSPoul-Henning Kamp int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 508a62dc406SDoug Rabson int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 50948fbb6ccSPoul-Henning Kamp void nfsm_adj __P((struct mbuf *,int,int)); 51048fbb6ccSPoul-Henning Kamp int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 51148fbb6ccSPoul-Henning Kamp void nfsrv_initcache __P((void)); 51248fbb6ccSPoul-Henning Kamp int nfs_rcvlock __P((struct nfsreq *)); 513a62dc406SDoug Rabson int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 514a62dc406SDoug Rabson int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 515a62dc406SDoug Rabson int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 51648fbb6ccSPoul-Henning Kamp int nfs_msg __P((struct proc *,char *,char *)); 51748fbb6ccSPoul-Henning Kamp int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 51848fbb6ccSPoul-Henning Kamp int nfsrv_getstream __P((struct nfssvc_sock *,int)); 51948fbb6ccSPoul-Henning Kamp void nfs_nhinit __P((void)); 52048fbb6ccSPoul-Henning Kamp void nfs_timer __P((void*)); 521a62dc406SDoug Rabson u_long nfs_hash __P((nfsfh_t *,int)); 52248fbb6ccSPoul-Henning Kamp int nfssvc_iod __P((struct proc *)); 52348fbb6ccSPoul-Henning Kamp int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); 52448fbb6ccSPoul-Henning Kamp int nfssvc_addsock __P((struct file *,struct mbuf *)); 525a62dc406SDoug Rabson int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 526a62dc406SDoug Rabson int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 527a62dc406SDoug Rabson void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 52848fbb6ccSPoul-Henning Kamp int mountnfs __P((struct nfs_args *,struct mount *,struct mbuf *,char *,char *,struct vnode **)); 52948fbb6ccSPoul-Henning Kamp int nfs_connect __P((struct nfsmount *,struct nfsreq *)); 53048fbb6ccSPoul-Henning Kamp int nfs_getattrcache __P((struct vnode *,struct vattr *)); 53148fbb6ccSPoul-Henning Kamp int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 53248fbb6ccSPoul-Henning Kamp int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 53348fbb6ccSPoul-Henning Kamp int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 53448fbb6ccSPoul-Henning Kamp void nfsrv_init __P((int)); 535a62dc406SDoug Rabson void nfs_clearcommit __P((struct mount *)); 536a62dc406SDoug Rabson int nfsrv_errmap __P((struct nfsrv_descript *, int)); 537a62dc406SDoug Rabson void nfsrvw_coalesce __P((struct nfsrv_descript *,struct nfsrv_descript *)); 538a62dc406SDoug Rabson void nfsrvw_sort __P((gid_t [],int)); 539a62dc406SDoug Rabson void nfsrv_setcred __P((struct ucred *,struct ucred *)); 540a62dc406SDoug Rabson int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); 541a62dc406SDoug Rabson int nfs_writebp __P((struct buf *,int)); 542473e9734SPoul-Henning Kamp int nfsrv_vput __P(( struct vnode * )); 543473e9734SPoul-Henning Kamp int nfsrv_vrele __P(( struct vnode * )); 544473e9734SPoul-Henning Kamp int nfsrv_vmio __P(( struct vnode * )); 545a62dc406SDoug Rabson int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 546a62dc406SDoug Rabson struct proc *, struct mbuf **)); 547a62dc406SDoug Rabson int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 548a62dc406SDoug Rabson struct proc *p)); 549473e9734SPoul-Henning Kamp 550df8bae1dSRodney W. Grimes #endif /* KERNEL */ 55133420ec6SPaul Richards 55233420ec6SPaul Richards #endif 553