Windows: mark volume status online during cm_MergeStatus
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 16 Oct 2009 19:31:02 +0000 (15:31 -0400)
committerJeffrey Altman <jaltman|account-1000011@unknown>
Sat, 17 Oct 2009 05:14:43 +0000 (22:14 -0700)
During cm_MergeStatus, if the volume status is not vl_online
mark it vl_online.  The volume must be online because an
AFSFetchStatus was just processed.  This change reduces the
amount of work that must be performed by the daemon thread's
volume status check.

LICENSE MIT

Reviewed-on: http://gerrit.openafs.org/669
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_scache.c

index 9028d8c..bee91c4 100644 (file)
@@ -1514,6 +1514,8 @@ void cm_MergeStatus(cm_scache_t *dscp,
                     cm_user_t *userp, cm_req_t *reqp, afs_uint32 flags)
 {
     afs_uint64 dataVersion;
+    struct cm_volume *volp = NULL;
+    struct cm_cell *cellp = NULL;
 
     // yj: i want to create some fake status for the /afs directory and the
     // entries under that directory
@@ -1579,7 +1581,7 @@ void cm_MergeStatus(cm_scache_t *dscp,
             scp->parentVnode = 0;
             scp->parentUnique = 0;
        }
-       return;
+       goto done;
     } else {
        scp->flags &= ~CM_SCACHEFLAG_EACCESS;
     }
@@ -1591,18 +1593,14 @@ void cm_MergeStatus(cm_scache_t *dscp,
     if (!(flags & CM_MERGEFLAG_FORCE) && 
         dataVersion < scp->dataVersion &&
         scp->dataVersion != CM_SCACHE_VERSION_BAD) {
-        struct cm_cell *cellp;
 
         cellp = cm_FindCellByID(scp->fid.cell, 0);
         if (scp->cbServerp) {
-            struct cm_volume *volp = NULL;
             cm_FindVolumeByID(cellp, scp->fid.volume, userp,
                               reqp, CM_GETVOL_FLAG_CREATE, &volp);
             osi_Log2(afsd_logp, "old data from server %x volume %s",
                       scp->cbServerp->addr.sin_addr.s_addr,
                       volp ? volp->namep : "(unknown)");
-            if (volp)
-                cm_PutVolume(volp);
         }
         osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
                   scp, scp->dataVersion, dataVersion);
@@ -1634,7 +1632,7 @@ void cm_MergeStatus(cm_scache_t *dscp,
          * infinite loop.  So we just grin and bear it.
          */
         if (!(scp->flags & CM_SCACHEFLAG_RO))
-            return;
+            goto done;
     }       
 
     scp->volumeCreationDate = volsyncp->spare1;       /* volume creation date */
@@ -1766,6 +1764,29 @@ void cm_MergeStatus(cm_scache_t *dscp,
      * have completed yet.
      */
     cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_FETCHSTATUS);
+
+    /*
+     * We just successfully merged status on the stat cache object.
+     * This means that the associated volume must be online.
+     */
+    if (!volp) {
+        if (!cellp)
+            cellp = cm_FindCellByID(scp->fid.cell, 0);
+        cm_FindVolumeByID(cellp, scp->fid.volume, userp, reqp, 0, &volp);
+    }
+    if (volp) {
+        cm_vol_state_t *statep = cm_VolumeStateByID(volp, scp->fid.volume);
+        if (statep->state != vl_online) {
+            lock_ObtainWrite(&volp->rw);
+            cm_VolumeStatusNotification(volp, statep->ID, statep->state, vl_online);
+            statep->state = vl_online;
+            lock_ReleaseWrite(&volp->rw);
+        }
+    }
+  done:
+    if (volp)
+        cm_PutVolume(volp);
+
 }
 
 /* note that our stat cache info is incorrect, so force us eventually