DAFS: do not save or restore host state if CPS in progress 61/12561/3
authorMark Vitale <mvitale@sinenomine.net>
Tue, 21 Feb 2017 01:16:47 +0000 (20:16 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 10 Mar 2017 00:45:26 +0000 (19:45 -0500)
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.

Change-Id: I3fad67b70c96dc967d6f8e3a7b393cfda076c91d
Reviewed-on: https://gerrit.openafs.org/12561
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/viced/host.c

index 2b21a85..36f9e88 100644 (file)
@@ -107,6 +107,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
@@ -3174,8 +3177,7 @@ h_isBusy_r(struct host *host)
        return 1;
     }
 
-    if ((host->z.hostFlags & HWHO_INPROGRESS) || !(host->z.hostFlags & ALTADDR)) {
-       /* We shouldn't hit this if the host wasn't locked, but just in case... */
+    if (hostBusyFlags(host->z.hostFlags)) {
        return 1;
     }
 
@@ -3637,7 +3639,7 @@ h_stateRestoreHost(struct fs_dump_state * state)
        opr_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),