From 141aba2c7b24ff834f46b1db7dc419aed0f550ee Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 29 Mar 2005 13:00:37 +0000 Subject: - cache_lookup() now locks the new vnode for us to prevent some races. Remove redundant code. Sponsored by: Isilon Systems, Inc. --- sys/nfs4client/nfs4_vnops.c | 57 ++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) (limited to 'sys/nfs4client') diff --git a/sys/nfs4client/nfs4_vnops.c b/sys/nfs4client/nfs4_vnops.c index be6bd85..8877a95 100644 --- a/sys/nfs4client/nfs4_vnops.c +++ b/sys/nfs4client/nfs4_vnops.c @@ -956,50 +956,29 @@ nfs4_lookup(struct vop_lookup_args *ap) isdot = cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.'; + 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 (newvp != dvp) - 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); - *vpp = NULLVP; + cache_purge(newvp); + if (newvp != dvp) + vput(newvp); + else + vrele(newvp); + if (flags & ISDOTDOT) + vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, td); } error = 0; -- cgit v1.1