138414Smckusick /* 268653Smckusick * Copyright (c) 1989, 1993, 1995 363233Sbostic * The Regents of the University of California. All rights reserved. 438414Smckusick * 538414Smckusick * This code is derived from software contributed to Berkeley by 638414Smckusick * Rick Macklem at The University of Guelph. 738414Smckusick * 844509Sbostic * %sccs.include.redist.c% 938414Smckusick * 10*69134Smckusick * @(#)nfs.h 8.4 (Berkeley) 05/01/95 1138414Smckusick */ 1238414Smckusick 1368653Smckusick #ifndef _NFS_NFS_H_ 1468653Smckusick #define _NFS_NFS_H_ 1568653Smckusick 1638414Smckusick /* 1738414Smckusick * Tunable constants for nfs 1838414Smckusick */ 1940116Smckusick 2043345Smckusick #define NFS_MAXIOVEC 34 2168653Smckusick #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 2268653Smckusick #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 2368653Smckusick #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 2468653Smckusick #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 2568653Smckusick #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 2668653Smckusick #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 2740116Smckusick #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 2840116Smckusick #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 2940116Smckusick #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 3052139Smckusick #define NFS_MAXGRPS 16 /* Max. size of groups list */ 3168653Smckusick #ifndef NFS_MINATTRTIMO 3256276Smckusick #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 3368653Smckusick #endif 3468653Smckusick #ifndef NFS_MAXATTRTIMO 3556276Smckusick #define NFS_MAXATTRTIMO 60 3668653Smckusick #endif 3743345Smckusick #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 3843345Smckusick #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 3968653Smckusick #define NFS_READDIRSIZE 8192 /* Def. readdir size */ 4052139Smckusick #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 4152139Smckusick #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 4252139Smckusick #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 4368653Smckusick #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ 4468653Smckusick #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ 4568653Smckusick #ifndef NFS_GATHERDELAY 4668653Smckusick #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ 4768653Smckusick #endif 4868653Smckusick #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ 4968653Smckusick 5068653Smckusick /* 5168653Smckusick * Oddballs 5268653Smckusick */ 5339339Smckusick #define NMOD(a) ((a) % nfs_asyncdaemons) 5468653Smckusick #define NFS_CMPFH(n, f, s) \ 5568653Smckusick ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 5668653Smckusick #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) 5768653Smckusick #define NFS_SRVMAXDATA(n) \ 5868653Smckusick (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ 5968653Smckusick NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) 6038414Smckusick 6141906Smckusick /* 6268653Smckusick * XXX 6368653Smckusick * The B_INVAFTERWRITE flag should be set to whatever is required by the 6468653Smckusick * buffer cache code to say "Invalidate the block after it is written back". 6568653Smckusick */ 6668653Smckusick #define B_INVAFTERWRITE B_INVAL 6768653Smckusick 6868653Smckusick /* 6968653Smckusick * The IO_METASYNC flag should be implemented for local file systems. 7068653Smckusick * (Until then, it is nothin at all.) 7168653Smckusick */ 7268653Smckusick #ifndef IO_METASYNC 7368653Smckusick #define IO_METASYNC 0 7468653Smckusick #endif 7568653Smckusick 7668653Smckusick /* 7756276Smckusick * Set the attribute timeout based on how recently the file has been modified. 7856276Smckusick */ 7956276Smckusick #define NFS_ATTRTIMEO(np) \ 8056276Smckusick ((((np)->n_flag & NMODIFIED) || \ 8156598Smckusick (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ 8256598Smckusick ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ 8356598Smckusick (time.tv_sec - (np)->n_mtime) / 10)) 8456276Smckusick 8556276Smckusick /* 8668653Smckusick * Expected allocation sizes for major data structures. If the actual size 8768653Smckusick * of the structure exceeds these sizes, then malloc() will be allocating 8868653Smckusick * almost twice the memory required. This is used in nfs_init() to warn 8968653Smckusick * the sysadmin that the size of a structure should be reduced. 9068653Smckusick * (These sizes are always a power of 2. If the kernel malloc() changes 9168653Smckusick * to one that does not allocate space in powers of 2 size, then this all 9268653Smckusick * becomes bunk!) 9368653Smckusick */ 9468653Smckusick #define NFS_NODEALLOC 256 9568653Smckusick #define NFS_MNTALLOC 512 9668653Smckusick #define NFS_SVCALLOC 256 9768653Smckusick #define NFS_UIDALLOC 128 9868653Smckusick 9968653Smckusick /* 10068653Smckusick * Arguments to mount NFS 10168653Smckusick */ 102*69134Smckusick #define NFS_ARGSVERSION 3 /* change when nfs_args changes */ 10368653Smckusick struct nfs_args { 104*69134Smckusick int version; /* args structure version number */ 10568653Smckusick struct sockaddr *addr; /* file server address */ 10668653Smckusick int addrlen; /* length of address */ 10768653Smckusick int sotype; /* Socket type */ 10868653Smckusick int proto; /* and Protocol */ 10968653Smckusick u_char *fh; /* File handle to be mounted */ 11068653Smckusick int fhsize; /* Size, in bytes, of fh */ 11168653Smckusick int flags; /* flags */ 11268653Smckusick int wsize; /* write size in bytes */ 11368653Smckusick int rsize; /* read size in bytes */ 11468653Smckusick int readdirsize; /* readdir size in bytes */ 11568653Smckusick int timeo; /* initial timeout in .1 secs */ 11668653Smckusick int retrans; /* times to retry send */ 11768653Smckusick int maxgrouplist; /* Max. size of group list */ 11868653Smckusick int readahead; /* # of blocks to readahead */ 11968653Smckusick int leaseterm; /* Term (sec) of lease */ 12068653Smckusick int deadthresh; /* Retrans threshold */ 12168653Smckusick char *hostname; /* server's name */ 12268653Smckusick }; 12368653Smckusick 12468653Smckusick /* 12568653Smckusick * NFS mount option flags 12668653Smckusick */ 12768653Smckusick #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 12868653Smckusick #define NFSMNT_WSIZE 0x00000002 /* set write size */ 12968653Smckusick #define NFSMNT_RSIZE 0x00000004 /* set read size */ 13068653Smckusick #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 13168653Smckusick #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ 13268653Smckusick #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 13368653Smckusick #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 13468653Smckusick #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 13568653Smckusick #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 13668653Smckusick #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ 13768653Smckusick #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 13868653Smckusick #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 13968653Smckusick #define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ 14068653Smckusick #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ 14168653Smckusick #define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ 14268653Smckusick #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ 14368653Smckusick #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ 14468653Smckusick #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ 14568653Smckusick #define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ 14668653Smckusick #define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ 14768653Smckusick #define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ 14868653Smckusick #define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ 14968653Smckusick #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ 15068653Smckusick #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ 15168653Smckusick #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ 15268653Smckusick #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ 15368653Smckusick #define NFSMNT_WANTSND 0x02000000 /* Want above */ 15468653Smckusick #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ 15568653Smckusick #define NFSMNT_WANTRCV 0x08000000 /* Want above */ 15668653Smckusick #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ 15768653Smckusick #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ 15868653Smckusick #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ 15968653Smckusick #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ 16068653Smckusick 16168653Smckusick /* 16252139Smckusick * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 16352139Smckusick * should ever try and use it. 16452139Smckusick */ 16552139Smckusick struct nfsd_args { 16652139Smckusick int sock; /* Socket to serve */ 16768653Smckusick caddr_t name; /* Client addr for connection based sockets */ 16852139Smckusick int namelen; /* Length of name */ 16952139Smckusick }; 17052139Smckusick 17152139Smckusick struct nfsd_srvargs { 17252139Smckusick struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 17352139Smckusick uid_t nsd_uid; /* Effective uid mapped to cred */ 17452139Smckusick u_long nsd_haddr; /* Ip address of client */ 17552139Smckusick struct ucred nsd_cr; /* Cred. uid maps to */ 17652139Smckusick int nsd_authlen; /* Length of auth string (ret) */ 17768653Smckusick u_char *nsd_authstr; /* Auth string (ret) */ 17868653Smckusick int nsd_verflen; /* and the verfier */ 17968653Smckusick u_char *nsd_verfstr; 18068653Smckusick struct timeval nsd_timestamp; /* timestamp from verifier */ 18168653Smckusick u_long nsd_ttl; /* credential ttl (sec) */ 18268653Smckusick NFSKERBKEY_T nsd_key; /* Session key */ 18352139Smckusick }; 18452139Smckusick 18552139Smckusick struct nfsd_cargs { 18652139Smckusick char *ncd_dirp; /* Mount dir path */ 18752139Smckusick uid_t ncd_authuid; /* Effective uid */ 18852139Smckusick int ncd_authtype; /* Type of authenticator */ 18952139Smckusick int ncd_authlen; /* Length of authenticator string */ 19068653Smckusick u_char *ncd_authstr; /* Authenticator string */ 19168653Smckusick int ncd_verflen; /* and the verifier */ 19268653Smckusick u_char *ncd_verfstr; 19368653Smckusick NFSKERBKEY_T ncd_key; /* Session key */ 19452139Smckusick }; 19552139Smckusick 19652139Smckusick /* 19752139Smckusick * Stats structure 19852139Smckusick */ 19952139Smckusick struct nfsstats { 20052139Smckusick int attrcache_hits; 20152139Smckusick int attrcache_misses; 20252139Smckusick int lookupcache_hits; 20352139Smckusick int lookupcache_misses; 20452139Smckusick int direofcache_hits; 20552139Smckusick int direofcache_misses; 20652139Smckusick int biocache_reads; 20752139Smckusick int read_bios; 20852139Smckusick int read_physios; 20952139Smckusick int biocache_writes; 21052139Smckusick int write_bios; 21152139Smckusick int write_physios; 21252139Smckusick int biocache_readlinks; 21352139Smckusick int readlink_bios; 21452139Smckusick int biocache_readdirs; 21552139Smckusick int readdir_bios; 21652139Smckusick int rpccnt[NFS_NPROCS]; 21752139Smckusick int rpcretries; 21852139Smckusick int srvrpccnt[NFS_NPROCS]; 21952139Smckusick int srvrpc_errs; 22052139Smckusick int srv_errs; 22152139Smckusick int rpcrequests; 22252139Smckusick int rpctimeouts; 22352139Smckusick int rpcunexpected; 22452139Smckusick int rpcinvalid; 22552139Smckusick int srvcache_inproghits; 22652139Smckusick int srvcache_idemdonehits; 22752139Smckusick int srvcache_nonidemdonehits; 22852139Smckusick int srvcache_misses; 22952139Smckusick int srvnqnfs_leases; 23052139Smckusick int srvnqnfs_maxleases; 23152139Smckusick int srvnqnfs_getleases; 23268653Smckusick int srvvop_writes; 23352139Smckusick }; 23452139Smckusick 23552139Smckusick /* 23652139Smckusick * Flags for nfssvc() system call. 23752139Smckusick */ 23852139Smckusick #define NFSSVC_BIOD 0x002 23952139Smckusick #define NFSSVC_NFSD 0x004 24052139Smckusick #define NFSSVC_ADDSOCK 0x008 24152139Smckusick #define NFSSVC_AUTHIN 0x010 24252139Smckusick #define NFSSVC_GOTAUTH 0x040 24352139Smckusick #define NFSSVC_AUTHINFAIL 0x080 24452139Smckusick #define NFSSVC_MNTD 0x100 24552139Smckusick 24652139Smckusick /* 24768653Smckusick * fs.nfs sysctl(3) identifiers 24868653Smckusick */ 24968653Smckusick #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 25068653Smckusick 25168653Smckusick #define FS_NFS_NAMES { \ 25268653Smckusick { 0, 0 }, \ 25368653Smckusick { "nfsstats", CTLTYPE_STRUCT }, \ 25468653Smckusick } 25568653Smckusick 25668653Smckusick /* 25741906Smckusick * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 25841906Smckusick * What should be in this set is open to debate, but I believe that since 25941906Smckusick * I/O system calls on ufs are never interrupted by signals the set should 26041906Smckusick * be minimal. My reasoning is that many current programs that use signals 26141906Smckusick * such as SIGALRM will not expect file I/O system calls to be interrupted 26241906Smckusick * by them and break. 26341906Smckusick */ 26452139Smckusick #ifdef KERNEL 26568653Smckusick 26668653Smckusick struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 26768653Smckusick 26841906Smckusick #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 26941906Smckusick sigmask(SIGHUP)|sigmask(SIGQUIT)) 27040116Smckusick 27138414Smckusick /* 27241906Smckusick * Socket errors ignored for connectionless sockets?? 27341906Smckusick * For now, ignore them all 27441906Smckusick */ 27541906Smckusick #define NFSIGNORE_SOERROR(s, e) \ 27641906Smckusick ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 27741906Smckusick ((s) & PR_CONNREQUIRED) == 0) 27841906Smckusick 27941906Smckusick /* 28038414Smckusick * Nfs outstanding request list element 28138414Smckusick */ 28238414Smckusick struct nfsreq { 28367708Smckusick TAILQ_ENTRY(nfsreq) r_chain; 28438414Smckusick struct mbuf *r_mreq; 28538414Smckusick struct mbuf *r_mrep; 28652139Smckusick struct mbuf *r_md; 28752139Smckusick caddr_t r_dpos; 28841906Smckusick struct nfsmount *r_nmp; 28938414Smckusick struct vnode *r_vp; 29038414Smckusick u_long r_xid; 29152139Smckusick int r_flags; /* flags on request, see below */ 29252139Smckusick int r_retry; /* max retransmission count */ 29352139Smckusick int r_rexmit; /* current retrans count */ 29452139Smckusick int r_timer; /* tick counter on reply */ 29552139Smckusick int r_procnum; /* NFS procedure number */ 29652139Smckusick int r_rtt; /* RTT for rpc */ 29741906Smckusick struct proc *r_procp; /* Proc that did I/O system call */ 29838414Smckusick }; 29938414Smckusick 30067708Smckusick /* 30167708Smckusick * Queue head for nfsreq's 30267708Smckusick */ 30368653Smckusick TAILQ_HEAD(, nfsreq) nfs_reqq; 30467708Smckusick 30540116Smckusick /* Flag values for r_flags */ 30640116Smckusick #define R_TIMING 0x01 /* timing request (in mntp) */ 30740116Smckusick #define R_SENT 0x02 /* request has been sent */ 30841906Smckusick #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 30941906Smckusick #define R_INTR 0x08 /* intr mnt, signal pending */ 31041906Smckusick #define R_SOCKERR 0x10 /* Fatal error on socket */ 31141906Smckusick #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 31241906Smckusick #define R_MUSTRESEND 0x40 /* Must resend request */ 31359384Smckusick #define R_GETONEREP 0x80 /* Probe for one reply only */ 31440116Smckusick 31538414Smckusick /* 31652139Smckusick * A list of nfssvc_sock structures is maintained with all the sockets 31752139Smckusick * that require service by the nfsd. 31852139Smckusick * The nfsuid structs hang off of the nfssvc_sock structs in both lru 31952139Smckusick * and uid hash lists. 32038414Smckusick */ 32168653Smckusick #ifndef NFS_UIDHASHSIZ 32268653Smckusick #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 32368653Smckusick #endif 32467708Smckusick #define NUIDHASH(sock, uid) \ 32568653Smckusick (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 32668653Smckusick #ifndef NFS_WDELAYHASHSIZ 32768653Smckusick #define NFS_WDELAYHASHSIZ 16 /* and with this */ 32868653Smckusick #endif 32968653Smckusick #define NWDELAYHASH(sock, f) \ 33068653Smckusick (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) 33168653Smckusick #ifndef NFS_MUIDHASHSIZ 33268653Smckusick #define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */ 33368653Smckusick #endif 33468653Smckusick #define NMUIDHASH(nmp, uid) \ 33568653Smckusick (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 33668653Smckusick #define NFSNOHASH(fhsum) \ 33768653Smckusick (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 33852139Smckusick 33955892Smckusick /* 34055892Smckusick * Network address hash list element 34155892Smckusick */ 34255892Smckusick union nethostaddr { 34355892Smckusick u_long had_inetaddr; 34455892Smckusick struct mbuf *had_nam; 34555892Smckusick }; 34655892Smckusick 34752139Smckusick struct nfsuid { 34867708Smckusick TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 34967708Smckusick LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 35052139Smckusick int nu_flag; /* Flags */ 35152139Smckusick union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 35252139Smckusick struct ucred nu_cr; /* Cred uid mapped to */ 35368653Smckusick int nu_expire; /* Expiry time (sec) */ 35468653Smckusick struct timeval nu_timestamp; /* Kerb. timestamp */ 35568653Smckusick u_long nu_nickname; /* Nickname on server */ 35668653Smckusick NFSKERBKEY_T nu_key; /* and session key */ 35738414Smckusick }; 35838414Smckusick 35952139Smckusick #define nu_inetaddr nu_haddr.had_inetaddr 36052139Smckusick #define nu_nam nu_haddr.had_nam 36152139Smckusick /* Bits for nu_flag */ 36252139Smckusick #define NU_INETADDR 0x1 36368653Smckusick #define NU_NAM 0x2 36468653Smckusick #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 36538414Smckusick 36652139Smckusick struct nfssvc_sock { 36767708Smckusick TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 36868653Smckusick TAILQ_HEAD(, nfsuid) ns_uidlruhead; 36952139Smckusick struct file *ns_fp; 37052139Smckusick struct socket *ns_so; 37152139Smckusick struct mbuf *ns_nam; 37252139Smckusick struct mbuf *ns_raw; 37352139Smckusick struct mbuf *ns_rawend; 37452139Smckusick struct mbuf *ns_rec; 37552139Smckusick struct mbuf *ns_recend; 37668653Smckusick struct mbuf *ns_frag; 37768653Smckusick int ns_flag; 37868653Smckusick int ns_solock; 37968653Smckusick int ns_cc; 38068653Smckusick int ns_reclen; 38152139Smckusick int ns_numuids; 38268653Smckusick u_long ns_sref; 38368653Smckusick LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 38468653Smckusick LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 38568653Smckusick LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 38652139Smckusick }; 38752139Smckusick 38852139Smckusick /* Bits for "ns_flag" */ 38952139Smckusick #define SLP_VALID 0x01 39052903Smckusick #define SLP_DOREC 0x02 39152139Smckusick #define SLP_NEEDQ 0x04 39252139Smckusick #define SLP_DISCONN 0x08 39352139Smckusick #define SLP_GETSTREAM 0x10 39468653Smckusick #define SLP_LASTFRAG 0x20 39552980Smckusick #define SLP_ALLFLAGS 0xff 39652980Smckusick 39768653Smckusick TAILQ_HEAD(, nfssvc_sock) nfssvc_sockhead; 39867708Smckusick int nfssvc_sockhead_flag; 39967708Smckusick #define SLP_INIT 0x01 40067708Smckusick #define SLP_WANTINIT 0x02 40167708Smckusick 40238414Smckusick /* 40352139Smckusick * One of these structures is allocated for each nfsd. 40438414Smckusick */ 40552139Smckusick struct nfsd { 40668653Smckusick TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 40768653Smckusick int nfsd_flag; /* NFSD_ flags */ 40868653Smckusick struct nfssvc_sock *nfsd_slp; /* Current socket */ 40968653Smckusick int nfsd_authlen; /* Authenticator len */ 41068653Smckusick u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 41168653Smckusick int nfsd_verflen; /* and the Verifier */ 41268653Smckusick u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 41368653Smckusick struct proc *nfsd_procp; /* Proc ptr */ 41468653Smckusick struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 41538414Smckusick }; 41638414Smckusick 41768653Smckusick /* Bits for "nfsd_flag" */ 41852139Smckusick #define NFSD_WAITING 0x01 41967708Smckusick #define NFSD_REQINPROG 0x02 42067708Smckusick #define NFSD_NEEDAUTH 0x04 42167708Smckusick #define NFSD_AUTHFAIL 0x08 42267708Smckusick 42368653Smckusick /* 42468653Smckusick * This structure is used by the server for describing each request. 42568653Smckusick * Some fields are used only when write request gathering is performed. 42668653Smckusick */ 42768653Smckusick struct nfsrv_descript { 42868653Smckusick u_quad_t nd_time; /* Write deadline (usec) */ 42968653Smckusick off_t nd_off; /* Start byte offset */ 43068653Smckusick off_t nd_eoff; /* and end byte offset */ 43168653Smckusick LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 43268653Smckusick LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 43368653Smckusick LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 43468653Smckusick struct mbuf *nd_mrep; /* Request mbuf list */ 43568653Smckusick struct mbuf *nd_md; /* Current dissect mbuf */ 43668653Smckusick struct mbuf *nd_mreq; /* Reply mbuf list */ 43768653Smckusick struct mbuf *nd_nam; /* and socket addr */ 43868653Smckusick struct mbuf *nd_nam2; /* return socket addr */ 43968653Smckusick caddr_t nd_dpos; /* Current dissect pos */ 44068653Smckusick int nd_procnum; /* RPC # */ 44168653Smckusick int nd_stable; /* storage type */ 44268653Smckusick int nd_flag; /* nd_flag */ 44368653Smckusick int nd_len; /* Length of this write */ 44468653Smckusick int nd_repstat; /* Reply status */ 44568653Smckusick u_long nd_retxid; /* Reply xid */ 44668653Smckusick u_long nd_duration; /* Lease duration */ 44768653Smckusick struct timeval nd_starttime; /* Time RPC initiated */ 44868653Smckusick fhandle_t nd_fh; /* File handle */ 44968653Smckusick struct ucred nd_cr; /* Credentials */ 45068653Smckusick }; 45168653Smckusick 45268653Smckusick /* Bits for "nd_flag" */ 45368653Smckusick #define ND_READ LEASE_READ 45468653Smckusick #define ND_WRITE LEASE_WRITE 45568653Smckusick #define ND_CHECK 0x04 45668653Smckusick #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 45768653Smckusick #define ND_NFSV3 0x08 45868653Smckusick #define ND_NQNFS 0x10 45968653Smckusick #define ND_KERBNICK 0x20 46068653Smckusick #define ND_KERBFULL 0x40 46168653Smckusick #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 46268653Smckusick 46368653Smckusick TAILQ_HEAD(, nfsd) nfsd_head; 46467708Smckusick int nfsd_head_flag; 46567708Smckusick #define NFSD_CHECKSLP 0x01 46667708Smckusick 46768653Smckusick /* 46868653Smckusick * These macros compare nfsrv_descript structures. 46968653Smckusick */ 47068653Smckusick #define NFSW_CONTIG(o, n) \ 47168653Smckusick ((o)->nd_eoff >= (n)->nd_off && \ 47268653Smckusick !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 47368653Smckusick 47468653Smckusick #define NFSW_SAMECRED(o, n) \ 47568653Smckusick (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 47668653Smckusick !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 47768653Smckusick sizeof (struct ucred))) 47868653Smckusick 47968653Smckusick int nfs_reply __P((struct nfsreq *)); 48068653Smckusick int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 48168653Smckusick int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 48268653Smckusick int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 48368653Smckusick int nfs_sndlock __P((int *,struct nfsreq *)); 48468653Smckusick int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 48568653Smckusick int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 48668653Smckusick int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 48768653Smckusick int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 48868653Smckusick int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 48968653Smckusick int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); 49068653Smckusick int nfs_asyncio __P((struct buf *,struct ucred *)); 49168653Smckusick int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 49268653Smckusick int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 49368653Smckusick int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 49468653Smckusick int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 49568653Smckusick int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 49668653Smckusick void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 49768653Smckusick void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 49868653Smckusick void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 49968653Smckusick int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *,int)); 50068653Smckusick int nfsrv_access __P((struct vnode *,int,struct ucred *,int,struct proc *)); 50168653Smckusick int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 50268653Smckusick int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 50368653Smckusick int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 50468653Smckusick int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 50568653Smckusick void nfsm_adj __P((struct mbuf *,int,int)); 50668653Smckusick int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 50768653Smckusick void nfsrv_initcache __P((void)); 50868653Smckusick int nfs_rcvlock __P((struct nfsreq *)); 50968653Smckusick int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 51068653Smckusick int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 51168653Smckusick int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 51268653Smckusick int nfs_msg __P((struct proc *,char *,char *)); 51368653Smckusick int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 51468653Smckusick int nfsrv_getstream __P((struct nfssvc_sock *,int)); 51568653Smckusick void nfs_nhinit __P((void)); 51668653Smckusick void nfs_timer __P((void*)); 51768653Smckusick u_long nfs_hash __P((nfsfh_t *,int)); 51868653Smckusick int nfssvc_iod __P((struct proc *)); 51968653Smckusick int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); 52068653Smckusick int nfssvc_addsock __P((struct file *,struct mbuf *)); 52168653Smckusick int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 52268653Smckusick int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 52368653Smckusick void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 52468653Smckusick int mountnfs __P((struct nfs_args *,struct mount *,struct mbuf *,char *,char *,struct vnode **)); 52568653Smckusick int nfs_connect __P((struct nfsmount *,struct nfsreq *)); 52668653Smckusick int nfs_getattrcache __P((struct vnode *,struct vattr *)); 52768653Smckusick int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 52868653Smckusick int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 52968653Smckusick int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 53068653Smckusick void nfsrv_init __P((int)); 53168653Smckusick void nfs_clearcommit __P((struct mount *)); 53268653Smckusick int nfsrv_errmap __P((struct nfsrv_descript *, int)); 53368653Smckusick void nfsrvw_coalesce __P((struct nfsrv_descript *,struct nfsrv_descript *)); 53468653Smckusick void nfsrvw_sort __P((gid_t [],int)); 53568653Smckusick void nfsrv_setcred __P((struct ucred *,struct ucred *)); 53668653Smckusick int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); 53768653Smckusick int nfs_writebp __P((struct buf *,int)); 53852139Smckusick #endif /* KERNEL */ 53968653Smckusick 54068653Smckusick #endif 541