Adapt to cache_lookup() changes.

Tested by: jdolecek
Rewieved by: wrstuden
This commit is contained in:
jdolecek 1999-09-05 14:26:32 +00:00
parent 026b142488
commit 7dfaa17700
6 changed files with 21 additions and 323 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: adlookup.c,v 1.23 1999/07/08 01:05:58 wrstuden Exp $ */
/* $NetBSD: adlookup.c,v 1.24 1999/09/05 14:26:32 jdolecek Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -109,47 +109,12 @@ adosfs_lookup(v)
return (EROFS);
/*
* cache lookup algorithm borrowed from ufs_lookup()
* its not consistent with otherthings in this function..
* Before tediously performing a linear scan of the directory,
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
if (error == ENOENT)
return (error);
vpid = (*vpp)->v_id;
if (vdp == *vpp) {
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(vdp, 0); /* race */
cnp->cn_flags |= PDIRUNLOCK;
error = vget(*vpp, LK_EXCLUSIVE);
if (error == 0 && lockp && last) {
if ((error = vn_lock(vdp, LK_EXCLUSIVE)))
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(*vpp, LK_EXCLUSIVE);
/* if (lockp == 0 || error || last) */
if (lockp == 0 || error || last == 0) {
VOP_UNLOCK(vdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if (error == 0) {
if (vpid == vdp->v_id)
return (0);
vput(*vpp);
if (lockp && vdp != *vpp && last) {
VOP_UNLOCK(vdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
*vpp = NULL;
if ((error = vn_lock(vdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
}
if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
return (error);
/*
* fake a '.'

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecore_lookup.c,v 1.7 1999/08/18 22:01:53 mark Exp $ */
/* $NetBSD: filecore_lookup.c,v 1.8 1999/09/05 14:26:33 jdolecek Exp $ */
/*-
* Copyright (c) 1998 Andrew McMurry
@ -143,63 +143,8 @@ filecore_lookup(v)
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
int vpid; /* capability number of vnode */
if (error == ENOENT)
return (error);
#ifdef PARANOID
if ((vdp->v_flag & VROOT) && (flags & ISDOTDOT))
panic("filecore_lookup: .. through root");
#endif
/*
* Get the next vnode in the path.
* See comment below starting `Step through' for
* an explaination of the locking protocol.
*/
pdp = vdp;
dp = VTOI(*vpp);
vdp = *vpp;
vpid = vdp->v_id;
if (pdp == vdp) {
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = vget(vdp, LK_EXCLUSIVE);
if (!error && lockparent && (flags & ISLASTCN)) {
error = vn_lock(pdp, LK_EXCLUSIVE);
if (error == 0)
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(vdp, LK_EXCLUSIVE);
if (!lockparent || error || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
/*
* Check that the capability number did not change
* while we were waiting for the lock.
*/
if (!error) {
if (vpid == vdp->v_id)
return (0);
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
vdp = pdp;
dp = VTOI(pdp);
*vpp = NULL;
}
if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
return (error);
name = cnp->cn_nameptr;
namelen = cnp->cn_namelen;

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_lookup.c,v 1.41 1999/08/04 18:40:48 wrstuden Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.42 1999/09/05 14:26:33 jdolecek Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -147,64 +147,8 @@ msdosfs_lookup(v)
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
int vpid;
if (error == ENOENT)
return (error);
/*
* Get the next vnode in the path.
* See comment below starting `Step through' for
* an explaination of the locking protocol.
*/
pdp = vdp;
dp = VTODE(*vpp);
vdp = *vpp;
vpid = vdp->v_id;
if (pdp == vdp) { /* lookup on "." */
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = vget(vdp, LK_EXCLUSIVE);
if (!error && lockparent && (flags & ISLASTCN)){
error = vn_lock(pdp, LK_EXCLUSIVE);
if (error == 0)
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(vdp, LK_EXCLUSIVE);
if (!lockparent || error || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
/*
* Check that the capability number did not change
* while we were waiting for the lock.
*/
if (!error) {
if (vpid == vdp->v_id) {
#ifdef MSDOSFS_DEBUG
printf("msdosfs_lookup(): cache hit, vnode %p, file %s\n",
vdp, dp->de_Name);
#endif
return (0);
}
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
vdp = pdp;
dp = VTODE(vdp);
*vpp = NULL;
}
if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
return (error);
/*
* If they are going after the . or .. entry in the root directory,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntfs_vnops.c,v 1.11 1999/09/05 11:09:03 jdolecek Exp $ */
/* $NetBSD: ntfs_vnops.c,v 1.12 1999/09/05 14:26:33 jdolecek Exp $ */
/*
* Copyright (c) 1992, 1993
@ -898,62 +898,8 @@ ntfs_lookup(ap)
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) != 0) {
int vpid;
struct vnode *pdp, *vdp = ap->a_dvp;
struct vnode **vpp = ap->a_vpp;
u_long flags = cnp->cn_flags;
if (error == ENOENT)
return (error);
/*
* Get the next vnode in the path.
* See comment below starting `Step through' for
* an explaination of the locking protocol.
*/
pdp = vdp;
vdp = *vpp;
vpid = vdp->v_id;
if (pdp == vdp) { /* lookup on "." */
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = vget(vdp, LK_EXCLUSIVE);
if (!error && lockparent && (flags & ISLASTCN)){
error = vn_lock(pdp, LK_EXCLUSIVE);
if (error == 0)
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(vdp, LK_EXCLUSIVE);
if (!lockparent || error || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
/*
* Check that the capability number did not change
* while we were waiting for the lock.
*/
if (!error) {
if (vpid == vdp->v_id)
return (0);
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
vdp = pdp;
*vpp = NULL;
}
if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) >= 0)
return (error);
#endif
if(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_lookup.c,v 1.11 1999/08/04 18:40:47 wrstuden Exp $ */
/* $NetBSD: ext2fs_lookup.c,v 1.12 1999/09/05 14:26:34 jdolecek Exp $ */
/*
* Modified for NetBSD 1.2E
@ -316,59 +316,8 @@ ext2fs_lookup(v)
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
int vpid; /* capability number of vnode */
if (error == ENOENT)
return (error);
/*
* Get the next vnode in the path.
* See comment below starting `Step through' for
* an explaination of the locking protocol.
*/
pdp = vdp;
dp = VTOI(*vpp);
vdp = *vpp;
vpid = vdp->v_id;
if (pdp == vdp) { /* lookup on "." */
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = vget(vdp, LK_EXCLUSIVE);
if (!error && lockparent && (flags & ISLASTCN)) {
error = vn_lock(pdp, LK_EXCLUSIVE);
if (error == 0)
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(vdp, LK_EXCLUSIVE);
if (!lockparent || error || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
/*
* Check that the capability number did not change
* while we were waiting for the lock.
*/
if (!error) {
if (vpid == vdp->v_id)
return (0);
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
vdp = pdp;
dp = VTOI(pdp);
*vpp = NULL;
}
if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
return (error);
/*
* Suppress search for slots unless creating

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_lookup.c,v 1.25 1999/08/04 18:40:06 wrstuden Exp $ */
/* $NetBSD: ufs_lookup.c,v 1.26 1999/09/05 14:26:33 jdolecek Exp $ */
/*
* Copyright (c) 1989, 1993
@ -162,59 +162,8 @@ ufs_lookup(v)
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
int vpid; /* capability number of vnode */
if (error == ENOENT)
return (error);
/*
* Get the next vnode in the path.
* See comment below starting `Step through' for
* an explaination of the locking protocol.
*/
pdp = vdp;
dp = VTOI(*vpp);
vdp = *vpp;
vpid = vdp->v_id;
if (pdp == vdp) { /* lookup on "." */
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
error = vget(vdp, LK_EXCLUSIVE);
if (!error && lockparent && (flags & ISLASTCN)) {
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
}
} else {
error = vget(vdp, LK_EXCLUSIVE);
if (!lockparent || error || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
/*
* Check that the capability number did not change
* while we were waiting for the lock.
*/
if (!error) {
if (vpid == vdp->v_id)
return (0);
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0);
cnp->cn_flags |= PDIRUNLOCK;
}
}
if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
return (error);
cnp->cn_flags &= ~PDIRUNLOCK;
vdp = pdp;
dp = VTOI(pdp);
*vpp = NULL;
}
if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
return (error);
/*
* Suppress search for slots unless creating