vol-package-avoid-race-on-invalidating-hashed-vnode-20030111

thanks to whichever of jhutz@cmu.edu or cg2v@andrew.cmu.edu (or both)
noticed the race; also deal with wrap problem in VolumeCacheCheck that i
noticed
This commit is contained in:
Derrick Brashear 2003-01-11 07:26:35 +00:00
parent 92e76f7eb2
commit bd72450f80
4 changed files with 6 additions and 3 deletions

View File

@ -641,7 +641,7 @@ Vnode *VGetVnode_r(ec,vp,vnodeNumber,locktype)
/* Check that the vnode hasn't been removed while we were obtaining
the lock */
VNLog(102, 2, vnodeNumber, (afs_int32) vnp);
if (vnp->disk.type == vNull) {
if ((vnp->disk.type == vNull) || (vnp->cacheCheck == 0)){
if (vnp->nUsers-- == 1)
StickOnLruChain_r(vnp,vcp);
if (locktype == READ_LOCK)

View File

@ -138,7 +138,7 @@ typedef struct Vnode {
struct Volume
*volumePtr; /* Pointer to the volume containing this file*/
byte nUsers; /* Number of lwp's who have done a VGetVnode */
bit16 cacheCheck; /* Must equal the value in the volume Header
bit32 cacheCheck; /* Must equal the value in the volume Header
for the cache entry to be valid */
struct Lock lock; /* Internal lock */
#ifdef AFS_PTHREAD_ENV

View File

@ -709,6 +709,9 @@ private Volume *attach2(ec, path, header, partp, isbusy)
IH_INIT(vp->linkHandle, partp->device, header->parent,
header->linkTable);
vp->cacheCheck = ++VolumeCacheCheck;
/* just in case this ever rolls over */
if (!vp->cacheCheck)
vp->cacheCheck = ++VolumeCacheCheck;
vp->shuttingDown = 0;
vp->goingOffline = 0;
vp->nUsers = 1;

View File

@ -310,7 +310,7 @@ typedef struct Volume {
Added to vnode number for hash table index */
byte shuttingDown; /* This volume is going to be detached */
byte goingOffline; /* This volume is going offline */
bit16 cacheCheck; /* Online sequence number to be used to invalidate vnode cache entries
bit32 cacheCheck; /* Online sequence number to be used to invalidate vnode cache entries
that stayed around while a volume was offline */
short nUsers; /* Number of users of this volume header */
byte needsPutBack; /* For a volume utility, this flag is set if we need