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

(cherry picked from commit f2ab9fd440bcccb34e7875c06e00136fbefc10d1)

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 58836e698b2d6a9a6e55471ec3e4318667cea094..210544d7cb2dbe5c236c95a0c6bfaa17a38e0f56 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 ca69560d9a4e65dc9d0630a7cd925cd5fbf698ed..79a06809a5455cc79857b651cdf1926a5ba6e9b6 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;
 
@@ -417,6 +417,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;
@@ -484,6 +509,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) {
@@ -513,7 +543,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 c7123ab64af1f79e6b3388df99299f0cf885b434..1732443e8bdcb2947bb26b08f6463be9dd18b716 100644 (file)
@@ -2387,17 +2387,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));
@@ -2411,7 +2401,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 a0919dc8b419e99f877d6b5fb5c42a118c1ea541..d595c0c203cd1603414e95a793a8ab6b134e8f5a 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 de9071212a0ac043fd919305720694e54f3bc3a2..5fa821b4839c807eed585f0a318d999baa450f16 100644 (file)
@@ -3931,6 +3931,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);