diff options
author | phk <phk@FreeBSD.org> | 1997-08-26 07:32:51 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-08-26 07:32:51 +0000 |
commit | fddfc9d5bb4c35d88417fa80a062219876186593 (patch) | |
tree | 7f29931e5661e3731f6b972dc3a9508534617833 /sys/nfs | |
parent | f320b3a30651cae7b34067561adb48f2b6f57621 (diff) | |
download | FreeBSD-src-fddfc9d5bb4c35d88417fa80a062219876186593.zip FreeBSD-src-fddfc9d5bb4c35d88417fa80a062219876186593.tar.gz |
Uncut&paste cache_lookup().
This unifies several times in theory indentical 50 lines of code.
The filesystems have a new method: vop_cachedlookup, which is the
meat of the lookup, and use vfs_cache_lookup() for their vop_lookup
method. vfs_cache_lookup() will check the namecache and pass on
to the vop_cachedlookup method in case of a miss.
It's still the task of the individual filesystems to populate the
namecache with cache_enter().
Filesystems that do not use the namecache will just provide the
vop_lookup method as usual.
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_vnops.c | 58 |
1 files changed, 5 insertions, 53 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 0dff531..8ef10dd 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.54 1997/06/16 00:23:40 dyson Exp $ + * $Id: nfs_vnops.c,v 1.55 1997/06/25 08:32:33 dfr Exp $ */ @@ -102,7 +102,7 @@ static int nfs_ioctl __P((struct vop_ioctl_args *)); static int nfs_select __P((struct vop_select_args *)); static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int)); static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *)); -static int nfs_lookup __P((struct vop_lookup_args *)); +static int nfs_lookup __P((struct vop_cachedlookup_args *)); static int nfs_create __P((struct vop_create_args *)); static int nfs_mknod __P((struct vop_mknod_args *)); static int nfs_open __P((struct vop_open_args *)); @@ -141,7 +141,8 @@ static int nfs_update __P((struct vop_update_args *)); vop_t **nfsv2_vnodeop_p; static struct vnodeopv_entry_desc nfsv2_vnodeop_entries[] = { { &vop_default_desc, (vop_t *)vn_default_error }, - { &vop_lookup_desc, (vop_t *)nfs_lookup }, /* lookup */ + { &vop_lookup_desc, (vop_t *)vfs_cache_lookup }, /* lookup */ + { &vop_cachedlookup_desc, (vop_t *)nfs_lookup }, /* lookup */ { &vop_create_desc, (vop_t *)nfs_create }, /* create */ { &vop_mknod_desc, (vop_t *)nfs_mknod }, /* mknod */ { &vop_open_desc, (vop_t *)nfs_open }, /* open */ @@ -837,7 +838,7 @@ nfs_setattrrpc(vp, vap, cred, procp) */ static int nfs_lookup(ap) - struct vop_lookup_args /* { + struct vop_cachedlookup_args /* { struct vnodeop_desc *a_desc; struct vnode *a_dvp; struct vnode **a_vpp; @@ -872,55 +873,6 @@ nfs_lookup(ap) wantparent = flags & (LOCKPARENT|WANTPARENT); nmp = VFSTONFS(dvp->v_mount); np = VTONFS(dvp); - if ((error = cache_lookup(dvp, vpp, cnp)) && error != ENOENT) { - struct vattr vattr; - int vpid; - - if (error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) { - *vpp = NULLVP; - return (error); - } - - newvp = *vpp; - vpid = newvp->v_id; - /* - * See the comment starting `Step through' in ufs/ufs_lookup.c - * for an explanation of the locking protocol - */ - if (dvp == newvp) { - VREF(newvp); - error = 0; - } else if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0, p); - error = vget(newvp, LK_EXCLUSIVE, p); - if (!error && lockparent && (flags & ISLASTCN)) - error = vn_lock(dvp, LK_EXCLUSIVE, p); - } else { - error = vget(newvp, LK_EXCLUSIVE, p); - if (!lockparent || error || !(flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); - } - if (!error) { - if (vpid == newvp->v_id) { - if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, p) - && vattr.va_ctime.tv_sec == VTONFS(newvp)->n_ctime) { - nfsstats.lookupcache_hits++; - if (cnp->cn_nameiop != LOOKUP && - (flags & ISLASTCN)) - cnp->cn_flags |= SAVENAME; - return (0); - } - cache_purge(newvp); - } - vput(newvp); - if (lockparent && dvp != newvp && (flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); - } - error = vn_lock(dvp, LK_EXCLUSIVE, p); - *vpp = NULLVP; - if (error) - return (error); - } error = 0; newvp = NULLVP; nfsstats.lookupcache_misses++; |