nfsargs.h revision 50477
11541Srgrimes/* 222521Sdyson * Copyright (c) 1989, 1993, 1995 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 * 3622521Sdyson * @(#)nfs.h 8.4 (Berkeley) 5/1/95 3750477Speter * $FreeBSD: head/sys/nfsclient/nfsargs.h 50477 1999-08-28 01:08:13Z peter $ 381541Srgrimes */ 391541Srgrimes 402175Spaul#ifndef _NFS_NFS_H_ 412175Spaul#define _NFS_NFS_H_ 422175Spaul 4337291Sjmg#ifdef KERNEL 4437272Sjmg#include "opt_nfs.h" 4537291Sjmg#endif 4637272Sjmg 471541Srgrimes/* 481541Srgrimes * Tunable constants for nfs 491541Srgrimes */ 501541Srgrimes 511541Srgrimes#define NFS_MAXIOVEC 34 529336Sdfr#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 539336Sdfr#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 549336Sdfr#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 559336Sdfr#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 569336Sdfr#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 579336Sdfr#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 581541Srgrimes#define NFS_MAXREXMIT 100 /* Stop counting after this many */ 591541Srgrimes#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 601541Srgrimes#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 611541Srgrimes#define NFS_MAXGRPS 16 /* Max. size of groups list */ 621828Sdg#ifndef NFS_MINATTRTIMO 6336176Speter#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */ 641828Sdg#endif 651828Sdg#ifndef NFS_MAXATTRTIMO 661541Srgrimes#define NFS_MAXATTRTIMO 60 671828Sdg#endif 6836176Speter#ifndef NFS_MINDIRATTRTIMO 6936176Speter#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */ 7036176Speter#endif 7136176Speter#ifndef NFS_MAXDIRATTRTIMO 7236176Speter#define NFS_MAXDIRATTRTIMO 60 7336176Speter#endif 741541Srgrimes#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 751541Srgrimes#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 769336Sdfr#define NFS_READDIRSIZE 8192 /* Def. readdir size */ 771541Srgrimes#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 781541Srgrimes#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 791541Srgrimes#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 8024378Sbde#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ 819336Sdfr#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ 829336Sdfr#ifndef NFS_GATHERDELAY 839336Sdfr#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ 849336Sdfr#endif 859336Sdfr#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ 8624378Sbde#ifdef KERNEL 8724378Sbde#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ 8824378Sbde#endif 899336Sdfr 909336Sdfr/* 919336Sdfr * Oddballs 929336Sdfr */ 931541Srgrimes#define NMOD(a) ((a) % nfs_asyncdaemons) 949336Sdfr#define NFS_CMPFH(n, f, s) \ 959336Sdfr ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 969336Sdfr#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) 979336Sdfr#define NFS_SRVMAXDATA(n) \ 989336Sdfr (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ 999336Sdfr NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) 1001541Srgrimes 1011541Srgrimes/* 1029336Sdfr * XXX 1039336Sdfr * The B_INVAFTERWRITE flag should be set to whatever is required by the 1049336Sdfr * buffer cache code to say "Invalidate the block after it is written back". 1059336Sdfr */ 1069336Sdfr#define B_INVAFTERWRITE B_NOCACHE 1079336Sdfr 1089336Sdfr/* 1099336Sdfr * The IO_METASYNC flag should be implemented for local file systems. 1109336Sdfr * (Until then, it is nothin at all.) 1119336Sdfr */ 1129336Sdfr#ifndef IO_METASYNC 1139336Sdfr#define IO_METASYNC 0 1149336Sdfr#endif 1159336Sdfr 1169336Sdfr/* 1179336Sdfr * Expected allocation sizes for major data structures. If the actual size 1189336Sdfr * of the structure exceeds these sizes, then malloc() will be allocating 1199336Sdfr * almost twice the memory required. This is used in nfs_init() to warn 1209336Sdfr * the sysadmin that the size of a structure should be reduced. 1219336Sdfr * (These sizes are always a power of 2. If the kernel malloc() changes 1229336Sdfr * to one that does not allocate space in powers of 2 size, then this all 1239336Sdfr * becomes bunk!) 1249336Sdfr */ 1259336Sdfr#define NFS_SVCALLOC 256 1269336Sdfr#define NFS_UIDALLOC 128 1279336Sdfr 1289336Sdfr/* 12922521Sdyson * Arguments to mount NFS 13022521Sdyson */ 13122521Sdyson#define NFS_ARGSVERSION 3 /* change when nfs_args changes */ 13222521Sdysonstruct nfs_args { 13322521Sdyson int version; /* args structure version number */ 13422521Sdyson struct sockaddr *addr; /* file server address */ 13522521Sdyson int addrlen; /* length of address */ 13622521Sdyson int sotype; /* Socket type */ 13722521Sdyson int proto; /* and Protocol */ 13822521Sdyson u_char *fh; /* File handle to be mounted */ 13922521Sdyson int fhsize; /* Size, in bytes, of fh */ 14022521Sdyson int flags; /* flags */ 14122521Sdyson int wsize; /* write size in bytes */ 14222521Sdyson int rsize; /* read size in bytes */ 14322521Sdyson int readdirsize; /* readdir size in bytes */ 14422521Sdyson int timeo; /* initial timeout in .1 secs */ 14522521Sdyson int retrans; /* times to retry send */ 14622521Sdyson int maxgrouplist; /* Max. size of group list */ 14722521Sdyson int readahead; /* # of blocks to readahead */ 14822521Sdyson int leaseterm; /* Term (sec) of lease */ 14922521Sdyson int deadthresh; /* Retrans threshold */ 15022521Sdyson char *hostname; /* server's name */ 15136176Speter int acregmin; /* cache attrs for reg files min time */ 15236176Speter int acregmax; /* cache attrs for reg files max time */ 15336176Speter int acdirmin; /* cache attrs for dirs min time */ 15436176Speter int acdirmax; /* cache attrs for dirs max time */ 15522521Sdyson}; 15622521Sdyson 15722521Sdyson/* 15822521Sdyson * NFS mount option flags 15922521Sdyson */ 16022521Sdyson#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 16122521Sdyson#define NFSMNT_WSIZE 0x00000002 /* set write size */ 16222521Sdyson#define NFSMNT_RSIZE 0x00000004 /* set read size */ 16322521Sdyson#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 16422521Sdyson#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ 16522521Sdyson#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 16622521Sdyson#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 16722521Sdyson#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 16822521Sdyson#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 16922521Sdyson#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ 17022521Sdyson#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 17122521Sdyson#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 17222521Sdyson#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ 17322521Sdyson#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ 17422521Sdyson#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ 17522521Sdyson#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ 17622521Sdyson#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ 17722521Sdyson#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ 17836176Speter#define NFSMNT_ACREGMIN 0x00040000 17936176Speter#define NFSMNT_ACREGMAX 0x00080000 18036176Speter#define NFSMNT_ACDIRMIN 0x00100000 18136176Speter#define NFSMNT_ACDIRMAX 0x00200000 18222521Sdyson 18336176Speter#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ 18436176Speter#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ 18536176Speter#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ 18636176Speter#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */ 18736176Speter#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */ 18836176Speter#define NFSSTA_DISMNT 0x00800000 /* Dismounted */ 18936176Speter#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */ 19036176Speter#define NFSSTA_WANTSND 0x02000000 /* Want above */ 19136176Speter#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */ 19236176Speter#define NFSSTA_WANTRCV 0x08000000 /* Want above */ 19336176Speter#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */ 19436176Speter#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */ 19536176Speter#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */ 19636176Speter#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */ 19736176Speter 19822521Sdyson/* 1991541Srgrimes * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 2001541Srgrimes * should ever try and use it. 2011541Srgrimes */ 2021541Srgrimesstruct nfsd_args { 2031541Srgrimes int sock; /* Socket to serve */ 20422521Sdyson caddr_t name; /* Client addr for connection based sockets */ 2051541Srgrimes int namelen; /* Length of name */ 2061541Srgrimes}; 2071541Srgrimes 2081541Srgrimesstruct nfsd_srvargs { 2091541Srgrimes struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 2101541Srgrimes uid_t nsd_uid; /* Effective uid mapped to cred */ 21136541Speter u_int32_t nsd_haddr; /* Ip address of client */ 2121541Srgrimes struct ucred nsd_cr; /* Cred. uid maps to */ 2131541Srgrimes int nsd_authlen; /* Length of auth string (ret) */ 2149336Sdfr u_char *nsd_authstr; /* Auth string (ret) */ 2159336Sdfr int nsd_verflen; /* and the verfier */ 2169336Sdfr u_char *nsd_verfstr; 2179336Sdfr struct timeval nsd_timestamp; /* timestamp from verifier */ 21836541Speter u_int32_t nsd_ttl; /* credential ttl (sec) */ 2199336Sdfr NFSKERBKEY_T nsd_key; /* Session key */ 2201541Srgrimes}; 2211541Srgrimes 2221541Srgrimesstruct nfsd_cargs { 2231541Srgrimes char *ncd_dirp; /* Mount dir path */ 2241541Srgrimes uid_t ncd_authuid; /* Effective uid */ 2251541Srgrimes int ncd_authtype; /* Type of authenticator */ 2261541Srgrimes int ncd_authlen; /* Length of authenticator string */ 2279336Sdfr u_char *ncd_authstr; /* Authenticator string */ 2289336Sdfr int ncd_verflen; /* and the verifier */ 2299336Sdfr u_char *ncd_verfstr; 2309336Sdfr NFSKERBKEY_T ncd_key; /* Session key */ 2311541Srgrimes}; 2321541Srgrimes 2331541Srgrimes/* 23422521Sdyson * XXX to allow amd to include nfs.h without nfsproto.h 23522521Sdyson */ 23622521Sdyson#ifdef NFS_NPROCS 23722521Sdyson/* 2381541Srgrimes * Stats structure 2391541Srgrimes */ 2401541Srgrimesstruct nfsstats { 2411541Srgrimes int attrcache_hits; 2421541Srgrimes int attrcache_misses; 2431541Srgrimes int lookupcache_hits; 2441541Srgrimes int lookupcache_misses; 2451541Srgrimes int direofcache_hits; 2461541Srgrimes int direofcache_misses; 2471541Srgrimes int biocache_reads; 2481541Srgrimes int read_bios; 2491541Srgrimes int read_physios; 2501541Srgrimes int biocache_writes; 2511541Srgrimes int write_bios; 2521541Srgrimes int write_physios; 2531541Srgrimes int biocache_readlinks; 2541541Srgrimes int readlink_bios; 2551541Srgrimes int biocache_readdirs; 2561541Srgrimes int readdir_bios; 2571541Srgrimes int rpccnt[NFS_NPROCS]; 2581541Srgrimes int rpcretries; 2591541Srgrimes int srvrpccnt[NFS_NPROCS]; 2601541Srgrimes int srvrpc_errs; 2611541Srgrimes int srv_errs; 2621541Srgrimes int rpcrequests; 2631541Srgrimes int rpctimeouts; 2641541Srgrimes int rpcunexpected; 2651541Srgrimes int rpcinvalid; 2661541Srgrimes int srvcache_inproghits; 2671541Srgrimes int srvcache_idemdonehits; 2681541Srgrimes int srvcache_nonidemdonehits; 2691541Srgrimes int srvcache_misses; 2701541Srgrimes int srvnqnfs_leases; 2711541Srgrimes int srvnqnfs_maxleases; 2721541Srgrimes int srvnqnfs_getleases; 2739336Sdfr int srvvop_writes; 2741541Srgrimes}; 27522521Sdyson#endif 2761541Srgrimes 2771541Srgrimes/* 2781541Srgrimes * Flags for nfssvc() system call. 2791541Srgrimes */ 2801541Srgrimes#define NFSSVC_BIOD 0x002 2811541Srgrimes#define NFSSVC_NFSD 0x004 2821541Srgrimes#define NFSSVC_ADDSOCK 0x008 2831541Srgrimes#define NFSSVC_AUTHIN 0x010 2841541Srgrimes#define NFSSVC_GOTAUTH 0x040 2851541Srgrimes#define NFSSVC_AUTHINFAIL 0x080 2861541Srgrimes#define NFSSVC_MNTD 0x100 2871541Srgrimes 2881541Srgrimes/* 2893820Swollman * fs.nfs sysctl(3) identifiers 2903820Swollman */ 2913820Swollman#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 29224330Sguido#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */ 2933820Swollman 2943820Swollman#define FS_NFS_NAMES { \ 2953820Swollman { 0, 0 }, \ 2963820Swollman { "nfsstats", CTLTYPE_STRUCT }, \ 29724330Sguido { "nfsprivport", CTLTYPE_INT }, \ 2983820Swollman} 2993820Swollman 30022521Sdyson#ifdef KERNEL 3014067Swollman 30230354Sphk#ifdef MALLOC_DECLARE 30330354SphkMALLOC_DECLARE(M_NFSREQ); 30430354SphkMALLOC_DECLARE(M_NFSDIROFF); 30530354SphkMALLOC_DECLARE(M_NFSRVDESC); 30630354SphkMALLOC_DECLARE(M_NFSUID); 30730354SphkMALLOC_DECLARE(M_NQLEASE); 30830354SphkMALLOC_DECLARE(M_NFSD); 30930354SphkMALLOC_DECLARE(M_NFSBIGFH); 31036329SpeterMALLOC_DECLARE(M_NFSHASH); 31130354Sphk#endif 31230354Sphk 31336329Speter#ifdef ZONE_INTERRUPT 31436329Speterextern vm_zone_t nfsmount_zone; 31536329Speter#endif 31636329Speter 31738894Sbdeextern struct callout_handle nfs_timer_handle; 31838894Sbde 3194067Swollmanstruct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 3204067Swollman 32132998Sbde/* 32232998Sbde * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 32332998Sbde * What should be in this set is open to debate, but I believe that since 32432998Sbde * I/O system calls on ufs are never interrupted by signals the set should 32532998Sbde * be minimal. My reasoning is that many current programs that use signals 32632998Sbde * such as SIGALRM will not expect file I/O system calls to be interrupted 32732998Sbde * by them and break. 32832998Sbde */ 3291541Srgrimes#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 3301541Srgrimes sigmask(SIGHUP)|sigmask(SIGQUIT)) 3311541Srgrimes 3321541Srgrimes/* 3331541Srgrimes * Socket errors ignored for connectionless sockets?? 3341541Srgrimes * For now, ignore them all 3351541Srgrimes */ 3361541Srgrimes#define NFSIGNORE_SOERROR(s, e) \ 3371541Srgrimes ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 3381541Srgrimes ((s) & PR_CONNREQUIRED) == 0) 3391541Srgrimes 3401541Srgrimes/* 3411541Srgrimes * Nfs outstanding request list element 3421541Srgrimes */ 3431541Srgrimesstruct nfsreq { 3443664Sphk TAILQ_ENTRY(nfsreq) r_chain; 3451541Srgrimes struct mbuf *r_mreq; 3461541Srgrimes struct mbuf *r_mrep; 3471541Srgrimes struct mbuf *r_md; 3481541Srgrimes caddr_t r_dpos; 3491541Srgrimes struct nfsmount *r_nmp; 3501541Srgrimes struct vnode *r_vp; 35136541Speter u_int32_t r_xid; 3521541Srgrimes int r_flags; /* flags on request, see below */ 3531541Srgrimes int r_retry; /* max retransmission count */ 3541541Srgrimes int r_rexmit; /* current retrans count */ 3551541Srgrimes int r_timer; /* tick counter on reply */ 35626420Sdfr u_int32_t r_procnum; /* NFS procedure number */ 3571541Srgrimes int r_rtt; /* RTT for rpc */ 3581541Srgrimes struct proc *r_procp; /* Proc that did I/O system call */ 3591541Srgrimes}; 3601541Srgrimes 3613664Sphk/* 3623664Sphk * Queue head for nfsreq's 3633664Sphk */ 3649759Sbdeextern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; 3653664Sphk 3661541Srgrimes/* Flag values for r_flags */ 3671541Srgrimes#define R_TIMING 0x01 /* timing request (in mntp) */ 3681541Srgrimes#define R_SENT 0x02 /* request has been sent */ 3691541Srgrimes#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 3701541Srgrimes#define R_INTR 0x08 /* intr mnt, signal pending */ 3711541Srgrimes#define R_SOCKERR 0x10 /* Fatal error on socket */ 3721541Srgrimes#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 3731541Srgrimes#define R_MUSTRESEND 0x40 /* Must resend request */ 3741541Srgrimes#define R_GETONEREP 0x80 /* Probe for one reply only */ 3751541Srgrimes 3761541Srgrimes/* 3771541Srgrimes * A list of nfssvc_sock structures is maintained with all the sockets 3781541Srgrimes * that require service by the nfsd. 3791541Srgrimes * The nfsuid structs hang off of the nfssvc_sock structs in both lru 3801541Srgrimes * and uid hash lists. 3811541Srgrimes */ 3829336Sdfr#ifndef NFS_UIDHASHSIZ 3839336Sdfr#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 3849336Sdfr#endif 3853664Sphk#define NUIDHASH(sock, uid) \ 3869336Sdfr (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 3879336Sdfr#ifndef NFS_WDELAYHASHSIZ 3889336Sdfr#define NFS_WDELAYHASHSIZ 16 /* and with this */ 3899336Sdfr#endif 3909336Sdfr#define NWDELAYHASH(sock, f) \ 39136541Speter (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ]) 3929336Sdfr#ifndef NFS_MUIDHASHSIZ 39319449Sdfr#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ 3949336Sdfr#endif 3959336Sdfr#define NMUIDHASH(nmp, uid) \ 3969336Sdfr (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 3979336Sdfr#define NFSNOHASH(fhsum) \ 3989336Sdfr (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 3991541Srgrimes 40036503Speter/* 40136503Speter * Network address hash list element 40236503Speter */ 40336503Speterunion nethostaddr { 40436541Speter u_int32_t had_inetaddr; 40536503Speter struct sockaddr *had_nam; 40636503Speter}; 40736503Speter 4081541Srgrimesstruct nfsuid { 4093664Sphk TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 4103664Sphk LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 4111541Srgrimes int nu_flag; /* Flags */ 4121541Srgrimes union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 4131541Srgrimes struct ucred nu_cr; /* Cred uid mapped to */ 4149336Sdfr int nu_expire; /* Expiry time (sec) */ 4159336Sdfr struct timeval nu_timestamp; /* Kerb. timestamp */ 41636541Speter u_int32_t nu_nickname; /* Nickname on server */ 4179336Sdfr NFSKERBKEY_T nu_key; /* and session key */ 4181541Srgrimes}; 4191541Srgrimes 4201541Srgrimes#define nu_inetaddr nu_haddr.had_inetaddr 4211541Srgrimes#define nu_nam nu_haddr.had_nam 4221541Srgrimes/* Bits for nu_flag */ 4231541Srgrimes#define NU_INETADDR 0x1 4249336Sdfr#define NU_NAM 0x2 4259336Sdfr#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 4261541Srgrimes 42725781Sdfrstruct nfsrv_rec { 42825781Sdfr STAILQ_ENTRY(nfsrv_rec) nr_link; 42928270Swollman struct sockaddr *nr_address; 43025781Sdfr struct mbuf *nr_packet; 43125781Sdfr}; 43225781Sdfr 4331541Srgrimesstruct nfssvc_sock { 4343664Sphk TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 4353664Sphk TAILQ_HEAD(, nfsuid) ns_uidlruhead; 4361541Srgrimes struct file *ns_fp; 4371541Srgrimes struct socket *ns_so; 43828270Swollman struct sockaddr *ns_nam; 4391541Srgrimes struct mbuf *ns_raw; 4401541Srgrimes struct mbuf *ns_rawend; 44125781Sdfr STAILQ_HEAD(, nfsrv_rec) ns_rec; 4429336Sdfr struct mbuf *ns_frag; 4439336Sdfr int ns_flag; 4449336Sdfr int ns_solock; 4459336Sdfr int ns_cc; 4469336Sdfr int ns_reclen; 4471541Srgrimes int ns_numuids; 44836541Speter u_int32_t ns_sref; 4499336Sdfr LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 4509336Sdfr LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 4519336Sdfr LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 4521541Srgrimes}; 4531541Srgrimes 4541541Srgrimes/* Bits for "ns_flag" */ 4551541Srgrimes#define SLP_VALID 0x01 4561541Srgrimes#define SLP_DOREC 0x02 4571541Srgrimes#define SLP_NEEDQ 0x04 4581541Srgrimes#define SLP_DISCONN 0x08 4591541Srgrimes#define SLP_GETSTREAM 0x10 4609336Sdfr#define SLP_LASTFRAG 0x20 4611541Srgrimes#define SLP_ALLFLAGS 0xff 4621541Srgrimes 4639759Sbdeextern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; 4649759Sbdeextern int nfssvc_sockhead_flag; 4653664Sphk#define SLP_INIT 0x01 4663664Sphk#define SLP_WANTINIT 0x02 4673664Sphk 4681541Srgrimes/* 4691541Srgrimes * One of these structures is allocated for each nfsd. 4701541Srgrimes */ 4711541Srgrimesstruct nfsd { 4729336Sdfr TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 4739336Sdfr int nfsd_flag; /* NFSD_ flags */ 4749336Sdfr struct nfssvc_sock *nfsd_slp; /* Current socket */ 4759336Sdfr int nfsd_authlen; /* Authenticator len */ 4769336Sdfr u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 4779336Sdfr int nfsd_verflen; /* and the Verifier */ 4789336Sdfr u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 4799336Sdfr struct proc *nfsd_procp; /* Proc ptr */ 4809336Sdfr struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 4811541Srgrimes}; 4821541Srgrimes 4839336Sdfr/* Bits for "nfsd_flag" */ 4841541Srgrimes#define NFSD_WAITING 0x01 4853664Sphk#define NFSD_REQINPROG 0x02 4863664Sphk#define NFSD_NEEDAUTH 0x04 4873664Sphk#define NFSD_AUTHFAIL 0x08 4883305Sphk 4899336Sdfr/* 4909336Sdfr * This structure is used by the server for describing each request. 4919336Sdfr * Some fields are used only when write request gathering is performed. 4929336Sdfr */ 4939336Sdfrstruct nfsrv_descript { 4949336Sdfr u_quad_t nd_time; /* Write deadline (usec) */ 4959336Sdfr off_t nd_off; /* Start byte offset */ 4969336Sdfr off_t nd_eoff; /* and end byte offset */ 4979336Sdfr LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 4989336Sdfr LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 4999336Sdfr LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 5009336Sdfr struct mbuf *nd_mrep; /* Request mbuf list */ 5019336Sdfr struct mbuf *nd_md; /* Current dissect mbuf */ 5029336Sdfr struct mbuf *nd_mreq; /* Reply mbuf list */ 50328270Swollman struct sockaddr *nd_nam; /* and socket addr */ 50428270Swollman struct sockaddr *nd_nam2; /* return socket addr */ 5059336Sdfr caddr_t nd_dpos; /* Current dissect pos */ 50626420Sdfr u_int32_t nd_procnum; /* RPC # */ 5079336Sdfr int nd_stable; /* storage type */ 5089336Sdfr int nd_flag; /* nd_flag */ 5099336Sdfr int nd_len; /* Length of this write */ 5109336Sdfr int nd_repstat; /* Reply status */ 51136541Speter u_int32_t nd_retxid; /* Reply xid */ 51236541Speter u_int32_t nd_duration; /* Lease duration */ 5139336Sdfr struct timeval nd_starttime; /* Time RPC initiated */ 5149336Sdfr fhandle_t nd_fh; /* File handle */ 5159336Sdfr struct ucred nd_cr; /* Credentials */ 5169336Sdfr}; 5179336Sdfr 5189336Sdfr/* Bits for "nd_flag" */ 5199336Sdfr#define ND_READ LEASE_READ 5209336Sdfr#define ND_WRITE LEASE_WRITE 5219336Sdfr#define ND_CHECK 0x04 5229336Sdfr#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 5239336Sdfr#define ND_NFSV3 0x08 5249336Sdfr#define ND_NQNFS 0x10 5259336Sdfr#define ND_KERBNICK 0x20 5269336Sdfr#define ND_KERBFULL 0x40 5279336Sdfr#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 5289336Sdfr 5299759Sbdeextern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; 5309759Sbdeextern int nfsd_head_flag; 5313664Sphk#define NFSD_CHECKSLP 0x01 5323664Sphk 5339336Sdfr/* 5349336Sdfr * These macros compare nfsrv_descript structures. 5359336Sdfr */ 5369336Sdfr#define NFSW_CONTIG(o, n) \ 5379336Sdfr ((o)->nd_eoff >= (n)->nd_off && \ 5389336Sdfr !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 5399336Sdfr 5409336Sdfr#define NFSW_SAMECRED(o, n) \ 5419336Sdfr (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 5429336Sdfr !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 5439336Sdfr sizeof (struct ucred))) 5449336Sdfr 54527446Sdfr/* 54627446Sdfr * Defines for WebNFS 54727446Sdfr */ 54827446Sdfr 54927446Sdfr#define WEBNFS_ESC_CHAR '%' 55027446Sdfr#define WEBNFS_SPECCHAR_START 0x80 55127446Sdfr 55227446Sdfr#define WEBNFS_NATIVE_CHAR 0x80 55327446Sdfr/* 55427446Sdfr * .. 55527446Sdfr * Possibly more here in the future. 55627446Sdfr */ 55727446Sdfr 55827446Sdfr/* 55927446Sdfr * Macro for converting escape characters in WebNFS pathnames. 56027446Sdfr * Should really be in libkern. 56127446Sdfr */ 56227446Sdfr 56327446Sdfr#define HEXTOC(c) \ 56427446Sdfr ((c) >= 'a' ? ((c) - ('a' - 10)) : \ 56527446Sdfr ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) 56627446Sdfr#define HEXSTRTOI(p) \ 56727446Sdfr ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) 56827446Sdfr 56925663Sdfr#ifdef NFS_DEBUG 57022521Sdyson 57125663Sdfrextern int nfs_debug; 57225663Sdfr#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ 57325663Sdfr#define NFS_DEBUG_WG 2 /* server write gathering */ 57425663Sdfr#define NFS_DEBUG_RC 4 /* server request caching */ 57525663Sdfr 57625663Sdfr#define NFS_DPF(cat, args) \ 57725663Sdfr do { \ 57825663Sdfr if (nfs_debug & NFS_DEBUG_##cat) printf args; \ 57925663Sdfr } while (0) 58025663Sdfr 58125663Sdfr#else 58225663Sdfr 58325663Sdfr#define NFS_DPF(cat, args) 58425663Sdfr 58525663Sdfr#endif 58625663Sdfr 58734961Sphku_quad_t nfs_curusec __P((void)); 58822521Sdysonint nfs_init __P((struct vfsconf *vfsp)); 58938894Sbdeint nfs_uninit __P((struct vfsconf *vfsp)); 5903305Sphkint nfs_reply __P((struct nfsreq *)); 5919336Sdfrint nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 59228270Swollmanint nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *, 59328270Swollman struct nfsreq *)); 59428270Swollmanint nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *, 59528270Swollman int, int, u_quad_t *, struct mbuf **, struct mbuf **, 59628270Swollman caddr_t *)); 59744246Speterint nfs_sndlock __P((struct nfsreq *)); 59844246Spetervoid nfs_sndunlock __P((struct nfsreq *)); 59944246Speterint nfs_slplock __P((struct nfssvc_sock *, int)); 60044246Spetervoid nfs_slpunlock __P((struct nfssvc_sock *)); 60128270Swollmanint nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); 60228270Swollmanint nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, 60328270Swollman int)); 60428270Swollmanint nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); 60528270Swollmanint nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, 60628270Swollman int *)); 60728270Swollmanint nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); 60846580Sphkint nfs_asyncio __P((struct buf *, struct ucred *, struct proc *)); 60928270Swollmanint nfs_doio __P((struct buf *, struct ucred *, struct proc *)); 61028270Swollmanint nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); 61128270Swollmanint nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); 61228270Swollmanint nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); 61328270Swollmanint nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); 61428270Swollmanvoid nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *, 61528270Swollman struct nfs_fattr *)); 61628270Swollmanvoid nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, 61728270Swollman struct vattr *, struct mbuf **, char **)); 61828270Swollmanvoid nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, 61928270Swollman struct mbuf **, char **)); 62028270Swollmanint netaddr_match __P((int, union nethostaddr *, struct sockaddr *)); 62128270Swollmanint nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, 62228270Swollman struct ucred *, struct mbuf **, struct mbuf **, 62328270Swollman caddr_t *)); 62428270Swollmanint nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, 62528270Swollman struct vattr *)); 62628270Swollmanint nfs_namei __P((struct nameidata *, fhandle_t *, int, 62728270Swollman struct nfssvc_sock *, struct sockaddr *, struct mbuf **, 62828270Swollman caddr_t *, struct vnode **, struct proc *, int, int)); 62928270Swollmanvoid nfsm_adj __P((struct mbuf *, int, int)); 63028270Swollmanint nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); 6313305Sphkvoid nfsrv_initcache __P((void)); 63228270Swollmanint nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *, 63328270Swollman char **, int *, char *, int *, NFSKERBKEY_T)); 63428270Swollmanint nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, 63528270Swollman int *, char *, int)); 63628270Swollmanint nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, 63728270Swollman NFSKERBKEY_T, struct mbuf **, char **, 63828270Swollman struct mbuf *)); 63928270Swollmanint nfs_adv __P((struct mbuf **, caddr_t *, int, int)); 6403305Sphkvoid nfs_nhinit __P((void)); 6413305Sphkvoid nfs_timer __P((void*)); 64228270Swollmanu_long nfs_hash __P((nfsfh_t *, int)); 64328270Swollmanint nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *, 64428270Swollman struct nfsrv_descript **)); 64528270Swollmanint nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *, 64628270Swollman struct mbuf **)); 64728270Swollmanvoid nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *)); 64822521Sdysonvoid nfsrv_cleancache __P((void)); 64928270Swollmanint nfs_connect __P((struct nfsmount *, struct nfsreq *)); 65022521Sdysonvoid nfs_disconnect __P((struct nfsmount *)); 65136540Spetervoid nfs_safedisconnect __P((struct nfsmount *)); 65228270Swollmanint nfs_getattrcache __P((struct vnode *, struct vattr *)); 65336511Speterint nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long)); 65446349Salcint nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *)); 65528270Swollmanint nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *)); 6563305Sphkvoid nfsrv_init __P((int)); 6579336Sdfrvoid nfs_clearcommit __P((struct mount *)); 6589336Sdfrint nfsrv_errmap __P((struct nfsrv_descript *, int)); 65928270Swollmanvoid nfsrvw_sort __P((gid_t *, int)); 66028270Swollmanvoid nfsrv_setcred __P((struct ucred *, struct ucred *)); 66146580Sphkint nfs_writebp __P((struct buf *, int, struct proc *)); 66228270Swollmanint nfsrv_object_create __P((struct vnode *)); 66312588Sbdevoid nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); 6649336Sdfrint nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 6659336Sdfr struct proc *, struct mbuf **)); 6669336Sdfrint nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 6679336Sdfr struct proc *p)); 6686361Sphk 66928270Swollmanint nfsrv3_access __P((struct nfsrv_descript *nfsd, 67028270Swollman struct nfssvc_sock *slp, 67112588Sbde struct proc *procp, struct mbuf **mrq)); 67212588Sbdeint nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 67312588Sbde struct proc *procp, struct mbuf **mrq)); 67412588Sbdeint nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 67512588Sbde struct proc *procp, struct mbuf **mrq)); 67628270Swollmanint nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, 67728270Swollman struct nfssvc_sock *, struct sockaddr *, int *, 67828270Swollman int, int)); 67927446Sdfrint nfsrv_setpublicfs __P((struct mount *, struct netexport *, 68027446Sdfr struct export_args *)); 68127446Sdfrint nfs_ispublicfh __P((fhandle_t *)); 68212588Sbdeint nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 68312588Sbde struct proc *procp, struct mbuf **mrq)); 68412588Sbdeint nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 68512588Sbde struct proc *procp, struct mbuf **mrq)); 68612588Sbdeint nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 68712588Sbde struct proc *procp, struct mbuf **mrq)); 68812588Sbdeint nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 68912588Sbde struct proc *procp, struct mbuf **mrq)); 69012588Sbdeint nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 69112588Sbde struct proc *procp, struct mbuf **mrq)); 69212588Sbdeint nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 69312588Sbde struct proc *procp, struct mbuf **mrq)); 69412588Sbdeint nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 69512588Sbde struct proc *procp, struct mbuf **mrq)); 69612588Sbdeint nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 69712588Sbde struct proc *procp, struct mbuf **mrq)); 69812588Sbdeint nfsrv_pathconf __P((struct nfsrv_descript *nfsd, 69912588Sbde struct nfssvc_sock *slp, struct proc *procp, 70012588Sbde struct mbuf **mrq)); 70112588Sbdeint nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 70212588Sbde struct proc *procp, struct mbuf **mrq)); 70328270Swollmanint nfsrv_readdir __P((struct nfsrv_descript *nfsd, 70428270Swollman struct nfssvc_sock *slp, 70512588Sbde struct proc *procp, struct mbuf **mrq)); 70612588Sbdeint nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, 70712588Sbde struct nfssvc_sock *slp, struct proc *procp, 70812588Sbde struct mbuf **mrq)); 70912588Sbdeint nfsrv_readlink __P((struct nfsrv_descript *nfsd, 71012588Sbde struct nfssvc_sock *slp, struct proc *procp, 71112588Sbde struct mbuf **mrq)); 71212588Sbdeint nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 71312588Sbde struct proc *procp, struct mbuf **mrq)); 71412588Sbdeint nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 71512588Sbde struct proc *procp, struct mbuf **mrq)); 71612588Sbdeint nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 71712588Sbde struct proc *procp, struct mbuf **mrq)); 71828270Swollmanint nfsrv_setattr __P((struct nfsrv_descript *nfsd, 71928270Swollman struct nfssvc_sock *slp, 72012588Sbde struct proc *procp, struct mbuf **mrq)); 72128270Swollmanint nfsrv_statfs __P((struct nfsrv_descript *nfsd, 72228270Swollman struct nfssvc_sock *slp, 72312588Sbde struct proc *procp, struct mbuf **mrq)); 72428270Swollmanint nfsrv_symlink __P((struct nfsrv_descript *nfsd, 72528270Swollman struct nfssvc_sock *slp, 72612588Sbde struct proc *procp, struct mbuf **mrq)); 72712588Sbdeint nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 72812588Sbde struct proc *procp, struct mbuf **mrq)); 72938482Swollmanvoid nfsrv_rcv __P((struct socket *so, void *arg, int waitflag)); 73022521Sdysonvoid nfsrv_slpderef __P((struct nfssvc_sock *slp)); 7311541Srgrimes#endif /* KERNEL */ 7322175Spaul 7332175Spaul#endif 734