From: Jeffrey Altman Date: Sat, 4 Jul 2009 04:45:46 +0000 (+0000) Subject: DEVEL15-windows-optimizations-20090703 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=refs%2Fheads%2Fopenafs-devel-1_5_x DEVEL15-windows-optimizations-20090703 LICENSE MIT when performing offline volume checks, do so in most recently used order if the system is entering suspend state, short circuit the background daemon operations to avoid extra work that is going to fail when the network is shutdown behind the back of the service. (cherry picked from commit 46287f679023c8d1430c64d03e06933cf6121a24) --- diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c index 63e5c89..24019cf 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -45,6 +45,7 @@ int cm_bkgWaitingForCount; /* true if someone's waiting for cm_bkgQueueCount to cm_bkgRequest_t *cm_bkgListp; /* first elt in the list of requests */ cm_bkgRequest_t *cm_bkgListEndp; /* last elt in the list of requests */ +extern int powerStateSuspended; int daemon_ShutdownFlag = 0; static int cm_nDaemons = 0; static time_t lastIPAddrChange = 0; @@ -98,6 +99,10 @@ void cm_BkgDaemon(void * parm) lock_ObtainWrite(&cm_daemonLock); while (daemon_ShutdownFlag == 0) { + if (powerStateSuspended) { + Sleep(1000); + continue; + } if (!cm_bkgListEndp) { osi_SleepW((LONG_PTR)&cm_bkgListp, &cm_daemonLock); lock_ObtainWrite(&cm_daemonLock); @@ -406,6 +411,10 @@ void cm_Daemon(long parm) lastPerformanceCheck = now - cm_daemonPerformanceTuningInterval/2 * (rand() % cm_daemonPerformanceTuningInterval); while (daemon_ShutdownFlag == 0) { + if (powerStateSuspended) { + Sleep(1000); + continue; + } /* check to see if the listener threads halted due to network * disconnect or other issues. If so, attempt to restart them. */ @@ -449,11 +458,12 @@ void cm_Daemon(long parm) /* check down servers */ if ((bAddrChangeCheck || now > lastDownServerCheck + cm_daemonCheckDownInterval) && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastDownServerCheck = now; osi_Log0(afsd_logp, "cm_Daemon CheckDownServers"); cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } @@ -463,11 +473,12 @@ void cm_Daemon(long parm) /* check up servers */ if ((bAddrChangeCheck || now > lastUpServerCheck + cm_daemonCheckUpInterval) && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastUpServerCheck = now; osi_Log0(afsd_logp, "cm_Daemon CheckUpServers"); cm_CheckServers(CM_FLAG_CHECKUPSERVERS, NULL); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } @@ -478,56 +489,62 @@ void cm_Daemon(long parm) } if (now > lastVolCheck + cm_daemonCheckVolInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastVolCheck = now; cm_RefreshVolumes(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } if (cm_daemonCheckVolCBInterval && now > lastVolCBRenewalCheck + cm_daemonCheckVolCBInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastVolCBRenewalCheck = now; cm_VolumeRenewROCallbacks(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } if ((bAddrChangeCheck || now > lastBusyVolCheck + cm_daemonCheckOfflineVolInterval) && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastVolCheck = now; cm_CheckOfflineVolumes(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } if (now > lastCBExpirationCheck + cm_daemonCheckCBInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastCBExpirationCheck = now; cm_CheckCBExpiration(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } if (now > lastLockCheck + cm_daemonCheckLockInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastLockCheck = now; cm_CheckLocks(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } if (now > lastTokenCacheCheck + cm_daemonTokenCheckInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastTokenCacheCheck = now; cm_CheckTokenCache(now); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } @@ -551,16 +568,17 @@ void cm_Daemon(long parm) } } - if (daemon_ShutdownFlag == 1) { + if (daemon_ShutdownFlag == 1 || powerStateSuspended) { break; } if (cm_daemonPerformanceTuningInterval && now > lastPerformanceCheck + cm_daemonPerformanceTuningInterval && - daemon_ShutdownFlag == 0) { + daemon_ShutdownFlag == 0 && + powerStateSuspended == 0) { lastPerformanceCheck = now; cm_PerformanceTuningCheck(); - if (daemon_ShutdownFlag == 1) + if (daemon_ShutdownFlag == 1 || powerStateSuspended) break; now = osi_Time(); } diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index fbc7318..bafc02e 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -1298,15 +1298,21 @@ cm_CheckOfflineVolume(cm_volume_t *volp, afs_uint32 volID) } -/* called from the Daemon thread */ +/* + * called from the Daemon thread. + * when checking the offline status, check those of the most recently used volumes first. + */ void cm_CheckOfflineVolumes(void) { cm_volume_t *volp; afs_int32 refCount; extern int daemon_ShutdownFlag; + extern int powerStateSuspended; lock_ObtainRead(&cm_volumeLock); - for (volp = cm_data.allVolumesp; volp && !daemon_ShutdownFlag; volp=volp->allNextp) { + for (volp = cm_data.volumeLRULastp; + volp && !daemon_ShutdownFlag && !powerStateSuspended; + volp=(cm_volume_t *) osi_QPrev(&volp->q)) { if (volp->flags & CM_VOLUMEFLAG_IN_HASH) { InterlockedIncrement(&volp->refCount); lock_ReleaseRead(&cm_volumeLock);