]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: cm_ShutdownSCache corrections
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 15 Aug 2011 04:34:00 +0000 (00:34 -0400)
committerDerrick Brashear <shadow@dementix.org>
Mon, 15 Aug 2011 12:29:03 +0000 (05:29 -0700)
Obtain cm_scache.dirlock, cm_scache.rw and cm_scacheLock
in the correct order.

Do not release cm_scache.rw when it is not held.

Since the cm_scacheLock is being dropped, preserve the value
of scp->allNextp prior to dropping the lock.

Reviewed-on: http://gerrit.openafs.org/5279
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
(cherry picked from commit c58ae34f72d25434cd59228806ca59a6ff39a903)

Change-Id: I65f3c4be5436031cdd99d912b0277b54d4033bf6
Reviewed-on: http://gerrit.openafs.org/5282
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/WINNT/afsd/cm_scache.c

index 90615b0d531f659ecaf7a08a10d429c496c23a98..ef74caff47e54840ad0446d7523fb6fd87fabe0c 100644 (file)
@@ -580,18 +580,22 @@ cm_SuspendSCache(void)
 long
 cm_ShutdownSCache(void)
 {
-    cm_scache_t * scp;
+    cm_scache_t * scp, * nextp;
 
     lock_ObtainWrite(&cm_scacheLock);
 
     for ( scp = cm_data.allSCachesp; scp;
-          scp = scp->allNextp ) {
+          scp = nextp ) {
+        nextp = scp->allNextp;
+        lock_ReleaseWrite(&cm_scacheLock);
+#ifdef USE_BPLUS
+        lock_ObtainWrite(&scp->dirlock);
+#endif
+        lock_ObtainWrite(&scp->rw);
+        lock_ObtainWrite(&cm_scacheLock);
+
         if (scp->randomACLp) {
-            lock_ReleaseWrite(&cm_scacheLock);
-            lock_ObtainWrite(&scp->rw);
-            lock_ObtainWrite(&cm_scacheLock);
             cm_FreeAllACLEnts(scp);
-            lock_ReleaseWrite(&scp->rw);
         }
 
         if (scp->cbServerp) {
@@ -607,6 +611,7 @@ cm_ShutdownSCache(void)
             freeBtree(scp->dirBplus);
         scp->dirBplus = NULL;
         scp->dirDataVersion = CM_SCACHE_VERSION_BAD;
+        lock_ReleaseWrite(&scp->dirlock);
         lock_FinalizeRWLock(&scp->dirlock);
 #endif
         lock_FinalizeRWLock(&scp->rw);