Windows: Directory validation should purge data changes immediately
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 24 Apr 2012 00:18:20 +0000 (20:18 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 25 Apr 2012 01:37:11 +0000 (18:37 -0700)
During AFSEnumerateDirectory() and AFSVerifyDirectoryContent() calls
use AFSPerformObjectInvalidate() instead of AFSInvalidateObject()
to trigger the data purge.  This is necessary to avoid a race as
AFSInvalidateObject() will queue a work request that will be performed
after the metadata is updated.

Change-Id: Iaf09c6448927a037175cb4a83502fd4a1d210ef2
Reviewed-on: http://gerrit.openafs.org/7279
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp
src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp

index 77bf7e9..612e499 100644 (file)
@@ -643,6 +643,10 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                 if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE))
                 {
+                    //
+                    // The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
+                    //
+
                     InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
 
                     ClearFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
index 008d563..763c45d 100644 (file)
@@ -306,16 +306,14 @@ AFSEnumerateDirectory( IN GUID *AuthGroup,
                             LONG lCount;
                             AFSObjectInfoCB *pObjectInfo = pDirNode->ObjectInformation;
 
-                            lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
-
-                            AFSInvalidateObject( &pObjectInfo,
-                                                 AFS_INVALIDATE_DATA_VERSION);
+                            //
+                            // The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
+                            //
 
-                            if( pObjectInfo != NULL)
-                            {
+                            lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
 
-                                lCount = InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
-                            }
+                            AFSPerformObjectInvalidate( pObjectInfo,
+                                                        AFS_INVALIDATE_DATA_VERSION);
                         }
                         else
                         {
@@ -1070,16 +1068,14 @@ AFSVerifyDirectoryContent( IN AFSObjectInfoCB *ObjectInfoCB,
                         if( pObjectInfo->DataVersion.QuadPart != pCurrentDirEntry->DataVersion.QuadPart)
                         {
 
-                            lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
-
-                            AFSInvalidateObject( &pObjectInfo,
-                                                 AFS_INVALIDATE_DATA_VERSION);
+                            //
+                            // The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
+                            //
 
-                            if( pObjectInfo != NULL)
-                            {
+                            lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
 
-                                lCount = InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
-                            }
+                            AFSPerformObjectInvalidate( pObjectInfo,
+                                                        AFS_INVALIDATE_DATA_VERSION);
                         }
                         else
                         {