]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
vol: attach2 must always return with VOL_LOCK held
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 28 Oct 2010 04:37:03 +0000 (00:37 -0400)
committerDerrick Brashear <shadow@dementia.org>
Wed, 3 Nov 2010 10:47:14 +0000 (03:47 -0700)
attach2() is required to return with the VOL_LOCK held
even though it is called without it.  This must be true
for error conditions as well.  Not all error paths are
obtaining the VOL_LOCK before returning.  Add out paths for
lock held and lock unheld error cases.

(cherry picked from commit 58901738ad6280d0777dd8e77f8c09cc45da04bc)
Reviewed-on: http://gerrit.openafs.org/3177
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Change-Id: I6918987cd784e4e550c2525b537bda290dbacae8
Reviewed-on: http://gerrit.openafs.org/3221
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/libafsrpc/afsrpc.def
src/vol/volume.c

index 57735130555ad060ec51e651c70e946bb12fc890..39f08b2036bb82af42d806a0f3a340c72625e71f 100755 (executable)
@@ -266,7 +266,7 @@ EXPORTS
 ;       rx_FreeStatistics                       @271
        rx_SetConnHardDeadTime                  @272
        rx_SetConnIdleDeadTime                  @273
-       rx_InterruptCall                        @274
+;      rx_InterruptCall                        @274
         osi_Panic                              @275
 
 ; for performance testing
index 4530d3557ccb411c326fc5965925a4aabc0cf74a..552f8eee841f1769b7d46f5774585a1a1ea65597 100644 (file)
@@ -3098,7 +3098,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
     if (*ec == VNOVOL) {
        /* if the volume doesn't exist, skip straight to 'error' so we don't
         * request a salvage */
-       goto error;
+       goto unlocked_error;
     }
 
     if (!*ec) {
@@ -3185,17 +3185,15 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
        VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, VOL_SALVAGE_INVALIDATE_HEADER);
        vp->nUsers = 0;
 
-       goto error;
+       goto locked_error;
     } else if (*ec) {
        /* volume operation in progress */
-       VOL_LOCK;
-       goto error;
+       goto unlocked_error;
     }
 #else /* AFS_DEMAND_ATTACH_FS */
     if (*ec) {
        Log("VAttachVolume: Error attaching volume %s; volume needs salvage; error=%u\n", path, *ec);
-        VOL_LOCK;
-       goto error;
+       goto unlocked_error;
     }
 #endif /* AFS_DEMAND_ATTACH_FS */
 
@@ -3214,7 +3212,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
        *ec = VSALVAGE;
 #endif /* AFS_DEMAND_ATTACH_FS */
 
-       goto error;
+       goto locked_error;
     }
 
     VOL_LOCK;
@@ -3237,7 +3235,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
        *ec = VSALVAGE;
 #endif /* AFS_DEMAND_ATTACH_FS */
 
-       goto error;
+       goto locked_error;
     }
 
     if (programType == fileServer && V_destroyMe(vp) == DESTROY_ME) {
@@ -3258,7 +3256,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
        Log("VAttachVolume: volume %s is junk; it should be destroyed at next salvage\n", path);
        *ec = VNOVOL;
        forcefree = 1;
-       goto error;
+       goto locked_error;
     }
 
     vp->vnodeIndex[vSmall].bitmap = vp->vnodeIndex[vLarge].bitmap = NULL;
@@ -3274,7 +3272,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
 #endif /* AFS_DEMAND_ATTACH_FS */
                Log("VAttachVolume: error getting bitmap for volume (%s)\n",
                    path);
-               goto error;
+               goto locked_error;
            }
        }
     }
@@ -3322,7 +3320,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
 #else /* !AFS_DEMAND_ATTACH_FS */
            *ec = VSALVAGE;
 #endif /* !AFS_DEMAND_ATTACh_FS */
-           goto error;
+           goto locked_error;
        }
     }
 
@@ -3362,7 +3360,7 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
 #ifdef AFS_DEMAND_ATTACH_FS
            vp->nUsers = 0;
 #endif
-           goto error;
+           goto locked_error;
        }
     } else {
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -3389,7 +3387,9 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp,
 
     return vp;
 
- error:
+unlocked_error:
+    VOL_LOCK;
+locked_error:
 #ifdef AFS_DEMAND_ATTACH_FS
     if (!VIsErrorState(V_attachState(vp))) {
        VChangeState_r(vp, error_state);