In vn_mkdir(), use vrele() instead of vput() on the parent directory

vnode in the case that the target exists and is the same vnode as
the parent (i.e. "mkdir ."). The namei() call does not leave the
vnode locked in this case even though you might expect it to.

This bug was mostly harmless in practice because unlocking an already
unlocked vnode currently does not trigger any panics or warnings.

Reviewed by:	jeff
This commit is contained in:
Ian Dowse 2002-06-28 20:06:47 +00:00
parent 0080a004d7
commit 84b2995b2f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98984
2 changed files with 18 additions and 2 deletions

View File

@ -3652,7 +3652,15 @@ vn_mkdir(path, mode, segflg, td)
if (vp != NULL) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vrele(vp);
vput(nd.ni_dvp);
/*
* XXX namei called with LOCKPARENT but not LOCKLEAF has
* the strange behaviour of leaving the vnode unlocked
* if the target is the same vnode as the parent.
*/
if (vp == nd.ni_dvp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
return (EEXIST);
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {

View File

@ -3652,7 +3652,15 @@ vn_mkdir(path, mode, segflg, td)
if (vp != NULL) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vrele(vp);
vput(nd.ni_dvp);
/*
* XXX namei called with LOCKPARENT but not LOCKLEAF has
* the strange behaviour of leaving the vnode unlocked
* if the target is the same vnode as the parent.
*/
if (vp == nd.ni_dvp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
return (EEXIST);
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {