Windows: AFSCleanup Flush Data decision
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSCleanup.cpp
index 77bf7e9..3e370ab 100644 (file)
@@ -65,6 +65,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
     AFSDeviceExt *pControlDeviceExt = NULL;
     IO_STATUS_BLOCK stIoSB;
     AFSObjectInfoCB *pObjectInfo = NULL;
+    AFSObjectInfoCB *pParentObjectInfo = NULL;
     AFSFileCleanupCB stFileCleanup;
     AFSFileCleanupResultCB *pResultCB = NULL;
     ULONG ulResultLen = 0;
@@ -85,6 +86,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
         }
 
         pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
+
         pControlDeviceExt = (AFSDeviceExt *)AFSControlDeviceObject->DeviceExtension;
 
         //
@@ -384,23 +386,15 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                   &pFcb->NPFcb->Specific.File.ExtentsResource,
                                   PsGetCurrentThread());
 
-                    AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
+                    AFSAcquireExcl( &pFcb->NPFcb->Specific.File.ExtentsResource,
                                     TRUE);
 
-                    pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsRequestStatus = STATUS_FILE_DELETED;
+                    pFcb->NPFcb->Specific.File.ExtentsRequestStatus = STATUS_FILE_DELETED;
 
-                    KeSetEvent( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsRequestComplete,
+                    KeSetEvent( &pFcb->NPFcb->Specific.File.ExtentsRequestComplete,
                                 0,
                                 FALSE);
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSCleanup Releasing Fcb extents lock %08lX EXCL %08lX\n",
-                                  &pFcb->NPFcb->Specific.File.ExtentsResource,
-                                  PsGetCurrentThread());
-
-                    AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource);
-
                     //
                     // Before telling the server about the deleted file, tear down all extents for
                     // the file
@@ -409,6 +403,14 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     AFSTearDownFcbExtents( pFcb,
                                            &pCcb->AuthGroup);
 
+                    AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                                  AFS_TRACE_LEVEL_VERBOSE,
+                                  "AFSCleanup Releasing Fcb extents lock %08lX EXCL %08lX\n",
+                                  &pFcb->NPFcb->Specific.File.ExtentsResource,
+                                  PsGetCurrentThread());
+
+                    AFSReleaseResource( &pFcb->NPFcb->Specific.File.ExtentsResource);
+
                     ntStatus = STATUS_SUCCESS;
 
                     ulNotificationFlags |= AFS_REQUEST_FLAG_FILE_DELETED;
@@ -460,22 +462,26 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_DELETED);
 
-                        ASSERT( pObjectInfo->ParentObjectInformation != NULL);
+                        ClearFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
+
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        ASSERT( pParentObjectInfo != NULL);
 
-                        AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                        AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                         TRUE);
 
-                        if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+                        if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
                         {
 
-                            SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                            SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                            pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                         }
                         else
                         {
 
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+                            pParentObjectInfo->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
                         }
 
                         //
@@ -492,7 +498,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                           pCcb->DirectoryCB,
                                           &pCcb->DirectoryCB->NameInformation.FileName);
 
-                            AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+                            AFSRemoveNameEntry( pParentObjectInfo,
                                                 pCcb->DirectoryCB);
                         }
                         else
@@ -505,9 +511,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                           &pCcb->DirectoryCB->NameInformation.FileName);
                         }
 
-                        AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                        AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
 
-                        AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+                        AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
                                                         pCcb,
                                                         (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
                                                         (ULONG)FILE_ACTION_REMOVED);
@@ -544,6 +550,8 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         AFSFlushExtents( pFcb,
                                          &pCcb->AuthGroup);
+
+                        ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
                     }
 
                     if( pFcb->OpenHandleCount == 1)
@@ -555,7 +563,8 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         AFSWaitOnQueuedFlushes( pFcb);
 
-                        ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
+                        AFSTearDownFcbExtents( pFcb,
+                                               &pCcb->AuthGroup);
                     }
 
                     //
@@ -581,21 +590,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                            AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                             TRUE);
 
-                            if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+                            if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
                             {
 
-                                SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                                SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                                pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                                pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                             }
 
-                            AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                            AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
                         }
                     }
 
@@ -625,17 +636,19 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                 // Decrement the open child handle count
                 //
 
-                if( pObjectInfo->ParentObjectInformation != NULL)
+                pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                if( pParentObjectInfo != NULL)
                 {
 
-                    ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
+                    ASSERT( pParentObjectInfo->Specific.Directory.ChildOpenHandleCount > 0);
 
-                    lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+                    lCount = InterlockedDecrement( &pParentObjectInfo->Specific.Directory.ChildOpenHandleCount);
 
                     AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
                                   AFS_TRACE_LEVEL_VERBOSE,
                                   "AFSCleanup (File) Decrement child open handle count on Parent object %08lX Cnt %d\n",
-                                  pObjectInfo->ParentObjectInformation,
+                                  pParentObjectInfo,
                                   lCount);
                 }
 
@@ -643,7 +656,11 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                 if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE))
                 {
-                    InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+                    //
+                    // The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
+                    //
+
+                    AFSObjectInfoIncrement( pObjectInfo);
 
                     ClearFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
 
@@ -803,22 +820,26 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_DELETED);
 
-                        ASSERT( pObjectInfo->ParentObjectInformation != NULL);
+                        ClearFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
+
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
 
-                        AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                        ASSERT( pParentObjectInfo != NULL);
+
+                        AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                         TRUE);
 
-                        if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+                        if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
                         {
 
-                            SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                            SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                            pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                         }
                         else
                         {
 
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+                            pParentObjectInfo->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
                         }
 
                         //
@@ -829,7 +850,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                         if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
                         {
 
-                            AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+                            AFSRemoveNameEntry( pParentObjectInfo,
                                                 pCcb->DirectoryCB);
                         }
                         else
@@ -842,9 +863,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                           &pCcb->DirectoryCB->NameInformation.FileName);
                         }
 
-                        AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                        AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
 
-                        AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+                        AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
                                                         pCcb,
                                                         (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
                                                         (ULONG)FILE_ACTION_REMOVED);
@@ -867,12 +888,14 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         ClearFlag( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED);
 
-                        if(  pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if(  pParentObjectInfo != NULL)
                         {
 
                             ulNotifyFilter |= (FILE_NOTIFY_CHANGE_ATTRIBUTES);
 
-                            AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+                            AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
                                                             pCcb,
                                                             (ULONG)ulNotifyFilter,
                                                             (ULONG)FILE_ACTION_MODIFIED);
@@ -898,21 +921,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                            AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                               TRUE);
 
-                            if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+                            if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
                             {
 
-                                SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                                SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                                pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                                pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                             }
 
-                            AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                            AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
                         }
                     }
 
@@ -950,17 +975,19 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                 // Decrement the open child handle count
                 //
 
-                if( pObjectInfo->ParentObjectInformation != NULL)
+                pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                if( pParentObjectInfo != NULL)
                 {
 
-                    ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
+                    ASSERT( pParentObjectInfo->Specific.Directory.ChildOpenHandleCount > 0);
 
-                    lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+                    lCount = InterlockedDecrement( &pParentObjectInfo->Specific.Directory.ChildOpenHandleCount);
 
                     AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
                                   AFS_TRACE_LEVEL_VERBOSE,
                                   "AFSCleanup (Dir) Decrement child open handle count on Parent object %08lX Cnt %d\n",
-                                  pObjectInfo->ParentObjectInformation,
+                                  pParentObjectInfo,
                                   lCount);
                 }
 
@@ -1103,21 +1130,25 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_DELETED);
 
-                        ASSERT( pObjectInfo->ParentObjectInformation != NULL);
+                        ClearFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
+
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
 
-                        AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                        ASSERT( pParentObjectInfo != NULL);
+
+                        AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                         TRUE);
 
-                        if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+                        if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
                         {
 
-                            SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                            SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                            pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                         }
                         else
                         {
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+                            pParentObjectInfo->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
                         }
 
                         //
@@ -1128,7 +1159,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                         if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
                         {
 
-                            AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+                            AFSRemoveNameEntry( pParentObjectInfo,
                                                 pCcb->DirectoryCB);
                         }
                         else
@@ -1141,9 +1172,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                           &pCcb->DirectoryCB->NameInformation.FileName);
                         }
 
-                        AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                        AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
 
-                        AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+                        AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
                                                         pCcb,
                                                         (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
                                                         (ULONG)FILE_ACTION_REMOVED);
@@ -1166,12 +1197,14 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
 
                         ClearFlag( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED);
 
-                        if(  pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if(  pParentObjectInfo != NULL)
                         {
 
                             ulNotifyFilter |= (FILE_NOTIFY_CHANGE_ATTRIBUTES);
 
-                            AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+                            AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
                                                             pCcb,
                                                             (ULONG)ulNotifyFilter,
                                                             (ULONG)FILE_ACTION_MODIFIED);
@@ -1197,21 +1230,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                            AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
                                               TRUE);
 
-                            if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+                            if ( pParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
                             {
 
-                                SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+                                SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
 
-                                pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+                                pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                             }
 
-                            AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                            AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
                         }
                     }
 
@@ -1241,17 +1276,19 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                 // Decrement the open child handle count
                 //
 
-                if( pObjectInfo->ParentObjectInformation != NULL)
+                pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                if( pParentObjectInfo != NULL)
                 {
 
-                    ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
+                    ASSERT( pParentObjectInfo->Specific.Directory.ChildOpenHandleCount > 0);
 
-                    lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+                    lCount = InterlockedDecrement( &pParentObjectInfo->Specific.Directory.ChildOpenHandleCount);
 
                     AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
                                   AFS_TRACE_LEVEL_VERBOSE,
                                   "AFSCleanup (MP/SL) Decrement child open handle count on Parent object %08lX Cnt %d\n",
-                                  pObjectInfo->ParentObjectInformation,
+                                  pParentObjectInfo,
                                   lCount);
                 }
 
@@ -1286,16 +1323,18 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                 // Decrement the open child handle count
                 //
 
-                if( pObjectInfo->ParentObjectInformation != NULL &&
-                    pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0)
+                pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                if( pParentObjectInfo != NULL &&
+                    pParentObjectInfo->Specific.Directory.ChildOpenHandleCount > 0)
                 {
 
-                    lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+                    lCount = InterlockedDecrement( &pParentObjectInfo->Specific.Directory.ChildOpenHandleCount);
 
                     AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
                                   AFS_TRACE_LEVEL_VERBOSE,
                                   "AFSCleanup (Share) Decrement child open handle count on Parent object %08lX Cnt %d\n",
-                                  pObjectInfo->ParentObjectInformation,
+                                  pParentObjectInfo,
                                   lCount);
                 }
 
@@ -1328,7 +1367,7 @@ try_exit:
         if( pResultCB != NULL)
         {
 
-            AFSExFreePool( pResultCB);
+            AFSExFreePoolWithTag( pResultCB, AFS_GENERIC_MEMORY_32_TAG);
         }
 
         if( pFileObject != NULL)
@@ -1347,12 +1386,14 @@ try_exit:
 
         AFSCompleteRequest( Irp, ntStatus);
     }
-    __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+    __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
     {
 
         AFSDbgLogMsg( 0,
                       0,
                       "EXCEPTION - AFSCleanup\n");
+
+        AFSDumpTraceFilesFnc();
     }
 
     return ntStatus;