vol: Check for blank vnode in VAllocVnode_r

When we alloc a vnode in VAllocVnode_r, we look up that vnode in the
vnode cache, to see if a vnode struct already exists for it. If it
doesn't, we check the vnode index to ensure that the vnode actually is
not in use (among other things). However, we do not perform the same
check for a vnode already in the cache. Add this check, to make sure
that we don't allocate an already-used vnode number, even if the
bitmap is screwed up.

Change-Id: I63b3aa752d359a2ff8282b193e658d74d6b9719c
Reviewed-on: http://gerrit.openafs.org/4060
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2011-02-25 16:58:30 -06:00 committed by Derrick Brashear
parent b41575d176
commit 974e95302a

View File

@ -703,6 +703,28 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type)
}
}
/* sanity check: vnode should be blank if it was deleted. If it's
* not blank, it is still in use somewhere; but the bitmap told us
* this vnode number was free, so something is wrong. */
if (vnp->disk.type != vNull) {
Error tmp;
Log("VAllocVnode: addled bitmap or vnode object! (vol %ld, "
"vnode %p, number %ld, type %ld)\n", (long)vp->hashid, vnp,
(long)Vn_id(vnp), (long)vnp->disk.type);
*ec = EIO;
VFreeBitMapEntry_r(&tmp, vp, &vp->vnodeIndex[class], bitNumber,
VOL_FREE_BITMAP_WAIT);
VInvalidateVnode_r(vnp);
VnUnlock(vnp, WRITE_LOCK);
VnCancelReservation_r(vnp);
#ifdef AFS_DEMAND_ATTACH_FS
VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, 0);
#else
VForceOffline_r(vp, 0);
#endif
return NULL;
}
} else {
/* no such vnode in the cache */