- Reorder vrele calls after vput calls to prevent lock order reversals

between leaf and directory locks.

Found by:	kris
Sponsored by:	Isilon Systems, Inc.
This commit is contained in:
Jeff Roberson 2006-03-12 04:59:04 +00:00
parent 4bf5133b1f
commit e64df05c33
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=156586

View File

@ -599,15 +599,9 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
}
}
if (dirp) {
vrele(dirp);
dirp = NULL;
}
/*
* Resources at this point:
* ndp->ni_vp may not be NULL
*
*/
if (error) {
@ -620,15 +614,6 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
goto nfsmout;
}
/*
* Clear out some resources prior to potentially blocking. This
* is not as critical as ni_dvp resources in other routines, but
* it helps.
*/
vrele(ndp->ni_startdir);
ndp->ni_startdir = NULL;
NDFREE(&nd, NDF_ONLY_PNBUF);
/*
* Get underlying attribute, then release remaining resources ( for
* the same potential blocking reason ) and reply.
@ -641,8 +626,12 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
error = VOP_GETATTR(vp, vap, cred, td);
vput(vp);
mtx_unlock(&Giant); /* VFS */
vrele(ndp->ni_startdir);
vrele(dirp);
ndp->ni_vp = NULL;
ndp->ni_startdir = NULL;
dirp = NULL;
mtx_unlock(&Giant); /* VFS */
NFSD_LOCK();
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3));
if (error) {
@ -662,17 +651,19 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
nfsmout:
NFSD_LOCK_ASSERT();
NFSD_UNLOCK();
mtx_lock(&Giant); /* VFS */
if (ndp->ni_vp)
vput(ndp->ni_vp);
if (dirp)
vrele(dirp);
if (ndp->ni_vp || dirp || ndp->ni_startdir) {
NFSD_UNLOCK();
mtx_lock(&Giant); /* VFS */
if (ndp->ni_vp)
vput(ndp->ni_vp);
if (dirp)
vrele(dirp);
if (ndp->ni_startdir)
vrele(ndp->ni_startdir);
mtx_unlock(&Giant); /* VFS */
NFSD_LOCK();
}
NDFREE(&nd, NDF_ONLY_PNBUF);
if (ndp->ni_startdir)
vrele(ndp->ni_startdir);
mtx_unlock(&Giant); /* VFS */
NFSD_LOCK();
return (error);
}