nfsargs.h revision 9336
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1989, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * Rick Macklem at The University of Guelph. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 3. All advertising materials mentioning features or use of this software 171541Srgrimes * must display the following acknowledgement: 181541Srgrimes * This product includes software developed by the University of 191541Srgrimes * California, Berkeley and its contributors. 201541Srgrimes * 4. Neither the name of the University nor the names of its contributors 211541Srgrimes * may be used to endorse or promote products derived from this software 221541Srgrimes * without specific prior written permission. 231541Srgrimes * 241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341541Srgrimes * SUCH DAMAGE. 351541Srgrimes * 361541Srgrimes * @(#)nfs.h 8.1 (Berkeley) 6/10/93 379336Sdfr * $Id: nfs.h,v 1.9 1995/02/14 06:22:18 phk Exp $ 381541Srgrimes */ 391541Srgrimes 402175Spaul#ifndef _NFS_NFS_H_ 412175Spaul#define _NFS_NFS_H_ 422175Spaul 431541Srgrimes/* 441541Srgrimes * Tunable constants for nfs 451541Srgrimes */ 461541Srgrimes 471541Srgrimes#define NFS_MAXIOVEC 34 489336Sdfr#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 499336Sdfr#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 509336Sdfr#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 519336Sdfr#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 529336Sdfr#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 539336Sdfr#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 541541Srgrimes#define NFS_MAXREXMIT 100 /* Stop counting after this many */ 551541Srgrimes#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 561541Srgrimes#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 571541Srgrimes#define NFS_MAXGRPS 16 /* Max. size of groups list */ 581828Sdg#ifndef NFS_MINATTRTIMO 591541Srgrimes#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 601828Sdg#endif 611828Sdg#ifndef NFS_MAXATTRTIMO 621541Srgrimes#define NFS_MAXATTRTIMO 60 631828Sdg#endif 641541Srgrimes#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 651541Srgrimes#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 669336Sdfr#define NFS_READDIRSIZE 8192 /* Def. readdir size */ 671541Srgrimes#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 681541Srgrimes#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 691541Srgrimes#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 709336Sdfr#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ 719336Sdfr#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ 729336Sdfr#ifndef NFS_GATHERDELAY 739336Sdfr#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ 749336Sdfr#endif 759336Sdfr#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ 769336Sdfr 779336Sdfr/* 789336Sdfr * Oddballs 799336Sdfr */ 801541Srgrimes#define NMOD(a) ((a) % nfs_asyncdaemons) 819336Sdfr#define NFS_CMPFH(n, f, s) \ 829336Sdfr ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 839336Sdfr#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) 849336Sdfr#define NFS_SRVMAXDATA(n) \ 859336Sdfr (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ 869336Sdfr NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) 871541Srgrimes 881541Srgrimes/* 899336Sdfr * XXX 909336Sdfr * sys/buf.h should be editted to change B_APPENDWRITE --> B_NEEDCOMMIT, but 919336Sdfr * until then... 929336Sdfr * Same goes for sys/malloc.h, which needs M_NFSDIROFF, 939336Sdfr * M_NFSRVDESC and M_NFSBIGFH added. 949336Sdfr * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an 959336Sdfr * exclusive create. 969336Sdfr * The B_INVAFTERWRITE flag should be set to whatever is required by the 979336Sdfr * buffer cache code to say "Invalidate the block after it is written back". 989336Sdfr */ 999336Sdfr#ifndef B_NEEDCOMMIT 1009336Sdfr#define B_NEEDCOMMIT B_APPENDWRITE 1019336Sdfr#endif 1029336Sdfr#ifndef M_NFSRVDESC 1039336Sdfr#define M_NFSRVDESC M_TEMP 1049336Sdfr#endif 1059336Sdfr#ifndef M_NFSDIROFF 1069336Sdfr#define M_NFSDIROFF M_TEMP 1079336Sdfr#endif 1089336Sdfr#ifndef M_NFSBIGFH 1099336Sdfr#define M_NFSBIGFH M_TEMP 1109336Sdfr#endif 1119336Sdfr#ifndef VA_EXCLUSIVE 1129336Sdfr#define VA_EXCLUSIVE 0 1139336Sdfr#endif 1149336Sdfr#ifdef __FreeBSD__ 1159336Sdfr#define B_INVAFTERWRITE B_NOCACHE 1169336Sdfr#else 1179336Sdfr#define B_INVAFTERWRITE B_INVAL 1189336Sdfr#endif 1199336Sdfr 1209336Sdfr/* 1219336Sdfr * These ifdefs try to handle the differences between the various 4.4BSD-Lite 1229336Sdfr * based vfs interfaces. 1239336Sdfr * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to 1249336Sdfr * differentiate between NetBSD-1.0 and NetBSD-current, so.. 1259336Sdfr * I also don't know about BSDi's 2.0 release. 1269336Sdfr */ 1279336Sdfr#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) 1289336Sdfr#define HAS_VOPLEASE 1 1299336Sdfr#endif 1309336Sdfr#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) 1319336Sdfr#define HAS_VOPREVOKE 1 1329336Sdfr#endif 1339336Sdfr 1349336Sdfr/* 1359336Sdfr * The IO_METASYNC flag should be implemented for local file systems. 1369336Sdfr * (Until then, it is nothin at all.) 1379336Sdfr */ 1389336Sdfr#ifndef IO_METASYNC 1399336Sdfr#define IO_METASYNC 0 1409336Sdfr#endif 1419336Sdfr 1429336Sdfr/* 1431541Srgrimes * Set the attribute timeout based on how recently the file has been modified. 1441541Srgrimes */ 1451541Srgrimes#define NFS_ATTRTIMEO(np) \ 1461541Srgrimes ((((np)->n_flag & NMODIFIED) || \ 1471541Srgrimes (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ 1481541Srgrimes ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ 1491541Srgrimes (time.tv_sec - (np)->n_mtime) / 10)) 1501541Srgrimes 1511541Srgrimes/* 1529336Sdfr * Expected allocation sizes for major data structures. If the actual size 1539336Sdfr * of the structure exceeds these sizes, then malloc() will be allocating 1549336Sdfr * almost twice the memory required. This is used in nfs_init() to warn 1559336Sdfr * the sysadmin that the size of a structure should be reduced. 1569336Sdfr * (These sizes are always a power of 2. If the kernel malloc() changes 1579336Sdfr * to one that does not allocate space in powers of 2 size, then this all 1589336Sdfr * becomes bunk!) 1599336Sdfr */ 1609336Sdfr#define NFS_NODEALLOC 256 1619336Sdfr#define NFS_MNTALLOC 512 1629336Sdfr#define NFS_SVCALLOC 256 1639336Sdfr#define NFS_UIDALLOC 128 1649336Sdfr 1659336Sdfr/* 1661541Srgrimes * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 1671541Srgrimes * should ever try and use it. 1681541Srgrimes */ 1691541Srgrimesstruct nfsd_args { 1701541Srgrimes int sock; /* Socket to serve */ 1711541Srgrimes caddr_t name; /* Client address for connection based sockets */ 1721541Srgrimes int namelen; /* Length of name */ 1731541Srgrimes}; 1741541Srgrimes 1751541Srgrimesstruct nfsd_srvargs { 1761541Srgrimes struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 1771541Srgrimes uid_t nsd_uid; /* Effective uid mapped to cred */ 1781541Srgrimes u_long nsd_haddr; /* Ip address of client */ 1791541Srgrimes struct ucred nsd_cr; /* Cred. uid maps to */ 1801541Srgrimes int nsd_authlen; /* Length of auth string (ret) */ 1819336Sdfr u_char *nsd_authstr; /* Auth string (ret) */ 1829336Sdfr int nsd_verflen; /* and the verfier */ 1839336Sdfr u_char *nsd_verfstr; 1849336Sdfr struct timeval nsd_timestamp; /* timestamp from verifier */ 1859336Sdfr u_long nsd_ttl; /* credential ttl (sec) */ 1869336Sdfr NFSKERBKEY_T nsd_key; /* Session key */ 1871541Srgrimes}; 1881541Srgrimes 1891541Srgrimesstruct nfsd_cargs { 1901541Srgrimes char *ncd_dirp; /* Mount dir path */ 1911541Srgrimes uid_t ncd_authuid; /* Effective uid */ 1921541Srgrimes int ncd_authtype; /* Type of authenticator */ 1931541Srgrimes int ncd_authlen; /* Length of authenticator string */ 1949336Sdfr u_char *ncd_authstr; /* Authenticator string */ 1959336Sdfr int ncd_verflen; /* and the verifier */ 1969336Sdfr u_char *ncd_verfstr; 1979336Sdfr NFSKERBKEY_T ncd_key; /* Session key */ 1981541Srgrimes}; 1991541Srgrimes 2001541Srgrimes/* 2011541Srgrimes * Stats structure 2021541Srgrimes */ 2031541Srgrimesstruct nfsstats { 2041541Srgrimes int attrcache_hits; 2051541Srgrimes int attrcache_misses; 2061541Srgrimes int lookupcache_hits; 2071541Srgrimes int lookupcache_misses; 2081541Srgrimes int direofcache_hits; 2091541Srgrimes int direofcache_misses; 2101541Srgrimes int biocache_reads; 2111541Srgrimes int read_bios; 2121541Srgrimes int read_physios; 2131541Srgrimes int biocache_writes; 2141541Srgrimes int write_bios; 2151541Srgrimes int write_physios; 2161541Srgrimes int biocache_readlinks; 2171541Srgrimes int readlink_bios; 2181541Srgrimes int biocache_readdirs; 2191541Srgrimes int readdir_bios; 2201541Srgrimes int rpccnt[NFS_NPROCS]; 2211541Srgrimes int rpcretries; 2221541Srgrimes int srvrpccnt[NFS_NPROCS]; 2231541Srgrimes int srvrpc_errs; 2241541Srgrimes int srv_errs; 2251541Srgrimes int rpcrequests; 2261541Srgrimes int rpctimeouts; 2271541Srgrimes int rpcunexpected; 2281541Srgrimes int rpcinvalid; 2291541Srgrimes int srvcache_inproghits; 2301541Srgrimes int srvcache_idemdonehits; 2311541Srgrimes int srvcache_nonidemdonehits; 2321541Srgrimes int srvcache_misses; 2331541Srgrimes int srvnqnfs_leases; 2341541Srgrimes int srvnqnfs_maxleases; 2351541Srgrimes int srvnqnfs_getleases; 2369336Sdfr int srvvop_writes; 2371541Srgrimes}; 2381541Srgrimes 2391541Srgrimes/* 2401541Srgrimes * Flags for nfssvc() system call. 2411541Srgrimes */ 2421541Srgrimes#define NFSSVC_BIOD 0x002 2431541Srgrimes#define NFSSVC_NFSD 0x004 2441541Srgrimes#define NFSSVC_ADDSOCK 0x008 2451541Srgrimes#define NFSSVC_AUTHIN 0x010 2461541Srgrimes#define NFSSVC_GOTAUTH 0x040 2471541Srgrimes#define NFSSVC_AUTHINFAIL 0x080 2481541Srgrimes#define NFSSVC_MNTD 0x100 2491541Srgrimes 2501541Srgrimes/* 2513820Swollman * fs.nfs sysctl(3) identifiers 2523820Swollman */ 2533820Swollman#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 2543820Swollman 2553820Swollman#define FS_NFS_NAMES { \ 2563820Swollman { 0, 0 }, \ 2573820Swollman { "nfsstats", CTLTYPE_STRUCT }, \ 2583820Swollman} 2593820Swollman 2603820Swollman/* 2611541Srgrimes * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 2621541Srgrimes * What should be in this set is open to debate, but I believe that since 2631541Srgrimes * I/O system calls on ufs are never interrupted by signals the set should 2641541Srgrimes * be minimal. My reasoning is that many current programs that use signals 2651541Srgrimes * such as SIGALRM will not expect file I/O system calls to be interrupted 2661541Srgrimes * by them and break. 2671541Srgrimes */ 2689336Sdfr#if defined(KERNEL) || defined(_KERNEL) 2694067Swollman 2704067Swollmanstruct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 2714067Swollman 2721541Srgrimes#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 2731541Srgrimes sigmask(SIGHUP)|sigmask(SIGQUIT)) 2741541Srgrimes 2751541Srgrimes/* 2761541Srgrimes * Socket errors ignored for connectionless sockets?? 2771541Srgrimes * For now, ignore them all 2781541Srgrimes */ 2791541Srgrimes#define NFSIGNORE_SOERROR(s, e) \ 2801541Srgrimes ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 2811541Srgrimes ((s) & PR_CONNREQUIRED) == 0) 2821541Srgrimes 2831541Srgrimes/* 2841541Srgrimes * Nfs outstanding request list element 2851541Srgrimes */ 2861541Srgrimesstruct nfsreq { 2873664Sphk TAILQ_ENTRY(nfsreq) r_chain; 2881541Srgrimes struct mbuf *r_mreq; 2891541Srgrimes struct mbuf *r_mrep; 2901541Srgrimes struct mbuf *r_md; 2911541Srgrimes caddr_t r_dpos; 2921541Srgrimes struct nfsmount *r_nmp; 2931541Srgrimes struct vnode *r_vp; 2941541Srgrimes u_long r_xid; 2951541Srgrimes int r_flags; /* flags on request, see below */ 2961541Srgrimes int r_retry; /* max retransmission count */ 2971541Srgrimes int r_rexmit; /* current retrans count */ 2981541Srgrimes int r_timer; /* tick counter on reply */ 2991541Srgrimes int r_procnum; /* NFS procedure number */ 3001541Srgrimes int r_rtt; /* RTT for rpc */ 3011541Srgrimes struct proc *r_procp; /* Proc that did I/O system call */ 3021541Srgrimes}; 3031541Srgrimes 3043664Sphk/* 3053664Sphk * Queue head for nfsreq's 3063664Sphk */ 3073664SphkTAILQ_HEAD(, nfsreq) nfs_reqq; 3083664Sphk 3091541Srgrimes/* Flag values for r_flags */ 3101541Srgrimes#define R_TIMING 0x01 /* timing request (in mntp) */ 3111541Srgrimes#define R_SENT 0x02 /* request has been sent */ 3121541Srgrimes#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 3131541Srgrimes#define R_INTR 0x08 /* intr mnt, signal pending */ 3141541Srgrimes#define R_SOCKERR 0x10 /* Fatal error on socket */ 3151541Srgrimes#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 3161541Srgrimes#define R_MUSTRESEND 0x40 /* Must resend request */ 3171541Srgrimes#define R_GETONEREP 0x80 /* Probe for one reply only */ 3181541Srgrimes 3191541Srgrimes/* 3201541Srgrimes * A list of nfssvc_sock structures is maintained with all the sockets 3211541Srgrimes * that require service by the nfsd. 3221541Srgrimes * The nfsuid structs hang off of the nfssvc_sock structs in both lru 3231541Srgrimes * and uid hash lists. 3241541Srgrimes */ 3259336Sdfr#ifndef NFS_UIDHASHSIZ 3269336Sdfr#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 3279336Sdfr#endif 3283664Sphk#define NUIDHASH(sock, uid) \ 3299336Sdfr (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 3309336Sdfr#ifndef NFS_WDELAYHASHSIZ 3319336Sdfr#define NFS_WDELAYHASHSIZ 16 /* and with this */ 3329336Sdfr#endif 3339336Sdfr#define NWDELAYHASH(sock, f) \ 3349336Sdfr (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) 3359336Sdfr#ifndef NFS_MUIDHASHSIZ 3369336Sdfr#define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */ 3379336Sdfr#endif 3389336Sdfr#define NMUIDHASH(nmp, uid) \ 3399336Sdfr (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 3409336Sdfr#define NFSNOHASH(fhsum) \ 3419336Sdfr (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 3421541Srgrimes 3431541Srgrimes/* 3441541Srgrimes * Network address hash list element 3451541Srgrimes */ 3461541Srgrimesunion nethostaddr { 3471541Srgrimes u_long had_inetaddr; 3481541Srgrimes struct mbuf *had_nam; 3491541Srgrimes}; 3501541Srgrimes 3511541Srgrimesstruct nfsuid { 3523664Sphk TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 3533664Sphk LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 3541541Srgrimes int nu_flag; /* Flags */ 3551541Srgrimes union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 3561541Srgrimes struct ucred nu_cr; /* Cred uid mapped to */ 3579336Sdfr int nu_expire; /* Expiry time (sec) */ 3589336Sdfr struct timeval nu_timestamp; /* Kerb. timestamp */ 3599336Sdfr u_long nu_nickname; /* Nickname on server */ 3609336Sdfr NFSKERBKEY_T nu_key; /* and session key */ 3611541Srgrimes}; 3621541Srgrimes 3631541Srgrimes#define nu_inetaddr nu_haddr.had_inetaddr 3641541Srgrimes#define nu_nam nu_haddr.had_nam 3651541Srgrimes/* Bits for nu_flag */ 3661541Srgrimes#define NU_INETADDR 0x1 3679336Sdfr#define NU_NAM 0x2 3689336Sdfr#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 3691541Srgrimes 3701541Srgrimesstruct nfssvc_sock { 3713664Sphk TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 3723664Sphk TAILQ_HEAD(, nfsuid) ns_uidlruhead; 3731541Srgrimes struct file *ns_fp; 3741541Srgrimes struct socket *ns_so; 3751541Srgrimes struct mbuf *ns_nam; 3761541Srgrimes struct mbuf *ns_raw; 3771541Srgrimes struct mbuf *ns_rawend; 3781541Srgrimes struct mbuf *ns_rec; 3791541Srgrimes struct mbuf *ns_recend; 3809336Sdfr struct mbuf *ns_frag; 3819336Sdfr int ns_flag; 3829336Sdfr int ns_solock; 3839336Sdfr int ns_cc; 3849336Sdfr int ns_reclen; 3851541Srgrimes int ns_numuids; 3869336Sdfr u_long ns_sref; 3879336Sdfr LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 3889336Sdfr LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 3899336Sdfr LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 3901541Srgrimes}; 3911541Srgrimes 3921541Srgrimes/* Bits for "ns_flag" */ 3931541Srgrimes#define SLP_VALID 0x01 3941541Srgrimes#define SLP_DOREC 0x02 3951541Srgrimes#define SLP_NEEDQ 0x04 3961541Srgrimes#define SLP_DISCONN 0x08 3971541Srgrimes#define SLP_GETSTREAM 0x10 3989336Sdfr#define SLP_LASTFRAG 0x20 3991541Srgrimes#define SLP_ALLFLAGS 0xff 4001541Srgrimes 4013664SphkTAILQ_HEAD(, nfssvc_sock) nfssvc_sockhead; 4023664Sphkint nfssvc_sockhead_flag; 4033664Sphk#define SLP_INIT 0x01 4043664Sphk#define SLP_WANTINIT 0x02 4053664Sphk 4061541Srgrimes/* 4071541Srgrimes * One of these structures is allocated for each nfsd. 4081541Srgrimes */ 4091541Srgrimesstruct nfsd { 4109336Sdfr TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 4119336Sdfr int nfsd_flag; /* NFSD_ flags */ 4129336Sdfr struct nfssvc_sock *nfsd_slp; /* Current socket */ 4139336Sdfr int nfsd_authlen; /* Authenticator len */ 4149336Sdfr u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 4159336Sdfr int nfsd_verflen; /* and the Verifier */ 4169336Sdfr u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 4179336Sdfr struct proc *nfsd_procp; /* Proc ptr */ 4189336Sdfr struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 4191541Srgrimes}; 4201541Srgrimes 4219336Sdfr/* Bits for "nfsd_flag" */ 4221541Srgrimes#define NFSD_WAITING 0x01 4233664Sphk#define NFSD_REQINPROG 0x02 4243664Sphk#define NFSD_NEEDAUTH 0x04 4253664Sphk#define NFSD_AUTHFAIL 0x08 4263305Sphk 4279336Sdfr/* 4289336Sdfr * This structure is used by the server for describing each request. 4299336Sdfr * Some fields are used only when write request gathering is performed. 4309336Sdfr */ 4319336Sdfrstruct nfsrv_descript { 4329336Sdfr u_quad_t nd_time; /* Write deadline (usec) */ 4339336Sdfr off_t nd_off; /* Start byte offset */ 4349336Sdfr off_t nd_eoff; /* and end byte offset */ 4359336Sdfr LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 4369336Sdfr LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 4379336Sdfr LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 4389336Sdfr struct mbuf *nd_mrep; /* Request mbuf list */ 4399336Sdfr struct mbuf *nd_md; /* Current dissect mbuf */ 4409336Sdfr struct mbuf *nd_mreq; /* Reply mbuf list */ 4419336Sdfr struct mbuf *nd_nam; /* and socket addr */ 4429336Sdfr struct mbuf *nd_nam2; /* return socket addr */ 4439336Sdfr caddr_t nd_dpos; /* Current dissect pos */ 4449336Sdfr int nd_procnum; /* RPC # */ 4459336Sdfr int nd_stable; /* storage type */ 4469336Sdfr int nd_flag; /* nd_flag */ 4479336Sdfr int nd_len; /* Length of this write */ 4489336Sdfr int nd_repstat; /* Reply status */ 4499336Sdfr u_long nd_retxid; /* Reply xid */ 4509336Sdfr u_long nd_duration; /* Lease duration */ 4519336Sdfr struct timeval nd_starttime; /* Time RPC initiated */ 4529336Sdfr fhandle_t nd_fh; /* File handle */ 4539336Sdfr struct ucred nd_cr; /* Credentials */ 4549336Sdfr}; 4559336Sdfr 4569336Sdfr/* Bits for "nd_flag" */ 4579336Sdfr#define ND_READ LEASE_READ 4589336Sdfr#define ND_WRITE LEASE_WRITE 4599336Sdfr#define ND_CHECK 0x04 4609336Sdfr#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 4619336Sdfr#define ND_NFSV3 0x08 4629336Sdfr#define ND_NQNFS 0x10 4639336Sdfr#define ND_KERBNICK 0x20 4649336Sdfr#define ND_KERBFULL 0x40 4659336Sdfr#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 4669336Sdfr 4673664SphkTAILQ_HEAD(, nfsd) nfsd_head; 4683664Sphkint nfsd_head_flag; 4693664Sphk#define NFSD_CHECKSLP 0x01 4703664Sphk 4719336Sdfr/* 4729336Sdfr * These macros compare nfsrv_descript structures. 4739336Sdfr */ 4749336Sdfr#define NFSW_CONTIG(o, n) \ 4759336Sdfr ((o)->nd_eoff >= (n)->nd_off && \ 4769336Sdfr !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 4779336Sdfr 4789336Sdfr#define NFSW_SAMECRED(o, n) \ 4799336Sdfr (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 4809336Sdfr !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 4819336Sdfr sizeof (struct ucred))) 4829336Sdfr 4833305Sphkint nfs_reply __P((struct nfsreq *)); 4849336Sdfrint nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 4853305Sphkint nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 4869336Sdfrint nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 4873305Sphkint nfs_sndlock __P((int *,struct nfsreq *)); 4883305Sphkint nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 4893305Sphkint nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 4903305Sphkint nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 4919336Sdfrint nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 4923305Sphkint nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 4939336Sdfrint nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); 4943305Sphkint nfs_asyncio __P((struct buf *,struct ucred *)); 4953305Sphkint nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 4963305Sphkint nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 4973305Sphkint nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 4989336Sdfrint nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 4993305Sphkint nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 5009336Sdfrvoid nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 5019336Sdfrvoid nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 5029336Sdfrvoid nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 5039336Sdfrint nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *,int)); 5043305Sphkint nfsrv_access __P((struct vnode *,int,struct ucred *,int,struct proc *)); 5053305Sphkint netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 5063305Sphkint nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 5073305Sphkint nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 5089336Sdfrint nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 5093305Sphkvoid nfsm_adj __P((struct mbuf *,int,int)); 5103305Sphkint nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 5113305Sphkvoid nfsrv_initcache __P((void)); 5123305Sphkint nfs_rcvlock __P((struct nfsreq *)); 5139336Sdfrint nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 5149336Sdfrint nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 5159336Sdfrint nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 5163305Sphkint nfs_msg __P((struct proc *,char *,char *)); 5173305Sphkint nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 5183305Sphkint nfsrv_getstream __P((struct nfssvc_sock *,int)); 5193305Sphkvoid nfs_nhinit __P((void)); 5203305Sphkvoid nfs_timer __P((void*)); 5219336Sdfru_long nfs_hash __P((nfsfh_t *,int)); 5223305Sphkint nfssvc_iod __P((struct proc *)); 5233305Sphkint nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); 5243305Sphkint nfssvc_addsock __P((struct file *,struct mbuf *)); 5259336Sdfrint nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 5269336Sdfrint nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 5279336Sdfrvoid nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 5283305Sphkint mountnfs __P((struct nfs_args *,struct mount *,struct mbuf *,char *,char *,struct vnode **)); 5293305Sphkint nfs_connect __P((struct nfsmount *,struct nfsreq *)); 5303305Sphkint nfs_getattrcache __P((struct vnode *,struct vattr *)); 5313305Sphkint nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 5323305Sphkint nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 5333305Sphkint nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 5343305Sphkvoid nfsrv_init __P((int)); 5359336Sdfrvoid nfs_clearcommit __P((struct mount *)); 5369336Sdfrint nfsrv_errmap __P((struct nfsrv_descript *, int)); 5379336Sdfrvoid nfsrvw_coalesce __P((struct nfsrv_descript *,struct nfsrv_descript *)); 5389336Sdfrvoid nfsrvw_sort __P((gid_t [],int)); 5399336Sdfrvoid nfsrv_setcred __P((struct ucred *,struct ucred *)); 5409336Sdfrint nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); 5419336Sdfrint nfs_writebp __P((struct buf *,int)); 5426361Sphkint nfsrv_vput __P(( struct vnode * )); 5436361Sphkint nfsrv_vrele __P(( struct vnode * )); 5446361Sphkint nfsrv_vmio __P(( struct vnode * )); 5459336Sdfrint nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 5469336Sdfr struct proc *, struct mbuf **)); 5479336Sdfrint nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 5489336Sdfr struct proc *p)); 5496361Sphk 5501541Srgrimes#endif /* KERNEL */ 5512175Spaul 5522175Spaul#endif 553