Windows: AFSInvalidateCache volume refcounts
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 25 Nov 2012 23:06:17 +0000 (18:06 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 29 Nov 2012 23:49:09 +0000 (15:49 -0800)
AFSInvalidateCache failed to release the volume reference count
when FileId is the volume root.   In the non-root case it released
it too early permitting a race with AFSPrimaryVolumeWorkerThread
calling AFSRemoveVolume().

Change-Id: I12b756e5a543a2ef791d716f660df1f4a7ae2327
Reviewed-on: http://gerrit.openafs.org/8516
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/afsrdr/kernel/lib/AFSGeneric.cpp

index 3a0fde8..94dddb5 100644 (file)
@@ -2000,8 +2000,6 @@ AFSInvalidateCache( IN AFSInvalidateCacheCB *InvalidateCB)
             ntStatus = AFSInvalidateVolume( pVolumeCB,
                                             InvalidateCB->Reason);
 
-            lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
-
             try_return( ntStatus);
         }
 
@@ -2016,14 +2014,6 @@ AFSInvalidateCache( IN AFSInvalidateCacheCB *InvalidateCB)
         else
         {
 
-            lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
-
-            AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
-                          AFS_TRACE_LEVEL_VERBOSE,
-                          "AFSInvalidateCache Decrement count on volume %08lX Cnt %d\n",
-                          pVolumeCB,
-                          pVolumeCB->VolumeReferenceCount);
-
             ullIndex = AFSCreateLowIndex( &InvalidateCB->FileID);
 
             ntStatus = AFSLocateHashEntry( pVolumeCB->ObjectInfoTree.TreeHead,
@@ -2081,6 +2071,18 @@ try_exit:
                           pObjectInfo,
                           lCount);
         }
+
+        if ( pVolumeCB != NULL)
+        {
+
+            lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSInvalidateCache Decrement count on volume %08lX Cnt %d\n",
+                          pVolumeCB,
+                          lCount);
+        }
     }
 
     return ntStatus;