From bd72450f8051f2191c91ea79d1f8b6330b3b2734 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sat, 11 Jan 2003 07:26:35 +0000 Subject: [PATCH] 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 --- src/vol/vnode.c | 2 +- src/vol/vnode.h | 2 +- src/vol/volume.c | 3 +++ src/vol/volume.h | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vol/vnode.c b/src/vol/vnode.c index d385631ce8..ee3e663b3d 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -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) diff --git a/src/vol/vnode.h b/src/vol/vnode.h index 5477444d24..360c9227c8 100644 --- a/src/vol/vnode.h +++ b/src/vol/vnode.h @@ -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 diff --git a/src/vol/volume.c b/src/vol/volume.c index db5da58650..9f825bfddc 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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; diff --git a/src/vol/volume.h b/src/vol/volume.h index f1dcc49986..9b6adbda3c 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -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