Do negative lookup caching. Use a timestamp of the oldest negative cache
entry, so it can be checked against directory modification time for validity.
This commit is contained in:
parent
d9bc7315c5
commit
c3ce5f02ea
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfs_vnops.c,v 1.81 1997/10/10 01:53:30 fvdl Exp $ */
|
||||
/* $NetBSD: nfs_vnops.c,v 1.82 1997/10/12 23:13:35 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -810,10 +810,20 @@ nfs_lookup(v)
|
|||
wantparent = flags & (LOCKPARENT|WANTPARENT);
|
||||
nmp = VFSTONFS(dvp->v_mount);
|
||||
np = VTONFS(dvp);
|
||||
if ((error = cache_lookup(dvp, vpp, cnp)) != 0 && error != ENOENT) {
|
||||
if ((error = cache_lookup(dvp, vpp, cnp)) != 0) {
|
||||
struct vattr vattr;
|
||||
int vpid;
|
||||
|
||||
if (error == ENOENT) {
|
||||
if (!VOP_GETATTR(dvp, &vattr, cnp->cn_cred,
|
||||
cnp->cn_proc) && vattr.va_mtime.tv_sec ==
|
||||
VTONFS(dvp)->n_nctime)
|
||||
return (ENOENT);
|
||||
cache_purge(dvp);
|
||||
np->n_nctime = 0;
|
||||
goto dorpc;
|
||||
}
|
||||
|
||||
newvp = *vpp;
|
||||
vpid = newvp->v_id;
|
||||
/*
|
||||
|
@ -845,6 +855,7 @@ nfs_lookup(v)
|
|||
}
|
||||
*vpp = NULLVP;
|
||||
}
|
||||
dorpc:
|
||||
error = 0;
|
||||
newvp = NULLVP;
|
||||
nfsstats.lookupcache_misses++;
|
||||
|
@ -913,6 +924,13 @@ nfs_lookup(v)
|
|||
*vpp = newvp;
|
||||
nfsm_reqdone;
|
||||
if (error) {
|
||||
if (error == ENOENT && (cnp->cn_flags & MAKEENTRY) &&
|
||||
cnp->cn_nameiop != CREATE) {
|
||||
if (VTONFS(dvp)->n_nctime == 0)
|
||||
VTONFS(dvp)->n_nctime =
|
||||
VTONFS(dvp)->n_vattr.va_mtime.tv_sec;
|
||||
cache_enter(dvp, NULL, cnp);
|
||||
}
|
||||
if (newvp != NULLVP)
|
||||
vrele(newvp);
|
||||
if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
|
||||
|
@ -1861,8 +1879,11 @@ nfs_mkdir(v)
|
|||
if (error) {
|
||||
if (newvp)
|
||||
vrele(newvp);
|
||||
} else
|
||||
} else {
|
||||
if (cnp->cn_flags & MAKEENTRY)
|
||||
cache_enter(dvp, newvp, cnp);
|
||||
*ap->a_vpp = newvp;
|
||||
}
|
||||
FREE(cnp->cn_pnbuf, M_NAMEI);
|
||||
vrele(dvp);
|
||||
return (error);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfsnode.h,v 1.21 1997/10/10 01:53:32 fvdl Exp $ */
|
||||
/* $NetBSD: nfsnode.h,v 1.22 1997/10/12 23:13:38 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -109,6 +109,7 @@ struct nfsnode {
|
|||
time_t n_attrstamp; /* Attr. cache timestamp */
|
||||
time_t n_mtime; /* Prev modify time. */
|
||||
time_t n_ctime; /* Prev create time. */
|
||||
time_t n_nctime; /* Last neg cache entry (dir) */
|
||||
time_t n_expiry; /* Lease expiry time */
|
||||
nfsfh_t *n_fhp; /* NFS File Handle */
|
||||
struct vnode *n_vnode; /* associated vnode */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfsproto.h,v 1.3 1997/10/10 01:53:33 fvdl Exp $ */
|
||||
/* $NetBSD: nfsproto.h,v 1.4 1997/10/12 23:13:39 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -252,7 +252,7 @@ typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
|
|||
* NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
|
||||
*/
|
||||
#ifndef NFS_SMALLFH
|
||||
#define NFS_SMALLFH 48
|
||||
#define NFS_SMALLFH 44
|
||||
#endif
|
||||
union nfsfh {
|
||||
fhandle_t fh_generic;
|
||||
|
|
Loading…
Reference in New Issue