afsd -dynroot-sparse mode for hushed cells
[openafs.git] / src / afs / afs_cell.c
index b7553cb..89d385d 100644 (file)
@@ -33,7 +33,6 @@ afs_rwlock_t afs_xcell;               /* Export for cmdebug peeking at locks */
  * afs_LookupAFSDB: look up AFSDB for given cell name and create locally
  */
 
-#ifdef AFS_AFSDB_ENV
 afs_rwlock_t afsdb_client_lock;        /* Serializes client requests */
 afs_rwlock_t afsdb_req_lock;   /* Serializes client requests */
 static char afsdb_handler_running;     /* Protected by GLOCK */
@@ -59,6 +58,7 @@ afs_StopAFSDB(void)
     } else {
        afsdb_handler_shutdown = 1;
        afs_termState = AFSOP_STOP_RXEVENT;
+       afs_osi_Wakeup(&afs_termState);
     }
 }
 
@@ -74,7 +74,7 @@ int
 afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg)
 {
     afs_int32 timeout, code;
-    afs_int32 cellHosts[MAXCELLHOSTS];
+    afs_int32 cellHosts[AFS_MAXCELLHOSTS];
 
     if (afsdb_handler_shutdown)
        return -2;
@@ -90,7 +90,7 @@ afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg)
        if (timeout)
            timeout += osi_Time();
 
-       for (i = 0; i < MAXCELLHOSTS; i++) {
+       for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
            if (i >= hostCount)
                cellHosts[i] = 0;
            else
@@ -180,7 +180,6 @@ afs_GetCellHostsAFSDB(char *acellName)
     } else
        return ENOENT;
 }
-#endif
 
 
 /*! 
@@ -190,7 +189,6 @@ afs_GetCellHostsAFSDB(char *acellName)
 void
 afs_LookupAFSDB(char *acellName)
 {
-#ifdef AFS_AFSDB_ENV
     int code;
     char *cellName = afs_strdup(acellName);
 
@@ -198,7 +196,6 @@ afs_LookupAFSDB(char *acellName)
     afs_Trace2(afs_iclSetp, CM_TRACE_AFSDB, ICL_TYPE_STRING, cellName, 
                ICL_TYPE_INT32, code);
     afs_osi_FreeStr(cellName);
-#endif
 }
 
 /*
@@ -552,7 +549,7 @@ afs_NewCellAlias(char *alias, char *cell)
  */
 
 struct afs_q CellLRU;          /* Export for kdump */
-static char *afs_thiscell;
+static char *afs_thiscell = NULL;
 afs_int32 afs_cellindex;       /* Export for kdump */
 
 /*!
@@ -917,7 +914,7 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
        aflags &= ~CNoSUID;
     } else {
        tc = (struct cell *)afs_osi_Alloc(sizeof(struct cell));
-       memset((char *)tc, 0, sizeof(*tc));
+       memset(tc, 0, sizeof(*tc));
        tc->cellName = afs_strdup(acellName);
        tc->fsport = AFS_FSPORT;
        tc->vlport = AFS_VLPORT;
@@ -942,7 +939,7 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
     /* we don't want to keep pinging old vlservers which were down,
      * since they don't matter any more.  It's easier to do this than
      * to remove the server from its various hash tables. */
-    for (i = 0; i < MAXCELLHOSTS; i++) {
+    for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
        if (!tc->cellHosts[i])
            break;
        tc->cellHosts[i]->flags &= ~SRVR_ISDOWN;
@@ -974,8 +971,8 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
     tc->states |= aflags;
     tc->timeout = timeout;
     
-    memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts));
-    for (i = 0; i < MAXCELLHOSTS; i++) {
+    memset(tc->cellHosts, 0, sizeof(tc->cellHosts));
+    for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
        /* Get server for each host and link this cell in.*/    
        struct server *ts;
        afs_uint32 temp = acellHosts[i];
@@ -988,7 +985,7 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
        tc->cellHosts[i] = ts;
        afs_PutServer(ts, WRITE_LOCK);
     }
-    afs_SortServers(tc->cellHosts, MAXCELLHOSTS);      /* randomize servers */
+    afs_SortServers(tc->cellHosts, AFS_MAXCELLHOSTS);  /* randomize servers */
        
     /* New cell: Build and add to LRU cell queue. */
     if (newc) {
@@ -1008,7 +1005,8 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
     ReleaseWriteLock(&tc->lock);
     ReleaseWriteLock(&afs_xcell);
     afs_PutCell(tc, 0);
-    afs_DynrootInvalidate();
+    if (!aflags & CHush)
+       afs_DynrootInvalidate();
     return 0;
 
   bad:
@@ -1038,11 +1036,16 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags,
 void
 afs_CellInit(void)
 {
+    static char CellInit_done = 0;
+
+    if (CellInit_done)
+       return;
+
+    CellInit_done = 1;
+
     AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
-#ifdef AFS_AFSDB_ENV
     AFS_RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
     AFS_RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
-#endif
     QInit(&CellLRU);
 
     afs_cellindex = 0;
@@ -1058,6 +1061,11 @@ shutdown_cell(void)
     struct afs_q *cq, *tq;
     struct cell *tc;
 
+#ifdef AFS_CACHE_VNODE_PATH
+    if (cacheDiskType != AFS_FCACHE_TYPE_MEM) {
+       afs_osi_FreeStr(afs_cellname_inode.ufs);
+    }
+#endif
     AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
 
     for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
@@ -1099,7 +1107,7 @@ afs_RemoveCellEntry(struct server *srvp)
 
     /* Remove the server structure from the cell list - if there */
     ObtainWriteLock(&tc->lock, 200);
-    for (j = k = 0; j < MAXCELLHOSTS; j++) {
+    for (j = k = 0; j < AFS_MAXCELLHOSTS; j++) {
        if (!tc->cellHosts[j])
            break;
        if (tc->cellHosts[j] != srvp) {
@@ -1109,7 +1117,7 @@ afs_RemoveCellEntry(struct server *srvp)
     if (k == 0) {
        /* What do we do if we remove the last one? */
     }
-    for (; k < MAXCELLHOSTS; k++) {
+    for (; k < AFS_MAXCELLHOSTS; k++) {
        tc->cellHosts[k] = 0;
     }
     ReleaseWriteLock(&tc->lock);