AFSDeviceExt *pControlDeviceExt = NULL;
IO_STATUS_BLOCK stIoSB;
AFSObjectInfoCB *pObjectInfo = NULL;
+ AFSObjectInfoCB *pParentObjectInfo = NULL;
AFSFileCleanupCB stFileCleanup;
AFSFileCleanupResultCB *pResultCB = NULL;
ULONG ulResultLen = 0;
}
pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
+
pControlDeviceExt = (AFSDeviceExt *)AFSControlDeviceObject->DeviceExtension;
//
&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
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;
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;
}
//
pCcb->DirectoryCB,
&pCcb->DirectoryCB->NameInformation.FileName);
- AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+ AFSRemoveNameEntry( pParentObjectInfo,
pCcb->DirectoryCB);
}
else
&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);
AFSWaitOnQueuedFlushes( pFcb);
ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
+
+ AFSTearDownFcbExtents( pFcb,
+ &pCcb->AuthGroup);
}
//
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);
}
}
// 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,
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;
}
//
if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
{
- AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+ AFSRemoveNameEntry( pParentObjectInfo,
pCcb->DirectoryCB);
}
else
&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);
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);
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);
}
}
// 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);
}
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;
}
//
if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
{
- AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
+ AFSRemoveNameEntry( pParentObjectInfo,
pCcb->DirectoryCB);
}
else
&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);
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);
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);
}
}
// 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);
}
// 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);
}
if( pResultCB != NULL)
{
- AFSExFreePool( pResultCB);
+ AFSExFreePoolWithTag( pResultCB, AFS_GENERIC_MEMORY_32_TAG);
}
if( pFileObject != NULL)
AFSCompleteRequest( Irp, ntStatus);
}
- __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+ __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSCleanup\n");
+
+ AFSDumpTraceFilesFnc();
}
return ntStatus;