viced: avoid aborting on host table exhaustion
authorDerrick Brashear <shadow@dementia.org>
Thu, 11 Aug 2011 15:11:01 +0000 (11:11 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 12 Aug 2011 03:18:24 +0000 (20:18 -0700)
if we exhaust the host table, instead of aborting, return VBUSY at
the client, to defer until hopefully hosts are freed.

Change-Id: Ie8b026992bdde1b46117e6f592f9cf0ea4c85a7e
Reviewed-on: http://gerrit.openafs.org/5181
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/viced/afsfileprocs.c
src/viced/host.c
src/viced/host.h

index d09ef96..7e422c0 100644 (file)
@@ -346,7 +346,7 @@ CallPreamble(struct rx_call *acall, int activecall,
   retry:
     tclient = h_FindClient_r(*tconn);
     if (!tclient) {
-       ViceLog(0, ("CallPreamble: Couldn't get CPS. Too many lockers\n"));
+       ViceLog(0, ("CallPreamble: Couldn't get client.\n"));
        H_UNLOCK;
        return VBUSY;
     }
index cf559e2..0630067 100644 (file)
@@ -200,7 +200,7 @@ GetHTBlock(void)
 
     if (HTBlocks == h_MAXHOSTTABLES) {
        ViceLog(0, ("h_MAXHOSTTABLES reached\n"));
-       ShutDownAndCore(PANIC);
+       return;
     }
 
     block = (struct HTBlock *)malloc(sizeof(struct HTBlock));
@@ -233,7 +233,8 @@ GetHT(void)
 
     if (HTFree == NULL)
        GetHTBlock();
-    osi_Assert(HTFree != NULL);
+    if (HTFree == NULL)
+       return NULL;
     entry = HTFree;
     HTFree = entry->next;
     HTs++;
@@ -674,7 +675,7 @@ h_flushhostcps(afs_uint32 hostaddr, afs_uint16 hport)
  */
 #define        DEF_ROPCONS 2115
 
-struct host *
+static struct host *
 h_Alloc_r(struct rx_connection *r_con)
 {
     struct servent *serverentry;
@@ -684,6 +685,8 @@ h_Alloc_r(struct rx_connection *r_con)
 #endif /* FS_STATS_DETAILED */
 
     host = GetHT();
+    if (!host)
+       return NULL;
 
     host->host = rxr_HostOf(r_con);
     host->port = rxr_PortOf(r_con);
@@ -1951,6 +1954,8 @@ h_GetHost_r(struct rx_connection *tcon)
        }
     } else {
        host = h_Alloc_r(tcon); /* returned held and locked */
+       if (!host)
+           goto gethost_out;
        h_gethostcps_r(host, FT_ApproxTime());
        if (!(host->Console & 1)) {
            int pident = 0;
@@ -3362,6 +3367,7 @@ h_stateRestoreHost(struct fs_dump_state * state)
        osi_Assert(hcps != NULL);
     }
 
+    /* for restoring state, we better be able to get a host! */
     host = GetHT();
     osi_Assert(host != NULL);
 
index e935353..58b2b93 100644 (file)
@@ -215,8 +215,6 @@ extern int PrintCallBackStats(void);
 extern void *ShutDown(void *);
 extern void ShutDownAndCore(int dopanic);
 
-extern struct host *h_Alloc(struct rx_connection *r_con);
-extern struct host *h_Alloc_r(struct rx_connection *r_con);
 extern int h_Lookup_r(afs_uint32 hostaddr, afs_uint16 hport,
                      struct host **hostp);
 extern struct host *h_LookupUuid_r(afsUUID * uuidp);