summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2005-03-29 13:00:37 +0000
committerjeff <jeff@FreeBSD.org>2005-03-29 13:00:37 +0000
commit141aba2c7b24ff834f46b1db7dc419aed0f550ee (patch)
treefaf5d3118e523395cb521d1c94dad8620a55b8b8 /sys/nfsclient
parent39f5b5cc72ed461ecb05c4ed8423ccdb62b4a737 (diff)
downloadFreeBSD-src-141aba2c7b24ff834f46b1db7dc419aed0f550ee.zip
FreeBSD-src-141aba2c7b24ff834f46b1db7dc419aed0f550ee.tar.gz
- cache_lookup() now locks the new vnode for us to prevent some races.
Remove redundant code. Sponsored by: Isilon Systems, Inc.
Diffstat (limited to 'sys/nfsclient')
-rw-r--r--sys/nfsclient/nfs_vnops.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 2dfb345..b07a358 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -789,49 +789,29 @@ nfs_lookup(struct vop_lookup_args *ap)
wantparent = flags & (LOCKPARENT|WANTPARENT);
nmp = VFSTONFS(dvp->v_mount);
np = VTONFS(dvp);
+ if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) {
+ *vpp = NULLVP;
+ return (error);
+ }
if ((error = cache_lookup(dvp, vpp, cnp)) && error != ENOENT) {
struct vattr vattr;
- if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
-
- vhold(*vpp);
newvp = *vpp;
- /*
- * 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, td);
- error = vget(newvp, LK_EXCLUSIVE, td);
- if (error)
- vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, td);
- } else
- error = vget(newvp, LK_EXCLUSIVE, td);
- if (!error) {
- if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td)
- && vattr.va_ctime.tv_sec == VTONFS(newvp)->n_ctime) {
- nfsstats.lookupcache_hits++;
- if (cnp->cn_nameiop != LOOKUP &&
- (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
- vdrop(newvp);
- return (0);
- }
- cache_purge(newvp);
- if (dvp != newvp)
- vput(newvp);
- else
- vrele(newvp);
- if (flags & ISDOTDOT)
- vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, td);
+ if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td)
+ && 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);
}
- vdrop(newvp);
+ cache_purge(newvp);
+ if (dvp != newvp)
+ vput(newvp);
+ else
+ vrele(newvp);
+ if (flags & ISDOTDOT)
+ vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, td);
*vpp = NULLVP;
}
error = 0;
OpenPOWER on IntegriCloud