]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-vc-hashing-be-less-expensive-20050728
authorChas Williams <chas@cmf.nrl.navy.mil>
Thu, 13 Oct 2005 19:08:39 +0000 (19:08 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 13 Oct 2005 19:08:39 +0000 (19:08 +0000)
use an afs_q so this is less expensive to deal with

src/afs/LINUX/osi_vfsops.c
src/afs/afs.h
src/afs/afs_callback.c
src/afs/afs_pioctl.c
src/afs/afs_prototypes.h
src/afs/afs_vcache.c

index 3b6ec40e7fb0d0da3e683cfdad9a5127b9ff0961..8d6ce9bddc95cc7fb5e79e5b149512ae8d0803f4 100644 (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)
index 7b2496e7e74e8b5fbe3bc5b1cf6d7f6c60b2e320..04d8287c7118f3cab267161fb8e54037b129bb75 100644 (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 */
@@ -618,7 +619,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;
@@ -1063,7 +1064,7 @@ extern afs_int32 afs_cacheFiles;  /*Size of afs_indexTable */
 extern afs_int32 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 */
index ba1617b5b1d1adb17c37557f601de95fbe2c3df0..e54d8850dfcff08762fa127ed713a1db452d8ca2 100644 (file)
@@ -400,12 +400,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)
index 2478bf8e6b3cd24f76f62f1ca5e0d9196976c72e..e98643ce57fab9276f8f27b220d81cace7771732 100644 (file)
@@ -2535,6 +2535,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)
@@ -2552,7 +2553,9 @@ DECL_PIOCTL(PFlushVolumeData)
  loop:
     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 (tvc->states & CVInit) {
                     ReleaseReadLock(&afs_xvcache);
index eb40bcd174ba1af4acdb1fde0a00e53a14fcafdd..ecddbea7eb36ea0629fc1afa26acf09dac59a7ce 100644 (file)
@@ -817,7 +817,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;
 
index ecc5f6381d3c32d25481dd59d9fbfc590ea0b362..2e903d8a0c8c21f8e5dc3aadb70b794973894dd6 100644 (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;
@@ -608,7 +599,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);
@@ -894,8 +884,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");
@@ -2872,10 +2862,9 @@ afs_vcacheInit(int astatSize)
 #endif /* AFS_SGI62_ENV */
     }
 #endif
-
     QInit(&VLRU);
-
-
+    for(i = 0; i < VCSIZE; ++i)
+       QInit(&afs_vhashTV[i]);
 }
 
 /*
@@ -2951,7 +2940,7 @@ shutdown_vcache(void)
 
                afs_FreeAllAxs(&(tvc->Access));
            }
-           afs_vhashT[i] = afs_vhashTV[i] = 0;
+           afs_vhashT[i] = 0;
        }
     }
     /*
@@ -2976,5 +2965,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]);
 }