From 72a48c34e79b6bf0ea251cf46122c973d1bf6555 Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Mon, 20 Feb 2017 20:16:47 -0500 Subject: [PATCH] DAFS: do not save or restore host state if CPS in progress If a fileserver is shutdown while one or more PR_GetHostCPS calls are in progress, this state is saved in the fsstate.dat file as hostFlags HCPS_WAITING, HCPS_INPROGRESS. Other hosts that are merely waiting will have HCPS_WAITING recorded. However, it makes no sense to restore host structs in this state, because the GetCPS calls will no longer be in progress. Once these hosts become active, they will block server threads and quickly cause all server threads to be exhausted as other CPS requests are blocked behind them. Instead, exclude these states from both save and restore. Reviewed-on: https://gerrit.openafs.org/12561 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot (cherry picked from commit 38a3f51fb8b3910ecdd7cacb06f35ec681990aea) Change-Id: I0e02543fd2e547fcc9f95db0973f09e5951a1da1 Reviewed-on: https://gerrit.openafs.org/12568 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Stephan Wiesand --- src/viced/host.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/viced/host.c b/src/viced/host.c index e4501c691d..4edcf43e4d 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -123,6 +123,9 @@ void h_TossStuff_r(struct host *host); #define IN_CLASSB_SUBNET 0xffffff00 #endif +#define hostBusyFlags(hf) \ + ((hf) & (HWHO_INPROGRESS | HCPS_INPROGRESS | HCPS_WAITING) \ + || !((hf) & ALTADDR)) /* get a new block of CEs and chain it on CEFree */ static void @@ -3007,8 +3010,7 @@ h_isBusy_r(struct host *host) return 1; } - if ((host->hostFlags & HWHO_INPROGRESS) || !(host->hostFlags & ALTADDR)) { - /* We shouldn't hit this if the host wasn't locked, but just in case... */ + if (hostBusyFlags(host->hostFlags)) { return 1; } @@ -3471,7 +3473,7 @@ h_stateRestoreHost(struct fs_dump_state * state) osi_Assert(hcps != NULL); } - if ((hdsk.hostFlags & HWHO_INPROGRESS) || !(hdsk.hostFlags & ALTADDR)) { + if (hostBusyFlags(hdsk.hostFlags)) { char hoststr[16]; ViceLog(0, ("h_stateRestoreHost: skipping host %s:%d due to invalid flags 0x%x\n", afs_inet_ntoa_r(hdsk.host, hoststr), (int)ntohs(hdsk.port),