Windows: Remove fallback from GetCaps to GetTime
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 1 Dec 2010 23:47:29 +0000 (18:47 -0500)
committerJeffrey Altman <jaltman@openafs.org>
Sat, 4 Dec 2010 23:32:38 +0000 (15:32 -0800)
If the file server responds to RXAFS_GetCapabilities with
RXGEN_OPCODE the server is up and there is no need to fallback to
RXAFS_GetTime.  Remove the code that performs the extra work.

Change-Id: Ieb0d1cce6f356a8988f2464227dec9b6cd9e6fcf
Reviewed-on: http://gerrit.openafs.org/3419
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_server.c

index e9751e1..32a5132 100644 (file)
@@ -166,8 +166,6 @@ cm_PingServer(cm_server_t *tsp)
        else {
            /* file server */
            code = RXAFS_GetCapabilities(rxconnp, &caps);
-           if (code == RXGEN_OPCODE)
-               code = RXAFS_GetTime(rxconnp, &secs, &usecs);
        }
        if (wasDown)
            rx_SetConnDeadTime(rxconnp, ConnDeadtimeout);
@@ -176,13 +174,13 @@ cm_PingServer(cm_server_t *tsp)
     }  /* got an unauthenticated connection to this server */
 
     lock_ObtainMutex(&tsp->mx);
-    if (code >= 0) {
+    if (code >= 0 || code == RXGEN_OPCODE) {
        /* mark server as up */
        tsp->flags &= ~CM_SERVERFLAG_DOWN;
         tsp->downTime = 0;
 
        /* we currently handle 32-bits of capabilities */
-       if (caps.Capabilities_len > 0) {
+       if (code != RXGEN_OPCODE && caps.Capabilities_len > 0) {
            tsp->capabilities = caps.Capabilities_val[0];
            xdr_free((xdrproc_t) xdr_Capabilities, &caps);
            caps.Capabilities_len = 0;
@@ -450,10 +448,6 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp)
 
         /* Process results of servers that support RXAFS_GetCapabilities */
         for (i=0; i<nconns; i++) {
-            /* Leave the servers that did not support GetCapabilities alone */
-            if (results[i] == RXGEN_OPCODE)
-                continue;
-
             if (conntimer[i])
                 rx_SetConnDeadTime(rxconns[i], ConnDeadtimeout);
             rx_PutConnection(rxconns[i]);
@@ -465,13 +459,13 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp)
             lock_ObtainMutex(&tsp->mx);
             wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
 
-            if (results[i] >= 0)  {
+            if (results[i] >= 0 || results[i] == RXGEN_OPCODE)  {
                 /* mark server as up */
                 tsp->flags &= ~CM_SERVERFLAG_DOWN;
                 tsp->downTime = 0;
 
                 /* we currently handle 32-bits of capabilities */
-                if (caps[i].Capabilities_len > 0) {
+                if (results[i] != RXGEN_OPCODE && caps[i].Capabilities_len > 0) {
                     tsp->capabilities = caps[i].Capabilities_val[0];
                     xdr_free((xdrproc_t) xdr_Capabilities, &caps[i]);
                     caps[i].Capabilities_len = 0;
@@ -560,137 +554,6 @@ static void cm_CheckServersMulti(afs_uint32 flags, cm_cell_t *cellp)
 
             cm_PutServer(tsp);
         }
-
-        /* 
-         * At this point we have handled any responses that did not indicate
-         * that RXAFS_GetCapabilities is not supported.
-         */
-        for ( i=0, j=0; i<nconns; i++) {
-            if (results[i] == RXGEN_OPCODE) {
-                if (i != j) {
-                    conns[j] = conns[i];
-                    rxconns[j] = rxconns[i];
-                    serversp[j] = serversp[i];
-                }
-                j++;
-            }
-        }
-        nconns = j;
-
-        if (nconns) {
-            /* Perform the multi call */
-            start = time(NULL);
-            multi_Rx(rxconns,nconns)
-            {
-                secs = usecs = 0;
-                multi_RXAFS_GetTime(&secs, &usecs);
-                end = time(NULL);
-                results[multi_i]=multi_error;
-                if ((start == end) && !multi_error)
-                    deltas[multi_i] = end - secs;
-            } multi_End;
-        }
-
-        /* Process Results of servers that only support RXAFS_GetTime */
-        for (i=0; i<nconns; i++) {
-            /* Leave the servers that did not support GetCapabilities alone */
-            if (conntimer[i])
-                rx_SetConnDeadTime(rxconns[i], ConnDeadtimeout);
-            rx_PutConnection(rxconns[i]);
-            cm_PutConn(conns[i]);
-
-            tsp = serversp[i];
-            cm_GCConnections(tsp);
-
-            lock_ObtainMutex(&tsp->mx);
-            wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
-
-            if (results[i] >= 0)  {
-                /* mark server as up */
-                tsp->flags &= ~CM_SERVERFLAG_DOWN;
-                tsp->downTime = 0;
-                tsp->capabilities = 0;
-
-                afs_inet_ntoa_r(tsp->addr.sin_addr.S_un.S_addr, hoststr);
-                osi_Log3(afsd_logp, "cm_MultiPingServer server %s (%s) is up with caps 0x%x",
-                          osi_LogSaveString(afsd_logp, hoststr), 
-                          tsp->type == CM_SERVER_VLDB ? "vldb" : "file",
-                          tsp->capabilities);
-
-                /* Now update the volume status if necessary */
-                if (wasDown) {
-                    cm_server_vols_t * tsrvp;
-                    cm_volume_t * volp;
-                    int i;
-
-                    for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) {
-                        for (i=0; i<NUM_SERVER_VOLS; i++) {
-                            if (tsrvp->ids[i] != 0) {
-                                cm_InitReq(&req);
-
-                                lock_ReleaseMutex(&tsp->mx);
-                                code = cm_FindVolumeByID(tsp->cellp, tsrvp->ids[i], cm_rootUserp,
-                                                         &req, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp);
-                                lock_ObtainMutex(&tsp->mx);
-                                if (code == 0) {
-                                    cm_UpdateVolumeStatus(volp, tsrvp->ids[i]);
-                                    cm_PutVolume(volp);
-                                }
-                            }
-                        }
-                    }
-                }
-            } else {
-                /* mark server as down */
-                if (!(tsp->flags & CM_SERVERFLAG_DOWN)) {
-                    tsp->flags |= CM_SERVERFLAG_DOWN;
-                    tsp->downTime = time(NULL);
-                }
-                if (code != VRESTARTING) {
-                    lock_ReleaseMutex(&tsp->mx);
-                    cm_ForceNewConnections(tsp);
-                    lock_ObtainMutex(&tsp->mx);
-                }
-                afs_inet_ntoa_r(tsp->addr.sin_addr.S_un.S_addr, hoststr);
-                osi_Log3(afsd_logp, "cm_MultiPingServer server %s (%s) is down with caps 0x%x",
-                          osi_LogSaveString(afsd_logp, hoststr), 
-                          tsp->type == CM_SERVER_VLDB ? "vldb" : "file",
-                          tsp->capabilities);
-
-                /* Now update the volume status if necessary */
-                if (!wasDown) {
-                    cm_server_vols_t * tsrvp;
-                    cm_volume_t * volp;
-                    int i;
-
-                    for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) {
-                        for (i=0; i<NUM_SERVER_VOLS; i++) {
-                            if (tsrvp->ids[i] != 0) {
-                                cm_InitReq(&req);
-
-                                lock_ReleaseMutex(&tsp->mx);
-                                code = cm_FindVolumeByID(tsp->cellp, tsrvp->ids[i], cm_rootUserp,
-                                                         &req, CM_GETVOL_FLAG_NO_LRU_UPDATE, &volp);
-                                lock_ObtainMutex(&tsp->mx);
-                                if (code == 0) {
-                                    cm_UpdateVolumeStatus(volp, tsrvp->ids[i]);
-                                    cm_PutVolume(volp);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (tsp->waitCount == 0)
-                tsp->flags &= ~CM_SERVERFLAG_PINGING;
-            else 
-                osi_Wakeup((LONG_PTR)tsp);
-            
-            lock_ReleaseMutex(&tsp->mx);
-
-            cm_PutServer(tsp);
-        }
     }
 
     if ((flags & CM_FLAG_CHECKVLDBSERVERS) ||