From 483184b737ab3f6fee272136afc42b6372961d20 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Thu, 13 Oct 2005 19:53:39 +0000 Subject: [PATCH] STABLE14-vc-hashing-be-less-expensive-20050728 pullup the rest of this --- src/afs/afs_vcache.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 2e903d8a0..ecc5f6381 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -71,7 +71,7 @@ struct afs_q VLRU; /*vcache LRU */ afs_int32 vcachegen = 0; unsigned int afs_paniconwarn = 0; struct vcache *afs_vhashT[VCSIZE]; -struct afs_q afs_vhashTV[VCSIZE]; +struct vcache *afs_vhashTV[VCSIZE]; static struct afs_cbr *afs_cbrHashT[CBRSIZE]; afs_int32 afs_bulkStatsLost; int afs_norefpanic = 0; @@ -132,8 +132,8 @@ int afs_FlushVCache(struct vcache *avc, int *slept) { /*afs_FlushVCache */ - afs_int32 i, code; - struct vcache **uvc, *wvc; + afs_int32 i, code, j; + struct vcache **uvc, *wvc, **uvc2, *wvc2; *slept = 0; AFS_STATCNT(afs_FlushVCache); @@ -181,8 +181,17 @@ afs_FlushVCache(struct vcache *avc, int *slept) } /* remove entry from the volume hash table */ - QRemove(&avc->vhashq); - + j = VCHashV(&avc->fid); + uvc2 = &afs_vhashTV[j]; + for (wvc2 = *uvc2; wvc2; uvc2 = &wvc2->vhnext, wvc2 = *uvc2) { + if (avc == wvc2) { + *uvc2 = avc->vhnext; + avc->vhnext = (struct vcache *)NULL; + break; + } + } + if (!wvc || !wvc2) + osi_Panic("flushvcache"); /* not in correct hash bucket */ if (avc->mvid) osi_FreeSmallSpace(avc->mvid); avc->mvid = (struct VenusFid *)0; @@ -599,6 +608,7 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) #ifdef AFS_OSF_ENV struct vcache *nvc; #endif /* AFS_OSF_ENV */ + struct afs_q *tq, *uq; int code, fv_slept; AFS_STATCNT(afs_NewVCache); @@ -884,8 +894,8 @@ restart: j = VCHashV(afid); tvc->hnext = afs_vhashT[i]; - afs_vhashT[i] = tvc; - QAdd(&afs_vhashTV[i], &tvc->vhashq); + tvc->vhnext = afs_vhashTV[j]; + afs_vhashT[i] = afs_vhashTV[j] = tvc; if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { refpanic("NewVCache VLRU inconsistent"); @@ -2862,9 +2872,10 @@ afs_vcacheInit(int astatSize) #endif /* AFS_SGI62_ENV */ } #endif + QInit(&VLRU); - for(i = 0; i < VCSIZE; ++i) - QInit(&afs_vhashTV[i]); + + } /* @@ -2940,7 +2951,7 @@ shutdown_vcache(void) afs_FreeAllAxs(&(tvc->Access)); } - afs_vhashT[i] = 0; + afs_vhashT[i] = afs_vhashTV[i] = 0; } } /* @@ -2965,6 +2976,5 @@ shutdown_vcache(void) RWLOCK_INIT(&afs_xvcache, "afs_xvcache"); LOCK_INIT(&afs_xvcb, "afs_xvcb"); QInit(&VLRU); - for(i = 0; i < VCSIZE; ++i) - QInit(&afs_vhashTV[i]); + } -- 2.39.5