vc-hashing-be-less-expensive-20050728

use an afs_q so this is less expensive to deal with
This commit is contained in:
Chas Williams 2005-07-28 15:38:36 +00:00 committed by Derrick Brashear
parent 459636211c
commit 4fc48af834
6 changed files with 25 additions and 28 deletions

View File

@ -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)

View File

@ -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 */

View File

@ -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)

View File

@ -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));

View File

@ -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;

View File

@ -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]);
}