nfsrvstats.h revision 1541
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 371541Srgrimes */ 381541Srgrimes 391541Srgrimes/* 401541Srgrimes * Tunable constants for nfs 411541Srgrimes */ 421541Srgrimes 431541Srgrimes#define NFS_MAXIOVEC 34 441541Srgrimes#define NFS_HZ 25 /* Ticks per second for NFS timeouts */ 451541Srgrimes#define NFS_TIMEO (1*NFS_HZ) /* Default timeout = 1 second */ 461541Srgrimes#define NFS_MINTIMEO (1*NFS_HZ) /* Min timeout to use */ 471541Srgrimes#define NFS_MAXTIMEO (60*NFS_HZ) /* Max timeout to backoff to */ 481541Srgrimes#define NFS_MINIDEMTIMEO (5*NFS_HZ) /* Min timeout for non-idempotent ops*/ 491541Srgrimes#define NFS_MAXREXMIT 100 /* Stop counting after this many */ 501541Srgrimes#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 511541Srgrimes#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 521541Srgrimes#define NFS_MAXGRPS 16 /* Max. size of groups list */ 531541Srgrimes#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 541541Srgrimes#define NFS_MAXATTRTIMO 60 551541Srgrimes#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 561541Srgrimes#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 571541Srgrimes#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 581541Srgrimes#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ 591541Srgrimes#define NFS_MAXREADDIR NFS_MAXDATA /* Max. size of directory read */ 601541Srgrimes#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 611541Srgrimes#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */ 621541Srgrimes#define NFS_DIRBLKSIZ 1024 /* Size of an NFS directory block */ 631541Srgrimes#define NMOD(a) ((a) % nfs_asyncdaemons) 641541Srgrimes 651541Srgrimes/* 661541Srgrimes * Set the attribute timeout based on how recently the file has been modified. 671541Srgrimes */ 681541Srgrimes#define NFS_ATTRTIMEO(np) \ 691541Srgrimes ((((np)->n_flag & NMODIFIED) || \ 701541Srgrimes (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ 711541Srgrimes ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ 721541Srgrimes (time.tv_sec - (np)->n_mtime) / 10)) 731541Srgrimes 741541Srgrimes/* 751541Srgrimes * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs 761541Srgrimes * should ever try and use it. 771541Srgrimes */ 781541Srgrimesstruct nfsd_args { 791541Srgrimes int sock; /* Socket to serve */ 801541Srgrimes caddr_t name; /* Client address for connection based sockets */ 811541Srgrimes int namelen; /* Length of name */ 821541Srgrimes}; 831541Srgrimes 841541Srgrimesstruct nfsd_srvargs { 851541Srgrimes struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ 861541Srgrimes uid_t nsd_uid; /* Effective uid mapped to cred */ 871541Srgrimes u_long nsd_haddr; /* Ip address of client */ 881541Srgrimes struct ucred nsd_cr; /* Cred. uid maps to */ 891541Srgrimes int nsd_authlen; /* Length of auth string (ret) */ 901541Srgrimes char *nsd_authstr; /* Auth string (ret) */ 911541Srgrimes}; 921541Srgrimes 931541Srgrimesstruct nfsd_cargs { 941541Srgrimes char *ncd_dirp; /* Mount dir path */ 951541Srgrimes uid_t ncd_authuid; /* Effective uid */ 961541Srgrimes int ncd_authtype; /* Type of authenticator */ 971541Srgrimes int ncd_authlen; /* Length of authenticator string */ 981541Srgrimes char *ncd_authstr; /* Authenticator string */ 991541Srgrimes}; 1001541Srgrimes 1011541Srgrimes/* 1021541Srgrimes * Stats structure 1031541Srgrimes */ 1041541Srgrimesstruct nfsstats { 1051541Srgrimes int attrcache_hits; 1061541Srgrimes int attrcache_misses; 1071541Srgrimes int lookupcache_hits; 1081541Srgrimes int lookupcache_misses; 1091541Srgrimes int direofcache_hits; 1101541Srgrimes int direofcache_misses; 1111541Srgrimes int biocache_reads; 1121541Srgrimes int read_bios; 1131541Srgrimes int read_physios; 1141541Srgrimes int biocache_writes; 1151541Srgrimes int write_bios; 1161541Srgrimes int write_physios; 1171541Srgrimes int biocache_readlinks; 1181541Srgrimes int readlink_bios; 1191541Srgrimes int biocache_readdirs; 1201541Srgrimes int readdir_bios; 1211541Srgrimes int rpccnt[NFS_NPROCS]; 1221541Srgrimes int rpcretries; 1231541Srgrimes int srvrpccnt[NFS_NPROCS]; 1241541Srgrimes int srvrpc_errs; 1251541Srgrimes int srv_errs; 1261541Srgrimes int rpcrequests; 1271541Srgrimes int rpctimeouts; 1281541Srgrimes int rpcunexpected; 1291541Srgrimes int rpcinvalid; 1301541Srgrimes int srvcache_inproghits; 1311541Srgrimes int srvcache_idemdonehits; 1321541Srgrimes int srvcache_nonidemdonehits; 1331541Srgrimes int srvcache_misses; 1341541Srgrimes int srvnqnfs_leases; 1351541Srgrimes int srvnqnfs_maxleases; 1361541Srgrimes int srvnqnfs_getleases; 1371541Srgrimes}; 1381541Srgrimes 1391541Srgrimes/* 1401541Srgrimes * Flags for nfssvc() system call. 1411541Srgrimes */ 1421541Srgrimes#define NFSSVC_BIOD 0x002 1431541Srgrimes#define NFSSVC_NFSD 0x004 1441541Srgrimes#define NFSSVC_ADDSOCK 0x008 1451541Srgrimes#define NFSSVC_AUTHIN 0x010 1461541Srgrimes#define NFSSVC_GOTAUTH 0x040 1471541Srgrimes#define NFSSVC_AUTHINFAIL 0x080 1481541Srgrimes#define NFSSVC_MNTD 0x100 1491541Srgrimes 1501541Srgrimes/* 1511541Srgrimes * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 1521541Srgrimes * What should be in this set is open to debate, but I believe that since 1531541Srgrimes * I/O system calls on ufs are never interrupted by signals the set should 1541541Srgrimes * be minimal. My reasoning is that many current programs that use signals 1551541Srgrimes * such as SIGALRM will not expect file I/O system calls to be interrupted 1561541Srgrimes * by them and break. 1571541Srgrimes */ 1581541Srgrimes#ifdef KERNEL 1591541Srgrimes#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 1601541Srgrimes sigmask(SIGHUP)|sigmask(SIGQUIT)) 1611541Srgrimes 1621541Srgrimes/* 1631541Srgrimes * Socket errors ignored for connectionless sockets?? 1641541Srgrimes * For now, ignore them all 1651541Srgrimes */ 1661541Srgrimes#define NFSIGNORE_SOERROR(s, e) \ 1671541Srgrimes ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 1681541Srgrimes ((s) & PR_CONNREQUIRED) == 0) 1691541Srgrimes 1701541Srgrimes/* 1711541Srgrimes * Nfs outstanding request list element 1721541Srgrimes */ 1731541Srgrimesstruct nfsreq { 1741541Srgrimes struct nfsreq *r_next; 1751541Srgrimes struct nfsreq *r_prev; 1761541Srgrimes struct mbuf *r_mreq; 1771541Srgrimes struct mbuf *r_mrep; 1781541Srgrimes struct mbuf *r_md; 1791541Srgrimes caddr_t r_dpos; 1801541Srgrimes struct nfsmount *r_nmp; 1811541Srgrimes struct vnode *r_vp; 1821541Srgrimes u_long r_xid; 1831541Srgrimes int r_flags; /* flags on request, see below */ 1841541Srgrimes int r_retry; /* max retransmission count */ 1851541Srgrimes int r_rexmit; /* current retrans count */ 1861541Srgrimes int r_timer; /* tick counter on reply */ 1871541Srgrimes int r_procnum; /* NFS procedure number */ 1881541Srgrimes int r_rtt; /* RTT for rpc */ 1891541Srgrimes struct proc *r_procp; /* Proc that did I/O system call */ 1901541Srgrimes}; 1911541Srgrimes 1921541Srgrimes/* Flag values for r_flags */ 1931541Srgrimes#define R_TIMING 0x01 /* timing request (in mntp) */ 1941541Srgrimes#define R_SENT 0x02 /* request has been sent */ 1951541Srgrimes#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 1961541Srgrimes#define R_INTR 0x08 /* intr mnt, signal pending */ 1971541Srgrimes#define R_SOCKERR 0x10 /* Fatal error on socket */ 1981541Srgrimes#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 1991541Srgrimes#define R_MUSTRESEND 0x40 /* Must resend request */ 2001541Srgrimes#define R_GETONEREP 0x80 /* Probe for one reply only */ 2011541Srgrimes 2021541Srgrimesstruct nfsstats nfsstats; 2031541Srgrimes 2041541Srgrimes/* 2051541Srgrimes * A list of nfssvc_sock structures is maintained with all the sockets 2061541Srgrimes * that require service by the nfsd. 2071541Srgrimes * The nfsuid structs hang off of the nfssvc_sock structs in both lru 2081541Srgrimes * and uid hash lists. 2091541Srgrimes */ 2101541Srgrimes#define NUIDHASHSIZ 32 2111541Srgrimes#define NUIDHASH(uid) ((uid) & (NUIDHASHSIZ - 1)) 2121541Srgrimes 2131541Srgrimes/* 2141541Srgrimes * Network address hash list element 2151541Srgrimes */ 2161541Srgrimesunion nethostaddr { 2171541Srgrimes u_long had_inetaddr; 2181541Srgrimes struct mbuf *had_nam; 2191541Srgrimes}; 2201541Srgrimes 2211541Srgrimesstruct nfsuid { 2221541Srgrimes struct nfsuid *nu_lrunext; /* MUST be first */ 2231541Srgrimes struct nfsuid *nu_lruprev; 2241541Srgrimes struct nfsuid *nu_hnext; 2251541Srgrimes struct nfsuid *nu_hprev; 2261541Srgrimes int nu_flag; /* Flags */ 2271541Srgrimes uid_t nu_uid; /* Uid mapped by this entry */ 2281541Srgrimes union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 2291541Srgrimes struct ucred nu_cr; /* Cred uid mapped to */ 2301541Srgrimes}; 2311541Srgrimes 2321541Srgrimes#define nu_inetaddr nu_haddr.had_inetaddr 2331541Srgrimes#define nu_nam nu_haddr.had_nam 2341541Srgrimes/* Bits for nu_flag */ 2351541Srgrimes#define NU_INETADDR 0x1 2361541Srgrimes 2371541Srgrimesstruct nfssvc_sock { 2381541Srgrimes struct nfsuid *ns_lrunext; /* MUST be first */ 2391541Srgrimes struct nfsuid *ns_lruprev; 2401541Srgrimes struct nfssvc_sock *ns_next; 2411541Srgrimes struct nfssvc_sock *ns_prev; 2421541Srgrimes int ns_flag; 2431541Srgrimes u_long ns_sref; 2441541Srgrimes struct file *ns_fp; 2451541Srgrimes struct socket *ns_so; 2461541Srgrimes int ns_solock; 2471541Srgrimes struct mbuf *ns_nam; 2481541Srgrimes int ns_cc; 2491541Srgrimes struct mbuf *ns_raw; 2501541Srgrimes struct mbuf *ns_rawend; 2511541Srgrimes int ns_reclen; 2521541Srgrimes struct mbuf *ns_rec; 2531541Srgrimes struct mbuf *ns_recend; 2541541Srgrimes int ns_numuids; 2551541Srgrimes struct nfsuid *ns_uidh[NUIDHASHSIZ]; 2561541Srgrimes}; 2571541Srgrimes 2581541Srgrimes/* Bits for "ns_flag" */ 2591541Srgrimes#define SLP_VALID 0x01 2601541Srgrimes#define SLP_DOREC 0x02 2611541Srgrimes#define SLP_NEEDQ 0x04 2621541Srgrimes#define SLP_DISCONN 0x08 2631541Srgrimes#define SLP_GETSTREAM 0x10 2641541Srgrimes#define SLP_INIT 0x20 2651541Srgrimes#define SLP_WANTINIT 0x40 2661541Srgrimes 2671541Srgrimes#define SLP_ALLFLAGS 0xff 2681541Srgrimes 2691541Srgrimes/* 2701541Srgrimes * One of these structures is allocated for each nfsd. 2711541Srgrimes */ 2721541Srgrimesstruct nfsd { 2731541Srgrimes struct nfsd *nd_next; /* Must be first */ 2741541Srgrimes struct nfsd *nd_prev; 2751541Srgrimes int nd_flag; /* NFSD_ flags */ 2761541Srgrimes struct nfssvc_sock *nd_slp; /* Current socket */ 2771541Srgrimes struct mbuf *nd_nam; /* Client addr for datagram req. */ 2781541Srgrimes struct mbuf *nd_mrep; /* Req. mbuf list */ 2791541Srgrimes struct mbuf *nd_md; 2801541Srgrimes caddr_t nd_dpos; /* Position in list */ 2811541Srgrimes int nd_procnum; /* RPC procedure number */ 2821541Srgrimes u_long nd_retxid; /* RPC xid */ 2831541Srgrimes int nd_repstat; /* Reply status value */ 2841541Srgrimes struct ucred nd_cr; /* Credentials for req. */ 2851541Srgrimes int nd_nqlflag; /* Leasing flag */ 2861541Srgrimes int nd_duration; /* Lease duration */ 2871541Srgrimes int nd_authlen; /* Authenticator len */ 2881541Srgrimes u_char nd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 2891541Srgrimes struct proc *nd_procp; /* Proc ptr */ 2901541Srgrimes}; 2911541Srgrimes 2921541Srgrimes#define NFSD_WAITING 0x01 2931541Srgrimes#define NFSD_CHECKSLP 0x02 2941541Srgrimes#define NFSD_REQINPROG 0x04 2951541Srgrimes#define NFSD_NEEDAUTH 0x08 2961541Srgrimes#define NFSD_AUTHFAIL 0x10 2971541Srgrimes#endif /* KERNEL */ 298