Windows: AFSNotifyFileCreate() DirOpenReferenceCount handling
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 29 Dec 2012 05:36:44 +0000 (00:36 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 31 Jan 2013 19:19:50 +0000 (11:19 -0800)
This patchset consolidates the releasing of the DirOpenReferenceCount
within AFSNotifyFileCreate() into the try_exit block.  This clarifies
the logic and avoids duplicate code blocks.

Change-Id: I82e964f579f9e8b6e095291ace0bbe2cdac5af60
Reviewed-on: http://gerrit.openafs.org/8855
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
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/AFSCommSupport.cpp

index 821daba..8563a59 100644 (file)
@@ -1526,10 +1526,13 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
     LONG       lCount;
     LARGE_INTEGER liOldDataVersion;
     AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+    BOOLEAN bReleaseParentTreeLock = FALSE;
 
     __Enter
     {
 
+        *DirNode = NULL;
+
         //
         // Init the control block for the request
         //
@@ -1602,6 +1605,8 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
         AFSAcquireExcl( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                         TRUE);
 
+        bReleaseParentTreeLock = TRUE;
+
         if( ParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
         {
 
@@ -1642,21 +1647,8 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
                                     &pResultCB->DirEnum.FileId))
                 {
 
-                    lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
-
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n",
-                                  &pDirNode->NameInformation.FileName,
-                                  pDirNode,
-                                  lCount);
-
-                    ASSERT( lCount >= 0);
-
                     *DirNode = pDirNode;
 
-                    AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
                     try_return( ntStatus = STATUS_REPARSE);
                 }
                 else
@@ -1766,8 +1758,6 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
 
             ParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
 
-            AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
 
@@ -1833,8 +1823,6 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
                           ParentObjectInfo->DataVersion.QuadPart);
         }
 
-        AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
         //
         // Return the directory node
         //
@@ -1843,6 +1831,27 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
 
 try_exit:
 
+        if ( *DirNode != NULL)
+        {
+
+            lCount = InterlockedIncrement( &(*DirNode)->DirOpenReferenceCount);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n",
+                          &(*DirNode)->NameInformation.FileName,
+                          *DirNode,
+                          lCount);
+
+            ASSERT( lCount >= 0);
+        }
+
+        if ( bReleaseParentTreeLock)
+        {
+
+            AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+        }
+
         if( pResultCB != NULL)
         {