- A sanity check in unionfs verifies that lookups of '.' return the

vnode of the parent.  However, this check should not be performed if
  the lookup failed.  This change should fix "union_lookup returning
  . not same as startdir" panics people were seeing.  The bug was
  introduced by an incomplete import of a NetBSD delta in rev 1.38.
- Move the aforementioned check out from DIAGNOSTIC.  Performance
  is the least of our unionfs worries.
- Minor reorganization.

PR:		53004
MFC after:	1 week
This commit is contained in:
David Schultz 2003-11-14 08:23:13 +00:00
parent 6f8b4fc03a
commit 95eac68fea

View File

@ -583,37 +583,31 @@ union_lookup(ap)
((*ap->a_vpp) ? vrefcnt(*ap->a_vpp) : -99),
lowervp, uppervp));
/*
* dvp lock state, determine whether to relock dvp. dvp is expected
* to be locked on return if:
*
* - there was an error (except not EJUSTRETURN), or
* - we hit the last component and lockparent is true
*
* dvp_is_locked is the current state of the dvp lock, not counting
* the possibility that *ap->a_vpp == dvp (in which case it is locked
* anyway). Note that *ap->a_vpp == dvp only if no error occured.
*/
if (error == 0 || error == EJUSTRETURN) {
/*
* dvp lock state, determine whether to relock dvp.
* We are expected to unlock dvp unless:
*
* - there was an error (other than EJUSTRETURN), or
* - we hit the last component and lockparent is true
*/
if (*ap->a_vpp != dvp) {
if (!lockparent || (cnp->cn_flags & ISLASTCN) == 0)
VOP_UNLOCK(dvp, 0, td);
}
if (*ap->a_vpp != dvp) {
if ((error == 0 || error == EJUSTRETURN) &&
(!lockparent || (cnp->cn_flags & ISLASTCN) == 0)) {
VOP_UNLOCK(dvp, 0, td);
if (cnp->cn_namelen == 1 &&
cnp->cn_nameptr[0] == '.' &&
*ap->a_vpp != dvp) {
#ifdef DIAGNOSTIC
vprint("union_lookup: vp", *ap->a_vpp);
vprint("union_lookup: dvp", dvp);
#endif
panic("union_lookup returning . (%p) != startdir (%p)",
*ap->a_vpp, dvp);
}
}
/*
* Diagnostics
*/
#ifdef DIAGNOSTIC
if (cnp->cn_namelen == 1 &&
cnp->cn_nameptr[0] == '.' &&
*ap->a_vpp != dvp) {
panic("union_lookup returning . (%p) not same as startdir (%p)", ap->a_vpp, dvp);
}
#endif
return (error);
}