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

Change-Id: I7bf7e5af55646ea570c76e36a673900521a3582c
Reviewed-on: http://gerrit.openafs.org/8856
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 8563a59..fb69008 100644 (file)
@@ -2240,19 +2240,6 @@ AFSNotifyHardLink( IN AFSObjectInfoCB *ObjectInfo,
                                     &pResultCB->DirEnum.FileId))
                 {
 
-                    lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
-
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSNotifyHardLink Increment count on %wZ DE %p Cnt %d\n",
-                                  &pDirNode->NameInformation.FileName,
-                                  pDirNode,
-                                  lCount);
-
-                    ASSERT( lCount >= 0);
-
-                    AFSReleaseResource( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
                     try_return( ntStatus = STATUS_REPARSE);
                 }
                 else
@@ -2360,8 +2347,6 @@ AFSNotifyHardLink( IN AFSObjectInfoCB *ObjectInfo,
 
             TargetParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
 
-            AFSReleaseResource( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
 
@@ -2429,6 +2414,23 @@ AFSNotifyHardLink( IN AFSObjectInfoCB *ObjectInfo,
 
 try_exit:
 
+        if ( TargetDirectoryCB != NULL)
+        {
+
+            lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSNotifyHardLink Increment count on %wZ DE %p Cnt %d\n",
+                          &pDirNode->NameInformation.FileName,
+                          pDirNode,
+                          lCount);
+
+            ASSERT( lCount >= 0);
+
+            *TargetDirectoryCB = pDirNode;
+        }
+
         if ( bReleaseTargetParentLock)
         {
 
@@ -2446,12 +2448,6 @@ try_exit:
 
             AFSExFreePoolWithTag( pHardLinkCB, AFS_HARDLINK_REQUEST_TAG);
         }
-
-        if ( TargetDirectoryCB)
-        {
-
-            *TargetDirectoryCB = pDirNode;
-        }
     }
 
     return ntStatus;