summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfsstats.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nfsclient/nfsstats.h')
-rw-r--r--sys/nfsclient/nfsstats.h279
1 files changed, 226 insertions, 53 deletions
diff --git a/sys/nfsclient/nfsstats.h b/sys/nfsclient/nfsstats.h
index cbf80c6..e1a0f07 100644
--- a/sys/nfsclient/nfsstats.h
+++ b/sys/nfsclient/nfsstats.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
- * $Id: nfs.h,v 1.8 1994/11/02 00:11:00 wollman Exp $
+ * $Id: nfs.h,v 1.9 1995/02/14 06:22:18 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -45,11 +45,12 @@
*/
#define NFS_MAXIOVEC 34
-#define NFS_HZ 25 /* Ticks per second for NFS timeouts */
-#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_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 */
@@ -62,13 +63,81 @@
#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_MAXREADDIR NFS_MAXDATA /* Max. size of directory read */
#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */
-#define NFS_DIRBLKSIZ 1024 /* Size of an NFS directory block */
+#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */
+#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 editted 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.
@@ -80,6 +149,20 @@
(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.
*/
@@ -95,7 +178,12 @@ struct nfsd_srvargs {
u_long nsd_haddr; /* Ip address of client */
struct ucred nsd_cr; /* Cred. uid maps to */
int nsd_authlen; /* Length of auth string (ret) */
- char *nsd_authstr; /* 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 {
@@ -103,7 +191,10 @@ struct nfsd_cargs {
uid_t ncd_authuid; /* Effective uid */
int ncd_authtype; /* Type of authenticator */
int ncd_authlen; /* Length of authenticator string */
- char *ncd_authstr; /* Authenticator string */
+ u_char *ncd_authstr; /* Authenticator string */
+ int ncd_verflen; /* and the verifier */
+ u_char *ncd_verfstr;
+ NFSKERBKEY_T ncd_key; /* Session key */
};
/*
@@ -142,6 +233,7 @@ struct nfsstats {
int srvnqnfs_leases;
int srvnqnfs_maxleases;
int srvnqnfs_getleases;
+ int srvvop_writes;
};
/*
@@ -173,7 +265,7 @@ struct nfsstats {
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#ifdef KERNEL
+#if defined(KERNEL) || defined(_KERNEL)
struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
@@ -224,17 +316,29 @@ TAILQ_HEAD(, nfsreq) nfs_reqq;
#define R_MUSTRESEND 0x40 /* Must resend request */
#define R_GETONEREP 0x80 /* Probe for one reply only */
-extern struct nfsstats nfsstats;
-
/*
* A list of nfssvc_sock structures is maintained with all the sockets
* that require service by the nfsd.
* The nfsuid structs hang off of the nfssvc_sock structs in both lru
* and uid hash lists.
*/
-#define NUIDHASHSIZ 32
+#ifndef NFS_UIDHASHSIZ
+#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
+#endif
#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) & (sock)->ns_uidhash])
+ (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
+#ifndef NFS_WDELAYHASHSIZ
+#define NFS_WDELAYHASHSIZ 16 /* and with this */
+#endif
+#define NWDELAYHASH(sock, f) \
+ (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
+#ifndef NFS_MUIDHASHSIZ
+#define NFS_MUIDHASHSIZ 67 /* Tune the size of nfsmount with this */
+#endif
+#define NMUIDHASH(nmp, uid) \
+ (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
+#define NFSNOHASH(fhsum) \
+ (&nfsnodehashtbl[(fhsum) & nfsnodehash])
/*
* Network address hash list element
@@ -248,35 +352,41 @@ struct nfsuid {
TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
int nu_flag; /* Flags */
- uid_t nu_uid; /* Uid mapped by this entry */
union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
struct ucred nu_cr; /* Cred uid mapped to */
+ int nu_expire; /* Expiry time (sec) */
+ struct timeval nu_timestamp; /* Kerb. timestamp */
+ u_long nu_nickname; /* Nickname on server */
+ NFSKERBKEY_T nu_key; /* and session key */
};
#define nu_inetaddr nu_haddr.had_inetaddr
#define nu_nam nu_haddr.had_nam
/* Bits for nu_flag */
#define NU_INETADDR 0x1
+#define NU_NAM 0x2
+#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
struct nfssvc_sock {
TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- LIST_HEAD(, nfsuid) *ns_uidhashtbl;
- u_long ns_uidhash;
-
- int ns_flag;
- u_long ns_sref;
struct file *ns_fp;
struct socket *ns_so;
- int ns_solock;
struct mbuf *ns_nam;
- int ns_cc;
struct mbuf *ns_raw;
struct mbuf *ns_rawend;
- int ns_reclen;
struct mbuf *ns_rec;
struct mbuf *ns_recend;
+ struct mbuf *ns_frag;
+ int ns_flag;
+ int ns_solock;
+ int ns_cc;
+ int ns_reclen;
int ns_numuids;
+ u_long ns_sref;
+ LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
+ LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
+ LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
};
/* Bits for "ns_flag" */
@@ -285,6 +395,7 @@ struct nfssvc_sock {
#define SLP_NEEDQ 0x04
#define SLP_DISCONN 0x08
#define SLP_GETSTREAM 0x10
+#define SLP_LASTFRAG 0x20
#define SLP_ALLFLAGS 0xff
TAILQ_HEAD(, nfssvc_sock) nfssvc_sockhead;
@@ -296,73 +407,124 @@ int nfssvc_sockhead_flag;
* One of these structures is allocated for each nfsd.
*/
struct nfsd {
- TAILQ_ENTRY(nfsd) nd_chain; /* List of all nfsd's */
- int nd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nd_slp; /* Current socket */
- struct mbuf *nd_nam; /* Client addr for datagram req. */
- struct mbuf *nd_mrep; /* Req. mbuf list */
- struct mbuf *nd_md;
- caddr_t nd_dpos; /* Position in list */
- int nd_procnum; /* RPC procedure number */
- u_long nd_retxid; /* RPC xid */
- int nd_repstat; /* Reply status value */
- struct ucred nd_cr; /* Credentials for req. */
- int nd_nqlflag; /* Leasing flag */
- u_long nd_duration; /* Lease duration */
- int nd_authlen; /* Authenticator len */
- u_char nd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- struct proc *nd_procp; /* Proc ptr */
+ TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
+ int nfsd_flag; /* NFSD_ flags */
+ struct nfssvc_sock *nfsd_slp; /* Current socket */
+ int nfsd_authlen; /* Authenticator len */
+ u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
+ int nfsd_verflen; /* and the Verifier */
+ u_char nfsd_verfstr[RPCVERF_MAXSIZ];
+ struct proc *nfsd_procp; /* Proc ptr */
+ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
};
-/* Bits for "nd_flag" */
+/* Bits for "nfsd_flag" */
#define NFSD_WAITING 0x01
#define NFSD_REQINPROG 0x02
#define NFSD_NEEDAUTH 0x04
#define NFSD_AUTHFAIL 0x08
+/*
+ * This structure is used by the server for describing each request.
+ * Some fields are used only when write request gathering is performed.
+ */
+struct nfsrv_descript {
+ u_quad_t nd_time; /* Write deadline (usec) */
+ off_t nd_off; /* Start byte offset */
+ off_t nd_eoff; /* and end byte offset */
+ LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
+ LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
+ LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
+ struct mbuf *nd_mrep; /* Request mbuf list */
+ struct mbuf *nd_md; /* Current dissect mbuf */
+ struct mbuf *nd_mreq; /* Reply mbuf list */
+ struct mbuf *nd_nam; /* and socket addr */
+ struct mbuf *nd_nam2; /* return socket addr */
+ caddr_t nd_dpos; /* Current dissect pos */
+ int nd_procnum; /* RPC # */
+ int nd_stable; /* storage type */
+ int nd_flag; /* nd_flag */
+ int nd_len; /* Length of this write */
+ int nd_repstat; /* Reply status */
+ u_long nd_retxid; /* Reply xid */
+ u_long nd_duration; /* Lease duration */
+ struct timeval nd_starttime; /* Time RPC initiated */
+ fhandle_t nd_fh; /* File handle */
+ struct ucred nd_cr; /* Credentials */
+};
+
+/* Bits for "nd_flag" */
+#define ND_READ LEASE_READ
+#define ND_WRITE LEASE_WRITE
+#define ND_CHECK 0x04
+#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
+#define ND_NFSV3 0x08
+#define ND_NQNFS 0x10
+#define ND_KERBNICK 0x20
+#define ND_KERBFULL 0x40
+#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
+
TAILQ_HEAD(, nfsd) nfsd_head;
int nfsd_head_flag;
#define NFSD_CHECKSLP 0x01
+/*
+ * These macros compare nfsrv_descript structures.
+ */
+#define NFSW_CONTIG(o, n) \
+ ((o)->nd_eoff >= (n)->nd_off && \
+ !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
+
+#define NFSW_SAMECRED(o, n) \
+ (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
+ !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
+ sizeof (struct ucred)))
+
int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsd *,int));
+int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *));
-int nfs_rephead __P((int,struct nfsd *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));
+int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));
int nfs_sndlock __P((int *,struct nfsreq *));
int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int));
int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *));
-int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int));
+int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *));
int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *));
+int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *));
int nfs_asyncio __P((struct buf *,struct ucred *));
int nfs_doio __P((struct buf *,struct ucred *,struct proc *));
int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *));
int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *));
-int nfs_readdirlookrpc __P((struct vnode *,register struct uio *,struct ucred *));
+int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *));
int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));
-int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *));
+void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *));
+void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **));
+void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **));
+int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **,struct ucred *,struct nfssvc_sock *,struct mbuf *,int *,int));
int nfsrv_access __P((struct vnode *,int,struct ucred *,int,struct proc *));
int netaddr_match __P((int,union nethostaddr *,struct mbuf *));
int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *));
int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *));
-int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct proc *));
+int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int));
void nfsm_adj __P((struct mbuf *,int,int));
int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *));
void nfsrv_initcache __P((void));
int nfs_rcvlock __P((struct nfsreq *));
-int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,int *,char **,int *));
+int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T));
+int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int));
+int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *));
int nfs_msg __P((struct proc *,char *,char *));
int nfs_adv __P((struct mbuf **,caddr_t *,int,int));
int nfsrv_getstream __P((struct nfssvc_sock *,int));
void nfs_nhinit __P((void));
void nfs_timer __P((void*));
-struct nfsnodehashhead * nfs_hash __P((nfsv2fh_t *));
+u_long nfs_hash __P((nfsfh_t *,int));
int nfssvc_iod __P((struct proc *));
int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
int nfssvc_addsock __P((struct file *,struct mbuf *));
-int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *));
-int nfsrv_getcache __P((struct mbuf *,struct nfsd *,struct mbuf **));
-void nfsrv_updatecache __P((struct mbuf *,struct nfsd *,int,struct mbuf *));
+int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **));
+int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **));
+void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *));
int mountnfs __P((struct nfs_args *,struct mount *,struct mbuf *,char *,char *,struct vnode **));
int nfs_connect __P((struct nfsmount *,struct nfsreq *));
int nfs_getattrcache __P((struct vnode *,struct vattr *));
@@ -370,9 +532,20 @@ int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long));
int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *));
int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *));
void nfsrv_init __P((int));
+void nfs_clearcommit __P((struct mount *));
+int nfsrv_errmap __P((struct nfsrv_descript *, int));
+void nfsrvw_coalesce __P((struct nfsrv_descript *,struct nfsrv_descript *));
+void nfsrvw_sort __P((gid_t [],int));
+void nfsrv_setcred __P((struct ucred *,struct ucred *));
+int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int));
+int nfs_writebp __P((struct buf *,int));
int nfsrv_vput __P(( struct vnode * ));
int nfsrv_vrele __P(( struct vnode * ));
int nfsrv_vmio __P(( struct vnode * ));
+int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
+ struct proc *, struct mbuf **));
+int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
+ struct proc *p));
#endif /* KERNEL */
OpenPOWER on IntegriCloud