diff options
author | dm <dm@cvs.openbsd.org> | 1996-12-17 03:46:40 +0000 |
---|---|---|
committer | dm <dm@cvs.openbsd.org> | 1996-12-17 03:46:40 +0000 |
commit | 7e77de81db5ad5ee0d7455dfa9a016a680c5387b (patch) | |
tree | 8ce852bde705fcb343dc1752810bb2a41db23c9a /sys/nfs | |
parent | 5ab777dc75b17b54c14b6c1bdda9e4b3e9201bf9 (diff) |
NFS attribute cache timeout mount param
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs.h | 4 | ||||
-rw-r--r-- | sys/nfs/nfs_subs.c | 29 | ||||
-rw-r--r-- | sys/nfs/nfs_vfsops.c | 42 | ||||
-rw-r--r-- | sys/nfs/nfsmount.h | 6 |
4 files changed, 74 insertions, 7 deletions
diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h index 1de0ee04b42..7055409babe 100644 --- a/sys/nfs/nfs.h +++ b/sys/nfs/nfs.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -127,11 +127,13 @@ /* * 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 diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 231f8e509ba..27e475c0ebc 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -1321,6 +1321,31 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper) 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 @@ -1334,7 +1359,7 @@ nfs_getattrcache(vp, vaper) 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); } diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index 5e9fd779b7d..1b09ef1789a 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -543,6 +543,29 @@ nfs_decode_args(nmp, argp) 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) @@ -580,11 +603,20 @@ nfs_mount(mp, path, data, ndp, p) 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); @@ -674,6 +706,10 @@ mountnfs(argp, mp, nam, pth, hst, vpp) 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; diff --git a/sys/nfs/nfsmount.h b/sys/nfs/nfsmount.h index 12cae0aef94..290f83736b4 100644 --- a/sys/nfs/nfsmount.h +++ b/sys/nfs/nfsmount.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -85,6 +85,10 @@ struct nfsmount { 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 |