From: Jeffrey Altman Date: Sun, 1 May 2011 04:11:13 +0000 (-0400) Subject: Windows: Fix caching of non-existing vols X-Git-Tag: upstream/1.8.0_pre1^2~3775 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=66db3f38da5527d67631d85fd3ff5a9c77cc1f11;p=packages%2Fo%2Fopenafs.git Windows: Fix caching of non-existing vols In cm_UpdateVolumeLocation() the conditional that would trigger the immediate return of CM_ERROR_NOSUCHVOLUME was backwards which prevented the caching from working. cm_CheckOfflineVolumes() is called by the daemon thread to reset the status of offline volumes. Non-existing volumes are by definition offline and cannot be brought online. Therefore, the cm_CheckOfflineVolumes() function should skip volumes with the CM_VOLUMEFLAG_NOEXIST flag set. Change-Id: If4093132322e7dd02d71c0f18d6492abbea53e01 Reviewed-on: http://gerrit.openafs.org/4597 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index 2afd6c6ec..5620895be 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -190,6 +190,7 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * int freelance = 0; #endif afs_uint32 volType; + time_t now; lock_AssertWrite(&volp->rw); @@ -198,8 +199,9 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * * minutes and it did not exist, then avoid the RPC * and return No Such Volume immediately. */ + now = time(NULL); if ((volp->flags & CM_VOLUMEFLAG_NOEXIST) && - volp->lastUpdateTime + 600 < time(0)) + (now < volp->lastUpdateTime + 600)) { return CM_ERROR_NOSUCHVOLUME; } @@ -655,7 +657,7 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t * volp->vol[BACKVOL].state = bkNewstate; } - volp->lastUpdateTime = time(0); + volp->lastUpdateTime = time(NULL); if (code == 0) volp->flags &= ~CM_VOLUMEFLAG_RESET; @@ -1328,7 +1330,14 @@ void cm_CheckOfflineVolumes(void) for (volp = cm_data.volumeLRULastp; volp && !daemon_ShutdownFlag && !powerStateSuspended; volp=(cm_volume_t *) osi_QPrev(&volp->q)) { - if (volp->qflags & CM_VOLUME_QFLAG_IN_HASH) { + /* + * Skip volume entries that did not exist last time + * the vldb was queried. For those entries wait until + * the next actual request is received for the volume + * before checking its state. + */ + if ((volp->qflags & CM_VOLUME_QFLAG_IN_HASH) && + !(volp->flags & CM_VOLUMEFLAG_NOEXIST)) { InterlockedIncrement(&volp->refCount); lock_ReleaseRead(&cm_volumeLock); cm_CheckOfflineVolume(volp, 0);