Windows: Fix caching of non-existing vols
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 1 May 2011 04:11:13 +0000 (00:11 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Mon, 2 May 2011 03:41:34 +0000 (20:41 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_volume.c

index 2afd6c6..5620895 100644 (file)
@@ -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);