]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs-getcell-pioctl-should-be-able-to-provide-complete-list-20020731
authorDerrick Brashear <shadow@dementia.org>
Wed, 31 Jul 2002 23:15:16 +0000 (23:15 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 31 Jul 2002 23:15:16 +0000 (23:15 +0000)
don't use the LRUq since it can make us miss cells. don't use the existant
index because it includes cell aliases

src/afs/afs.h
src/afs/afs_cell.c
src/afs/afs_pioctl.c
src/afs/afs_stats.h
src/venus/kdump.c
src/xstat/xstat_cm_test.c

index d164b5892108218d9c07f4508c68de935e12c576..e3fa64ad6020b33880597223d8ff3dadad5833e1 100644 (file)
@@ -201,6 +201,7 @@ struct cell {
     u_short vlport;                        /* volume server port */
     short states;                          /* state flags */
     short cellIndex;                       /* relative index number per cell */
+    short realcellIndex;                   /* as above but ignoring aliases */
     time_t timeout;                        /* data expire time, if non-zero */
     char *realName;                        /* who this cell is an alias for */
 };
index d8c01da190ad5468ccee246aa1767157b72f48b5..7b3a42e7797435939f79d810703f7db80aa5e8a9 100644 (file)
@@ -46,9 +46,9 @@ RCSID("$Header$");
 afs_rwlock_t afs_xcell;                        /* allocation lock for cells */
 struct afs_q CellLRU;
 afs_int32 afs_cellindex=0;
+afs_int32 afs_realcellindex=0;
 afs_uint32 afs_nextCellNum = 0x100;
 
-
 /* Local variables. */
 struct cell *afs_rootcell = 0;
 
@@ -420,6 +420,31 @@ struct cell *afs_GetCellByIndex(cellindex, locktype, refresh)
 } /*afs_GetCellByIndex*/
 
 
+struct cell *afs_GetRealCellByIndex(cellindex, locktype, refresh)
+    register afs_int32 cellindex;
+    afs_int32 locktype;
+    afs_int32 refresh;
+{
+    register struct cell *tc;
+    register struct afs_q *cq, *tq;
+
+    AFS_STATCNT(afs_GetCellByIndex);
+    ObtainWriteLock(&afs_xcell,102);
+    for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
+       tc = QTOC(cq); tq = QNext(cq);
+       if (tc->realcellIndex == cellindex) {
+           QRemove(&tc->lruq);
+           QAdd(&CellLRU, &tc->lruq);
+           ReleaseWriteLock(&afs_xcell);
+           if (refresh) afs_RefreshCell(tc);
+           return tc;
+       }
+    }
+    ReleaseWriteLock(&afs_xcell);
+    return (struct cell *) 0;
+} /*afs_GetRealCellByIndex*/
+
+
 afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport, timeout, aliasFor)
     int aflags;
     char *acellName;
@@ -487,6 +512,11 @@ afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport
        tc->vlport = (vlport ? vlport : AFS_VLPORT);
        afs_stats_cmperf.numCellsVisible++;
        newc++;
+       if (!aflags & CAlias) {
+           tc->realcellIndex = afs_realcellindex++;
+       } else {
+           tc->realcellIndex = -1;
+       }
     }
 
     if (aflags & CLinkedCell) {
@@ -516,7 +546,10 @@ afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport
     tc->timeout = timeout;
 
     /* Allow converting an alias into a real cell */
-    if (!(aflags & CAlias)) tc->states &= ~CAlias;
+    if (!(aflags & CAlias)) {
+       tc->states &= ~CAlias;
+       tc->realcellIndex = afs_realcellindex++;
+    }
  
     memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts));
     if (aflags & CAlias) {
index fe5c6c67bfdbb9d3f8c75c650536619b1d68bc58..945c07e742b27a5d13e16f6fa792040d77ce0e3b 100644 (file)
@@ -2392,17 +2392,7 @@ static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize)
 
     memcpy((char *)&whichCell, tp, sizeof(afs_int32));
     tp += sizeof(afs_int32);
-    ObtainReadLock(&afs_xcell);
-    for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
-       tcell = QTOC(cq); tq = QNext(cq);
-       if (tcell->states & CAlias) {
-           tcell = 0;
-           continue;
-       }
-       if (whichCell == 0) break;
-       tcell = 0;
-       whichCell--;
-    }
+    tcell = afs_GetRealCellByIndex(whichCell, READ_LOCK, 0);
     if (tcell) {
        cp = aout;
        memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32));
@@ -2416,7 +2406,6 @@ static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize)
        cp += strlen(tcell->cellName)+1;
        *aoutSize = cp - aout;
     }
-    ReleaseReadLock(&afs_xcell);
     if (tcell) return 0;
     else return EDOM;
 }
index 6fe1da442cfd28e4658889574bcdd74438d8607a..189ae73aec8085c14a28bc5239b15e1231c81e15 100644 (file)
@@ -455,6 +455,7 @@ struct afs_CMCallStats {
     afs_int32 C_afs_GetCell;   /* afs_resource.c*/
     afs_int32 C_afs_GetCellByIndex;    /* afs_resource.c*/
     afs_int32 C_afs_GetCellByName;     /* afs_resource.c*/
+    afs_int32 C_afs_GetRealCellByIndex;        /* afs_resource.c*/
     afs_int32 C_afs_NewCell;   /* afs_resource.c*/
     afs_int32 C_afs_GetUser;   /* afs_resource.c*/
     afs_int32 C_afs_PutUser;   /* afs_resource.c*/
index 35995bfd2214ccafb0a424bd1ba770398fc237d8..2ee696142c0288f7ce61fb02ac15056b919df1f9 100644 (file)
@@ -3950,6 +3950,7 @@ void print_cmstats(cmp)
     printf("\t%10d afs_GetCell\n",         cmp->callInfo.C_afs_GetCell);
     printf("\t%10d afs_GetCellByIndex\n",         cmp->callInfo.C_afs_GetCellByIndex);
     printf("\t%10d afs_GetCellByName\n",         cmp->callInfo.C_afs_GetCellByName);
+    printf("\t%10d afs_GetRealCellByIndex\n",         cmp->callInfo.C_afs_GetRealCellByIndex);
     printf("\t%10d afs_NewCell\n",         cmp->callInfo.C_afs_NewCell);
     printf("\t%10d CheckVLDB\n",         cmp->callInfo.C_CheckVLDB);
     printf("\t%10d afs_GetVolume\n",         cmp->callInfo.C_afs_GetVolume);
index 3c5d4c9a094c7038450f71e8ccda61e410a8295a..33e8364e005fd9c01baab571df98d02ebdff36cd 100644 (file)
@@ -451,6 +451,7 @@ print_cmCallStats()
     printf("\t%10d afs_GetCell\n",         cmp->callInfo.C_afs_GetCell);
     printf("\t%10d afs_GetCellByIndex\n",         cmp->callInfo.C_afs_GetCellByIndex);
     printf("\t%10d afs_GetCellByName\n",         cmp->callInfo.C_afs_GetCellByName);
+    printf("\t%10d afs_GetRealCellByIndex\n",         cmp->callInfo.C_afs_GetRealCellByIndex);
     printf("\t%10d afs_NewCell\n",         cmp->callInfo.C_afs_NewCell);
     printf("\t%10d CheckVLDB\n",         cmp->callInfo.C_CheckVLDB);
     printf("\t%10d afs_GetVolume\n",         cmp->callInfo.C_afs_GetVolume);