Windows: Introduce NameArray Reference Counts
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 24 Jan 2013 23:55:24 +0000 (18:55 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 2 Feb 2013 17:04:01 +0000 (09:04 -0800)
Split the DirOpenReferenceCounts into those related to DirectoryCB
reference counting unrelated to the NameArrays and those that are
related to the NameArrays.  This helps track down the source of
overcounts and undercounts.

Change-Id: Ie3c6f15394fe116761e32ed4d7756a4bf6a5549f
Reviewed-on: http://gerrit.openafs.org/8959
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/common/AFSUserDefines.h
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSStructs.h

index 83652c8..38ba7a2 100644 (file)
 #define AFS_SUBSYSTEM_EXTENT_ACTIVE_COUNTING 0x00040000 // Extent Active Counts
 #define AFS_SUBSYSTEM_INIT_PROCESSING       0x00080000  // Redirector Initialization
 #define AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING 0x00100000  // Name Array Processing
+#define AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING 0x00200000  // Name Array DirectoryCB refcnts
 
 //
 // Invalidation Reasons
index ccceed1..dd342cb 100644 (file)
@@ -5016,9 +5016,9 @@ AFSInitNameArray( IN AFSDirectoryCB *DirectoryCB,
 
             pNameArray->LinkCount = 0;
 
-            lCount = InterlockedIncrement( &DirectoryCB->DirOpenReferenceCount);
+            lCount = InterlockedIncrement( &DirectoryCB->NameArrayReferenceCount);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+            AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSInitNameArray [NA:%p] Increment count on %wZ DE %p Cnt %d\n",
                           pNameArray,
@@ -5099,9 +5099,9 @@ AFSPopulateNameArray( IN AFSNameArrayHdr *NameArray,
 
         pCurrentElement->DirectoryCB = DirectoryCB->ObjectInformation->VolumeCB->DirectoryCB;
 
-        lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->DirOpenReferenceCount);
+        lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->NameArrayReferenceCount);
 
-        AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+        AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                       AFS_TRACE_LEVEL_VERBOSE,
                       "AFSPopulateNameArray [NA:%p] Increment count on volume %wZ DE %p Cnt %d\n",
                       NameArray,
@@ -5213,9 +5213,9 @@ AFSPopulateNameArrayFromRelatedArray( IN AFSNameArrayHdr *NameArray,
                 SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
             }
 
-            lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->DirOpenReferenceCount);
+            lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->NameArrayReferenceCount);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+            AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSPopulateNameArrayFromRelatedArray [NA:%p] Increment count on %wZ DE %p Cnt %d\n",
                           NameArray,
@@ -5281,9 +5281,9 @@ AFSFreeNameArray( IN AFSNameArrayHdr *NameArray)
 
             pCurrentElement = &NameArray->ElementArray[ lElement];
 
-            lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->DirOpenReferenceCount);
+            lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->NameArrayReferenceCount);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+            AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSFreeNameArray [NA:%p] Decrement count on %wZ DE %p Cnt %d\n",
                           NameArray,
@@ -5367,9 +5367,9 @@ AFSInsertNextElement( IN AFSNameArrayHdr *NameArray,
 
         lCount = InterlockedIncrement( &NameArray->Count);
 
-        lCount = InterlockedIncrement( &DirectoryCB->DirOpenReferenceCount);
+        lCount = InterlockedIncrement( &DirectoryCB->NameArrayReferenceCount);
 
-        AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+        AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                       AFS_TRACE_LEVEL_VERBOSE,
                       "AFSInsertNextElement [NA:%p] Increment count on %wZ DE %p Cnt %d\n",
                       NameArray,
@@ -5377,7 +5377,7 @@ AFSInsertNextElement( IN AFSNameArrayHdr *NameArray,
                       DirectoryCB,
                       lCount);
 
-        ASSERT( lCount >= 2);
+        ASSERT( lCount > 0);
 
         pCurrentElement->DirectoryCB = DirectoryCB;
 
@@ -5442,9 +5442,9 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
             try_return( pCurrentElement);
         }
 
-        lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->DirOpenReferenceCount);
+        lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->NameArrayReferenceCount);
 
-        AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+        AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                       AFS_TRACE_LEVEL_VERBOSE,
                       "AFSBackupEntry [NA:%p] Decrement count on %wZ DE %p Cnt %d\n",
                       NameArray,
@@ -5601,9 +5601,9 @@ AFSResetNameArray( IN AFSNameArrayHdr *NameArray,
 
             pCurrentElement = &NameArray->ElementArray[ lElement];
 
-            lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->DirOpenReferenceCount);
+            lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->NameArrayReferenceCount);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+            AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSResetNameArray [NA:%p] Decrement count on %wZ DE %p Cnt %d\n",
                           NameArray,
@@ -5631,9 +5631,9 @@ AFSResetNameArray( IN AFSNameArrayHdr *NameArray,
 
             NameArray->LinkCount = 0;
 
-            lCount = InterlockedIncrement( &DirectoryCB->DirOpenReferenceCount);
+            lCount = InterlockedIncrement( &DirectoryCB->NameArrayReferenceCount);
 
-            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+            AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_REF_COUNTING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSResetNameArray [NA:%p] Increment count on %wZ DE %p Cnt %d\n",
                           NameArray,
index f9b1019..5e0c190 100644 (file)
@@ -1085,6 +1085,7 @@ AFSPrimaryVolumeWorkerThread( IN PVOID Context)
 
                 if( pVolumeCB->ObjectInfoListHead == NULL &&
                     pVolumeCB->DirectoryCB->DirOpenReferenceCount <= 0 &&
+                    pVolumeCB->DirectoryCB->NameArrayReferenceCount <= 0 &&
                     pVolumeCB->VolumeReferenceCount == 1 &&
                     ( pVolumeCB->RootFcb == NULL ||
                       pVolumeCB->RootFcb->OpenReferenceCount == 0) &&
@@ -1277,6 +1278,7 @@ AFSPrimaryVolumeWorkerThread( IN PVOID Context)
                         {
 
                             if( pCurrentDirEntry->DirOpenReferenceCount > 0 ||
+                                pCurrentDirEntry->NameArrayReferenceCount > 0 ||
                                 ( pCurrentDirEntry->ObjectInformation->Fcb != NULL &&
                                   pCurrentDirEntry->ObjectInformation->Fcb->OpenReferenceCount > 0) ||
                                 liCurrentTime.QuadPart <= pCurrentDirEntry->ObjectInformation->LastAccessCount.QuadPart ||
@@ -1342,6 +1344,7 @@ AFSPrimaryVolumeWorkerThread( IN PVOID Context)
                                 {
 
                                     if( pCurrentDirEntry->DirOpenReferenceCount > 0 ||
+                                        pCurrentDirEntry->NameArrayReferenceCount > 0 ||
                                         ( pCurrentDirEntry->ObjectInformation->Fcb != NULL &&
                                           pCurrentDirEntry->ObjectInformation->Fcb->OpenReferenceCount > 0) ||
                                         liCurrentTime.QuadPart <= pCurrentDirEntry->ObjectInformation->LastAccessCount.QuadPart ||
index e4d47a9..9977f05 100644 (file)
@@ -436,6 +436,12 @@ typedef struct _AFS_DIRECTORY_CB
     LONG             DirOpenReferenceCount;
 
     //
+    // Current count of reference from Name Array entries
+    //
+
+    LONG             NameArrayReferenceCount;
+
+    //
     // File index used in directory enumerations
     //