📄 nfs.h
字号:
/* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Macklem at The University of Guelph. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)nfs.h 8.1 (Berkeley) 6/10/93 * $Id: nfs.h,v 1.1 1998/08/19 21:32:22 joel Exp $ */#ifndef _NFS_NFS_H_#define _NFS_NFS_H_#include <nfs/rpcv2.h>/* * Tunable constants for nfs */#define NFS_MAXIOVEC 34#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/#define NFS_MAXREXMIT 100 /* Stop counting after this many */#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */#define NFS_RETRANS 10 /* Num of retrans for soft mounts */#define NFS_MAXGRPS 16 /* Max. size of groups list */#ifndef NFS_MINATTRTIMO#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */#endif#ifndef NFS_MAXATTRTIMO#define NFS_MAXATTRTIMO 60#endif#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */#define NFS_READDIRSIZE 8192 /* Def. readdir size */#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */#ifndef NFS_GATHERDELAY#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */#endif#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ *//* * Oddballs */#define NMOD(a) ((a) % nfs_asyncdaemons)#define NFS_CMPFH(n, f, s) \ ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)#define NFS_SRVMAXDATA(n) \ (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)/* * XXX * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but * until then... * Same goes for sys/malloc.h, which needs M_NFSDIROFF, * M_NFSRVDESC and M_NFSBIGFH added. * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an * exclusive create. * The B_INVAFTERWRITE flag should be set to whatever is required by the * buffer cache code to say "Invalidate the block after it is written back". */#ifndef B_NEEDCOMMIT#define B_NEEDCOMMIT B_APPENDWRITE#endif#ifndef M_NFSRVDESC#define M_NFSRVDESC M_TEMP#endif#ifndef M_NFSDIROFF#define M_NFSDIROFF M_TEMP#endif#ifndef M_NFSBIGFH#define M_NFSBIGFH M_TEMP#endif#ifndef VA_EXCLUSIVE#define VA_EXCLUSIVE 0#endif#ifdef __FreeBSD__#define B_INVAFTERWRITE B_NOCACHE#else#define B_INVAFTERWRITE B_INVAL#endif/* * These ifdefs try to handle the differences between the various 4.4BSD-Lite * based vfs interfaces. * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to * differentiate between NetBSD-1.0 and NetBSD-current, so.. * I also don't know about BSDi's 2.0 release. */#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__)#define HAS_VOPLEASE 1#endif#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__)#define HAS_VOPREVOKE 1#endif/* * The IO_METASYNC flag should be implemented for local file systems. * (Until then, it is nothin at all.) */#ifndef IO_METASYNC#define IO_METASYNC 0#endif/* * Set the attribute timeout based on how recently the file has been modified. */#define NFS_ATTRTIMEO(np) \ ((((np)->n_flag & NMODIFIED) || \ (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ (time.tv_sec - (np)->n_mtime) / 10))/* * Expected allocation sizes for major data structures. If the actual size * of the structure exceeds these sizes, then malloc() will be allocating * almost twice the memory required. This is used in nfs_init() to warn * the sysadmin that the size of a structure should be reduced. * (These sizes are always a power of 2. If the kernel malloc() changes * to one that does not allocate space in powers of 2 size, then this all * becomes bunk!) */#define NFS_NODEALLOC 256#define NFS_MNTALLOC 512#define NFS_SVCALLOC 256#define NFS_UIDALLOC 128/* * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs * should ever try and use it. */struct nfsd_args { int sock; /* Socket to serve */ caddr_t name; /* Client address for connection based sockets */ int namelen; /* Length of name */};struct nfsd_srvargs { struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ uid_t nsd_uid; /* Effective uid mapped to cred */ u_long nsd_haddr; /* Ip address of client */ struct ucred nsd_cr; /* Cred. uid maps to */ int nsd_authlen; /* Length of auth string (ret) */ u_char *nsd_authstr; /* Auth string (ret) */ int nsd_verflen; /* and the verfier */ u_char *nsd_verfstr; struct timeval nsd_timestamp; /* timestamp from verifier */ u_long nsd_ttl; /* credential ttl (sec) */ NFSKERBKEY_T nsd_key; /* Session key */};struct nfsd_cargs { char *ncd_dirp; /* Mount dir path */ uid_t ncd_authuid; /* Effective uid */ int ncd_authtype; /* Type of authenticator */ int ncd_authlen; /* Length of authenticator string */ u_char *ncd_authstr; /* Authenticator string */ int ncd_verflen; /* and the verifier */ u_char *ncd_verfstr; NFSKERBKEY_T ncd_key; /* Session key */};/* * Stats structure */struct nfsstats { int attrcache_hits; int attrcache_misses; int lookupcache_hits; int lookupcache_misses; int direofcache_hits; int direofcache_misses; int biocache_reads; int read_bios; int read_physios; int biocache_writes; int write_bios; int write_physios; int biocache_readlinks; int readlink_bios; int biocache_readdirs; int readdir_bios; int rpccnt[NFS_NPROCS]; int rpcretries; int srvrpccnt[NFS_NPROCS]; int srvrpc_errs; int srv_errs; int rpcrequests; int rpctimeouts; int rpcunexpected; int rpcinvalid; int srvcache_inproghits; int srvcache_idemdonehits; int srvcache_nonidemdonehits; int srvcache_misses; int srvnqnfs_leases; int srvnqnfs_maxleases; int srvnqnfs_getleases; int srvvop_writes;};/* * Flags for nfssvc() system call. */#define NFSSVC_BIOD 0x002#define NFSSVC_NFSD 0x004#define NFSSVC_ADDSOCK 0x008#define NFSSVC_AUTHIN 0x010#define NFSSVC_GOTAUTH 0x040#define NFSSVC_AUTHINFAIL 0x080#define NFSSVC_MNTD 0x100/* * fs.nfs sysctl(3) identifiers */#define NFS_NFSSTATS 1 /* struct: struct nfsstats */#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */#define FS_NFS_NAMES { \ { 0, 0 }, \ { "nfsstats", CTLTYPE_STRUCT }, \ { "nfsprivport", CTLTYPE_INT }, \}/* * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. * What should be in this set is open to debate, but I believe that since * I/O system calls on ufs are never interrupted by signals the set should * be minimal. My reasoning is that many current programs that use signals * such as SIGALRM will not expect file I/O system calls to be interrupted * by them and break. */#if defined(KERNEL) || defined(_KERNEL)struct uio; struct buf; struct vattr; struct nameidata; /* XXX */#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ sigmask(SIGHUP)|sigmask(SIGQUIT))/* * Socket errors ignored for connectionless sockets?? * For now, ignore them all */#define NFSIGNORE_SOERROR(s, e) \ ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ ((s) & PR_CONNREQUIRED) == 0)/* * Nfs outstanding request list element */struct nfsreq { TAILQ_ENTRY(nfsreq) r_chain; struct mbuf *r_mreq; struct mbuf *r_mrep; struct mbuf *r_md; caddr_t r_dpos; struct nfsmount *r_nmp; struct vnode *r_vp; u_long r_xid; int r_flags; /* flags on request, see below */ int r_retry; /* max retransmission count */ int r_rexmit; /* current retrans count */ int r_timer; /* tick counter on reply */ int r_procnum; /* NFS procedure number */ int r_rtt; /* RTT for rpc */ struct proc *r_procp; /* Proc that did I/O system call */};/* * Queue head for nfsreq's */extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -