Updates to Jake's RTT based server ranking (Gerrit 317)
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 17 Aug 2009 16:23:57 +0000 (12:23 -0400)
committerJeffrey Altman <jaltman|account-1000011@unknown>
Mon, 26 Oct 2009 14:31:40 +0000 (07:31 -0700)
Remove check on powerStateSuspend in cm_Daemon()

Update the server Reference lists if the ranking changes.

Change-Id: Id290e0f98c616a12f4f8b1746dca58ad7a0f06ce
Reviewed-on: http://gerrit.openafs.org/729
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jacob Thebault-Spieker <summatusmentis@gmail.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_daemon.c
src/WINNT/afsd/cm_server.c

index e71fbbe..48c859d 100644 (file)
@@ -519,7 +519,7 @@ void cm_Daemon(long parm)
            lastServerRankCheck = now;
            osi_Log0(afsd_logp, "cm_Daemon RankServer");
            cm_RankUpServers();
-           if(daemon_ShutdownFlag == 1 || powerStateSuspended)
+           if(daemon_ShutdownFlag == 1)
                break;
            now = osi_Time();
        }
index 33ff2dc..fa78028 100644 (file)
@@ -57,6 +57,7 @@ cm_RankServer(cm_server_t * tsp)
     afs_int32 code = 0; /* start with "success" */
     struct rx_debugPeer tpeer;
     afs_uint16 port;
+    afs_uint16 newRank;
 
     switch(tsp->type) {
        case CM_SERVER_VLDB:
@@ -77,12 +78,33 @@ cm_RankServer(cm_server_t * tsp)
 
     if(code == 0) {
        if((tsp->flags & CM_SERVERFLAG_PREF_SET))
-           tsp->ipRank = tsp->adminRank + ((int)(623 * log(tpeer.rtt) / 10) *
-                                       10 + 5);
+           newRank = tsp->adminRank +
+                ((int)(623 * log(tpeer.rtt) / 10) * 10 + 5);
        else /* rank has not been set by admin, derive rank from rtt */
-           tsp->ipRank = (int)(7200 * log(tpeer.rtt) / 5000) * 5000 + 5000;
+           newRank = (int)(7200 * log(tpeer.rtt) / 5000) * 5000 + 5000;
 
-       tsp->ipRank += (rand() & 0x000f); /* randomize */
+       newRank += (rand() & 0x000f); /* randomize */
+
+        if (abs(newRank - tsp->ipRank) > 0xf) {
+            tsp->ipRank = newRank;
+
+            lock_ReleaseMutex(&tsp->mx);
+            switch (tsp->type) {
+            case CM_SERVER_FILE:
+                /*
+                 * find volumes which might have RO copy
+                 * on server and change the ordering of
+                 * their RO list
+                 */
+                cm_ChangeRankVolume(tsp);
+                break;
+            case CM_SERVER_VLDB:
+                /* set preferences for an existing vlserver */
+                cm_ChangeRankCellVLServer(tsp);
+                break;
+            }
+            lock_ObtainMutex(&tsp->mx);
+        }
     }
 
     return code;