From dd8b624cf73c98d8edab2b253d40b4c2589d44d0 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 1 May 2011 00:11:13 -0400 Subject: [PATCH] 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: I65534b78842b4887d2fde67162a9d854437001ed Reviewed-on: http://gerrit.openafs.org/4597 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman Reviewed-on: http://gerrit.openafs.org/4598 Reviewed-by: Derrick Brashear --- src/WINNT/afsd/cm_volume.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c index 2a0809c18..ba6607e59 100644 --- a/src/WINNT/afsd/cm_volume.c +++ b/src/WINNT/afsd/cm_volume.c @@ -187,6 +187,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); @@ -195,8 +196,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; } @@ -652,7 +654,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; @@ -1325,7 +1327,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); -- 2.39.5