Windows: AFSLocateNameEntry separate VolumeCB In/Out
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 8 Feb 2013 22:28:09 +0000 (17:28 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 12 Feb 2013 04:15:53 +0000 (20:15 -0800)
Tracking the VolumeCB references within AFSLocateNameEntry has
proven to be very error prone.  When the VolumeCB parameter is
an in/out parameter the caller cannot reliably determine whether
or not AFSLocateNameEntry replaced the updated the pointer and
whether it properly released the references.  This patchset
changes the interface so that VolumeCB and ParentDirectoryCB
have separate in and out parameters.  The caller is now responsible
for tracking its own Volume reference counts and AFSLocateNameEntry
obtains its own which will either be returned to the caller as a
non-NULL OutVolumeCB or released.

This patchset turns ParentDirectoryCB into an IN only parameter
and adds OutParentDirectoryCB as a dedicated OUT parameter.  However,
it does not alter any associated reference count logic.  That will
be implemented in a subsequent patchset.

Change-Id: Ic271d13496b4af80339c5ccd505fa04ec57b4700
Reviewed-on: http://gerrit.openafs.org/9086
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/AFSCreate.cpp
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h

index bff8341..b7d9e2b 100644 (file)
@@ -144,6 +144,8 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject,
     AFSNameArrayHdr    *pNameArray = NULL;
     AFSVolumeCB        *pVolumeCB = NULL;
     LONG                VolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+    AFSVolumeCB        *pNewVolumeCB = NULL;
+    LONG                NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
     AFSDirectoryCB     *pParentDirectoryCB = NULL, *pDirectoryCB = NULL;
     BOOLEAN             bReleaseParentDir = FALSE, bReleaseDir = FALSE;
     ULONG               ulParseFlags = 0;
@@ -443,12 +445,42 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject,
                                            &uniParsedFileName,
                                            pNameArray,
                                            ulNameProcessingFlags,
-                                           &pVolumeCB,
-                                           &VolumeReferenceReason,
+                                           pVolumeCB,
+                                           pParentDirectoryCB,
+                                           &pNewVolumeCB,
+                                           &NewVolumeReferenceReason,
                                            &pParentDirectoryCB,
                                            &pDirectoryCB,
                                            &uniComponentName);
 
+            //
+            // AFSLocateNameEntry returns pNewVolumeCB with a reference held
+            // even if pVolumeCB == pNewVolumeCB.  It is always safe to release
+            // the reference on pVolumeCB that was held prior to the call.
+            // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry
+            // will be released second.
+            //
+
+            lCount = AFSVolumeDecrement( pVolumeCB,
+                                         VolumeReferenceReason);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSCommonCreate Decrement count on volume %p Reason %u Cnt %d\n",
+                          pVolumeCB,
+                          VolumeReferenceReason,
+                          lCount);
+
+            pVolumeCB = pNewVolumeCB;
+
+            pNewVolumeCB = NULL;
+
+            VolumeReferenceReason = NewVolumeReferenceReason;
+
+            NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+
+            bReleaseVolume = (pVolumeCB != NULL);
+
             if( !NT_SUCCESS( ntStatus) &&
                 ntStatus != STATUS_OBJECT_NAME_NOT_FOUND)
             {
@@ -470,17 +502,8 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject,
                               &uniFileName,
                               ntStatus);
 
-                //
-                // We released any root volume locks in AFSLocateNameEntry on failure
-                // other than STATUS_OBJECT_NAME_NOT_FOUND
-                //
-
-                bReleaseVolume = FALSE;
-
                 bReleaseParentDir = FALSE;
 
-                VolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
-
                 try_return( ntStatus);
             }
 
@@ -499,12 +522,6 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject,
 
                 Irp->IoStatus.Information = IO_REPARSE;
 
-                //
-                // We released the volume lock above
-                //
-
-                bReleaseVolume = FALSE;
-
                 bReleaseParentDir = FALSE;
 
                 try_return( ntStatus);
index a152e1d..0d2c4cf 100644 (file)
@@ -6050,6 +6050,8 @@ AFSRetrieveFileAttributes( IN AFSDirectoryCB *ParentDirectoryCB,
     AFSNameArrayHdr    *pNameArray = NULL;
     AFSVolumeCB *pVolumeCB = NULL;
     LONG VolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+    AFSVolumeCB *pNewVolumeCB = NULL;
+    LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
     AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
     WCHAR *pwchBuffer = NULL;
     UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
@@ -6330,38 +6332,47 @@ AFSRetrieveFileAttributes( IN AFSDirectoryCB *ParentDirectoryCB,
                                        &uniParsedName,
                                        pNameArray,
                                        AFS_LOCATE_FLAGS_NO_MP_TARGET_EVAL,
-                                       &pVolumeCB,
-                                       &VolumeReferenceReason,
+                                       pVolumeCB,
+                                       pParentDirEntry,
+                                       &pNewVolumeCB,
+                                       &NewVolumeReferenceReason,
                                        &pParentDirEntry,
                                        &pDirectoryEntry,
                                        NULL);
 
+        //
+        // AFSLocateNameEntry returns pNewVolumeCB with a reference held
+        // even if pVolumeCB == pNewVolumeCB.  It is always safe to release
+        // the reference on pVolumeCB that was held prior to the call.
+        // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry
+        // will be released second.
+        //
+
+        lCount = AFSVolumeDecrement( pVolumeCB,
+                                     VolumeReferenceReason);
+
+        AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                      AFS_TRACE_LEVEL_VERBOSE,
+                      "AFSRetrieveFileAttributes Decrement count on volume %p Reason %u Cnt %d\n",
+                      pVolumeCB,
+                      VolumeReferenceReason,
+                      lCount);
+
+        pVolumeCB = pNewVolumeCB;
+
+        pNewVolumeCB = NULL;
+
+        VolumeReferenceReason = NewVolumeReferenceReason;
+
+        NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+
         if( !NT_SUCCESS( ntStatus) ||
             ntStatus == STATUS_REPARSE)
         {
 
-            //
-            // The volume lock was released on failure or reparse above
-            // Except for STATUS_OBJECT_NAME_NOT_FOUND
-            //
-
             if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
             {
 
-                if( pVolumeCB != NULL)
-                {
-
-                    lCount = AFSVolumeDecrement( pVolumeCB,
-                                                 VolumeReferenceReason);
-
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSRetrieveFileAttributes Decrement count on volume %p Reason %u Cnt %d\n",
-                                  pVolumeCB,
-                                  VolumeReferenceReason,
-                                  lCount);
-                }
-
                 if( pDirectoryEntry != NULL)
                 {
 
@@ -6394,8 +6405,6 @@ AFSRetrieveFileAttributes( IN AFSDirectoryCB *ParentDirectoryCB,
                 }
             }
 
-            pVolumeCB = NULL;
-
             try_return( ntStatus);
         }
 
@@ -6915,6 +6924,8 @@ AFSEvaluateRootEntry( IN AFSDirectoryCB *DirectoryCB,
     AFSNameArrayHdr    *pNameArray = NULL;
     AFSVolumeCB *pVolumeCB = NULL;
     LONG VolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+    AFSVolumeCB *pNewVolumeCB = NULL;
+    LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
     AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
     WCHAR *pwchBuffer = NULL;
     UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
@@ -7102,38 +7113,47 @@ AFSEvaluateRootEntry( IN AFSDirectoryCB *DirectoryCB,
                                        &uniParsedName,
                                        pNameArray,
                                        0,
-                                       &pVolumeCB,
+                                       pVolumeCB,
+                                       pParentDirEntry,
+                                       &pNewVolumeCB,
                                        &VolumeReferenceReason,
                                        &pParentDirEntry,
                                        &pDirectoryEntry,
                                        NULL);
 
+        //
+        // AFSLocateNameEntry returns pNewVolumeCB with a reference held
+        // even if pVolumeCB == pNewVolumeCB.  It is always safe to release
+        // the reference on pVolumeCB that was held prior to the call.
+        // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry
+        // will be released second.
+        //
+
+        lCount = AFSVolumeDecrement( pVolumeCB,
+                                     VolumeReferenceReason);
+
+        AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                      AFS_TRACE_LEVEL_VERBOSE,
+                      "AFSEvaluateRootEntry Decrement count on volume %p Reason %u Cnt %d\n",
+                      pVolumeCB,
+                      VolumeReferenceReason,
+                      lCount);
+
+        pVolumeCB = pNewVolumeCB;
+
+        pNewVolumeCB = NULL;
+
+        VolumeReferenceReason = NewVolumeReferenceReason;
+
+        NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+
         if( !NT_SUCCESS( ntStatus) ||
             ntStatus == STATUS_REPARSE)
         {
 
-            //
-            // The volume lock was released on failure or reparse above
-            // Except for STATUS_OBJECT_NAME_NOT_FOUND
-            //
-
             if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
             {
 
-                if( pVolumeCB != NULL)
-                {
-
-                    lCount = AFSVolumeDecrement( pVolumeCB,
-                                                 VolumeReferenceReason);
-
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSEvaluateRootEntry Decrement count on volume %p Reason %u Cnt %d\n",
-                                  pVolumeCB,
-                                  VolumeReferenceReason,
-                                  lCount);
-                }
-
                 if( pDirectoryEntry != NULL)
                 {
 
@@ -8363,6 +8383,8 @@ AFSGetObjectStatus( IN AFSGetStatusInfoCB *GetStatusInfo,
     NTSTATUS ntStatus = STATUS_SUCCESS;
     AFSVolumeCB *pVolumeCB = NULL;
     LONG VolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+    AFSVolumeCB *pNewVolumeCB = NULL;
+    LONG NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
     AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
     AFSObjectInfoCB *pObjectInfo = NULL;
     ULONGLONG   ullIndex = 0;
@@ -8560,12 +8582,40 @@ AFSGetObjectStatus( IN AFSGetStatusInfoCB *GetStatusInfo,
                                            pNameArray,
                                            AFS_LOCATE_FLAGS_NO_MP_TARGET_EVAL |
                                                AFS_LOCATE_FLAGS_NO_SL_TARGET_EVAL,
-                                           &pVolumeCB,
-                                           &VolumeReferenceReason,
+                                           pVolumeCB,
+                                           pParentDirEntry,
+                                           &pNewVolumeCB,
+                                           &NewVolumeReferenceReason,
                                            &pParentDirEntry,
                                            &pDirectoryEntry,
                                            NULL);
 
+            //
+            // AFSLocateNameEntry returns pNewVolumeCB with a reference held
+            // even if pVolumeCB == pNewVolumeCB.  It is always safe to release
+            // the reference on pVolumeCB that was held prior to the call.
+            // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry
+            // will be released second.
+            //
+
+            lCount = AFSVolumeDecrement( pVolumeCB,
+                                         VolumeReferenceReason);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSGetObjectStatus Decrement count on volume %p Reason %u Cnt %d\n",
+                          pVolumeCB,
+                          VolumeReferenceReason,
+                          lCount);
+
+            pVolumeCB = pNewVolumeCB;
+
+            pNewVolumeCB = NULL;
+
+            VolumeReferenceReason = NewVolumeReferenceReason;
+
+            NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID;
+
             if( !NT_SUCCESS( ntStatus) ||
                 ntStatus == STATUS_REPARSE)
             {
@@ -8578,20 +8628,6 @@ AFSGetObjectStatus( IN AFSGetStatusInfoCB *GetStatusInfo,
                 if( ntStatus == STATUS_OBJECT_NAME_NOT_FOUND)
                 {
 
-                    if( pVolumeCB != NULL)
-                    {
-
-                        lCount = AFSVolumeDecrement( pVolumeCB,
-                                                     VolumeReferenceReason);
-
-                        AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
-                                      AFS_TRACE_LEVEL_VERBOSE,
-                                      "AFSGetObjectStatus Decrement3 count on volume %p Reason %u Cnt %d\n",
-                                      pVolumeCB,
-                                      VolumeReferenceReason,
-                                      lCount);
-                    }
-
                     if( pDirectoryEntry != NULL)
                     {
 
index 45abe94..60ceb75 100644 (file)
@@ -42,7 +42,7 @@
 // AFSLocateNameEntry
 //
 // On entry, *VolumeCB must have a held ReferenceCount provided by
-// the caller which will be released.  On successful exit, *VolumeCB
+// the caller which will not be released.  On successful exit, *OutVolumeCB
 // will be assigned the new current volume with a held ReferenceCount.
 //
 // On entry, *ParentDirectoryCB must have a held DirOpenReferenceCount
 NTSTATUS
 AFSLocateNameEntry( IN GUID *AuthGroup,
                     IN PFILE_OBJECT FileObject,
-                    IN UNICODE_STRING *RootPathName,
+                    IN OUT UNICODE_STRING *RootPathName,
                     IN UNICODE_STRING *ParsedPathName,
                     IN AFSNameArrayHdr *NameArray,
                     IN ULONG Flags,
-                    IN OUT AFSVolumeCB **VolumeCB,
-                    IN OUT LONG *pVolumeReferenceReason,
-                    IN OUT AFSDirectoryCB **ParentDirectoryCB,
-                    OUT AFSDirectoryCB **DirectoryCB,
+                    IN AFSVolumeCB *VolumeCB,
+                    IN AFSDirectoryCB *ParentDirectoryCB,
+                    OUT AFSVolumeCB **OutVolumeCB,
+                    OUT LONG *OutVolumeReferenceReason,
+                    OUT AFSDirectoryCB **OutParentDirectoryCB,
+                    OUT AFSDirectoryCB **OutDirectoryCB,
                     OUT PUNICODE_STRING ComponentName)
 {
 
@@ -76,16 +78,18 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
     UNICODE_STRING    uniRelativeName, uniNoOpName;
     AFSObjectInfoCB  *pCurrentObject = NULL;
     AFSObjectInfoCB  *pParentObjectInfo = NULL;
-    AFSVolumeCB      *pCurrentVolume = *VolumeCB;
+    AFSVolumeCB      *pCurrentVolume = NULL;
     AFSVolumeCB      *pTargetVolume = NULL;
-    BOOLEAN           bReleaseCurrentVolume = TRUE;
-    LONG              VolumeReferenceReason = *pVolumeReferenceReason;
+    BOOLEAN           bReleaseCurrentVolume = FALSE;
+    LONG              VolumeReferenceReason;
     BOOLEAN           bSubstitutedName = FALSE;
     LONG              lCount;
 
     __Enter
     {
 
+        ASSERT( *OutVolumeCB != VolumeCB);
+
         AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
                       AFS_TRACE_LEVEL_VERBOSE_2,
                       "AFSLocateNameEntry (FO: %p) Processing full name %wZ\n",
@@ -120,7 +124,23 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
 
         pParentDirEntry = NULL;
 
-        pDirEntry = *ParentDirectoryCB;
+        pDirEntry = ParentDirectoryCB;
+
+        pCurrentVolume = VolumeCB;
+
+        VolumeReferenceReason = AFS_VOLUME_REFERENCE_LOCATE_NAME;
+
+        lCount = AFSVolumeIncrement( pCurrentVolume,
+                                     VolumeReferenceReason);
+
+        AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                      AFS_TRACE_LEVEL_VERBOSE,
+                      "AFSLocateNameEntry Increment count on volume %p Reason %u Cnt %d\n",
+                      pCurrentVolume,
+                      VolumeReferenceReason,
+                      lCount);
+
+        bReleaseCurrentVolume = TRUE;
 
         uniPathName = *ParsedPathName;
 
@@ -350,11 +370,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         // Pass back the directory entries
                         //
 
-                        *ParentDirectoryCB = pParentDirEntry;
+                        *OutParentDirectoryCB = pParentDirEntry;
+
+                        *OutDirectoryCB = pDirEntry;
+
+                        *OutVolumeCB = pCurrentVolume;
 
-                        *DirectoryCB = pDirEntry;
+                        *OutVolumeReferenceReason = VolumeReferenceReason;
 
-                        *VolumeCB = pCurrentVolume;
+                        bReleaseCurrentVolume = FALSE;
 
                         *RootPathName = uniFullPathName;
 
@@ -864,11 +888,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         // Pass back the directory entries
                         //
 
-                        *ParentDirectoryCB = pParentDirEntry;
+                        *OutParentDirectoryCB = pParentDirEntry;
 
-                        *DirectoryCB = pDirEntry;
+                        *OutDirectoryCB = pDirEntry;
 
-                        *VolumeCB = pCurrentVolume;
+                        *OutVolumeCB = pCurrentVolume;
+
+                        *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                        bReleaseCurrentVolume = FALSE;
 
                         *RootPathName = uniFullPathName;
 
@@ -991,11 +1019,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         // Pass back the directory entries
                         //
 
-                        *ParentDirectoryCB = pParentDirEntry;
+                        *OutParentDirectoryCB = pParentDirEntry;
+
+                        *OutDirectoryCB = pDirEntry;
 
-                        *DirectoryCB = pDirEntry;
+                        *OutVolumeCB = pCurrentVolume;
 
-                        *VolumeCB = pCurrentVolume;
+                        *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                        bReleaseCurrentVolume = FALSE;
 
                         *RootPathName = uniFullPathName;
 
@@ -1152,11 +1184,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                     // Pass back the directory entries
                     //
 
-                    *ParentDirectoryCB = pParentDirEntry;
+                    *OutParentDirectoryCB = pParentDirEntry;
+
+                    *OutDirectoryCB = pDirEntry;
 
-                    *DirectoryCB = pDirEntry;
+                    *OutVolumeCB = pCurrentVolume;
 
-                    *VolumeCB = pCurrentVolume;
+                    *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                    bReleaseCurrentVolume = FALSE;
 
                     *RootPathName = uniFullPathName;
                 }
@@ -1185,11 +1221,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                 // Pass back the directory entries
                 //
 
-                *ParentDirectoryCB = pParentDirEntry;
+                *OutParentDirectoryCB = pParentDirEntry;
+
+                *OutDirectoryCB = pDirEntry;
 
-                *DirectoryCB = pDirEntry;
+                *OutVolumeCB = pCurrentVolume;
 
-                *VolumeCB = pCurrentVolume;
+                *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                bReleaseCurrentVolume = FALSE;
 
                 *RootPathName = uniFullPathName;
 
@@ -1382,11 +1422,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                             // Pass back the directory entries
                             //
 
-                            *ParentDirectoryCB = pParentDirEntry;
+                            *OutParentDirectoryCB = pParentDirEntry;
+
+                            *OutDirectoryCB = NULL;
 
-                            *DirectoryCB = NULL;
+                            *OutVolumeCB = pCurrentVolume;
 
-                            *VolumeCB = pCurrentVolume;
+                            *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                            bReleaseCurrentVolume = FALSE;
 
                             if( ComponentName != NULL)
                             {
@@ -1544,11 +1588,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                                 // Pass back the directory entries
                                 //
 
-                                *ParentDirectoryCB = pParentDirEntry;
+                                *OutParentDirectoryCB = pParentDirEntry;
+
+                                *OutDirectoryCB = NULL;
+
+                                *OutVolumeCB = pCurrentVolume;
 
-                                *DirectoryCB = NULL;
+                                *OutVolumeReferenceReason = VolumeReferenceReason;
 
-                                *VolumeCB = pCurrentVolume;
+                                bReleaseCurrentVolume = FALSE;
 
                                 if( ComponentName != NULL)
                                 {
@@ -1675,7 +1723,7 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
 
                     AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
                                   AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSLocateNameEntry Increment5 count on %wZ DE %p Ccb %p Cnt %d\n",
+                                  "AFSLocateNameEntry Increment6 count on %wZ DE %p Ccb %p Cnt %d\n",
                                   &pDirEntry->NameInformation.FileName,
                                   pDirEntry,
                                   NULL,
@@ -1838,11 +1886,15 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                     // Pass back the directory entries
                     //
 
-                    *ParentDirectoryCB = pParentDirEntry;
+                    *OutParentDirectoryCB = pParentDirEntry;
 
-                    *DirectoryCB = NULL;
+                    *OutDirectoryCB = NULL;
 
-                    *VolumeCB = pCurrentVolume;
+                    *OutVolumeCB = pCurrentVolume;
+
+                    *OutVolumeReferenceReason = VolumeReferenceReason;
+
+                    bReleaseCurrentVolume = FALSE;
 
                     if( ComponentName != NULL)
                     {
@@ -2044,24 +2096,6 @@ try_exit:
                 ASSERT( lCount >= 0);
             }
 
-            if( bReleaseCurrentVolume)
-            {
-
-                ASSERT( pCurrentVolume->VolumeReferenceCount > 0);
-
-                lCount = AFSVolumeDecrement( pCurrentVolume,
-                                             VolumeReferenceReason);
-
-                AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
-                              AFS_TRACE_LEVEL_VERBOSE,
-                              "AFSLocateNameEntry Decrement3 count on volume %p Reason %u Cnt %d\n",
-                              pCurrentVolume,
-                              VolumeReferenceReason,
-                              lCount);
-
-                bReleaseCurrentVolume = FALSE;
-            }
-
             if( RootPathName->Buffer != uniFullPathName.Buffer)
             {
 
@@ -2071,41 +2105,54 @@ try_exit:
         else
         {
 
-            if( *ParentDirectoryCB != NULL)
+            if( *OutParentDirectoryCB != NULL)
             {
 
                 AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
                               AFS_TRACE_LEVEL_VERBOSE,
                               "AFSLocateNameEntry Count on Parent %wZ DE %p Ccb %p Cnt %d\n",
-                              &(*ParentDirectoryCB)->NameInformation.FileName,
-                              *ParentDirectoryCB,
+                              &(*OutParentDirectoryCB)->NameInformation.FileName,
+                              *OutParentDirectoryCB,
                               NULL,
-                              (*ParentDirectoryCB)->DirOpenReferenceCount);
+                              (*OutParentDirectoryCB)->DirOpenReferenceCount);
             }
 
-            if( *DirectoryCB != NULL)
+            if( *OutDirectoryCB != NULL)
             {
 
                 AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
                               AFS_TRACE_LEVEL_VERBOSE,
                               "AFSLocateNameEntry Count on %wZ DE %p Ccb %p Cnt %d\n",
-                              &(*DirectoryCB)->NameInformation.FileName,
-                              *DirectoryCB,
+                              &(*OutDirectoryCB)->NameInformation.FileName,
+                              *OutDirectoryCB,
                               NULL,
-                              (*DirectoryCB)->DirOpenReferenceCount);
+                              (*OutDirectoryCB)->DirOpenReferenceCount);
             }
         }
 
-        if( bSubstituteName &&
-            uniSearchName.Buffer != NULL)
+        if( bReleaseCurrentVolume)
         {
 
-            AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
+            ASSERT( pCurrentVolume->VolumeReferenceCount > 0);
+
+            lCount = AFSVolumeDecrement( pCurrentVolume,
+                                         VolumeReferenceReason);
+
+            AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+                          AFS_TRACE_LEVEL_VERBOSE,
+                          "AFSLocateNameEntry Decrement7 count on volume %p Reason %u Cnt %d\n",
+                          pCurrentVolume,
+                          VolumeReferenceReason,
+                          lCount);
+
+            bReleaseCurrentVolume = FALSE;
         }
 
-        if ( bReleaseCurrentVolume) {
+        if( bSubstituteName &&
+            uniSearchName.Buffer != NULL)
+        {
 
-            *pVolumeReferenceReason = VolumeReferenceReason;
+            AFSExFreePoolWithTag( uniSearchName.Buffer, 0);
         }
     }
 
index fca40b8..41108e3 100644 (file)
@@ -572,14 +572,16 @@ AFSInsertCcb( IN AFSFcb *Fcb,
 NTSTATUS
 AFSLocateNameEntry( IN GUID *AuthGroup,
                     IN PFILE_OBJECT FileObject,
-                    IN UNICODE_STRING *RootPathName,
+                    IN OUT UNICODE_STRING *RootPathName,
                     IN UNICODE_STRING *ParsedPathName,
                     IN AFSNameArrayHdr *NameArray,
                     IN ULONG Flags,
-                    IN OUT AFSVolumeCB **VolumeCB,
-                    IN OUT LONG *pVolumeReferenceReason,
-                    IN OUT AFSDirectoryCB **ParentDirectoryCB,
-                    OUT AFSDirectoryCB **DirectoryCB,
+                    IN AFSVolumeCB *VolumeCB,
+                    IN AFSDirectoryCB *ParentDirectoryCB,
+                    OUT AFSVolumeCB **OutVolumeCB,
+                    OUT LONG *OutVolumeReferenceReason,
+                    OUT AFSDirectoryCB **OutParentDirectoryCB,
+                    OUT AFSDirectoryCB **OutDirectoryCB,
                     OUT PUNICODE_STRING ComponentName);
 
 NTSTATUS