Windows: clear pending delete upon deletion
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSCleanup.cpp
index 5f5be09..0130c3d 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,19 +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);
 
-                        AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        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);
+
+                            pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                         }
                         else
                         {
-                            pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+
+                            pParentObjectInfo->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
                         }
 
                         //
@@ -489,7 +498,7 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                           pCcb->DirectoryCB,
                                           &pCcb->DirectoryCB->NameInformation.FileName);
 
-                            AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+                            AFSRemoveNameEntry( pParentObjectInfo,
                                                 pCcb->DirectoryCB);
                         }
                         else
@@ -502,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);
@@ -553,6 +562,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                         AFSWaitOnQueuedFlushes( pFcb);
 
                         ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
+
+                        AFSTearDownFcbExtents( pFcb,
+                                               &pCcb->AuthGroup);
                     }
 
                     //
@@ -578,19 +590,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireShared( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
-                                              TRUE);
+                            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);
+
+                                pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
                             }
 
-                            AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                            AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
                         }
                     }
 
@@ -620,22 +636,38 @@ 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);
                 }
 
                 AFSReleaseResource( &pFcb->NPFcb->Resource);
 
+                if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE))
+                {
+                    //
+                    // The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
+                    //
+
+                    AFSObjectInfoIncrement( pObjectInfo);
+
+                    ClearFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+
+                    AFSPerformObjectInvalidate( pObjectInfo,
+                                                AFS_INVALIDATE_DATA_VERSION);
+                }
+
                 lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
 
                 AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
@@ -788,21 +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;
+
+                        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;
                         }
 
                         //
@@ -813,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
@@ -826,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);
@@ -851,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);
@@ -882,21 +921,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireShared( 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);
                         }
                     }
 
@@ -934,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);
                 }
 
@@ -1087,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;
                         }
 
                         //
@@ -1112,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
@@ -1125,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);
@@ -1150,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);
@@ -1181,21 +1230,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                     if ( NT_SUCCESS( ntStatus))
                     {
 
-                        if ( pObjectInfo->ParentObjectInformation != NULL)
+                        pParentObjectInfo = pObjectInfo->ParentObjectInformation;
+
+                        if ( pParentObjectInfo != NULL)
                         {
 
-                            AFSAcquireShared( 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);
                         }
                     }
 
@@ -1225,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);
                 }
 
@@ -1270,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);
                 }
 
@@ -1312,7 +1367,7 @@ try_exit:
         if( pResultCB != NULL)
         {
 
-            AFSExFreePool( pResultCB);
+            AFSExFreePoolWithTag( pResultCB, AFS_GENERIC_MEMORY_32_TAG);
         }
 
         if( pFileObject != NULL)
@@ -1331,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;