]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: cm_UpdateVolumeLocation misplaced lock
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 2 Jul 2012 02:19:08 +0000 (22:19 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 3 Jul 2012 16:34:52 +0000 (09:34 -0700)
The volume->mx was obtained in the wrong place which resulted
in the potential of a panic caused by obtaining the mutex when
it was already held.

Change-Id: I812ed57bef93c60358591a2a1e19009fc6bb1a2d
Reviewed-on: http://gerrit.openafs.org/7654
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
src/WINNT/afsd/cm_volume.c

index 1c181209cf132cc34e1dadbb5d8e5bcf61186b5a..951e047b2bb9c686318a3b8ba938c2e482fe51c1 100644 (file)
@@ -312,6 +312,8 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *
         }
 
         _InterlockedOr(&volp->flags, CM_VOLUMEFLAG_UPDATING_VL);
+
+        /* Do not hold the volume lock across the RPC calls */
         lock_ReleaseWrite(&volp->rw);
 
         if (cellp->flags & CM_CELLFLAG_VLSERVER_INVALID)
@@ -321,45 +323,45 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *
         code = cm_GetEntryByName(cellp, volp->namep, &vldbEntry, &nvldbEntry,
                                  &uvldbEntry,
                                  &method, userp, reqp);
-    }
-
-    /* We can end up here with code == CM_ERROR_NOSUCHVOLUME if the base volume name
-     * does not exist and is not a numeric string but there might exist a .readonly volume.
-     * If the base name doesn't exist we will not care about the .backup that might be left
-     * behind since there should be no method to access it.
-     */
-    if (code == CM_ERROR_NOSUCHVOLUME &&
-        _atoi64(volp->namep) == 0 &&
-        volp->vol[RWVOL].ID == 0 &&
-        strlen(volp->namep) < (VL_MAXNAMELEN - 9)) {
-        char name[VL_MAXNAMELEN];
-
-        snprintf(name, VL_MAXNAMELEN, "%s.readonly", volp->namep);
 
-        /* now we have volume structure locked and held; make RPC to fill it */
-        code = cm_GetEntryByName(cellp, name, &vldbEntry, &nvldbEntry,
-                                 &uvldbEntry,
-                                 &method, userp, reqp);
-    }
+        /* We can end up here with code == CM_ERROR_NOSUCHVOLUME if the base volume name
+         * does not exist and is not a numeric string but there might exist a .readonly volume.
+         * If the base name doesn't exist we will not care about the .backup that might be left
+         * behind since there should be no method to access it.
+         */
+        if (code == CM_ERROR_NOSUCHVOLUME &&
+             _atoi64(volp->namep) == 0 &&
+             volp->vol[RWVOL].ID == 0 &&
+             strlen(volp->namep) < (VL_MAXNAMELEN - 9)) {
+            char name[VL_MAXNAMELEN];
+
+            snprintf(name, VL_MAXNAMELEN, "%s.readonly", volp->namep);
+
+            /* now we have volume structure locked and held; make RPC to fill it */
+            code = cm_GetEntryByName(cellp, name, &vldbEntry, &nvldbEntry,
+                                     &uvldbEntry,
+                                     &method, userp, reqp);
+        }
 
-    /*
-     * What if there was a volume rename?  The volume name no longer exists but the
-     * volume id might.  Try to refresh the volume location information based one
-     * of the readwrite or readonly volume id.
-     */
-    if (code == CM_ERROR_NOSUCHVOLUME) {
-        if (volp->vol[RWVOL].ID != 0) {
-            code = cm_GetEntryByID(cellp, volp->vol[RWVOL].ID, &vldbEntry, &nvldbEntry,
-                                    &uvldbEntry,
-                                    &method, userp, reqp);
-        } else if (volp->vol[ROVOL].ID != 0) {
-            code = cm_GetEntryByID(cellp, volp->vol[ROVOL].ID, &vldbEntry, &nvldbEntry,
-                                    &uvldbEntry,
-                                    &method, userp, reqp);
+        /*
+         * What if there was a volume rename?  The volume name no longer exists but the
+         * volume id might.  Try to refresh the volume location information based one
+         * of the readwrite or readonly volume id.
+         */
+        if (code == CM_ERROR_NOSUCHVOLUME) {
+            if (volp->vol[RWVOL].ID != 0) {
+                code = cm_GetEntryByID(cellp, volp->vol[RWVOL].ID, &vldbEntry, &nvldbEntry,
+                                       &uvldbEntry,
+                                       &method, userp, reqp);
+            } else if (volp->vol[ROVOL].ID != 0) {
+                code = cm_GetEntryByID(cellp, volp->vol[ROVOL].ID, &vldbEntry, &nvldbEntry,
+                                       &uvldbEntry,
+                                       &method, userp, reqp);
+            }
         }
+        lock_ObtainWrite(&volp->rw);
     }
 
-    lock_ObtainWrite(&volp->rw);
     if (code == 0) {
         afs_int32 flags;
         afs_int32 nServers;