-/* $OpenBSD: nfs.h,v 1.5 1996/06/10 07:28:52 deraadt Exp $ */
+/* $OpenBSD: nfs.h,v 1.6 1996/12/17 03:46:37 dm Exp $ */
/* $NetBSD: nfs.h,v 1.10.4.1 1996/05/27 11:23:56 fvdl Exp $ */
/*
/*
* Set the attribute timeout based on how recently the file has been modified.
*/
+#if 0 /* replaced by nfs_attrtimeo() in nfs_subs.c */
#define NFS_ATTRTIMEO(np) \
((((np)->n_flag & NMODIFIED) || \
(time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
(time.tv_sec - (np)->n_mtime) / 10))
+#endif
/*
* Expected allocation sizes for major data structures. If the actual size
-/* $OpenBSD: nfs_subs.c,v 1.13 1996/10/15 11:34:15 deraadt Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.14 1996/12/17 03:46:38 dm Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
return (0);
}
+inline int
+nfs_attrtimeo (struct nfsnode *np)
+{
+ struct vnode *vp = np->n_vnode;
+ struct nfsmount *nmp = VFSTONFS(vp->v_mount);
+ int tenthage = (time.tv_sec - np->n_mtime) / 10;
+ int minto, maxto;
+
+ if (vp->v_type == VDIR) {
+ maxto = nmp->nm_acdirmax;
+ minto = nmp->nm_acdirmin;
+ }
+ else {
+ maxto = nmp->nm_acregmax;
+ minto = nmp->nm_acregmin;
+ }
+
+ if (np->n_flag & NMODIFIED || tenthage < minto)
+ return minto;
+ else if (tenthage < maxto)
+ return tenthage;
+ else
+ return maxto;
+}
+
/*
* Check the time stamp
* If the cache is valid, copy contents to *vap and return 0
register struct nfsnode *np = VTONFS(vp);
register struct vattr *vap;
- if ((time.tv_sec - np->n_attrstamp) >= NFS_ATTRTIMEO(np)) {
+ if ((time.tv_sec - np->n_attrstamp) >= nfs_attrtimeo(np)) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
-/* $OpenBSD: nfs_vfsops.c,v 1.13 1996/09/21 11:06:22 deraadt Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.14 1996/12/17 03:46:39 dm Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
argp->deadthresh <= NQ_NEVERDEAD)
nmp->nm_deadthresh = argp->deadthresh;
+ if (argp->flags & NFSMNT_ACTIMES) {
+ if (argp->acregmax > 0xffff)
+ nmp->nm_acregmax = 0xffff;
+ else if (argp->acregmax >= 0)
+ nmp->nm_acregmax = argp->acregmax;
+ if (argp->acregmin >= 0) {
+ if (argp->acregmin > nmp->nm_acregmax)
+ nmp->nm_acregmin = nmp->nm_acregmax;
+ else
+ nmp->nm_acregmin = argp->acregmin;
+ }
+ if (argp->acdirmax > 0xffff)
+ nmp->nm_acdirmax = 0xffff;
+ else if (argp->acdirmax >= 0)
+ nmp->nm_acdirmax = argp->acdirmax;
+ if (argp->acdirmin >= 0) {
+ if (argp->acdirmin > nmp->nm_acdirmax)
+ nmp->nm_acdirmin = nmp->nm_acdirmax;
+ else
+ nmp->nm_acdirmin = argp->acdirmin;
+ }
+ }
+
if (nmp->nm_so && adjsock) {
nfs_disconnect(nmp);
if (nmp->nm_sotype == SOCK_DGRAM)
size_t len;
u_char nfh[NFSX_V3FHMAX];
- error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args));
+ error = copyin (data, (caddr_t)&args, sizeof (args.version));
if (error)
return (error);
- if (args.version != NFS_ARGSVERSION)
+ if (args.version == 3) {
+ error = copyin (data, (caddr_t)&args,
+ sizeof (struct nfs_args3));
+ args.flags &= ~NFSMNT_INTERNAL;
+ }
+ else if (args.version == NFS_ARGSVERSION)
+ error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args));
+ else
return (EPROGMISMATCH);
+ if (error)
+ return (error);
args.flags |= NFSMNT_RESVPORT; /* ALWAYS allocate one */
if (mp->mnt_flag & MNT_UPDATE) {
register struct nfsmount *nmp = VFSTONFS(mp);
CIRCLEQ_INIT(&nmp->nm_timerhead);
nmp->nm_inprog = NULLVP;
nmp->nm_fhsize = argp->fhsize;
+ nmp->nm_acregmin = NFS_MINATTRTIMO;
+ nmp->nm_acregmax = NFS_MAXATTRTIMO;
+ nmp->nm_acdirmin = NFS_MINATTRTIMO;
+ nmp->nm_acdirmax = NFS_MAXATTRTIMO;
bcopy((caddr_t)argp->fh, (caddr_t)nmp->nm_fh, argp->fhsize);
#ifdef COMPAT_09
mp->mnt_stat.f_type = 2;
-/* $OpenBSD: nfsmount.h,v 1.3 1996/03/31 13:16:12 mickey Exp $ */
+/* $OpenBSD: nfsmount.h,v 1.4 1996/12/17 03:46:39 dm Exp $ */
/* $NetBSD: nfsmount.h,v 1.10 1996/02/18 11:54:03 fvdl Exp $ */
/*
int nm_numuids; /* Number of nfsuid mappings */
TAILQ_HEAD(, nfsuid) nm_uidlruhead; /* Lists of nfsuid mappings */
LIST_HEAD(, nfsuid) nm_uidhashtbl[NFS_MUIDHASHSIZ];
+ u_short nm_acregmin; /* Attr cache file recently modified */
+ u_short nm_acregmax; /* ac file not recently modified */
+ u_short nm_acdirmin; /* ac for dir recently modified */
+ u_short nm_acdirmax; /* ac for dir not recently modified */
};
#ifdef _KERNEL
-/* $OpenBSD: mount.h,v 1.10 1996/07/05 09:09:06 deraadt Exp $ */
+/* $OpenBSD: mount.h,v 1.11 1996/12/17 03:46:36 dm Exp $ */
/* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */
/*
/*
* Arguments to mount NFS
*/
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
+#define NFS_ARGSVERSION 4 /* change when nfs_args changes */
struct nfs_args {
int version; /* args structure version number */
struct sockaddr *addr; /* file server address */
int leaseterm; /* Term (sec) of lease */
int deadthresh; /* Retrans threshold */
char *hostname; /* server's name */
+ int acregmin; /* Attr cache file recently modified */
+ int acregmax; /* ac file not recently modified */
+ int acdirmin; /* ac for dir recently modified */
+ int acdirmax; /* ac for dir not recently modified */
+};
+/* NFS args version 3 (for backwards compatibility) */
+struct nfs_args3 {
+ int version; /* args structure version number */
+ struct sockaddr *addr; /* file server address */
+ int addrlen; /* length of address */
+ int sotype; /* Socket type */
+ int proto; /* and Protocol */
+ u_char *fh; /* File handle to be mounted */
+ int fhsize; /* Size, in bytes, of fh */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int readdirsize; /* readdir size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ int maxgrouplist; /* Max. size of group list */
+ int readahead; /* # of blocks to readahead */
+ int leaseterm; /* Term (sec) of lease */
+ int deadthresh; /* Retrans threshold */
+ char *hostname; /* server's name */
};
/*
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
+
+/* Flags valid only in mount syscall arguments */
+#define NFSMNT_ACTIMES 0x00040000 /* Args contain attr cache times*/
+
+/* Flags valid only in kernel */
#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 */