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 */
};
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;
} /*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;
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) {
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) {
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));
cp += strlen(tcell->cellName)+1;
*aoutSize = cp - aout;
}
- ReleaseReadLock(&afs_xcell);
if (tcell) return 0;
else return EDOM;
}
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*/
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);
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);