From 4fc48af8346665004b566c80b2ec3b5146b6ab95 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Thu, 28 Jul 2005 15:38:36 +0000 Subject: [PATCH] vc-hashing-be-less-expensive-20050728 use an afs_q so this is less expensive to deal with --- src/afs/LINUX/osi_vfsops.c | 2 +- src/afs/afs.h | 5 +++-- src/afs/afs_callback.c | 5 ++++- src/afs/afs_pioctl.c | 5 ++++- src/afs/afs_prototypes.h | 2 +- src/afs/afs_vcache.c | 34 ++++++++++++---------------------- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index f81dc5d..a18ecbd 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -324,7 +324,7 @@ afs_clear_inode(struct inode *ip) if (vcp->vlruq.prev || vcp->vlruq.next) osi_Panic("inode freed while on LRU"); - if (vcp->hnext || vcp->vhnext) + if (vcp->hnext) osi_Panic("inode freed while still hashed"); #if !defined(STRUCT_SUPER_HAS_ALLOC_INODE) diff --git a/src/afs/afs.h b/src/afs/afs.h index 99c2216..412ebd1 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -329,6 +329,7 @@ struct conn { */ #define QTOV(e) ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vlruq))) - ((char *)(e))))) #define QTOC(e) ((struct cell *)((char *) (e))) +#define QTOVH(e) ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vhashq))) - ((char *)(e))))) #define SRVADDR_MH 1 #define SRVADDR_ISDOWN 0x20 /* same as SRVR_ISDOWN */ @@ -603,7 +604,7 @@ struct vcache { struct vcache *nextfree; /* next on free list (if free) */ #endif struct vcache *hnext; /* Hash next */ - struct vcache *vhnext; /* vol hash next */ + struct afs_q vhashq; /* Hashed per-volume list */ struct VenusFid fid; struct mstat { afs_size_t Length; @@ -1045,7 +1046,7 @@ extern afs_int32 afs_cacheFiles; /*Size of afs_indexTable */ extern afs_size_t afs_cacheBlocks; /*1K blocks in cache */ extern afs_int32 afs_cacheStats; /*Stat entries in cache */ extern struct vcache *afs_vhashT[VCSIZE]; /*Stat cache hash table */ -extern struct vcache *afs_vhashTV[VCSIZE]; /* cache hash table on volume */ +extern struct afs_q afs_vhashTV[VCSIZE]; /* cache hash table on volume */ extern afs_int32 afs_initState; /*Initialization state */ extern afs_int32 afs_termState; /* Termination state */ extern struct VenusFid afs_rootFid; /*Root for whole file system */ diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 49c6bb9..73bebfd 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -384,12 +384,15 @@ ClearCallBack(register struct rx_connection *a_conn, */ if (a_fid->Volume != 0) { if (a_fid->Vnode == 0) { + struct afs_q *tq, *uq; /* * Clear callback for the whole volume. Zip through the * hash chain, nullifying entries whose volume ID matches. */ i = VCHashV(&localFid); - for (tvc = afs_vhashTV[i]; tvc; tvc = tvc->vhnext) { + for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) { + uq = QPrev(tq); + tvc = QTOVH(tq); if (tvc->fid.Fid.Volume == a_fid->Volume) { tvc->callback = NULL; if (!localFid.Cell) diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index cc13e04..27cab48 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -2527,6 +2527,7 @@ DECL_PIOCTL(PFlushVolumeData) register struct vcache *tvc; register struct volume *tv; afs_int32 cell, volume; + struct afs_q *tq, *uq; AFS_STATCNT(PFlushVolumeData); if (!avc) @@ -2543,7 +2544,9 @@ DECL_PIOCTL(PFlushVolumeData) */ ObtainReadLock(&afs_xvcache); i = VCHashV(&avc->fid); - for (tvc = afs_vhashT[i]; tvc; tvc = tvc->vhnext) { + for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) { + uq = QPrev(tq); + tvc = QTOVH(tq); if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) { #if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) VN_HOLD(AFSTOV(tvc)); diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index f997aa4..0006896 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -818,7 +818,7 @@ extern afs_lock_t afs_xvcb; extern struct afs_q VLRU; extern afs_int32 vcachegen; extern unsigned int afs_paniconwarn; -extern struct vcache *afs_vhashT[VCSIZE]; +extern struct afs_q afs_vhashTV[VCSIZE]; extern afs_int32 afs_bulkStatsLost; extern int afs_norefpanic; diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index d006eb1..e0ab774 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 vcache *afs_vhashTV[VCSIZE]; +struct afs_q 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, j; - struct vcache **uvc, *wvc, **uvc2, *wvc2; + afs_int32 i, code; + struct vcache **uvc, *wvc; *slept = 0; AFS_STATCNT(afs_FlushVCache); @@ -181,17 +181,8 @@ afs_FlushVCache(struct vcache *avc, int *slept) } /* remove entry from the volume hash table */ - 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 */ + QRemove(&avc->vhashq); + if (avc->mvid) osi_FreeSmallSpace(avc->mvid); avc->mvid = (struct VenusFid *)0; @@ -603,7 +594,6 @@ 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); @@ -1038,8 +1028,8 @@ restart: j = VCHashV(afid); tvc->hnext = afs_vhashT[i]; - tvc->vhnext = afs_vhashTV[j]; - afs_vhashT[i] = afs_vhashTV[j] = tvc; + afs_vhashT[i] = tvc; + QAdd(&afs_vhashTV[i], &tvc->vhashq); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { refpanic("NewVCache VLRU inconsistent"); @@ -2724,10 +2714,9 @@ afs_vcacheInit(int astatSize) #endif /* AFS_SGI62_ENV */ } #endif - QInit(&VLRU); - - + for(i = 0; i < VCSIZE; ++i) + QInit(&afs_vhashTV[i]); } /* @@ -2803,7 +2792,7 @@ shutdown_vcache(void) afs_FreeAllAxs(&(tvc->Access)); } - afs_vhashT[i] = afs_vhashTV[i] = 0; + afs_vhashT[i] = 0; } } /* @@ -2828,5 +2817,6 @@ 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]); } -- 1.9.4