IO_STATUS_BLOCK stIoSB;
AFSObjectInfoCB *pObjectInfo = NULL;
AFSFileCleanupCB stFileCleanup;
+ AFSFileCleanupResultCB *pResultCB = NULL;
+ ULONG ulResultLen = 0;
ULONG ulNotificationFlags = 0;
+ LONG lCount;
__try
{
stFileCleanup.Identifier = (ULONGLONG)pFileObject;
//
+ // Allocate our return buffer
+ //
+
+ pResultCB = (AFSFileCleanupResultCB *)AFSExAllocatePoolWithTag( PagedPool,
+ PAGE_SIZE,
+ AFS_GENERIC_MEMORY_32_TAG);
+
+ if( pResultCB == NULL)
+ {
+
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+ }
+
+ RtlZeroMemory( pResultCB,
+ PAGE_SIZE);
+
+ ulResultLen = PAGE_SIZE;
+
+
+ //
// Perform the cleanup functionality depending on the type of node it is
//
ASSERT( pFcb->OpenHandleCount != 0);
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup (RootAll) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
FsRtlNotifyCleanup( pControlDeviceExt->Specific.Control.NotifySync,
&pControlDeviceExt->Specific.Control.DirNotifyList,
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0)
{
- InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup (IOCtl) Decrement child open handle count on Parent object %08lX Cnt %d\n",
pObjectInfo->ParentObjectInformation,
- pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount);
}
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup (IOCtl) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- //
- // And finally, release the Fcb if we acquired it.
- //
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
break;
}
&pObjectInfo->FileId,
&stFileCleanup,
sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ pResultCB,
+ &ulResultLen);
if( !NT_SUCCESS( ntStatus) &&
ntStatus != STATUS_OBJECT_NAME_NOT_FOUND)
ASSERT( pObjectInfo->ParentObjectInformation != NULL);
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
- pCcb,
- (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
- (ULONG)FILE_ACTION_REMOVED);
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+ else
+ {
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+ }
//
// Now that the service has the entry has deleted we need to remove it from the parent
if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
{
- AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
- TRUE);
-
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup DE %p for %wZ removing entry\n",
AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
pCcb->DirectoryCB);
-
- AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
else
{
pCcb->DirectoryCB,
&pCcb->DirectoryCB->NameInformation.FileName);
}
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+ AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+ pCcb,
+ (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
+ (ULONG)FILE_ACTION_REMOVED);
+
}
}
else
// Push the request to the service
//
- AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
- ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
- &pCcb->AuthGroup,
- &pCcb->DirectoryCB->NameInformation.FileName,
- &pObjectInfo->FileId,
- &stFileCleanup,
- sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
+ ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
+ &pCcb->AuthGroup,
+ &pCcb->DirectoryCB->NameInformation.FileName,
+ &pObjectInfo->FileId,
+ &stFileCleanup,
+ sizeof( AFSFileCleanupCB),
+ pResultCB,
+ &ulResultLen);
+
+ if ( NT_SUCCESS( ntStatus))
+ {
+
+ if ( pObjectInfo->ParentObjectInformation != NULL)
+ {
+
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+ }
+
+ ntStatus = STATUS_SUCCESS;
}
//
ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
- InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->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,
- pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount);
+ }
+
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE))
+ {
+ InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+
+ ClearFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+
+ AFSPerformObjectInvalidate( pObjectInfo,
+ AFS_INVALIDATE_DATA_VERSION);
}
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup (File) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- //
- // And finally, release the Fcb if we acquired it.
- //
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
break;
}
&pObjectInfo->FileId,
&stFileCleanup,
sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ pResultCB,
+ &ulResultLen);
if( !NT_SUCCESS( ntStatus) &&
ntStatus != STATUS_OBJECT_NAME_NOT_FOUND)
ASSERT( pObjectInfo->ParentObjectInformation != NULL);
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
- pCcb,
- (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
- (ULONG)FILE_ACTION_REMOVED);
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+ else
+ {
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+ }
//
// Now that the service has the entry has deleted we need to remove it from the parent
if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
{
- AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
- TRUE);
-
AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
pCcb->DirectoryCB);
-
- AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
else
{
pCcb->DirectoryCB,
&pCcb->DirectoryCB->NameInformation.FileName);
}
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+ AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+ pCcb,
+ (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
+ (ULONG)FILE_ACTION_REMOVED);
+
}
}
stFileCleanup.FileAccess = pCcb->FileAccess;
- AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
- ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
- &pCcb->AuthGroup,
- &pCcb->DirectoryCB->NameInformation.FileName,
- &pObjectInfo->FileId,
- &stFileCleanup,
- sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
+ ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
+ &pCcb->AuthGroup,
+ &pCcb->DirectoryCB->NameInformation.FileName,
+ &pObjectInfo->FileId,
+ &stFileCleanup,
+ sizeof( AFSFileCleanupCB),
+ pResultCB,
+ &ulResultLen);
+
+ if ( NT_SUCCESS( ntStatus))
+ {
+
+ if ( pObjectInfo->ParentObjectInformation != NULL)
+ {
+
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+ }
+
+ ntStatus = STATUS_SUCCESS;
}
//
ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
- InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->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,
- pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount);
}
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCleanup (Dir) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- //
- // And finally, release the Fcb if we acquired it.
- //
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
break;
}
&pObjectInfo->FileId,
&stFileCleanup,
sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ pResultCB,
+ &ulResultLen);
if( !NT_SUCCESS( ntStatus) &&
ntStatus != STATUS_OBJECT_NAME_NOT_FOUND)
ASSERT( pObjectInfo->ParentObjectInformation != NULL);
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
- pCcb,
- (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
- (ULONG)FILE_ACTION_REMOVED);
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+ else
+ {
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = pResultCB->ParentDataVersion.QuadPart;
+ }
//
// Now that the service has the entry has deleted we need to remove it from the parent
if( !BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_NOT_IN_PARENT_TREE))
{
- AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
- TRUE);
-
AFSRemoveNameEntry( pObjectInfo->ParentObjectInformation,
pCcb->DirectoryCB);
-
- AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
else
{
pCcb->DirectoryCB,
&pCcb->DirectoryCB->NameInformation.FileName);
}
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+ AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+ pCcb,
+ (ULONG)FILE_NOTIFY_CHANGE_FILE_NAME,
+ (ULONG)FILE_ACTION_REMOVED);
+
}
}
stFileCleanup.FileAccess = pCcb->FileAccess;
- AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
- ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
- &pCcb->AuthGroup,
- &pCcb->DirectoryCB->NameInformation.FileName,
- &pObjectInfo->FileId,
- &stFileCleanup,
- sizeof( AFSFileCleanupCB),
- NULL,
- NULL);
+ ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_CLEANUP_PROCESSING,
+ ulNotificationFlags | AFS_REQUEST_FLAG_SYNCHRONOUS,
+ &pCcb->AuthGroup,
+ &pCcb->DirectoryCB->NameInformation.FileName,
+ &pObjectInfo->FileId,
+ &stFileCleanup,
+ sizeof( AFSFileCleanupCB),
+ pResultCB,
+ &ulResultLen);
+
+ if ( NT_SUCCESS( ntStatus))
+ {
+
+ if ( pObjectInfo->ParentObjectInformation != NULL)
+ {
+
+ AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ if ( pObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart)
+ {
+
+ SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+
+ AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+ }
+
+ ntStatus = STATUS_SUCCESS;
}
//
ASSERT( pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0);
- InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->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,
- pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount);
}
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSCleanup (Share) Decrement handle count on Fcb %08lX Cnt %d\n",
+ "AFSCleanup (MP/SL) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- //
- // And finally, release the Fcb if we acquired it.
- //
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
break;
}
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount > 0)
{
- InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ParentObjectInformation->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,
- pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount);
}
- InterlockedDecrement( &pFcb->OpenHandleCount);
+ AFSReleaseResource( &pFcb->NPFcb->Resource);
+
+ lCount = InterlockedDecrement( &pFcb->OpenHandleCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSCleanup (MP/SL) Decrement handle count on Fcb %08lX Cnt %d\n",
+ "AFSCleanup (Share) Decrement handle count on Fcb %08lX Cnt %d\n",
pFcb,
- pFcb->OpenHandleCount);
-
- //
- // And finally, release the Fcb if we acquired it.
- //
-
- AFSReleaseResource( &pFcb->NPFcb->Resource);
+ lCount);
break;
}
try_exit:
+ if( pResultCB != NULL)
+ {
+
+ AFSExFreePool( pResultCB);
+ }
+
if( pFileObject != NULL)
{