From: Derrick Brashear Date: Thu, 11 Aug 2011 15:11:01 +0000 (-0400) Subject: viced: avoid aborting on host table exhaustion X-Git-Tag: openafs-devel-1_7_1~154 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=a3b4cd3c7325c7878ec7b47008f0eec8bfcb1175 viced: avoid aborting on host table exhaustion 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 Tested-by: Derrick Brashear --- diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index d09ef968c..7e422c0 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -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; } diff --git a/src/viced/host.c b/src/viced/host.c index cf559e2..0630067 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -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); diff --git a/src/viced/host.h b/src/viced/host.h index e935353..58b2b93 100644 --- a/src/viced/host.h +++ b/src/viced/host.h @@ -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);