Support empty CellServDB entries like arla; this is useful to

tell dynroot about the existence of a cell without hard-coding
the server list (it will be fetched from AFSDB).
This commit is contained in:
Nickolai Zeldovich 2002-07-29 21:03:36 +00:00
parent b8ebb1a225
commit 4e13acfe3b
5 changed files with 31 additions and 28 deletions

View File

@ -1016,7 +1016,7 @@ extern struct brequest afs_brs[NBRS]; /* request structures */
extern struct cell *afs_GetCell();
extern struct cell *afs_GetCellNoLock();
extern struct cell *afs_GetCellByName();
extern struct cell *afs_GetCellByName2();
extern struct cell *afs_FindCellByName();
extern struct cell *afs_GetCellByIndex();
extern struct unixuser *afs_GetUser();
extern struct volume *afs_GetVolume();

View File

@ -293,8 +293,8 @@ long parm, parm2, parm3, parm4, parm5, parm6;
else {
AFS_COPYIN((char *)parm3, tcell.cellName, parm4, code);
if (!code)
afs_NewCell(tcell.cellName, tcell.hosts, parm5,
(char *)0, (u_short)0, (u_short)0, (int)0);
afs_NewCell(tcell.cellName, tcell.hosts, parm5, (char *)0,
(u_short)0, (u_short)0, (int)0, (char *)0);
}
}
} else if (parm == AFSOP_ADDCELL2) {
@ -323,8 +323,8 @@ long parm, parm2, parm3, parm4, parm5, parm6;
}
}
if (!code)
afs_NewCell(tbuffer1, tcell.hosts, cflags,
lcnamep, (u_short)0, (u_short)0, (int)0);
afs_NewCell(tbuffer1, tcell.hosts, cflags, lcnamep,
(u_short)0, (u_short)0, (int)0, (char *)0);
}
}
osi_FreeSmallSpace(tbuffer);

View File

@ -78,8 +78,6 @@ char afs_AfsdbHandler_ReqPending = 0;
char afs_AfsdbHandler_Completed = 0;
struct cell *afs_GetCellByName2();
int afs_strcasecmp(s1, s2)
register char *s1, *s2;
{
@ -228,8 +226,10 @@ void afs_RefreshCell(ac)
struct cell *tc;
int timeout;
/* Don't need to do anything if no timeout or it's not expired */
if (!ac->timeout || ac->timeout > osi_Time()) return;
if (ac->cellHosts[0]) /* If we already have some servers.. */
if (!ac->timeout || ac->timeout > osi_Time())
/* Don't refresh if not expired */
return;
if (afs_GetCellHostsFromDns(ac->cellName, cellHosts, &timeout, &realName))
/* In case of lookup failure, keep old data */
@ -244,7 +244,7 @@ void afs_RefreshCell(ac)
* Look up the entry we just updated, to compensate for
* uppercase-vs-lowercase lossage with DNS.
*/
tc = afs_GetCellByName2(realName, READ_LOCK, 0 /* no AFSDB */);
tc = afs_FindCellByName(realName, READ_LOCK);
if (tc) {
afs_NewCell(ac->cellName, 0, CAlias, (char *) 0, 0, 0,
@ -280,7 +280,7 @@ struct cell *afs_GetCellByName_Dns(acellName, locktype)
* Look up the entry we just updated, to compensate for
* uppercase-vs-lowercase lossage with DNS.
*/
tc = afs_GetCellByName2(realName, READ_LOCK, 0 /* no AFSDB */);
tc = afs_FindCellByName(realName, READ_LOCK);
if (!tc)
goto bad;
@ -295,7 +295,7 @@ struct cell *afs_GetCellByName_Dns(acellName, locktype)
if (realName)
afs_osi_Free(realName, strlen(realName) + 1);
return afs_GetCellByName2(acellName, locktype, 0);
return afs_FindCellByName(acellName, locktype);
bad:
if (realName)
@ -304,10 +304,9 @@ bad:
}
struct cell *afs_GetCellByName2(acellName, locktype, trydns)
struct cell *afs_FindCellByName(acellName, locktype)
register char *acellName;
afs_int32 locktype;
char trydns;
{
register struct cell *tc;
register struct afs_q *cq, *tq;
@ -332,19 +331,23 @@ retry:
return tc;
}
}
ReleaseWriteLock(&afs_xcell);
return trydns ? afs_GetCellByName_Dns(acellName, locktype)
: (struct cell *) 0;
} /*afs_GetCellByName2*/
ReleaseWriteLock(&afs_xcell);
return (struct cell *) 0;
} /*afs_FindCellByName*/
struct cell *afs_GetCellByName(acellName, locktype)
register char *acellName;
afs_int32 locktype;
{
return afs_GetCellByName2(acellName, locktype, 1);
struct cell *tc;
tc = afs_FindCellByName(acellName, locktype);
if (!tc)
tc = afs_GetCellByName_Dns(acellName, locktype);
return tc;
} /*afs_GetCellByName*/
static struct cell *afs_GetCellInternal(acell, locktype, holdxcell)
@ -431,9 +434,6 @@ afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport
register struct afs_q *cq, *tq;
AFS_STATCNT(afs_NewCell);
if (!(aflags & CAlias) && *acellHosts == 0)
/* need >= one host to gen cell # */
return EINVAL;
ObtainWriteLock(&afs_xcell,103);
@ -441,10 +441,13 @@ afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport
for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
tc = QTOC(cq); tq = QNext(cq);
if (afs_strcasecmp(tc->cellName, acellName) == 0) {
/* if the cell we've found has the correct name but no timeout,
/* If the cell we've found has the correct name but no timeout,
* and we're called with a non-zero timeout, bail out: never
* override static configuration entries with AFSDB ones. */
if (timeout && !tc->timeout) {
* override static configuration entries with AFSDB ones.
* One exception: if the original cell entry had no servers,
* it must get servers from AFSDB.
*/
if (timeout && !tc->timeout && tc->cellHosts[0]) {
ReleaseWriteLock(&afs_xcell);
return 0;
}

View File

@ -584,7 +584,7 @@ afs_DynrootVOPRemove(avc, acred, aname)
}
/* Check if this is an actual cell? */
c = afs_GetCellByName2(aname, READ_LOCK, 0 /* no AFSDB */);
c = afs_FindCellByName(aname, READ_LOCK);
if (c) {
afs_PutCell(c, READ_LOCK);
return EROFS;
@ -610,7 +610,7 @@ afs_DynrootVOPSymlink(avc, acred, aname, atargetName)
return EPERM;
/* Check if it's already a cell */
c = afs_GetCellByName2(aname, READ_LOCK, 0 /* no AFSDB */);
c = afs_FindCellByName(aname, READ_LOCK);
if (c) {
afs_PutCell(c, READ_LOCK);
return EEXIST;

View File

@ -856,7 +856,7 @@ struct afsconf_cell *acellInfo; {
bestce = tce;
}
}
if (!ambig && bestce) {
if (!ambig && bestce && bestce->cellInfo.numServers) {
*acellInfo = bestce->cellInfo; /* structure assignment */
if (aservice) {
tservice = afsconf_FindService(aservice);