summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/nfs/nfs.h61
-rw-r--r--sys/nfs/nfs_bio.c8
-rw-r--r--sys/nfs/nfs_common.c49
-rw-r--r--sys/nfs/nfs_nqlease.c37
-rw-r--r--sys/nfs/nfs_socket.c69
-rw-r--r--sys/nfs/nfs_subs.c49
-rw-r--r--sys/nfs/nfs_syscalls.c37
-rw-r--r--sys/nfs/nfs_vfsops.c127
-rw-r--r--sys/nfs/nfs_vnops.c9
-rw-r--r--sys/nfs/nfsmount.h7
-rw-r--r--sys/nfsclient/nfs.h61
-rw-r--r--sys/nfsclient/nfs_bio.c8
-rw-r--r--sys/nfsclient/nfs_nfsiod.c37
-rw-r--r--sys/nfsclient/nfs_socket.c69
-rw-r--r--sys/nfsclient/nfs_subs.c49
-rw-r--r--sys/nfsclient/nfs_vfsops.c127
-rw-r--r--sys/nfsclient/nfs_vnops.c9
-rw-r--r--sys/nfsclient/nfsargs.h61
-rw-r--r--sys/nfsclient/nfsmount.h7
-rw-r--r--sys/nfsclient/nfsstats.h61
-rw-r--r--sys/nfsserver/nfs.h61
-rw-r--r--sys/nfsserver/nfs_srvsock.c69
-rw-r--r--sys/nfsserver/nfs_srvsubs.c49
-rw-r--r--sys/nfsserver/nfs_syscalls.c37
-rw-r--r--sys/nfsserver/nfsrvstats.h61
25 files changed, 754 insertions, 465 deletions
diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h
index 8b28c00..ad606ad 100644
--- a/sys/nfs/nfs.h
+++ b/sys/nfs/nfs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c
index 46020e5..544ba32 100644
--- a/sys/nfs/nfs_bio.c
+++ b/sys/nfs/nfs_bio.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95
- * $Id: nfs_bio.c,v 1.53 1998/03/08 09:57:54 julian Exp $
+ * $Id: nfs_bio.c,v 1.54 1998/03/28 16:05:05 steve Exp $
*/
@@ -257,7 +257,8 @@ nfs_bioread(vp, uio, ioflag, cred, getpages)
if (uio->uio_offset < 0)
return (EINVAL);
p = uio->uio_procp;
- if ((nmp->nm_flag & (NFSMNT_NFSV3 | NFSMNT_GOTFSINFO)) == NFSMNT_NFSV3)
+ if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
+ (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
biosize = vp->v_mount->mnt_stat.f_iosize;
/*
@@ -636,7 +637,8 @@ nfs_write(ap)
np->n_flag &= ~NWRITEERR;
return (np->n_error);
}
- if ((nmp->nm_flag & (NFSMNT_NFSV3 | NFSMNT_GOTFSINFO)) == NFSMNT_NFSV3)
+ if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
+ (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
if (ioflag & (IO_APPEND | IO_SYNC)) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
index f9eabdd..b81eedf 100644
--- a/sys/nfs/nfs_common.c
+++ b/sys/nfs/nfs_common.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
- * $Id: nfs_subs.c,v 1.52 1998/03/30 09:54:12 phk Exp $
+ * $Id: nfs_subs.c,v 1.53 1998/04/06 11:41:07 phk Exp $
*/
/*
@@ -1363,6 +1363,12 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
return (0);
}
+#ifdef NFS_ACDEBUG
+#include <sys/sysctl.h>
+static int nfs_acdebug;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
+#endif
+
/*
* Check the time stamp
* If the cache is valid, copy contents to *vap and return 0
@@ -1373,15 +1379,50 @@ nfs_getattrcache(vp, vaper)
register struct vnode *vp;
struct vattr *vaper;
{
- register struct nfsnode *np = VTONFS(vp);
+ register struct nfsnode *np;
register struct vattr *vap;
+ struct nfsmount *nmp;
+ int timeo;
- if ((time_second - np->n_attrstamp) >= NFS_ATTRTIMEO(np)) {
+ np = VTONFS(vp);
+ vap = &np->n_vattr;
+ nmp = VFSTONFS(vp->v_mount);
+ /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
+ timeo = (time_second - np->n_mtime) / 10;
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug>1)
+ printf("nfs_getattrcache: initial timeo = %d\n", timeo);
+#endif
+
+ if (vap->va_type == VDIR) {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
+ timeo = nmp->nm_acdirmin;
+ else if (timeo > nmp->nm_acdirmax)
+ timeo = nmp->nm_acdirmax;
+ } else {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
+ timeo = nmp->nm_acregmin;
+ else if (timeo > nmp->nm_acregmax)
+ timeo = nmp->nm_acregmax;
+ }
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug > 2)
+ printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
+ nmp->nm_acregmin, nmp->nm_acregmax,
+ nmp->nm_acdirmin, nmp->nm_acdirmax);
+
+ if (nfs_acdebug)
+ printf("nfs_getattrcache: age = %d; final timeo = %d\n",r
+ (time_second - np->n_attrstamp), timeo);
+#endif
+
+ if ((time_second - np->n_attrstamp) >= timeo) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
nfsstats.attrcache_hits++;
- vap = &np->n_vattr;
if (vap->va_size != np->n_size) {
if (vap->va_type == VREG) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c
index 7f4fd9f..2858da5 100644
--- a/sys/nfs/nfs_nqlease.c
+++ b/sys/nfs/nfs_nqlease.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_nqlease.c 8.9 (Berkeley) 5/20/95
- * $Id: nfs_nqlease.c,v 1.32 1997/11/07 08:53:23 phk Exp $
+ * $Id: nfs_nqlease.c,v 1.33 1998/03/30 09:53:48 phk Exp $
*/
@@ -560,15 +560,15 @@ nqsrv_send_eviction(vp, lp, slp, nam, cred)
}
if (((lph->lph_flag & (LC_UDP | LC_CLTP)) == 0 &&
(lph->lph_slp->ns_flag & SLP_VALID) == 0) ||
- (solockp && (*solockp & NFSMNT_SNDLOCK)))
+ (solockp && (*solockp & NFSSTA_SNDLOCK)))
m_freem(m);
else {
if (solockp)
- *solockp |= NFSMNT_SNDLOCK;
+ *solockp |= NFSSTA_SNDLOCK;
(void) nfs_send(so, nam2, m,
(struct nfsreq *)0);
if (solockp)
- nfs_sndunlock(solockp);
+ nfs_sndunlock(solockp, solockp);
}
if (lph->lph_flag & LC_UDP)
FREE(nam2, M_SONAME);
@@ -940,10 +940,11 @@ nqnfs_vacated(vp, cred)
myrep.r_flags = 0;
myrep.r_nmp = nmp;
if (nmp->nm_soflags & PR_CONNREQUIRED)
- (void) nfs_sndlock(&nmp->nm_flag, (struct nfsreq *)0);
+ (void) nfs_sndlock(&nmp->nm_flag, &nmp->nm_state,
+ (struct nfsreq *)0);
(void) nfs_send(nmp->nm_so, nmp->nm_nam, m, &myrep);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(&nmp->nm_flag);
+ nfs_sndunlock(&nmp->nm_flag, &nmp->nm_state);
nfsmout:
return (error);
}
@@ -1039,8 +1040,8 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
* If an authorization string is being passed in, get it.
*/
if ((flag & NFSSVC_GOTAUTH) &&
- (nmp->nm_flag & (NFSMNT_WAITAUTH | NFSMNT_DISMNT)) == 0) {
- if (nmp->nm_flag & NFSMNT_HASAUTH)
+ (nmp->nm_state & (NFSSTA_WAITAUTH | NFSSTA_DISMNT)) == 0) {
+ if (nmp->nm_state & NFSSTA_HASAUTH)
panic("cld kerb");
if ((flag & NFSSVC_AUTHINFAIL) == 0) {
if (ncd->ncd_authlen <= nmp->nm_authlen &&
@@ -1054,18 +1055,18 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
nmp->nm_key = ncd->ncd_key;
#endif
} else
- nmp->nm_flag |= NFSMNT_AUTHERR;
+ nmp->nm_state |= NFSSTA_AUTHERR;
} else
- nmp->nm_flag |= NFSMNT_AUTHERR;
- nmp->nm_flag |= NFSMNT_HASAUTH;
+ nmp->nm_state |= NFSSTA_AUTHERR;
+ nmp->nm_state |= NFSSTA_HASAUTH;
wakeup((caddr_t)&nmp->nm_authlen);
} else
- nmp->nm_flag |= NFSMNT_WAITAUTH;
+ nmp->nm_state |= NFSSTA_WAITAUTH;
/*
* Loop every second updating queue until there is a termination sig.
*/
- while ((nmp->nm_flag & NFSMNT_DISMNT) == 0) {
+ while ((nmp->nm_state & NFSSTA_DISMNT) == 0) {
if (nmp->nm_flag & NFSMNT_NQNFS) {
/*
* If there are no outstanding requests (and therefore no
@@ -1086,7 +1087,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
*/
np = nmp->nm_timerhead.cqh_first;
while (np != (void *)&nmp->nm_timerhead &&
- (nmp->nm_flag & NFSMNT_DISMINPROG) == 0) {
+ (nmp->nm_state & NFSSTA_DISMINPROG) == 0) {
vp = NFSTOV(np);
vpid = vp->v_id;
if (np->n_expiry < time_second) {
@@ -1136,10 +1137,10 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
/*
* Get an authorization string, if required.
*/
- if ((nmp->nm_flag & (NFSMNT_WAITAUTH | NFSMNT_DISMNT | NFSMNT_HASAUTH)) == 0) {
+ if ((nmp->nm_state & (NFSSTA_WAITAUTH | NFSSTA_DISMNT | NFSSTA_HASAUTH)) == 0) {
ncd->ncd_authuid = nmp->nm_authuid;
if (copyout((caddr_t)ncd, argp, sizeof (struct nfsd_cargs)))
- nmp->nm_flag |= NFSMNT_WAITAUTH;
+ nmp->nm_state |= NFSSTA_WAITAUTH;
else
return (ENEEDAUTH);
}
@@ -1147,8 +1148,8 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
/*
* Wait a bit (no pun) and do it again.
*/
- if ((nmp->nm_flag & NFSMNT_DISMNT) == 0 &&
- (nmp->nm_flag & (NFSMNT_WAITAUTH | NFSMNT_HASAUTH))) {
+ if ((nmp->nm_state & NFSSTA_DISMNT) == 0 &&
+ (nmp->nm_state & (NFSSTA_WAITAUTH | NFSSTA_HASAUTH))) {
error = tsleep((caddr_t)&nmp->nm_authstr, PSOCK | PCATCH,
"nqnfstimr", hz / 3);
if (error == EINTR || error == ERESTART)
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 5c084b7..3fe0cec 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_socket.c,v 1.30 1997/10/28 15:59:07 bde Exp $
+ * $Id: nfs_socket.c,v 1.31 1998/03/30 09:54:04 phk Exp $
*/
/*
@@ -136,7 +136,7 @@ struct nfsrtt nfsrtt;
static int nfs_msg __P((struct proc *,char *,char *));
static int nfs_rcvlock __P((struct nfsreq *));
-static void nfs_rcvunlock __P((int *flagp));
+static void nfs_rcvunlock __P((int *flagp, int *statep));
static void nfs_realign __P((struct mbuf *m, int hsiz));
static int nfs_receive __P((struct nfsreq *rep, struct sockaddr **aname,
struct mbuf **mp));
@@ -483,7 +483,8 @@ nfs_receive(rep, aname, mp)
* until we have an entire rpc request/reply.
*/
if (sotype != SOCK_DGRAM) {
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state,
+ rep);
if (error)
return (error);
tryagain:
@@ -497,14 +498,16 @@ tryagain:
* mount point.
*/
if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (EINTR);
}
so = rep->r_nmp->nm_so;
if (!so) {
error = nfs_reconnect(rep);
if (error) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
@@ -516,13 +519,14 @@ tryagain:
if (error) {
if (error == EINTR || error == ERESTART ||
(error = nfs_reconnect(rep))) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
}
}
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state);
if (sotype == SOCK_STREAM) {
aio.iov_base = (caddr_t) &len;
aio.iov_len = sizeof(u_long);
@@ -621,7 +625,8 @@ errout:
"receive error %d from nfs server %s\n",
error,
rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state, rep);
if (!error)
error = nfs_reconnect(rep);
if (!error)
@@ -704,7 +709,7 @@ nfs_reply(myrep)
* Get the next Rpc reply off the socket
*/
error = nfs_receive(myrep, &nam, &mrep);
- nfs_rcvunlock(&nmp->nm_flag);
+ nfs_rcvunlock(&nmp->nm_flag, &nmp->nm_state);
if (error) {
/*
@@ -964,12 +969,12 @@ tryagain:
nmp->nm_sent < nmp->nm_cwnd)) {
splx(s);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- error = nfs_sndlock(&nmp->nm_flag, rep);
+ error = nfs_sndlock(&nmp->nm_flag, &nmp->nm_state, rep);
if (!error) {
m = m_copym(m, 0, M_COPYALL, M_WAIT);
error = nfs_send(nmp->nm_so, nmp->nm_nam, m, rep);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(&nmp->nm_flag);
+ nfs_sndunlock(&nmp->nm_flag, &nmp->nm_state);
}
if (!error && (rep->r_flags & R_MUSTRESEND) == 0) {
nmp->nm_sent += NFS_CWNDSCALE;
@@ -1445,8 +1450,9 @@ nfs_sigintr(nmp, rep, p)
* in progress when a reconnect is necessary.
*/
int
-nfs_sndlock(flagp, rep)
+nfs_sndlock(flagp, statep, rep)
register int *flagp;
+ register int *statep;
struct nfsreq *rep;
{
struct proc *p;
@@ -1458,18 +1464,18 @@ nfs_sndlock(flagp, rep)
slpflag = PCATCH;
} else
p = (struct proc *)0;
- while (*flagp & NFSMNT_SNDLOCK) {
+ while (*statep & NFSSTA_SNDLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, p))
return (EINTR);
- *flagp |= NFSMNT_WANTSND;
- (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsndlck",
- slptimeo);
+ *statep |= NFSSTA_WANTSND;
+ (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1),
+ "nfsndlck", slptimeo);
if (slpflag == PCATCH) {
slpflag = 0;
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_SNDLOCK;
+ *statep |= NFSSTA_SNDLOCK;
return (0);
}
@@ -1477,15 +1483,16 @@ nfs_sndlock(flagp, rep)
* Unlock the stream socket for others.
*/
void
-nfs_sndunlock(flagp)
+nfs_sndunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_SNDLOCK) == 0)
+ if ((*statep & NFSSTA_SNDLOCK) == 0)
panic("nfs sndunlock");
- *flagp &= ~NFSMNT_SNDLOCK;
- if (*flagp & NFSMNT_WANTSND) {
- *flagp &= ~NFSMNT_WANTSND;
+ *statep &= ~NFSSTA_SNDLOCK;
+ if (*statep & NFSSTA_WANTSND) {
+ *statep &= ~NFSSTA_WANTSND;
wakeup((caddr_t)flagp);
}
}
@@ -1495,16 +1502,17 @@ nfs_rcvlock(rep)
register struct nfsreq *rep;
{
register int *flagp = &rep->r_nmp->nm_flag;
+ register int *statep = &rep->r_nmp->nm_state;
int slpflag, slptimeo = 0;
if (*flagp & NFSMNT_INT)
slpflag = PCATCH;
else
slpflag = 0;
- while (*flagp & NFSMNT_RCVLOCK) {
+ while (*statep & NFSSTA_RCVLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp))
return (EINTR);
- *flagp |= NFSMNT_WANTRCV;
+ *statep |= NFSSTA_WANTRCV;
(void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk",
slptimeo);
/*
@@ -1520,7 +1528,7 @@ nfs_rcvlock(rep)
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_RCVLOCK;
+ *statep |= NFSSTA_RCVLOCK;
return (0);
}
@@ -1528,15 +1536,16 @@ nfs_rcvlock(rep)
* Unlock the stream socket for others.
*/
static void
-nfs_rcvunlock(flagp)
+nfs_rcvunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_RCVLOCK) == 0)
+ if ((*statep & NFSSTA_RCVLOCK) == 0)
panic("nfs rcvunlock");
- *flagp &= ~NFSMNT_RCVLOCK;
- if (*flagp & NFSMNT_WANTRCV) {
- *flagp &= ~NFSMNT_WANTRCV;
+ *statep &= ~NFSSTA_RCVLOCK;
+ if (*statep & NFSSTA_WANTRCV) {
+ *statep &= ~NFSSTA_WANTRCV;
wakeup((caddr_t)flagp);
}
}
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index f9eabdd..b81eedf 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
- * $Id: nfs_subs.c,v 1.52 1998/03/30 09:54:12 phk Exp $
+ * $Id: nfs_subs.c,v 1.53 1998/04/06 11:41:07 phk Exp $
*/
/*
@@ -1363,6 +1363,12 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
return (0);
}
+#ifdef NFS_ACDEBUG
+#include <sys/sysctl.h>
+static int nfs_acdebug;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
+#endif
+
/*
* Check the time stamp
* If the cache is valid, copy contents to *vap and return 0
@@ -1373,15 +1379,50 @@ nfs_getattrcache(vp, vaper)
register struct vnode *vp;
struct vattr *vaper;
{
- register struct nfsnode *np = VTONFS(vp);
+ register struct nfsnode *np;
register struct vattr *vap;
+ struct nfsmount *nmp;
+ int timeo;
- if ((time_second - np->n_attrstamp) >= NFS_ATTRTIMEO(np)) {
+ np = VTONFS(vp);
+ vap = &np->n_vattr;
+ nmp = VFSTONFS(vp->v_mount);
+ /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
+ timeo = (time_second - np->n_mtime) / 10;
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug>1)
+ printf("nfs_getattrcache: initial timeo = %d\n", timeo);
+#endif
+
+ if (vap->va_type == VDIR) {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
+ timeo = nmp->nm_acdirmin;
+ else if (timeo > nmp->nm_acdirmax)
+ timeo = nmp->nm_acdirmax;
+ } else {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
+ timeo = nmp->nm_acregmin;
+ else if (timeo > nmp->nm_acregmax)
+ timeo = nmp->nm_acregmax;
+ }
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug > 2)
+ printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
+ nmp->nm_acregmin, nmp->nm_acregmax,
+ nmp->nm_acdirmin, nmp->nm_acdirmax);
+
+ if (nfs_acdebug)
+ printf("nfs_getattrcache: age = %d; final timeo = %d\n",r
+ (time_second - np->n_attrstamp), timeo);
+#endif
+
+ if ((time_second - np->n_attrstamp) >= timeo) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
nfsstats.attrcache_hits++;
- vap = &np->n_vattr;
if (vap->va_size != np->n_size) {
if (vap->va_type == VREG) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index c2f9071..317b1c0 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_syscalls.c,v 1.36 1998/02/09 06:10:37 eivind Exp $
+ * $Id: nfs_syscalls.c,v 1.37 1998/03/30 09:54:17 phk Exp $
*/
#include <sys/param.h>
@@ -223,10 +223,10 @@ nfssvc(p, uap)
vput(nd.ni_vp);
if (error)
return (error);
- if ((nmp->nm_flag & NFSMNT_MNTD) &&
+ if ((nmp->nm_state & NFSSTA_MNTD) &&
(uap->flag & NFSSVC_GOTAUTH) == 0)
return (0);
- nmp->nm_flag |= NFSMNT_MNTD;
+ nmp->nm_state |= NFSSTA_MNTD;
error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag,
uap->argp, p);
} else if (uap->flag & NFSSVC_ADDSOCK) {
@@ -514,10 +514,12 @@ nfssvc_nfsd(nsd, argp, p)
else if (slp->ns_flag & SLP_NEEDQ) {
slp->ns_flag &= ~SLP_NEEDQ;
(void) nfs_sndlock(&slp->ns_solock,
+ &slp->ns_solock,
(struct nfsreq *)0);
nfsrv_rcv(slp->ns_so, (caddr_t)slp,
M_WAIT);
- nfs_sndunlock(&slp->ns_solock);
+ nfs_sndunlock(&slp->ns_solock,
+ &slp->ns_solock);
}
error = nfsrv_dorec(slp, nfsd, &nd);
cur_usec = nfs_curusec();
@@ -677,7 +679,8 @@ nfssvc_nfsd(nsd, argp, p)
*mtod(m, u_long *) = htonl(0x80000000 | siz);
}
if (solockp)
- (void) nfs_sndlock(solockp, (struct nfsreq *)0);
+ (void) nfs_sndlock(solockp, solockp,
+ (struct nfsreq *)0);
if (slp->ns_flag & SLP_VALID)
error = nfs_send(so, nd->nd_nam2, m, NULL);
else {
@@ -693,7 +696,7 @@ nfssvc_nfsd(nsd, argp, p)
if (error == EPIPE)
nfsrv_zapsock(slp);
if (solockp)
- nfs_sndunlock(solockp);
+ nfs_sndunlock(solockp, solockp);
if (error == EINTR || error == ERESTART) {
free((caddr_t)nd, M_NFSRVDESC);
nfsrv_slpderef(slp);
@@ -899,17 +902,17 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
{
int error = 0;
- while ((nmp->nm_flag & NFSMNT_WAITAUTH) == 0) {
- nmp->nm_flag |= NFSMNT_WANTAUTH;
+ while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) {
+ nmp->nm_state |= NFSSTA_WANTAUTH;
(void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
"nfsauth1", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
if (error) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
return (error);
}
}
- nmp->nm_flag &= ~(NFSMNT_WAITAUTH | NFSMNT_WANTAUTH);
+ nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH);
nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
nmp->nm_authlen = RPCAUTH_MAXSIZ;
nmp->nm_verfstr = verf_str;
@@ -920,13 +923,13 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
/*
* And wait for mount_nfs to do its stuff.
*/
- while ((nmp->nm_flag & NFSMNT_HASAUTH) == 0 && error == 0) {
+ while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) {
(void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
"nfsauth2", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
}
- if (nmp->nm_flag & NFSMNT_AUTHERR) {
- nmp->nm_flag &= ~NFSMNT_AUTHERR;
+ if (nmp->nm_state & NFSSTA_AUTHERR) {
+ nmp->nm_state &= ~NFSSTA_AUTHERR;
error = EAUTH;
}
if (error)
@@ -936,10 +939,10 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
*verf_len = nmp->nm_verflen;
bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (key));
}
- nmp->nm_flag &= ~NFSMNT_HASAUTH;
- nmp->nm_flag |= NFSMNT_WAITAUTH;
- if (nmp->nm_flag & NFSMNT_WANTAUTH) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_HASAUTH;
+ nmp->nm_state |= NFSSTA_WAITAUTH;
+ if (nmp->nm_state & NFSSTA_WANTAUTH) {
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
wakeup((caddr_t)&nmp->nm_authtype);
}
return (error);
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index e108dcf..eb577d2 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
- * $Id: nfs_vfsops.c,v 1.57 1998/03/30 09:54:23 phk Exp $
+ * $Id: nfs_vfsops.c,v 1.58 1998/05/06 05:29:38 msmith Exp $
*/
#include <sys/param.h>
@@ -166,7 +166,8 @@ static void nfs_convert_diskless __P((void));
static void nfs_convert_oargs __P((struct nfs_args *args,
struct onfs_args *oargs));
-static int nfs_iosize(nmp)
+static int
+nfs_iosize(nmp)
struct nfsmount* nmp;
{
int iosize;
@@ -182,58 +183,57 @@ static int nfs_iosize(nmp)
return iosize;
}
-static void nfs_convert_oargs(args,oargs)
- struct nfs_args *args;
- struct onfs_args *oargs;
+static void
+nfs_convert_oargs(args, oargs)
+ struct nfs_args *args;
+ struct onfs_args *oargs;
{
- args->version = NFS_ARGSVERSION;
- args->addr = oargs->addr;
- args->addrlen = oargs->addrlen;
- args->sotype = oargs->sotype;
- args->proto = oargs->proto;
- args->fh = oargs->fh;
- args->fhsize = oargs->fhsize;
- args->flags = oargs->flags;
- args->wsize = oargs->wsize;
- args->rsize = oargs->rsize;
- args->readdirsize = oargs->readdirsize;
- args->timeo = oargs->timeo;
- args->retrans = oargs->retrans;
- args->maxgrouplist = oargs->maxgrouplist;
- args->readahead = oargs->readahead;
- args->leaseterm = oargs->leaseterm;
- args->deadthresh = oargs->deadthresh;
- args->hostname = oargs->hostname;
+ args->version = NFS_ARGSVERSION;
+ args->addr = oargs->addr;
+ args->addrlen = oargs->addrlen;
+ args->sotype = oargs->sotype;
+ args->proto = oargs->proto;
+ args->fh = oargs->fh;
+ args->fhsize = oargs->fhsize;
+ args->flags = oargs->flags;
+ args->wsize = oargs->wsize;
+ args->rsize = oargs->rsize;
+ args->readdirsize = oargs->readdirsize;
+ args->timeo = oargs->timeo;
+ args->retrans = oargs->retrans;
+ args->maxgrouplist = oargs->maxgrouplist;
+ args->readahead = oargs->readahead;
+ args->leaseterm = oargs->leaseterm;
+ args->deadthresh = oargs->deadthresh;
+ args->hostname = oargs->hostname;
}
static void
nfs_convert_diskless()
{
- bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
- sizeof(struct ifaliasreq));
- bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway,
- sizeof(struct sockaddr_in));
- nfs_convert_oargs(&nfsv3_diskless.swap_args,&nfs_diskless.swap_args);
- nfsv3_diskless.swap_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam,
- MNAMELEN);
- nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
- bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
- sizeof(struct ucred));
- nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args);
- nfsv3_diskless.root_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam,
- MNAMELEN);
- nfsv3_diskless.root_time = nfs_diskless.root_time;
- bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
- MAXHOSTNAMELEN);
- nfs_diskless_valid = 3;
+ bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
+ sizeof(struct ifaliasreq));
+ bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway,
+ sizeof(struct sockaddr_in));
+ nfs_convert_oargs(&nfsv3_diskless.swap_args,&nfs_diskless.swap_args);
+ nfsv3_diskless.swap_fhsize = NFSX_V2FH;
+ bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
+ bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
+ sizeof(struct sockaddr_in));
+ bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam, MNAMELEN);
+ nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
+ bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
+ sizeof(struct ucred));
+ nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args);
+ nfsv3_diskless.root_fhsize = NFSX_V2FH;
+ bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
+ bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
+ sizeof(struct sockaddr_in));
+ bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam, MNAMELEN);
+ nfsv3_diskless.root_time = nfs_diskless.root_time;
+ bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
+ MAXHOSTNAMELEN);
+ nfs_diskless_valid = 3;
}
/*
@@ -267,7 +267,7 @@ nfs_statfs(mp, sbp, p)
vp = NFSTOV(np);
cred = crget();
cred->cr_ngroups = 1;
- if (v3 && (nmp->nm_flag & NFSMNT_GOTFSINFO) == 0)
+ if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
nfsstats.rpccnt[NFSPROC_FSSTAT]++;
nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3));
@@ -364,7 +364,7 @@ nfs_fsinfo(nmp, vp, cred, p)
if (max < nmp->nm_readdirsize) {
nmp->nm_readdirsize = max;
}
- nmp->nm_flag |= NFSMNT_GOTFSINFO;
+ nmp->nm_state |= NFSSTA_GOTFSINFO;
}
nfsm_reqdone;
return (error);
@@ -766,6 +766,27 @@ mountnfs(argp, mp, nam, pth, hst, vpp)
if (nmp->nm_readdirsize > nmp->nm_rsize)
nmp->nm_readdirsize = nmp->nm_rsize;
+ if ((argp->flags & NFSMNT_ACREGMIN) && argp->acregmin >= 0)
+ nmp->nm_acregmin = argp->acregmin;
+ else
+ nmp->nm_acregmin = NFS_MINATTRTIMO;
+ if ((argp->flags & NFSMNT_ACREGMAX) && argp->acregmax >= 0)
+ nmp->nm_acregmax = argp->acregmax;
+ else
+ nmp->nm_acregmax = NFS_MAXATTRTIMO;
+ if ((argp->flags & NFSMNT_ACDIRMIN) && argp->acdirmin >= 0)
+ nmp->nm_acdirmin = argp->acdirmin;
+ else
+ nmp->nm_acdirmin = NFS_MINDIRATTRTIMO;
+ if ((argp->flags & NFSMNT_ACDIRMAX) && argp->acdirmax >= 0)
+ nmp->nm_acdirmax = argp->acdirmax;
+ else
+ nmp->nm_acdirmax = NFS_MAXDIRATTRTIMO;
+ if (nmp->nm_acdirmin > nmp->nm_acdirmax)
+ nmp->nm_acdirmin = nmp->nm_acdirmax;
+ if (nmp->nm_acregmin > nmp->nm_acregmax)
+ nmp->nm_acregmin = nmp->nm_acregmax;
+
if ((argp->flags & NFSMNT_MAXGRPS) && argp->maxgrouplist >= 0 &&
argp->maxgrouplist <= NFS_MAXGRPS)
nmp->nm_numgrps = argp->maxgrouplist;
@@ -872,13 +893,13 @@ nfs_unmount(mp, mntflags, p)
/*
* Must handshake with nqnfs_clientd() if it is active.
*/
- nmp->nm_flag |= NFSMNT_DISMINPROG;
+ nmp->nm_state |= NFSSTA_DISMINPROG;
while (nmp->nm_inprog != NULLVP)
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfsdism", 0);
error = vflush(mp, vp, flags);
if (error) {
vput(vp);
- nmp->nm_flag &= ~NFSMNT_DISMINPROG;
+ nmp->nm_state &= ~NFSSTA_DISMINPROG;
return (error);
}
@@ -887,7 +908,7 @@ nfs_unmount(mp, mntflags, p)
* For NQNFS, let the server daemon free the nfsmount structure.
*/
if (nmp->nm_flag & (NFSMNT_NQNFS | NFSMNT_KERB))
- nmp->nm_flag |= NFSMNT_DISMNT;
+ nmp->nm_state |= NFSSTA_DISMNT;
/*
* There are two reference counts and one lock to get rid of here.
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index c8d99a9..246757f 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
- * $Id: nfs_vnops.c,v 1.87 1998/05/16 16:03:10 bde Exp $
+ * $Id: nfs_vnops.c,v 1.88 1998/05/16 16:20:50 bde Exp $
*/
@@ -1146,10 +1146,11 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit)
else if (committed == NFSV3WRITE_DATASYNC &&
commit == NFSV3WRITE_UNSTABLE)
committed = commit;
- if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0) {
+ if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0)
+ {
bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf,
NFSX_V3WRITEVERF);
- nmp->nm_flag |= NFSMNT_HASWRITEVERF;
+ nmp->nm_state |= NFSSTA_HASWRITEVERF;
} else if (bcmp((caddr_t)tl,
(caddr_t)nmp->nm_verf, NFSX_V3WRITEVERF)) {
*must_commit = 1;
@@ -2531,7 +2532,7 @@ nfs_commit(vp, offset, cnt, cred, procp)
int error = 0, wccflag = NFSV3_WCCRATTR;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0)
+ if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0)
return (0);
nfsstats.rpccnt[NFSPROC_COMMIT]++;
nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1));
diff --git a/sys/nfs/nfsmount.h b/sys/nfs/nfsmount.h
index 63de0ad..2d502bd 100644
--- a/sys/nfs/nfsmount.h
+++ b/sys/nfs/nfsmount.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfsmount.h 8.3 (Berkeley) 3/30/95
- * $Id: nfsmount.h,v 1.12 1997/05/10 16:12:03 dfr Exp $
+ * $Id: nfsmount.h,v 1.13 1997/08/16 19:16:05 wollman Exp $
*/
@@ -48,6 +48,7 @@
*/
struct nfsmount {
int nm_flag; /* Flags for soft/hard... */
+ int nm_state; /* Internal state flags */
struct mount *nm_mountp; /* Vfs structure for this filesystem */
int nm_numgrps; /* Max. size of groupslist */
u_char nm_fh[NFSX_V3FHMAX]; /* File handle of root dir */
@@ -70,6 +71,10 @@ struct nfsmount {
int nm_readdirsize; /* Size of a readdir rpc */
int nm_readahead; /* Num. of blocks to readahead */
int nm_leaseterm; /* Term (sec) for NQNFS lease */
+ int nm_acdirmin; /* Directory attr cache min lifetime */
+ int nm_acdirmax; /* Directory attr cache max lifetime */
+ int nm_acregmin; /* Reg file attr cache min lifetime */
+ int nm_acregmax; /* Reg file attr cache max lifetime */
CIRCLEQ_HEAD(, nfsnode) nm_timerhead; /* Head of lease timer queue */
struct vnode *nm_inprog; /* Vnode in prog by nqnfs_clientd() */
uid_t nm_authuid; /* Uid for authenticator */
diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h
index 8b28c00..ad606ad 100644
--- a/sys/nfsclient/nfs.h
+++ b/sys/nfsclient/nfs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c
index 46020e5..544ba32 100644
--- a/sys/nfsclient/nfs_bio.c
+++ b/sys/nfsclient/nfs_bio.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95
- * $Id: nfs_bio.c,v 1.53 1998/03/08 09:57:54 julian Exp $
+ * $Id: nfs_bio.c,v 1.54 1998/03/28 16:05:05 steve Exp $
*/
@@ -257,7 +257,8 @@ nfs_bioread(vp, uio, ioflag, cred, getpages)
if (uio->uio_offset < 0)
return (EINVAL);
p = uio->uio_procp;
- if ((nmp->nm_flag & (NFSMNT_NFSV3 | NFSMNT_GOTFSINFO)) == NFSMNT_NFSV3)
+ if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
+ (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
biosize = vp->v_mount->mnt_stat.f_iosize;
/*
@@ -636,7 +637,8 @@ nfs_write(ap)
np->n_flag &= ~NWRITEERR;
return (np->n_error);
}
- if ((nmp->nm_flag & (NFSMNT_NFSV3 | NFSMNT_GOTFSINFO)) == NFSMNT_NFSV3)
+ if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
+ (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
if (ioflag & (IO_APPEND | IO_SYNC)) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c
index c2f9071..317b1c0 100644
--- a/sys/nfsclient/nfs_nfsiod.c
+++ b/sys/nfsclient/nfs_nfsiod.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_syscalls.c,v 1.36 1998/02/09 06:10:37 eivind Exp $
+ * $Id: nfs_syscalls.c,v 1.37 1998/03/30 09:54:17 phk Exp $
*/
#include <sys/param.h>
@@ -223,10 +223,10 @@ nfssvc(p, uap)
vput(nd.ni_vp);
if (error)
return (error);
- if ((nmp->nm_flag & NFSMNT_MNTD) &&
+ if ((nmp->nm_state & NFSSTA_MNTD) &&
(uap->flag & NFSSVC_GOTAUTH) == 0)
return (0);
- nmp->nm_flag |= NFSMNT_MNTD;
+ nmp->nm_state |= NFSSTA_MNTD;
error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag,
uap->argp, p);
} else if (uap->flag & NFSSVC_ADDSOCK) {
@@ -514,10 +514,12 @@ nfssvc_nfsd(nsd, argp, p)
else if (slp->ns_flag & SLP_NEEDQ) {
slp->ns_flag &= ~SLP_NEEDQ;
(void) nfs_sndlock(&slp->ns_solock,
+ &slp->ns_solock,
(struct nfsreq *)0);
nfsrv_rcv(slp->ns_so, (caddr_t)slp,
M_WAIT);
- nfs_sndunlock(&slp->ns_solock);
+ nfs_sndunlock(&slp->ns_solock,
+ &slp->ns_solock);
}
error = nfsrv_dorec(slp, nfsd, &nd);
cur_usec = nfs_curusec();
@@ -677,7 +679,8 @@ nfssvc_nfsd(nsd, argp, p)
*mtod(m, u_long *) = htonl(0x80000000 | siz);
}
if (solockp)
- (void) nfs_sndlock(solockp, (struct nfsreq *)0);
+ (void) nfs_sndlock(solockp, solockp,
+ (struct nfsreq *)0);
if (slp->ns_flag & SLP_VALID)
error = nfs_send(so, nd->nd_nam2, m, NULL);
else {
@@ -693,7 +696,7 @@ nfssvc_nfsd(nsd, argp, p)
if (error == EPIPE)
nfsrv_zapsock(slp);
if (solockp)
- nfs_sndunlock(solockp);
+ nfs_sndunlock(solockp, solockp);
if (error == EINTR || error == ERESTART) {
free((caddr_t)nd, M_NFSRVDESC);
nfsrv_slpderef(slp);
@@ -899,17 +902,17 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
{
int error = 0;
- while ((nmp->nm_flag & NFSMNT_WAITAUTH) == 0) {
- nmp->nm_flag |= NFSMNT_WANTAUTH;
+ while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) {
+ nmp->nm_state |= NFSSTA_WANTAUTH;
(void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
"nfsauth1", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
if (error) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
return (error);
}
}
- nmp->nm_flag &= ~(NFSMNT_WAITAUTH | NFSMNT_WANTAUTH);
+ nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH);
nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
nmp->nm_authlen = RPCAUTH_MAXSIZ;
nmp->nm_verfstr = verf_str;
@@ -920,13 +923,13 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
/*
* And wait for mount_nfs to do its stuff.
*/
- while ((nmp->nm_flag & NFSMNT_HASAUTH) == 0 && error == 0) {
+ while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) {
(void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
"nfsauth2", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
}
- if (nmp->nm_flag & NFSMNT_AUTHERR) {
- nmp->nm_flag &= ~NFSMNT_AUTHERR;
+ if (nmp->nm_state & NFSSTA_AUTHERR) {
+ nmp->nm_state &= ~NFSSTA_AUTHERR;
error = EAUTH;
}
if (error)
@@ -936,10 +939,10 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
*verf_len = nmp->nm_verflen;
bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (key));
}
- nmp->nm_flag &= ~NFSMNT_HASAUTH;
- nmp->nm_flag |= NFSMNT_WAITAUTH;
- if (nmp->nm_flag & NFSMNT_WANTAUTH) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_HASAUTH;
+ nmp->nm_state |= NFSSTA_WAITAUTH;
+ if (nmp->nm_state & NFSSTA_WANTAUTH) {
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
wakeup((caddr_t)&nmp->nm_authtype);
}
return (error);
diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c
index 5c084b7..3fe0cec 100644
--- a/sys/nfsclient/nfs_socket.c
+++ b/sys/nfsclient/nfs_socket.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_socket.c,v 1.30 1997/10/28 15:59:07 bde Exp $
+ * $Id: nfs_socket.c,v 1.31 1998/03/30 09:54:04 phk Exp $
*/
/*
@@ -136,7 +136,7 @@ struct nfsrtt nfsrtt;
static int nfs_msg __P((struct proc *,char *,char *));
static int nfs_rcvlock __P((struct nfsreq *));
-static void nfs_rcvunlock __P((int *flagp));
+static void nfs_rcvunlock __P((int *flagp, int *statep));
static void nfs_realign __P((struct mbuf *m, int hsiz));
static int nfs_receive __P((struct nfsreq *rep, struct sockaddr **aname,
struct mbuf **mp));
@@ -483,7 +483,8 @@ nfs_receive(rep, aname, mp)
* until we have an entire rpc request/reply.
*/
if (sotype != SOCK_DGRAM) {
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state,
+ rep);
if (error)
return (error);
tryagain:
@@ -497,14 +498,16 @@ tryagain:
* mount point.
*/
if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (EINTR);
}
so = rep->r_nmp->nm_so;
if (!so) {
error = nfs_reconnect(rep);
if (error) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
@@ -516,13 +519,14 @@ tryagain:
if (error) {
if (error == EINTR || error == ERESTART ||
(error = nfs_reconnect(rep))) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
}
}
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state);
if (sotype == SOCK_STREAM) {
aio.iov_base = (caddr_t) &len;
aio.iov_len = sizeof(u_long);
@@ -621,7 +625,8 @@ errout:
"receive error %d from nfs server %s\n",
error,
rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state, rep);
if (!error)
error = nfs_reconnect(rep);
if (!error)
@@ -704,7 +709,7 @@ nfs_reply(myrep)
* Get the next Rpc reply off the socket
*/
error = nfs_receive(myrep, &nam, &mrep);
- nfs_rcvunlock(&nmp->nm_flag);
+ nfs_rcvunlock(&nmp->nm_flag, &nmp->nm_state);
if (error) {
/*
@@ -964,12 +969,12 @@ tryagain:
nmp->nm_sent < nmp->nm_cwnd)) {
splx(s);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- error = nfs_sndlock(&nmp->nm_flag, rep);
+ error = nfs_sndlock(&nmp->nm_flag, &nmp->nm_state, rep);
if (!error) {
m = m_copym(m, 0, M_COPYALL, M_WAIT);
error = nfs_send(nmp->nm_so, nmp->nm_nam, m, rep);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(&nmp->nm_flag);
+ nfs_sndunlock(&nmp->nm_flag, &nmp->nm_state);
}
if (!error && (rep->r_flags & R_MUSTRESEND) == 0) {
nmp->nm_sent += NFS_CWNDSCALE;
@@ -1445,8 +1450,9 @@ nfs_sigintr(nmp, rep, p)
* in progress when a reconnect is necessary.
*/
int
-nfs_sndlock(flagp, rep)
+nfs_sndlock(flagp, statep, rep)
register int *flagp;
+ register int *statep;
struct nfsreq *rep;
{
struct proc *p;
@@ -1458,18 +1464,18 @@ nfs_sndlock(flagp, rep)
slpflag = PCATCH;
} else
p = (struct proc *)0;
- while (*flagp & NFSMNT_SNDLOCK) {
+ while (*statep & NFSSTA_SNDLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, p))
return (EINTR);
- *flagp |= NFSMNT_WANTSND;
- (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsndlck",
- slptimeo);
+ *statep |= NFSSTA_WANTSND;
+ (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1),
+ "nfsndlck", slptimeo);
if (slpflag == PCATCH) {
slpflag = 0;
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_SNDLOCK;
+ *statep |= NFSSTA_SNDLOCK;
return (0);
}
@@ -1477,15 +1483,16 @@ nfs_sndlock(flagp, rep)
* Unlock the stream socket for others.
*/
void
-nfs_sndunlock(flagp)
+nfs_sndunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_SNDLOCK) == 0)
+ if ((*statep & NFSSTA_SNDLOCK) == 0)
panic("nfs sndunlock");
- *flagp &= ~NFSMNT_SNDLOCK;
- if (*flagp & NFSMNT_WANTSND) {
- *flagp &= ~NFSMNT_WANTSND;
+ *statep &= ~NFSSTA_SNDLOCK;
+ if (*statep & NFSSTA_WANTSND) {
+ *statep &= ~NFSSTA_WANTSND;
wakeup((caddr_t)flagp);
}
}
@@ -1495,16 +1502,17 @@ nfs_rcvlock(rep)
register struct nfsreq *rep;
{
register int *flagp = &rep->r_nmp->nm_flag;
+ register int *statep = &rep->r_nmp->nm_state;
int slpflag, slptimeo = 0;
if (*flagp & NFSMNT_INT)
slpflag = PCATCH;
else
slpflag = 0;
- while (*flagp & NFSMNT_RCVLOCK) {
+ while (*statep & NFSSTA_RCVLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp))
return (EINTR);
- *flagp |= NFSMNT_WANTRCV;
+ *statep |= NFSSTA_WANTRCV;
(void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk",
slptimeo);
/*
@@ -1520,7 +1528,7 @@ nfs_rcvlock(rep)
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_RCVLOCK;
+ *statep |= NFSSTA_RCVLOCK;
return (0);
}
@@ -1528,15 +1536,16 @@ nfs_rcvlock(rep)
* Unlock the stream socket for others.
*/
static void
-nfs_rcvunlock(flagp)
+nfs_rcvunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_RCVLOCK) == 0)
+ if ((*statep & NFSSTA_RCVLOCK) == 0)
panic("nfs rcvunlock");
- *flagp &= ~NFSMNT_RCVLOCK;
- if (*flagp & NFSMNT_WANTRCV) {
- *flagp &= ~NFSMNT_WANTRCV;
+ *statep &= ~NFSSTA_RCVLOCK;
+ if (*statep & NFSSTA_WANTRCV) {
+ *statep &= ~NFSSTA_WANTRCV;
wakeup((caddr_t)flagp);
}
}
diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c
index f9eabdd..b81eedf 100644
--- a/sys/nfsclient/nfs_subs.c
+++ b/sys/nfsclient/nfs_subs.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
- * $Id: nfs_subs.c,v 1.52 1998/03/30 09:54:12 phk Exp $
+ * $Id: nfs_subs.c,v 1.53 1998/04/06 11:41:07 phk Exp $
*/
/*
@@ -1363,6 +1363,12 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
return (0);
}
+#ifdef NFS_ACDEBUG
+#include <sys/sysctl.h>
+static int nfs_acdebug;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
+#endif
+
/*
* Check the time stamp
* If the cache is valid, copy contents to *vap and return 0
@@ -1373,15 +1379,50 @@ nfs_getattrcache(vp, vaper)
register struct vnode *vp;
struct vattr *vaper;
{
- register struct nfsnode *np = VTONFS(vp);
+ register struct nfsnode *np;
register struct vattr *vap;
+ struct nfsmount *nmp;
+ int timeo;
- if ((time_second - np->n_attrstamp) >= NFS_ATTRTIMEO(np)) {
+ np = VTONFS(vp);
+ vap = &np->n_vattr;
+ nmp = VFSTONFS(vp->v_mount);
+ /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
+ timeo = (time_second - np->n_mtime) / 10;
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug>1)
+ printf("nfs_getattrcache: initial timeo = %d\n", timeo);
+#endif
+
+ if (vap->va_type == VDIR) {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
+ timeo = nmp->nm_acdirmin;
+ else if (timeo > nmp->nm_acdirmax)
+ timeo = nmp->nm_acdirmax;
+ } else {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
+ timeo = nmp->nm_acregmin;
+ else if (timeo > nmp->nm_acregmax)
+ timeo = nmp->nm_acregmax;
+ }
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug > 2)
+ printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
+ nmp->nm_acregmin, nmp->nm_acregmax,
+ nmp->nm_acdirmin, nmp->nm_acdirmax);
+
+ if (nfs_acdebug)
+ printf("nfs_getattrcache: age = %d; final timeo = %d\n",r
+ (time_second - np->n_attrstamp), timeo);
+#endif
+
+ if ((time_second - np->n_attrstamp) >= timeo) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
nfsstats.attrcache_hits++;
- vap = &np->n_vattr;
if (vap->va_size != np->n_size) {
if (vap->va_type == VREG) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index e108dcf..eb577d2 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
- * $Id: nfs_vfsops.c,v 1.57 1998/03/30 09:54:23 phk Exp $
+ * $Id: nfs_vfsops.c,v 1.58 1998/05/06 05:29:38 msmith Exp $
*/
#include <sys/param.h>
@@ -166,7 +166,8 @@ static void nfs_convert_diskless __P((void));
static void nfs_convert_oargs __P((struct nfs_args *args,
struct onfs_args *oargs));
-static int nfs_iosize(nmp)
+static int
+nfs_iosize(nmp)
struct nfsmount* nmp;
{
int iosize;
@@ -182,58 +183,57 @@ static int nfs_iosize(nmp)
return iosize;
}
-static void nfs_convert_oargs(args,oargs)
- struct nfs_args *args;
- struct onfs_args *oargs;
+static void
+nfs_convert_oargs(args, oargs)
+ struct nfs_args *args;
+ struct onfs_args *oargs;
{
- args->version = NFS_ARGSVERSION;
- args->addr = oargs->addr;
- args->addrlen = oargs->addrlen;
- args->sotype = oargs->sotype;
- args->proto = oargs->proto;
- args->fh = oargs->fh;
- args->fhsize = oargs->fhsize;
- args->flags = oargs->flags;
- args->wsize = oargs->wsize;
- args->rsize = oargs->rsize;
- args->readdirsize = oargs->readdirsize;
- args->timeo = oargs->timeo;
- args->retrans = oargs->retrans;
- args->maxgrouplist = oargs->maxgrouplist;
- args->readahead = oargs->readahead;
- args->leaseterm = oargs->leaseterm;
- args->deadthresh = oargs->deadthresh;
- args->hostname = oargs->hostname;
+ args->version = NFS_ARGSVERSION;
+ args->addr = oargs->addr;
+ args->addrlen = oargs->addrlen;
+ args->sotype = oargs->sotype;
+ args->proto = oargs->proto;
+ args->fh = oargs->fh;
+ args->fhsize = oargs->fhsize;
+ args->flags = oargs->flags;
+ args->wsize = oargs->wsize;
+ args->rsize = oargs->rsize;
+ args->readdirsize = oargs->readdirsize;
+ args->timeo = oargs->timeo;
+ args->retrans = oargs->retrans;
+ args->maxgrouplist = oargs->maxgrouplist;
+ args->readahead = oargs->readahead;
+ args->leaseterm = oargs->leaseterm;
+ args->deadthresh = oargs->deadthresh;
+ args->hostname = oargs->hostname;
}
static void
nfs_convert_diskless()
{
- bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
- sizeof(struct ifaliasreq));
- bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway,
- sizeof(struct sockaddr_in));
- nfs_convert_oargs(&nfsv3_diskless.swap_args,&nfs_diskless.swap_args);
- nfsv3_diskless.swap_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam,
- MNAMELEN);
- nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
- bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
- sizeof(struct ucred));
- nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args);
- nfsv3_diskless.root_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam,
- MNAMELEN);
- nfsv3_diskless.root_time = nfs_diskless.root_time;
- bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
- MAXHOSTNAMELEN);
- nfs_diskless_valid = 3;
+ bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
+ sizeof(struct ifaliasreq));
+ bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway,
+ sizeof(struct sockaddr_in));
+ nfs_convert_oargs(&nfsv3_diskless.swap_args,&nfs_diskless.swap_args);
+ nfsv3_diskless.swap_fhsize = NFSX_V2FH;
+ bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
+ bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
+ sizeof(struct sockaddr_in));
+ bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam, MNAMELEN);
+ nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
+ bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
+ sizeof(struct ucred));
+ nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args);
+ nfsv3_diskless.root_fhsize = NFSX_V2FH;
+ bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
+ bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
+ sizeof(struct sockaddr_in));
+ bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam, MNAMELEN);
+ nfsv3_diskless.root_time = nfs_diskless.root_time;
+ bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
+ MAXHOSTNAMELEN);
+ nfs_diskless_valid = 3;
}
/*
@@ -267,7 +267,7 @@ nfs_statfs(mp, sbp, p)
vp = NFSTOV(np);
cred = crget();
cred->cr_ngroups = 1;
- if (v3 && (nmp->nm_flag & NFSMNT_GOTFSINFO) == 0)
+ if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
(void)nfs_fsinfo(nmp, vp, cred, p);
nfsstats.rpccnt[NFSPROC_FSSTAT]++;
nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3));
@@ -364,7 +364,7 @@ nfs_fsinfo(nmp, vp, cred, p)
if (max < nmp->nm_readdirsize) {
nmp->nm_readdirsize = max;
}
- nmp->nm_flag |= NFSMNT_GOTFSINFO;
+ nmp->nm_state |= NFSSTA_GOTFSINFO;
}
nfsm_reqdone;
return (error);
@@ -766,6 +766,27 @@ mountnfs(argp, mp, nam, pth, hst, vpp)
if (nmp->nm_readdirsize > nmp->nm_rsize)
nmp->nm_readdirsize = nmp->nm_rsize;
+ if ((argp->flags & NFSMNT_ACREGMIN) && argp->acregmin >= 0)
+ nmp->nm_acregmin = argp->acregmin;
+ else
+ nmp->nm_acregmin = NFS_MINATTRTIMO;
+ if ((argp->flags & NFSMNT_ACREGMAX) && argp->acregmax >= 0)
+ nmp->nm_acregmax = argp->acregmax;
+ else
+ nmp->nm_acregmax = NFS_MAXATTRTIMO;
+ if ((argp->flags & NFSMNT_ACDIRMIN) && argp->acdirmin >= 0)
+ nmp->nm_acdirmin = argp->acdirmin;
+ else
+ nmp->nm_acdirmin = NFS_MINDIRATTRTIMO;
+ if ((argp->flags & NFSMNT_ACDIRMAX) && argp->acdirmax >= 0)
+ nmp->nm_acdirmax = argp->acdirmax;
+ else
+ nmp->nm_acdirmax = NFS_MAXDIRATTRTIMO;
+ if (nmp->nm_acdirmin > nmp->nm_acdirmax)
+ nmp->nm_acdirmin = nmp->nm_acdirmax;
+ if (nmp->nm_acregmin > nmp->nm_acregmax)
+ nmp->nm_acregmin = nmp->nm_acregmax;
+
if ((argp->flags & NFSMNT_MAXGRPS) && argp->maxgrouplist >= 0 &&
argp->maxgrouplist <= NFS_MAXGRPS)
nmp->nm_numgrps = argp->maxgrouplist;
@@ -872,13 +893,13 @@ nfs_unmount(mp, mntflags, p)
/*
* Must handshake with nqnfs_clientd() if it is active.
*/
- nmp->nm_flag |= NFSMNT_DISMINPROG;
+ nmp->nm_state |= NFSSTA_DISMINPROG;
while (nmp->nm_inprog != NULLVP)
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfsdism", 0);
error = vflush(mp, vp, flags);
if (error) {
vput(vp);
- nmp->nm_flag &= ~NFSMNT_DISMINPROG;
+ nmp->nm_state &= ~NFSSTA_DISMINPROG;
return (error);
}
@@ -887,7 +908,7 @@ nfs_unmount(mp, mntflags, p)
* For NQNFS, let the server daemon free the nfsmount structure.
*/
if (nmp->nm_flag & (NFSMNT_NQNFS | NFSMNT_KERB))
- nmp->nm_flag |= NFSMNT_DISMNT;
+ nmp->nm_state |= NFSSTA_DISMNT;
/*
* There are two reference counts and one lock to get rid of here.
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index c8d99a9..246757f 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
- * $Id: nfs_vnops.c,v 1.87 1998/05/16 16:03:10 bde Exp $
+ * $Id: nfs_vnops.c,v 1.88 1998/05/16 16:20:50 bde Exp $
*/
@@ -1146,10 +1146,11 @@ nfs_writerpc(vp, uiop, cred, iomode, must_commit)
else if (committed == NFSV3WRITE_DATASYNC &&
commit == NFSV3WRITE_UNSTABLE)
committed = commit;
- if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0) {
+ if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0)
+ {
bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf,
NFSX_V3WRITEVERF);
- nmp->nm_flag |= NFSMNT_HASWRITEVERF;
+ nmp->nm_state |= NFSSTA_HASWRITEVERF;
} else if (bcmp((caddr_t)tl,
(caddr_t)nmp->nm_verf, NFSX_V3WRITEVERF)) {
*must_commit = 1;
@@ -2531,7 +2532,7 @@ nfs_commit(vp, offset, cnt, cred, procp)
int error = 0, wccflag = NFSV3_WCCRATTR;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0)
+ if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0)
return (0);
nfsstats.rpccnt[NFSPROC_COMMIT]++;
nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1));
diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h
index 8b28c00..ad606ad 100644
--- a/sys/nfsclient/nfsargs.h
+++ b/sys/nfsclient/nfsargs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
diff --git a/sys/nfsclient/nfsmount.h b/sys/nfsclient/nfsmount.h
index 63de0ad..2d502bd 100644
--- a/sys/nfsclient/nfsmount.h
+++ b/sys/nfsclient/nfsmount.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfsmount.h 8.3 (Berkeley) 3/30/95
- * $Id: nfsmount.h,v 1.12 1997/05/10 16:12:03 dfr Exp $
+ * $Id: nfsmount.h,v 1.13 1997/08/16 19:16:05 wollman Exp $
*/
@@ -48,6 +48,7 @@
*/
struct nfsmount {
int nm_flag; /* Flags for soft/hard... */
+ int nm_state; /* Internal state flags */
struct mount *nm_mountp; /* Vfs structure for this filesystem */
int nm_numgrps; /* Max. size of groupslist */
u_char nm_fh[NFSX_V3FHMAX]; /* File handle of root dir */
@@ -70,6 +71,10 @@ struct nfsmount {
int nm_readdirsize; /* Size of a readdir rpc */
int nm_readahead; /* Num. of blocks to readahead */
int nm_leaseterm; /* Term (sec) for NQNFS lease */
+ int nm_acdirmin; /* Directory attr cache min lifetime */
+ int nm_acdirmax; /* Directory attr cache max lifetime */
+ int nm_acregmin; /* Reg file attr cache min lifetime */
+ int nm_acregmax; /* Reg file attr cache max lifetime */
CIRCLEQ_HEAD(, nfsnode) nm_timerhead; /* Head of lease timer queue */
struct vnode *nm_inprog; /* Vnode in prog by nqnfs_clientd() */
uid_t nm_authuid; /* Uid for authenticator */
diff --git a/sys/nfsclient/nfsstats.h b/sys/nfsclient/nfsstats.h
index 8b28c00..ad606ad 100644
--- a/sys/nfsclient/nfsstats.h
+++ b/sys/nfsclient/nfsstats.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h
index 8b28c00..ad606ad 100644
--- a/sys/nfsserver/nfs.h
+++ b/sys/nfsserver/nfs.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c
index 5c084b7..3fe0cec 100644
--- a/sys/nfsserver/nfs_srvsock.c
+++ b/sys/nfsserver/nfs_srvsock.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_socket.c,v 1.30 1997/10/28 15:59:07 bde Exp $
+ * $Id: nfs_socket.c,v 1.31 1998/03/30 09:54:04 phk Exp $
*/
/*
@@ -136,7 +136,7 @@ struct nfsrtt nfsrtt;
static int nfs_msg __P((struct proc *,char *,char *));
static int nfs_rcvlock __P((struct nfsreq *));
-static void nfs_rcvunlock __P((int *flagp));
+static void nfs_rcvunlock __P((int *flagp, int *statep));
static void nfs_realign __P((struct mbuf *m, int hsiz));
static int nfs_receive __P((struct nfsreq *rep, struct sockaddr **aname,
struct mbuf **mp));
@@ -483,7 +483,8 @@ nfs_receive(rep, aname, mp)
* until we have an entire rpc request/reply.
*/
if (sotype != SOCK_DGRAM) {
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state,
+ rep);
if (error)
return (error);
tryagain:
@@ -497,14 +498,16 @@ tryagain:
* mount point.
*/
if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (EINTR);
}
so = rep->r_nmp->nm_so;
if (!so) {
error = nfs_reconnect(rep);
if (error) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
@@ -516,13 +519,14 @@ tryagain:
if (error) {
if (error == EINTR || error == ERESTART ||
(error = nfs_reconnect(rep))) {
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state);
return (error);
}
goto tryagain;
}
}
- nfs_sndunlock(&rep->r_nmp->nm_flag);
+ nfs_sndunlock(&rep->r_nmp->nm_flag, &rep->r_nmp->nm_state);
if (sotype == SOCK_STREAM) {
aio.iov_base = (caddr_t) &len;
aio.iov_len = sizeof(u_long);
@@ -621,7 +625,8 @@ errout:
"receive error %d from nfs server %s\n",
error,
rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = nfs_sndlock(&rep->r_nmp->nm_flag, rep);
+ error = nfs_sndlock(&rep->r_nmp->nm_flag,
+ &rep->r_nmp->nm_state, rep);
if (!error)
error = nfs_reconnect(rep);
if (!error)
@@ -704,7 +709,7 @@ nfs_reply(myrep)
* Get the next Rpc reply off the socket
*/
error = nfs_receive(myrep, &nam, &mrep);
- nfs_rcvunlock(&nmp->nm_flag);
+ nfs_rcvunlock(&nmp->nm_flag, &nmp->nm_state);
if (error) {
/*
@@ -964,12 +969,12 @@ tryagain:
nmp->nm_sent < nmp->nm_cwnd)) {
splx(s);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- error = nfs_sndlock(&nmp->nm_flag, rep);
+ error = nfs_sndlock(&nmp->nm_flag, &nmp->nm_state, rep);
if (!error) {
m = m_copym(m, 0, M_COPYALL, M_WAIT);
error = nfs_send(nmp->nm_so, nmp->nm_nam, m, rep);
if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(&nmp->nm_flag);
+ nfs_sndunlock(&nmp->nm_flag, &nmp->nm_state);
}
if (!error && (rep->r_flags & R_MUSTRESEND) == 0) {
nmp->nm_sent += NFS_CWNDSCALE;
@@ -1445,8 +1450,9 @@ nfs_sigintr(nmp, rep, p)
* in progress when a reconnect is necessary.
*/
int
-nfs_sndlock(flagp, rep)
+nfs_sndlock(flagp, statep, rep)
register int *flagp;
+ register int *statep;
struct nfsreq *rep;
{
struct proc *p;
@@ -1458,18 +1464,18 @@ nfs_sndlock(flagp, rep)
slpflag = PCATCH;
} else
p = (struct proc *)0;
- while (*flagp & NFSMNT_SNDLOCK) {
+ while (*statep & NFSSTA_SNDLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, p))
return (EINTR);
- *flagp |= NFSMNT_WANTSND;
- (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsndlck",
- slptimeo);
+ *statep |= NFSSTA_WANTSND;
+ (void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1),
+ "nfsndlck", slptimeo);
if (slpflag == PCATCH) {
slpflag = 0;
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_SNDLOCK;
+ *statep |= NFSSTA_SNDLOCK;
return (0);
}
@@ -1477,15 +1483,16 @@ nfs_sndlock(flagp, rep)
* Unlock the stream socket for others.
*/
void
-nfs_sndunlock(flagp)
+nfs_sndunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_SNDLOCK) == 0)
+ if ((*statep & NFSSTA_SNDLOCK) == 0)
panic("nfs sndunlock");
- *flagp &= ~NFSMNT_SNDLOCK;
- if (*flagp & NFSMNT_WANTSND) {
- *flagp &= ~NFSMNT_WANTSND;
+ *statep &= ~NFSSTA_SNDLOCK;
+ if (*statep & NFSSTA_WANTSND) {
+ *statep &= ~NFSSTA_WANTSND;
wakeup((caddr_t)flagp);
}
}
@@ -1495,16 +1502,17 @@ nfs_rcvlock(rep)
register struct nfsreq *rep;
{
register int *flagp = &rep->r_nmp->nm_flag;
+ register int *statep = &rep->r_nmp->nm_state;
int slpflag, slptimeo = 0;
if (*flagp & NFSMNT_INT)
slpflag = PCATCH;
else
slpflag = 0;
- while (*flagp & NFSMNT_RCVLOCK) {
+ while (*statep & NFSSTA_RCVLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp))
return (EINTR);
- *flagp |= NFSMNT_WANTRCV;
+ *statep |= NFSSTA_WANTRCV;
(void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk",
slptimeo);
/*
@@ -1520,7 +1528,7 @@ nfs_rcvlock(rep)
slptimeo = 2 * hz;
}
}
- *flagp |= NFSMNT_RCVLOCK;
+ *statep |= NFSSTA_RCVLOCK;
return (0);
}
@@ -1528,15 +1536,16 @@ nfs_rcvlock(rep)
* Unlock the stream socket for others.
*/
static void
-nfs_rcvunlock(flagp)
+nfs_rcvunlock(flagp, statep)
register int *flagp;
+ register int *statep;
{
- if ((*flagp & NFSMNT_RCVLOCK) == 0)
+ if ((*statep & NFSSTA_RCVLOCK) == 0)
panic("nfs rcvunlock");
- *flagp &= ~NFSMNT_RCVLOCK;
- if (*flagp & NFSMNT_WANTRCV) {
- *flagp &= ~NFSMNT_WANTRCV;
+ *statep &= ~NFSSTA_RCVLOCK;
+ if (*statep & NFSSTA_WANTRCV) {
+ *statep &= ~NFSSTA_WANTRCV;
wakeup((caddr_t)flagp);
}
}
diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c
index f9eabdd..b81eedf 100644
--- a/sys/nfsserver/nfs_srvsubs.c
+++ b/sys/nfsserver/nfs_srvsubs.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
- * $Id: nfs_subs.c,v 1.52 1998/03/30 09:54:12 phk Exp $
+ * $Id: nfs_subs.c,v 1.53 1998/04/06 11:41:07 phk Exp $
*/
/*
@@ -1363,6 +1363,12 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
return (0);
}
+#ifdef NFS_ACDEBUG
+#include <sys/sysctl.h>
+static int nfs_acdebug;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
+#endif
+
/*
* Check the time stamp
* If the cache is valid, copy contents to *vap and return 0
@@ -1373,15 +1379,50 @@ nfs_getattrcache(vp, vaper)
register struct vnode *vp;
struct vattr *vaper;
{
- register struct nfsnode *np = VTONFS(vp);
+ register struct nfsnode *np;
register struct vattr *vap;
+ struct nfsmount *nmp;
+ int timeo;
- if ((time_second - np->n_attrstamp) >= NFS_ATTRTIMEO(np)) {
+ np = VTONFS(vp);
+ vap = &np->n_vattr;
+ nmp = VFSTONFS(vp->v_mount);
+ /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
+ timeo = (time_second - np->n_mtime) / 10;
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug>1)
+ printf("nfs_getattrcache: initial timeo = %d\n", timeo);
+#endif
+
+ if (vap->va_type == VDIR) {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
+ timeo = nmp->nm_acdirmin;
+ else if (timeo > nmp->nm_acdirmax)
+ timeo = nmp->nm_acdirmax;
+ } else {
+ if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
+ timeo = nmp->nm_acregmin;
+ else if (timeo > nmp->nm_acregmax)
+ timeo = nmp->nm_acregmax;
+ }
+
+#ifdef NFS_ACDEBUG
+ if (nfs_acdebug > 2)
+ printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
+ nmp->nm_acregmin, nmp->nm_acregmax,
+ nmp->nm_acdirmin, nmp->nm_acdirmax);
+
+ if (nfs_acdebug)
+ printf("nfs_getattrcache: age = %d; final timeo = %d\n",r
+ (time_second - np->n_attrstamp), timeo);
+#endif
+
+ if ((time_second - np->n_attrstamp) >= timeo) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
nfsstats.attrcache_hits++;
- vap = &np->n_vattr;
if (vap->va_size != np->n_size) {
if (vap->va_type == VREG) {
if (np->n_flag & NMODIFIED) {
diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c
index c2f9071..317b1c0 100644
--- a/sys/nfsserver/nfs_syscalls.c
+++ b/sys/nfsserver/nfs_syscalls.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_syscalls.c,v 1.36 1998/02/09 06:10:37 eivind Exp $
+ * $Id: nfs_syscalls.c,v 1.37 1998/03/30 09:54:17 phk Exp $
*/
#include <sys/param.h>
@@ -223,10 +223,10 @@ nfssvc(p, uap)
vput(nd.ni_vp);
if (error)
return (error);
- if ((nmp->nm_flag & NFSMNT_MNTD) &&
+ if ((nmp->nm_state & NFSSTA_MNTD) &&
(uap->flag & NFSSVC_GOTAUTH) == 0)
return (0);
- nmp->nm_flag |= NFSMNT_MNTD;
+ nmp->nm_state |= NFSSTA_MNTD;
error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag,
uap->argp, p);
} else if (uap->flag & NFSSVC_ADDSOCK) {
@@ -514,10 +514,12 @@ nfssvc_nfsd(nsd, argp, p)
else if (slp->ns_flag & SLP_NEEDQ) {
slp->ns_flag &= ~SLP_NEEDQ;
(void) nfs_sndlock(&slp->ns_solock,
+ &slp->ns_solock,
(struct nfsreq *)0);
nfsrv_rcv(slp->ns_so, (caddr_t)slp,
M_WAIT);
- nfs_sndunlock(&slp->ns_solock);
+ nfs_sndunlock(&slp->ns_solock,
+ &slp->ns_solock);
}
error = nfsrv_dorec(slp, nfsd, &nd);
cur_usec = nfs_curusec();
@@ -677,7 +679,8 @@ nfssvc_nfsd(nsd, argp, p)
*mtod(m, u_long *) = htonl(0x80000000 | siz);
}
if (solockp)
- (void) nfs_sndlock(solockp, (struct nfsreq *)0);
+ (void) nfs_sndlock(solockp, solockp,
+ (struct nfsreq *)0);
if (slp->ns_flag & SLP_VALID)
error = nfs_send(so, nd->nd_nam2, m, NULL);
else {
@@ -693,7 +696,7 @@ nfssvc_nfsd(nsd, argp, p)
if (error == EPIPE)
nfsrv_zapsock(slp);
if (solockp)
- nfs_sndunlock(solockp);
+ nfs_sndunlock(solockp, solockp);
if (error == EINTR || error == ERESTART) {
free((caddr_t)nd, M_NFSRVDESC);
nfsrv_slpderef(slp);
@@ -899,17 +902,17 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
{
int error = 0;
- while ((nmp->nm_flag & NFSMNT_WAITAUTH) == 0) {
- nmp->nm_flag |= NFSMNT_WANTAUTH;
+ while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) {
+ nmp->nm_state |= NFSSTA_WANTAUTH;
(void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
"nfsauth1", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
if (error) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
return (error);
}
}
- nmp->nm_flag &= ~(NFSMNT_WAITAUTH | NFSMNT_WANTAUTH);
+ nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH);
nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
nmp->nm_authlen = RPCAUTH_MAXSIZ;
nmp->nm_verfstr = verf_str;
@@ -920,13 +923,13 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
/*
* And wait for mount_nfs to do its stuff.
*/
- while ((nmp->nm_flag & NFSMNT_HASAUTH) == 0 && error == 0) {
+ while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) {
(void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
"nfsauth2", 2 * hz);
error = nfs_sigintr(nmp, rep, rep->r_procp);
}
- if (nmp->nm_flag & NFSMNT_AUTHERR) {
- nmp->nm_flag &= ~NFSMNT_AUTHERR;
+ if (nmp->nm_state & NFSSTA_AUTHERR) {
+ nmp->nm_state &= ~NFSSTA_AUTHERR;
error = EAUTH;
}
if (error)
@@ -936,10 +939,10 @@ nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
*verf_len = nmp->nm_verflen;
bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (key));
}
- nmp->nm_flag &= ~NFSMNT_HASAUTH;
- nmp->nm_flag |= NFSMNT_WAITAUTH;
- if (nmp->nm_flag & NFSMNT_WANTAUTH) {
- nmp->nm_flag &= ~NFSMNT_WANTAUTH;
+ nmp->nm_state &= ~NFSSTA_HASAUTH;
+ nmp->nm_state |= NFSSTA_WAITAUTH;
+ if (nmp->nm_state & NFSSTA_WANTAUTH) {
+ nmp->nm_state &= ~NFSSTA_WANTAUTH;
wakeup((caddr_t)&nmp->nm_authtype);
}
return (error);
diff --git a/sys/nfsserver/nfsrvstats.h b/sys/nfsserver/nfsrvstats.h
index 8b28c00..ad606ad 100644
--- a/sys/nfsserver/nfsrvstats.h
+++ b/sys/nfsserver/nfsrvstats.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
+ * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
*/
#ifndef _NFS_NFS_H_
@@ -56,11 +56,17 @@
#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 */
+#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
#endif
#ifndef NFS_MAXATTRTIMO
#define NFS_MAXATTRTIMO 60
#endif
+#ifndef NFS_MINDIRATTRTIMO
+#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
+#endif
+#ifndef NFS_MAXDIRATTRTIMO
+#define NFS_MAXDIRATTRTIMO 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 */
@@ -104,15 +110,6 @@
#endif
/*
- * Set the attribute timeout based on how recently the file has been modified.
- */
-#define NFS_ATTRTIMEO(np) \
- ((((np)->n_flag & NMODIFIED) || \
- (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
- ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
- (time_second - (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
@@ -149,6 +146,10 @@ struct nfs_args {
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* cache attrs for reg files min time */
+ int acregmax; /* cache attrs for reg files max time */
+ int acdirmin; /* cache attrs for dirs min time */
+ int acdirmax; /* cache attrs for dirs max time */
};
/*
@@ -172,21 +173,25 @@ struct nfs_args {
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
-#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSMNT_WANTSND 0x02000000 /* Want above */
-#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSMNT_WANTRCV 0x08000000 /* Want above */
-#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
+#define NFSMNT_ACREGMIN 0x00040000
+#define NFSMNT_ACREGMAX 0x00080000
+#define NFSMNT_ACDIRMIN 0x00100000
+#define NFSMNT_ACDIRMAX 0x00200000
+
+#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
+#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
+#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
+#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
+#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
+#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
+#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
+#define NFSSTA_WANTSND 0x02000000 /* Want above */
+#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
+#define NFSSTA_WANTRCV 0x08000000 /* Want above */
+#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
+#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
+#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
+#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
@@ -580,8 +585,8 @@ int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
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 *));
-void nfs_sndunlock __P((int *flagp));
+int nfs_sndlock __P((int *, int *, struct nfsreq *));
+void nfs_sndunlock __P((int *, int *));
int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
int));
OpenPOWER on IntegriCloud