NTSTATUS ntStatus = STATUS_SUCCESS;
void *pAddress = NULL;
- MDL *pMdl = NULL;
+ MDL *pMdl = NULL;
- __Enter
- {
+ __Enter
+ {
pMdl = IoAllocateMdl( UserBuffer,
BufferLength,
FALSE,
NULL);
- if( pMdl == NULL)
- {
+ if( pMdl == NULL)
+ {
- try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
- }
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+ }
//
// Lock the new Mdl in memory.
{
MmProbeAndLockPages( pMdl,
- KernelMode,
+ KernelMode,
IoWriteAccess);
pAddress = MmGetSystemAddressForMdlSafe( pMdl,
- NormalPagePriority);
+ NormalPagePriority);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
pAddress = NULL;
}
- if( pMdl != NULL)
- {
+ if( pMdl != NULL)
+ {
- *Mdl = pMdl;
- }
+ *Mdl = pMdl;
+ }
try_exit:
AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
AFSObjectInfoCB *pObjectInfoCB = NULL;
AFSNonPagedDirectoryCB *pNonPagedDirEntry = NULL;
+ LONG lCount;
__Enter
{
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
- InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInitializeGlobalDirectoryEntries Increment count on object %08lX Cnt %d\n",
pObjectInfoCB,
- pObjectInfoCB->ObjectReferenceCount);
+ lCount);
ntStatus = STATUS_SUCCESS;
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
- InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInitializeGlobalDirectoryEntries Increment count on object %08lX Cnt %d\n",
pObjectInfoCB,
- pObjectInfoCB->ObjectReferenceCount);
+ lCount);
ntStatus = STATUS_SUCCESS;
BOOLEAN bAllocatedObjectCB = FALSE;
ULONGLONG ullIndex = 0;
AFSNonPagedDirectoryCB *pNonPagedDirEntry = NULL;
+ LONG lCount;
__Enter
{
FileName);
}
- InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfoCB->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInitDirEntry Increment count on object %08lX Cnt %d\n",
pObjectInfoCB,
- pObjectInfoCB->ObjectReferenceCount);
+ lCount);
AFSReleaseResource( ParentObjectInfo->VolumeCB->ObjectInfoTree.TreeLock);
if( pObjectInfoCB != NULL)
{
- InterlockedDecrement( &pObjectInfoCB->ObjectReferenceCount);
+ lCount = InterlockedDecrement( &pObjectInfoCB->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInitDirEntry Decrement count on object %08lX Cnt %d\n",
pObjectInfoCB,
- pObjectInfoCB->ObjectReferenceCount);
+ lCount);
if( bAllocatedObjectCB)
{
}
NTSTATUS
-AFSInvalidateCache( IN AFSInvalidateCacheCB *InvalidateCB)
+AFSInvalidateObject( IN OUT AFSObjectInfoCB **ppObjectInfo,
+ IN ULONG Reason)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
- AFSFcb *pDcb = NULL, *pFcb = NULL, *pNextFcb = NULL;
- AFSVolumeCB *pVolumeCB = NULL;
- AFSFcb *pTargetDcb = NULL;
- AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
- AFSDirectoryCB *pCurrentDirEntry = NULL;
- BOOLEAN bIsChild = FALSE;
- ULONGLONG ullIndex = 0;
- AFSObjectInfoCB *pObjectInfo = NULL;
IO_STATUS_BLOCK stIoStatus;
ULONG ulFilter = 0;
- __Enter
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateObject Invalidation on node type %d for fid %08lX-%08lX-%08lX-%08lX Reason %d\n",
+ (*ppObjectInfo)->FileType,
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique,
+ Reason);
+
+ if( (*ppObjectInfo)->FileType == AFS_FILE_TYPE_SYMLINK ||
+ (*ppObjectInfo)->FileType == AFS_FILE_TYPE_DFSLINK ||
+ (*ppObjectInfo)->FileType == AFS_FILE_TYPE_MOUNTPOINT)
{
-
//
- // Need to locate the Fcb for the directory to purge
+ // We only act on the mount point itself, not the target. If the
+ // node has been deleted then mark it as such otherwise indicate
+ // it requires verification
//
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Acquiring RDR VolumeTreeLock lock %08lX SHARED %08lX\n",
- &pDevExt->Specific.RDR.VolumeTreeLock,
- PsGetCurrentThread());
-
- //
- // Starve any exclusive waiters on this paticular call
- //
+ if( Reason == AFS_INVALIDATE_DELETED)
+ {
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID);
+ }
+ else
+ {
- AFSAcquireSharedStarveExclusive( &pDevExt->Specific.RDR.VolumeTreeLock, TRUE);
+ if( Reason == AFS_INVALIDATE_FLUSHED)
+ {
- //
- // Locate the volume node
- //
+ (*ppObjectInfo)->DataVersion.QuadPart = (ULONGLONG)-1;
- ullIndex = AFSCreateHighIndex( &InvalidateCB->FileID);
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_VERIFY_DATA);
+ }
- ntStatus = AFSLocateHashEntry( pDevExt->Specific.RDR.VolumeTree.TreeHead,
- ullIndex,
- (AFSBTreeEntry **)&pVolumeCB);
+ (*ppObjectInfo)->Expiration.QuadPart = 0;
- if( pVolumeCB != NULL)
- {
+ (*ppObjectInfo)->TargetFileId.Vnode = 0;
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ (*ppObjectInfo)->TargetFileId.Unique = 0;
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Increment count on volume %08lX Cnt %d\n",
- pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ "AFSInvalidateObject Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique);
+
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_VERIFY);
}
- AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
+ ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
- if( !NT_SUCCESS( ntStatus) ||
- pVolumeCB == NULL)
+ if( Reason == AFS_INVALIDATE_CREDS)
{
- try_return( ntStatus = STATUS_SUCCESS);
+ ulFilter |= FILE_NOTIFY_CHANGE_SECURITY;
}
- //
- // If this is a whole volume invalidation then go do it now
- //
-
- if( InvalidateCB->WholeVolume ||
- AFSIsVolumeFID( &InvalidateCB->FileID))
+ if( Reason == AFS_INVALIDATE_DATA_VERSION ||
+ Reason == AFS_INVALIDATE_FLUSHED)
{
-
- ntStatus = AFSInvalidateVolume( pVolumeCB,
- InvalidateCB->Reason);
-
- AFSFsRtlNotifyFullReportChange( &pVolumeCB->ObjectInformation,
- NULL,
- FILE_NOTIFY_CHANGE_FILE_NAME |
- FILE_NOTIFY_CHANGE_DIR_NAME |
- FILE_NOTIFY_CHANGE_NAME |
- FILE_NOTIFY_CHANGE_ATTRIBUTES |
- FILE_NOTIFY_CHANGE_SIZE,
- FILE_ACTION_MODIFIED);
-
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
-
- try_return( ntStatus);
+ ulFilter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
+ }
+ else
+ {
+ ulFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
}
- AFSAcquireShared( pVolumeCB->ObjectInfoTree.TreeLock,
- TRUE);
-
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ AFSFsRtlNotifyFullReportChange( (*ppObjectInfo)->ParentObjectInformation,
+ NULL,
+ ulFilter,
+ FILE_ACTION_MODIFIED);
- AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Decrement count on volume %08lX Cnt %d\n",
- pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ try_return( ntStatus);
+ }
- ullIndex = AFSCreateLowIndex( &InvalidateCB->FileID);
+ //
+ // Depending on the reason for invalidation then perform work on the node
+ //
- ntStatus = AFSLocateHashEntry( pVolumeCB->ObjectInfoTree.TreeHead,
- ullIndex,
- (AFSBTreeEntry **)&pObjectInfo);
+ switch( Reason)
+ {
- if( pObjectInfo != NULL)
+ case AFS_INVALIDATE_DELETED:
{
//
- // Reference the node so it won't be torn down
+ // Mark this node as invalid
//
- InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_DELETED);
- AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Increment count on object %08lX Cnt %d\n",
- pObjectInfo,
- pObjectInfo->ObjectReferenceCount);
- }
+ "AFSInvalidateObject Set DELETE flag on fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique);
- AFSReleaseResource( pVolumeCB->ObjectInfoTree.TreeLock);
+ if( (*ppObjectInfo)->ParentObjectInformation != NULL)
+ {
- if( !NT_SUCCESS( ntStatus) ||
- pObjectInfo == NULL)
- {
- try_return( ntStatus = STATUS_SUCCESS);
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateObject Set VERIFY flag on parent fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->ParentObjectInformation->FileId.Cell,
+ (*ppObjectInfo)->ParentObjectInformation->FileId.Volume,
+ (*ppObjectInfo)->ParentObjectInformation->FileId.Vnode,
+ (*ppObjectInfo)->ParentObjectInformation->FileId.Unique);
- if( pObjectInfo->FileType == AFS_FILE_TYPE_SYMLINK ||
- pObjectInfo->FileType == AFS_FILE_TYPE_DFSLINK ||
- pObjectInfo->FileType == AFS_FILE_TYPE_MOUNTPOINT)
- {
+ SetFlag( (*ppObjectInfo)->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Invalidation on node type %d for fid %08lX-%08lX-%08lX-%08lX Reason %d\n",
- pObjectInfo->FileType,
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique,
- InvalidateCB->Reason);
+ (*ppObjectInfo)->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
- //
- // We only act on the mount point itself, not the target. If the
- // node has been deleted then mark it as such otherwise indicate
- // it requires verification
- //
+ (*ppObjectInfo)->ParentObjectInformation->Expiration.QuadPart = 0;
+ }
- if( InvalidateCB->Reason == AFS_INVALIDATE_DELETED)
+ if( (*ppObjectInfo)->FileType == AFS_FILE_TYPE_DIRECTORY)
{
- SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID);
+ ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
}
else
{
+ ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
+ }
+
+ AFSFsRtlNotifyFullReportChange( (*ppObjectInfo)->ParentObjectInformation,
+ NULL,
+ ulFilter,
+ FILE_ACTION_REMOVED);
+
+ if( NT_SUCCESS( AFSQueueInvalidateObject( (*ppObjectInfo),
+ Reason)))
+ {
+ (*ppObjectInfo) = NULL; // We'll dec the count in the worker item
+ }
+
+ break;
+ }
+
+ case AFS_INVALIDATE_FLUSHED:
+ {
+
+ if( (*ppObjectInfo)->FileType == AFS_FILE_TYPE_FILE &&
+ (*ppObjectInfo)->Fcb != NULL)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateObject Flush/purge file fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique);
+
+ AFSAcquireExcl( &(*ppObjectInfo)->Fcb->NPFcb->Resource,
+ TRUE);
- if( InvalidateCB->Reason == AFS_INVALIDATE_FLUSHED ||
- InvalidateCB->Reason == AFS_INVALIDATE_DATA_VERSION)
+ __try
{
- pObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
+
+ CcFlushCache( &(*ppObjectInfo)->Fcb->NPFcb->SectionObjectPointers,
+ NULL,
+ 0,
+ &stIoStatus);
+
+ if( !NT_SUCCESS( stIoStatus.Status))
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSInvalidateObject CcFlushCache failure FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX Bytes 0x%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique,
+ stIoStatus.Status,
+ stIoStatus.Information);
+
+ ntStatus = stIoStatus.Status;
+ }
+
+ CcPurgeCacheSection( &(*ppObjectInfo)->Fcb->NPFcb->SectionObjectPointers,
+ NULL,
+ 0,
+ FALSE);
}
+ __except( EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ ntStatus = GetExceptionCode();
+ }
+
+ AFSReleaseResource( &(*ppObjectInfo)->Fcb->NPFcb->Resource);
- pObjectInfo->Expiration.QuadPart = 0;
+ //
+ // Clear out the extents
+ // Get rid of them (note this involves waiting
+ // for any writes or reads to the cache to complete)
+ //
+
+ (VOID) AFSTearDownFcbExtents( (*ppObjectInfo)->Fcb,
+ NULL);
+ }
- pObjectInfo->TargetFileId.Vnode = 0;
+ (*ppObjectInfo)->DataVersion.QuadPart = (ULONGLONG)-1;
- pObjectInfo->TargetFileId.Unique = 0;
+
+ if( (*ppObjectInfo)->FileType == AFS_FILE_TYPE_FILE)
+ {
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique);
+ "AFSInvalidateObject Setting VERIFY_DATA flag on fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique);
- SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_VERIFY_DATA);
}
- ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
+ // Fall through to the default processing
+ }
+
+ default:
+ {
+
+ if( (*ppObjectInfo)->FileType == AFS_FILE_TYPE_DIRECTORY)
+ {
+ ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
+ }
+ else
+ {
+ ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
+ }
- if( InvalidateCB->Reason == AFS_INVALIDATE_CREDS)
+ if( Reason == AFS_INVALIDATE_CREDS)
{
ulFilter |= FILE_NOTIFY_CHANGE_SECURITY;
}
- if( InvalidateCB->Reason == AFS_INVALIDATE_DATA_VERSION)
+ if( Reason == AFS_INVALIDATE_DATA_VERSION)
{
ulFilter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
}
ulFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
}
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
+ AFSFsRtlNotifyFullReportChange( (*ppObjectInfo)->ParentObjectInformation,
NULL,
- FILE_NOTIFY_CHANGE_FILE_NAME |
- FILE_NOTIFY_CHANGE_ATTRIBUTES,
+ ulFilter,
FILE_ACTION_MODIFIED);
- try_return( ntStatus);
+ //
+ // Indicate this node requires re-evaluation for the remaining reasons
+ //
+
+ (*ppObjectInfo)->Expiration.QuadPart = 0;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateObject Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
+ (*ppObjectInfo)->FileId.Cell,
+ (*ppObjectInfo)->FileId.Volume,
+ (*ppObjectInfo)->FileId.Vnode,
+ (*ppObjectInfo)->FileId.Unique);
+
+ SetFlag( (*ppObjectInfo)->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ if( Reason == AFS_INVALIDATE_DATA_VERSION ||
+ (*ppObjectInfo)->FileType == AFS_FILE_TYPE_FILE &&
+ ( Reason == AFS_INVALIDATE_CALLBACK ||
+ Reason == AFS_INVALIDATE_EXPIRED))
+ {
+ if ( NT_SUCCESS( AFSQueueInvalidateObject( (*ppObjectInfo),
+ AFS_INVALIDATE_DATA_VERSION)))
+ {
+
+ (*ppObjectInfo) = NULL; // We'll dec the count in the worker item
+ }
+ }
+
+ break;
}
+ }
- //
- // Depending on the reason for invalidation then perform work on the node
- //
+ try_exit:
- switch( InvalidateCB->Reason)
- {
+ return ntStatus;
+}
- case AFS_INVALIDATE_DELETED:
- {
+NTSTATUS
+AFSInvalidateCache( IN AFSInvalidateCacheCB *InvalidateCB)
+{
- //
- // Mark this node as invalid
- //
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ AFSFcb *pDcb = NULL, *pFcb = NULL, *pNextFcb = NULL;
+ AFSVolumeCB *pVolumeCB = NULL;
+ AFSFcb *pTargetDcb = NULL;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ AFSDirectoryCB *pCurrentDirEntry = NULL;
+ BOOLEAN bIsChild = FALSE;
+ ULONGLONG ullIndex = 0;
+ AFSObjectInfoCB *pObjectInfo = NULL;
+ LONG lCount;
- SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_DELETED);
+ __Enter
+ {
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Set DELETE flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateCache Invalidation FID %08lX-%08lX-%08lX-%08lX Type %d WholeVolume %d Reason %d\n",
+ InvalidateCB->FileID.Cell,
+ InvalidateCB->FileID.Volume,
+ InvalidateCB->FileID.Vnode,
+ InvalidateCB->FileID.Unique,
+ InvalidateCB->FileType,
+ InvalidateCB->WholeVolume,
+ InvalidateCB->Reason);
- if( pObjectInfo->ParentObjectInformation != NULL)
- {
+ //
+ // Need to locate the Fcb for the directory to purge
+ //
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Set VERIFY flag on parent fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->ParentObjectInformation->FileId.Cell,
- pObjectInfo->ParentObjectInformation->FileId.Volume,
- pObjectInfo->ParentObjectInformation->FileId.Vnode,
- pObjectInfo->ParentObjectInformation->FileId.Unique);
-
- SetFlag( pObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
- pObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
- pObjectInfo->ParentObjectInformation->Expiration.QuadPart = 0;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateCache Acquiring RDR VolumeTreeLock lock %08lX SHARED %08lX\n",
+ &pDevExt->Specific.RDR.VolumeTreeLock,
+ PsGetCurrentThread());
- if( pObjectInfo->FileType == AFS_FILE_TYPE_DIRECTORY)
- {
- ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
- }
- else
- {
- ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
- }
+ //
+ // Starve any exclusive waiters on this paticular call
+ //
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
- NULL,
- ulFilter,
- FILE_ACTION_REMOVED);
+ AFSAcquireSharedStarveExclusive( &pDevExt->Specific.RDR.VolumeTreeLock, TRUE);
- break;
- }
+ //
+ // Locate the volume node
+ //
- case AFS_INVALIDATE_FLUSHED:
- {
+ ullIndex = AFSCreateHighIndex( &InvalidateCB->FileID);
- if( pObjectInfo->FileType == AFS_FILE_TYPE_FILE &&
- pObjectInfo->Fcb != NULL)
- {
+ ntStatus = AFSLocateHashEntry( pDevExt->Specific.RDR.VolumeTree.TreeHead,
+ ullIndex,
+ (AFSBTreeEntry **)&pVolumeCB);
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Flush/purge file fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique);
+ if( pVolumeCB != NULL)
+ {
- AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->Resource,
- TRUE);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
- __try
- {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateCache Increment count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ lCount);
+ }
- CcFlushCache( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
- NULL,
- 0,
- &stIoStatus);
+ AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
- if( !NT_SUCCESS( stIoStatus.Status))
- {
+ if( !NT_SUCCESS( ntStatus) ||
+ pVolumeCB == NULL)
+ {
- AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
- AFS_TRACE_LEVEL_ERROR,
- "AFSInvalidateCache CcFlushCache failure FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX Bytes 0x%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique,
- stIoStatus.Status,
- stIoStatus.Information);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSInvalidateCache Invalidation FAILURE Unable to locate volume node FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ InvalidateCB->FileID.Cell,
+ InvalidateCB->FileID.Volume,
+ InvalidateCB->FileID.Vnode,
+ InvalidateCB->FileID.Unique,
+ ntStatus);
- ntStatus = stIoStatus.Status;
- }
+ try_return( ntStatus = STATUS_SUCCESS);
+ }
- CcPurgeCacheSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
- NULL,
- 0,
- FALSE);
- }
- __except( EXCEPTION_EXECUTE_HANDLER)
- {
+ //
+ // If this is a whole volume invalidation then go do it now
+ //
- ntStatus = GetExceptionCode();
- }
+ if( InvalidateCB->WholeVolume)
+ {
- AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->Resource);
+ ntStatus = AFSInvalidateVolume( pVolumeCB,
+ InvalidateCB->Reason);
- //
- // Clear out the extents
- // Get rid of them (note this involves waiting
- // for any writes or reads to the cache to complete)
- //
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
- (VOID) AFSTearDownFcbExtents( pObjectInfo->Fcb);
- }
+ try_return( ntStatus);
+ }
- // Fall through to the default processing
- }
+ AFSAcquireShared( pVolumeCB->ObjectInfoTree.TreeLock,
+ TRUE);
- default:
- {
+ if ( AFSIsVolumeFID( &InvalidateCB->FileID))
+ {
- if( pObjectInfo->FileType == AFS_FILE_TYPE_DIRECTORY)
- {
- ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
- }
- else
- {
- ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
- }
+ pObjectInfo = &pVolumeCB->ObjectInformation;
+ }
+ else
+ {
- if( InvalidateCB->Reason == AFS_INVALIDATE_CREDS)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SECURITY;
- }
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
- if( InvalidateCB->Reason == AFS_INVALIDATE_DATA_VERSION)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
- }
- else
- {
- ulFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateCache Decrement count on volume %08lX Cnt %d\n",
+ pVolumeCB,
+ pVolumeCB->VolumeReferenceCount);
- AFSFsRtlNotifyFullReportChange( pObjectInfo->ParentObjectInformation,
- NULL,
- ulFilter,
- FILE_ACTION_MODIFIED);
+ ullIndex = AFSCreateLowIndex( &InvalidateCB->FileID);
- //
- // Indicate this node requires re-evaluation for the remaining reasons
- //
+ ntStatus = AFSLocateHashEntry( pVolumeCB->ObjectInfoTree.TreeHead,
+ ullIndex,
+ (AFSBTreeEntry **)&pObjectInfo);
+ }
- pObjectInfo->Expiration.QuadPart = 0;
+ if( pObjectInfo != NULL)
+ {
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique);
+ //
+ // Reference the node so it won't be torn down
+ //
- SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
- if( InvalidateCB->Reason == AFS_INVALIDATE_FLUSHED ||
- InvalidateCB->Reason == AFS_INVALIDATE_DATA_VERSION)
- {
- pObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateCache Increment count on object %08lX Cnt %d\n",
+ pObjectInfo,
+ lCount);
+ }
- if( pObjectInfo->FileType == AFS_FILE_TYPE_FILE)
- {
+ AFSReleaseResource( pVolumeCB->ObjectInfoTree.TreeLock);
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateCache Setting VERIFY_DATA flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pObjectInfo->FileId.Cell,
- pObjectInfo->FileId.Volume,
- pObjectInfo->FileId.Vnode,
- pObjectInfo->FileId.Unique);
+ if( !NT_SUCCESS( ntStatus) ||
+ pObjectInfo == NULL)
+ {
- SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY_DATA);
- }
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSInvalidateCache Invalidation FAILURE Unable to locate object FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ InvalidateCB->FileID.Cell,
+ InvalidateCB->FileID.Volume,
+ InvalidateCB->FileID.Vnode,
+ InvalidateCB->FileID.Unique,
+ ntStatus);
- break;
- }
+ try_return( ntStatus = STATUS_SUCCESS);
}
+ AFSInvalidateObject( &pObjectInfo,
+ InvalidateCB->Reason);
+
try_exit:
if( pObjectInfo != NULL)
{
- InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInvalidateCache Decrement count on object %08lX Cnt %d\n",
pObjectInfo,
- pObjectInfo->ObjectReferenceCount);
+ lCount);
}
}
{
NTSTATUS ntStatus = STATUS_SUCCESS;
- AFSFcb *pFcb = NULL;
AFSObjectInfoCB *pCurrentObject = NULL;
+ AFSObjectInfoCB *pNextObject = NULL;
+ LONG lCount;
+ AFSFcb *pFcb = NULL;
ULONG ulFilter = 0;
__Enter
// Mark this volume as invalid
//
- VolumeCB->ObjectInformation.Expiration.QuadPart = 0;
-
SetFlag( VolumeCB->ObjectInformation.Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID);
SetFlag( VolumeCB->Flags, AFS_VOLUME_FLAGS_OFFLINE);
- AFSFsRtlNotifyFullReportChange( &VolumeCB->ObjectInformation,
- NULL,
- FILE_NOTIFY_CHANGE_DIR_NAME,
- FILE_ACTION_REMOVED);
-
- AFSAcquireShared( VolumeCB->ObjectInfoTree.TreeLock,
- TRUE);
-
- pCurrentObject = VolumeCB->ObjectInfoListHead;
+ break;
+ }
+ }
- while( pCurrentObject != NULL)
- {
+ //
+ // Invalidate the volume root directory
+ //
- if( pCurrentObject->FileType == AFS_FILE_TYPE_DIRECTORY)
- {
- ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
- }
- else
- {
- ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
- }
+ pCurrentObject = &VolumeCB->ObjectInformation;
- AFSFsRtlNotifyFullReportChange( pCurrentObject,
- NULL,
- ulFilter,
- FILE_ACTION_REMOVED);
+ if ( pCurrentObject )
+ {
- SetFlag( pCurrentObject->Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID);
+ lCount = InterlockedIncrement( &pCurrentObject->ObjectReferenceCount);
- pFcb = pCurrentObject->Fcb;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateVolumeObjects Increment count on object %08lX Cnt %d\n",
+ pCurrentObject,
+ lCount);
- if( pFcb != NULL &&
- pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
- {
+ AFSInvalidateObject( &pCurrentObject,
+ Reason);
+ if ( pCurrentObject)
+ {
- //
- // Clear out the extents
- // And get rid of them (note this involves waiting
- // for any writes or reads to the cache to complete)
- //
+ lCount = InterlockedDecrement( &pCurrentObject->ObjectReferenceCount);
- (VOID) AFSTearDownFcbExtents( pFcb);
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateVolumeObjects Decrement count on object %08lX Cnt %d\n",
+ pCurrentObject,
+ lCount);
+ }
+ }
- pCurrentObject = (AFSObjectInfoCB *)pCurrentObject->ListEntry.fLink;
- }
+ //
+ // Apply invalidation to all other volume objects
+ //
- AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
+ AFSAcquireShared( VolumeCB->ObjectInfoTree.TreeLock,
+ TRUE);
- break;
- }
+ pCurrentObject = VolumeCB->ObjectInfoListHead;
- default:
- {
+ if ( pCurrentObject)
+ {
- //
- // Indicate this node requires re-evaluation for the remaining reasons
- //
+ //
+ // Reference the node so it won't be torn down
+ //
- VolumeCB->ObjectInformation.Expiration.QuadPart = 0;
+ lCount = InterlockedIncrement( &pCurrentObject->ObjectReferenceCount);
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateVolume Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
- VolumeCB->ObjectInformation.FileId.Cell,
- VolumeCB->ObjectInformation.FileId.Volume,
- VolumeCB->ObjectInformation.FileId.Vnode,
- VolumeCB->ObjectInformation.FileId.Unique);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateVolumeObjects Increment count on object %08lX Cnt %d\n",
+ pCurrentObject,
+ lCount);
+ }
- SetFlag( VolumeCB->ObjectInformation.Flags, AFS_OBJECT_FLAGS_VERIFY);
+ while( pCurrentObject != NULL)
+ {
- if( Reason == AFS_INVALIDATE_FLUSHED ||
- Reason == AFS_INVALIDATE_DATA_VERSION)
- {
+ pNextObject = (AFSObjectInfoCB *)pCurrentObject->ListEntry.fLink;
- VolumeCB->ObjectInformation.DataVersion.QuadPart = (ULONGLONG)-1;
- }
+ if ( pNextObject)
+ {
//
- // Notify anyone that cares
+ // Reference the node so it won't be torn down
//
- ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
+ lCount = InterlockedIncrement( &pNextObject->ObjectReferenceCount);
- if( Reason == AFS_INVALIDATE_CREDS)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SECURITY;
- }
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateVolumeObjects Increment count on object %08lX Cnt %d\n",
+ pNextObject,
+ lCount);
+ }
- if( Reason == AFS_INVALIDATE_DATA_VERSION)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
- }
- else
- {
- ulFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
- }
+ AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
+
+ AFSInvalidateObject( &pCurrentObject,
+ Reason);
+
+ if ( pCurrentObject )
+ {
- AFSFsRtlNotifyFullReportChange( &VolumeCB->ObjectInformation,
- NULL,
- ulFilter,
- FILE_ACTION_MODIFIED);
+ lCount = InterlockedDecrement( &pCurrentObject->ObjectReferenceCount);
- //
- // Volume invalidations require all objects in the volume be re-verified
- //
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateVolumeObjects Decrement count on object %08lX Cnt %d\n",
+ pCurrentObject,
+ lCount);
+ }
- AFSAcquireShared( VolumeCB->ObjectInfoTree.TreeLock,
- TRUE);
+ AFSAcquireShared( VolumeCB->ObjectInfoTree.TreeLock,
+ TRUE);
- pCurrentObject = VolumeCB->ObjectInfoListHead;
+ pCurrentObject = pNextObject;
+ }
- while( pCurrentObject != NULL)
- {
+ AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
+ }
- pCurrentObject->Expiration.QuadPart = 0;
+ return ntStatus;
+}
- pCurrentObject->TargetFileId.Vnode = 0;
+VOID
+AFSInvalidateAllVolumes( VOID)
+{
+ AFSVolumeCB *pVolumeCB = NULL;
+ AFSVolumeCB *pNextVolumeCB = NULL;
+ AFSDeviceExt *pRDRDeviceExt = NULL;
+ LONG lCount;
- pCurrentObject->TargetFileId.Unique = 0;
+ pRDRDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateVolume Setting VERIFY flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pCurrentObject->FileId.Cell,
- pCurrentObject->FileId.Volume,
- pCurrentObject->FileId.Vnode,
- pCurrentObject->FileId.Unique);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateAllVolumes Acquiring RDR VolumeListLock lock %08lX SHARED %08lX\n",
+ &pRDRDeviceExt->Specific.RDR.VolumeListLock,
+ PsGetCurrentThread());
- SetFlag( pCurrentObject->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ AFSAcquireShared( &pRDRDeviceExt->Specific.RDR.VolumeListLock,
+ TRUE);
- if( Reason == AFS_INVALIDATE_FLUSHED ||
- Reason == AFS_INVALIDATE_DATA_VERSION)
- {
+ pVolumeCB = pRDRDeviceExt->Specific.RDR.VolumeListHead;
- pCurrentObject->DataVersion.QuadPart = (ULONGLONG)-1;
+ if ( pVolumeCB)
+ {
- if( pCurrentObject->FileType == AFS_FILE_TYPE_FILE)
- {
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInvalidateAllVolumes Acquiring VolumeRoot ObjectInfoTree lock %08lX SHARED %08lX\n",
+ pVolumeCB->ObjectInfoTree.TreeLock,
+ PsGetCurrentThread());
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSInvalidateVolume Setting VERIFY_DATA flag on fid %08lX-%08lX-%08lX-%08lX\n",
- pCurrentObject->FileId.Cell,
- pCurrentObject->FileId.Volume,
- pCurrentObject->FileId.Vnode,
- pCurrentObject->FileId.Unique);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ }
- SetFlag( pCurrentObject->Flags, AFS_OBJECT_FLAGS_VERIFY_DATA);
- }
- }
+ while( pVolumeCB != NULL)
+ {
- if( pCurrentObject->FileType == AFS_FILE_TYPE_DIRECTORY)
- {
- ulFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
- }
- else
- {
- ulFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
- }
+ pNextVolumeCB = (AFSVolumeCB *)pVolumeCB->ListEntry.fLink;
- if( Reason == AFS_INVALIDATE_CREDS)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SECURITY;
- }
+ if ( pNextVolumeCB)
+ {
- if( Reason == AFS_INVALIDATE_DATA_VERSION)
- {
- ulFilter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
- }
- else
- {
- ulFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
- }
+ lCount = InterlockedIncrement( &pNextVolumeCB->VolumeReferenceCount);
+ }
- AFSFsRtlNotifyFullReportChange( pCurrentObject,
- NULL,
- ulFilter,
- FILE_ACTION_MODIFIED);
+ AFSReleaseResource( &pRDRDeviceExt->Specific.RDR.VolumeListLock);
- pCurrentObject = (AFSObjectInfoCB *)pCurrentObject->ListEntry.fLink;
- }
+ // do I need to hold the volume lock here?
- AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
+ AFSInvalidateVolume( pVolumeCB, AFS_INVALIDATE_EXPIRED);
- break;
- }
- }
+ AFSAcquireShared( &pRDRDeviceExt->Specific.RDR.VolumeListLock,
+ TRUE);
+
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+
+ pVolumeCB = pNextVolumeCB;
}
- return ntStatus;
+ AFSReleaseResource( &pRDRDeviceExt->Specific.RDR.VolumeListLock);
}
NTSTATUS
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSInvalidateCache Meta Data Update failed %wZ FID %08lX-%08lX-%08lX-%08lX ntStatus %08lX\n",
+ "AFSVerifyEntry Meta Data Update failed %wZ FID %08lX-%08lX-%08lX-%08lX ntStatus %08lX\n",
&DirEntry->NameInformation.FileName,
pObjectInfo->FileId.Cell,
pObjectInfo->FileId.Volume,
if ( bPurgeExtents)
{
- AFSFlushExtents( pObjectInfo->Fcb);
+ AFSFlushExtents( pObjectInfo->Fcb,
+ AuthGroup);
}
//
AFSAcquireExcl( pObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
- AFSValidateDirectoryCache( pObjectInfo,
- AuthGroup);
+ ntStatus = AFSValidateDirectoryCache( pObjectInfo,
+ AuthGroup);
AFSReleaseResource( pObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+ if ( !NT_SUCCESS( ntStatus))
+ {
+
+ try_return( ntStatus);
+ }
}
//
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
- "AFSVerifyEntry Attempt to verify node of type %d\n",
- pObjectInfo->FileType);
+ "AFSVerifyEntry Attempt to verify node of type %d %wZ FID %08lX-%08lX-%08lX-%08lX\n",
+ pObjectInfo->FileType,
+ &DirEntry->NameInformation.FileName,
+ pObjectInfo->FileId.Cell,
+ pObjectInfo->FileId.Volume,
+ pObjectInfo->FileId.Vnode,
+ pObjectInfo->FileId.Unique);
break;
}
AFSVolumeCB *pVolumeCB = NULL;
AFSFcb *pFcb = NULL;
AFSObjectInfoCB *pCurrentObject = NULL;
+ LONG lCount;
__Enter
{
if( pVolumeCB != NULL)
{
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
// for any writes or reads to the cache to complete)
//
- (VOID) AFSTearDownFcbExtents( pFcb);
+ (VOID) AFSTearDownFcbExtents( pFcb,
+ NULL);
}
pCurrentObject = (AFSObjectInfoCB *)pCurrentObject->ListEntry.fLink;
AFSReleaseResource( pVolumeCB->ObjectInfoTree.TreeLock);
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
}
else
{
// Reget the directory contents
//
- AFSVerifyDirectoryContent( ObjectInfo,
- AuthGroup);
+ ntStatus = AFSVerifyDirectoryContent( ObjectInfo,
+ AuthGroup);
+
+ if ( !NT_SUCCESS( ntStatus))
+ {
+ try_return( ntStatus);
+ }
//
// Now start again and tear down any entries not valid
}
#endif
+try_exit:
+
if( bAcquiredLock)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSValidateEntry Failed to evaluate entry %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ "AFSValidateEntry Failed to evaluate entry FastCall %d %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ FastCall,
&DirEntry->NameInformation.FileName,
pObjectInfo->FileId.Cell,
pObjectInfo->FileId.Volume,
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSValidateEntry Validating entry %wZ FID %08lX-%08lX-%08lX-%08lX DV %I64X returned DV %I64X FT %d\n",
+ "AFSValidateEntry Validating entry FastCall %d %wZ FID %08lX-%08lX-%08lX-%08lX DV %I64X returned DV %I64X FT %d\n",
+ FastCall,
&DirEntry->NameInformation.FileName,
pObjectInfo->FileId.Cell,
pObjectInfo->FileId.Volume,
if ( bPurgeExtents)
{
- AFSFlushExtents( pCurrentFcb);
+ AFSFlushExtents( pCurrentFcb,
+ AuthGroup);
}
//
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
- "AFSValidateEntry Attempt to verify node of type %d\n",
- pObjectInfo->FileType);
+ "AFSValidateEntry Attempt to verify node of type %d FastCall %d %wZ FID %08lX-%08lX-%08lX-%08lX\n",
+ pObjectInfo->FileType,
+ FastCall,
+ &DirEntry->NameInformation.FileName,
+ pObjectInfo->FileId.Cell,
+ pObjectInfo->FileId.Volume,
+ pObjectInfo->FileId.Vnode,
+ pObjectInfo->FileId.Unique);
break;
}
{
AFSNameArrayHdr *pNameArray = NULL;
+ AFSNameArrayCB *pCurrentElement = NULL;
AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ LONG lCount;
__Enter
{
if( pNameArray == NULL)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSInitNameArray Failed to allocate name array\n");
if( DirectoryCB != NULL)
{
- pNameArray->CurrentEntry = &pNameArray->ElementArray[ 0];
+ pCurrentElement = &pNameArray->ElementArray[ 0];
- InterlockedIncrement( &pNameArray->Count);
+ pNameArray->CurrentEntry = pCurrentElement;
- InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
+ pNameArray->Count = 1;
+
+ pNameArray->LinkCount = 0;
+
+ lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInitNameArray Increment count on %wZ DE %p Cnt %d\n",
&DirectoryCB->NameInformation.FileName,
DirectoryCB,
- DirectoryCB->OpenReferenceCount);
+ lCount);
+
+ pCurrentElement->DirectoryCB = DirectoryCB;
+
+ pCurrentElement->Component = DirectoryCB->NameInformation.FileName;
- pNameArray->CurrentEntry->DirectoryCB = DirectoryCB;
+ pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId;
- pNameArray->CurrentEntry->Component = DirectoryCB->NameInformation.FileName;
+ if( pCurrentElement->FileId.Vnode == 1)
+ {
+
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ }
- pNameArray->CurrentEntry->FileId = DirectoryCB->ObjectInformation->FileId;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInitNameArray [NA:%p] Element[0] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ pNameArray,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
}
try_exit:
ULONG ulTotalCount = 0;
ULONG ulIndex = 0;
USHORT usLength = 0;
+ LONG lCount;
__Enter
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSPopulateNameArray [NA:%p] passed Path %wZ DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ &Path,
+ DirectoryCB,
+ DirectoryCB->ObjectInformation->FileId.Cell,
+ DirectoryCB->ObjectInformation->FileId.Volume,
+ DirectoryCB->ObjectInformation->FileId.Vnode,
+ DirectoryCB->ObjectInformation->FileId.Unique,
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB->ObjectInformation->FileType);
+
//
// Init some info in the header
//
pCurrentElement->DirectoryCB = DirectoryCB->ObjectInformation->VolumeCB->DirectoryCB;
- InterlockedIncrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSPopulateNameArray Increment count on volume %wZ DE %p Cnt %d\n",
&pCurrentElement->DirectoryCB->NameInformation.FileName,
pCurrentElement->DirectoryCB,
- pCurrentElement->DirectoryCB->OpenReferenceCount);
+ lCount);
pCurrentElement->Component = DirectoryCB->ObjectInformation->VolumeCB->DirectoryCB->NameInformation.FileName;
pCurrentElement->FileId = DirectoryCB->ObjectInformation->VolumeCB->ObjectInformation.FileId;
+ pCurrentElement->Flags = 0;
+
+ if( pCurrentElement->FileId.Vnode == 1)
+ {
+
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ }
+
NameArray->Count = 1;
NameArray->LinkCount = 0;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSPopulateNameArray [NA:%p] Element[0] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
+
//
// If the root is the parent then we are done ...
//
ULONG ulTotalCount = 0;
ULONG ulIndex = 0;
USHORT usLength = 0;
+ LONG lCount;
__Enter
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSPopulateNameArray [NA:%p] passed RelatedNameArray %p DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ RelatedNameArray,
+ DirectoryCB,
+ DirectoryCB->ObjectInformation->FileId.Cell,
+ DirectoryCB->ObjectInformation->FileId.Volume,
+ DirectoryCB->ObjectInformation->FileId.Vnode,
+ DirectoryCB->ObjectInformation->FileId.Unique,
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB->ObjectInformation->FileType);
+
//
// Init some info in the header
//
pCurrentElement->FileId = pCurrentElement->DirectoryCB->ObjectInformation->FileId;
- InterlockedIncrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
+ pCurrentElement->Flags = 0;
+
+ if( pCurrentElement->FileId.Vnode == 1)
+ {
+
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ }
+
+ lCount = InterlockedIncrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSPopulateNameArrayFromRelatedArray Increment count on %wZ DE %p Cnt %d\n",
&pCurrentElement->DirectoryCB->NameInformation.FileName,
pCurrentElement->DirectoryCB,
- pCurrentElement->DirectoryCB->OpenReferenceCount);
+ lCount);
- InterlockedIncrement( &NameArray->Count);
+ lCount = InterlockedIncrement( &NameArray->Count);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSPopulateNameArrayFromRelatedArray [NA:%p] Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ lCount - 1,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
if( pCurrentElement->DirectoryCB == DirectoryCB ||
NameArray->Count == RelatedNameArray->Count)
pCurrentRelatedElement++;
}
- if( NameArray->Count > 0)
- {
- NameArray->CurrentEntry = pCurrentElement;
- }
+ NameArray->CurrentEntry = NameArray->Count > 0 ? pCurrentElement : NULL;
}
return ntStatus;
NTSTATUS ntStatus = STATUS_SUCCESS;
AFSNameArrayCB *pCurrentElement = NULL;
+ LONG lCount, lElement;
__Enter
{
- pCurrentElement = &NameArray->ElementArray[ 0];
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSFreeNameArray [NA:%p]\n",
+ NameArray);
- while( TRUE)
+ for ( lElement = 0; lElement < NameArray->Count; lElement++)
{
- if( pCurrentElement->DirectoryCB == NULL)
- {
-
- break;
- }
+ pCurrentElement = &NameArray->ElementArray[ lElement];
- InterlockedDecrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSFreeNameArray Decrement count on %wZ DE %p Cnt %d\n",
&pCurrentElement->DirectoryCB->NameInformation.FileName,
pCurrentElement->DirectoryCB,
- pCurrentElement->DirectoryCB->OpenReferenceCount);
-
- pCurrentElement++;
+ lCount);
}
AFSExFreePool( NameArray);
NTSTATUS
AFSInsertNextElement( IN AFSNameArrayHdr *NameArray,
- IN AFSDirectoryCB *DirEntry)
+ IN AFSDirectoryCB *DirectoryCB)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
- AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ AFSNameArrayCB *pCurrentElement = NULL;
+ LONG lCount;
__Enter
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInsertNextElement [NA:%p] passed DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ DirectoryCB,
+ DirectoryCB->ObjectInformation->FileId.Cell,
+ DirectoryCB->ObjectInformation->FileId.Volume,
+ DirectoryCB->ObjectInformation->FileId.Vnode,
+ DirectoryCB->ObjectInformation->FileId.Unique,
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB->ObjectInformation->FileType);
+
if( NameArray->Count == NameArray->MaxElementCount)
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSInsertNextElement [NA:%p] Name has reached Maximum Size\n",
+ NameArray);
+
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
if( NameArray->CurrentEntry != NULL &&
- NameArray->CurrentEntry->DirectoryCB == DirEntry)
+ NameArray->CurrentEntry->DirectoryCB == DirectoryCB)
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSInsertNextElement [NA:%p] DE %p already current element\n",
+ NameArray,
+ DirectoryCB);
+
try_return( ntStatus);
}
NameArray->CurrentEntry = &NameArray->ElementArray[ 0];
}
- InterlockedIncrement( &NameArray->Count);
+ pCurrentElement = NameArray->CurrentEntry;
+
+ lCount = InterlockedIncrement( &NameArray->Count);
- InterlockedIncrement( &DirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSInsertNextElement Increment count on %wZ DE %p Cnt %d\n",
- &DirEntry->NameInformation.FileName,
- DirEntry,
- DirEntry->OpenReferenceCount);
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB,
+ lCount);
+
+ pCurrentElement->DirectoryCB = DirectoryCB;
+
+ pCurrentElement->Component = DirectoryCB->NameInformation.FileName;
+
+ pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId;
+
+ pCurrentElement->Flags = 0;
- NameArray->CurrentEntry->DirectoryCB = DirEntry;
+ if( pCurrentElement->FileId.Vnode == 1)
+ {
- NameArray->CurrentEntry->Component = DirEntry->NameInformation.FileName;
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ }
- NameArray->CurrentEntry->FileId = DirEntry->ObjectInformation->FileId;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInsertNextElement [NA:%p] Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ NameArray->Count - 1,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
try_exit:
AFSReplaceCurrentElement( IN AFSNameArrayHdr *NameArray,
IN AFSDirectoryCB *DirectoryCB)
{
+ AFSNameArrayCB *pCurrentElement = NULL;
+ LONG lCount;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSReplaceCurrentElement [NA:%p] passed DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ DirectoryCB,
+ DirectoryCB->ObjectInformation->FileId.Cell,
+ DirectoryCB->ObjectInformation->FileId.Volume,
+ DirectoryCB->ObjectInformation->FileId.Vnode,
+ DirectoryCB->ObjectInformation->FileId.Unique,
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB->ObjectInformation->FileType);
ASSERT( NameArray->CurrentEntry != NULL);
- InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
+ pCurrentElement = NameArray->CurrentEntry;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSReplaceCurrentElement [NA:%p] Replacing Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ NameArray->Count - 1,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
+
+ lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSReplaceCurrentElement Decrement count on %wZ DE %p Cnt %d\n",
- &NameArray->CurrentEntry->DirectoryCB->NameInformation.FileName,
- NameArray->CurrentEntry->DirectoryCB,
- NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB,
+ lCount);
- InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSReplaceCurrentElement Increment count on %wZ DE %p Cnt %d\n",
&DirectoryCB->NameInformation.FileName,
DirectoryCB,
- DirectoryCB->OpenReferenceCount);
+ lCount);
+
+ pCurrentElement->DirectoryCB = DirectoryCB;
- NameArray->CurrentEntry->DirectoryCB = DirectoryCB;
+ pCurrentElement->Component = DirectoryCB->NameInformation.FileName;
- NameArray->CurrentEntry->Component = DirectoryCB->NameInformation.FileName;
+ pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId;
- NameArray->CurrentEntry->FileId = DirectoryCB->ObjectInformation->FileId;
+ pCurrentElement->Flags = 0;
- if( DirectoryCB->ObjectInformation->ParentObjectInformation == NULL)
+ if( pCurrentElement->FileId.Vnode == 1)
{
- SetFlag( NameArray->CurrentEntry->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
}
return;
AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
{
- AFSDirectoryCB *pCurrentDirEntry = NULL;
+ AFSDirectoryCB *pDirectoryCB = NULL;
+ AFSNameArrayCB *pCurrentElement = NULL;
+ LONG lCount;
__Enter
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBackupEntry [NA:%p]\n",
+ NameArray);
+
if( NameArray->Count == 0)
{
- try_return( pCurrentDirEntry);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSBackupEntry [NA:%p] No more entries\n",
+ NameArray);
+
+ try_return( pCurrentElement);
}
- InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSBackupEntry Decrement count on %wZ DE %p Cnt %d\n",
&NameArray->CurrentEntry->DirectoryCB->NameInformation.FileName,
NameArray->CurrentEntry->DirectoryCB,
- NameArray->CurrentEntry->DirectoryCB->OpenReferenceCount);
+ lCount);
NameArray->CurrentEntry->DirectoryCB = NULL;
- if( InterlockedDecrement( &NameArray->Count) == 0)
+ lCount = InterlockedDecrement( &NameArray->Count);
+
+ if( lCount == 0)
{
NameArray->CurrentEntry = NULL;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSBackupEntry [NA:%p] No more entries\n",
+ NameArray);
}
else
{
NameArray->CurrentEntry--;
- pCurrentDirEntry = NameArray->CurrentEntry->DirectoryCB;
+
+ pCurrentElement = NameArray->CurrentEntry;
+
+ pDirectoryCB = pCurrentElement->DirectoryCB;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSBackupEntry [NA:%p] Returning Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ NameArray->Count - 1,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
}
try_exit:
NOTHING;
}
- return pCurrentDirEntry;
+ return pDirectoryCB;
}
AFSDirectoryCB *
__Enter
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetParentEntry [NA:%p]\n",
+ NameArray);
+
if( NameArray->Count == 0 ||
NameArray->Count == 1)
{
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSGetParentEntry [NA:%p] No more entries\n",
+ NameArray);
+
try_return( pDirEntry = NULL);
}
pDirEntry = pElement->DirectoryCB;
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetParentEntry [NA:%p] Returning Element[%d] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ NameArray->Count - 2,
+ pElement->DirectoryCB,
+ pElement->FileId.Cell,
+ pElement->FileId.Volume,
+ pElement->FileId.Vnode,
+ pElement->FileId.Unique,
+ &pElement->DirectoryCB->NameInformation.FileName,
+ pElement->DirectoryCB->ObjectInformation->FileType);
+
try_exit:
NOTHING;
void
AFSResetNameArray( IN AFSNameArrayHdr *NameArray,
- IN AFSDirectoryCB *DirEntry)
+ IN AFSDirectoryCB *DirectoryCB)
{
AFSNameArrayCB *pCurrentElement = NULL;
AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ LONG lCount, lElement;
__Enter
{
- pCurrentElement = &NameArray->ElementArray[ 0];
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSResetNameArray [NA:%p] passed DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ DirectoryCB,
+ DirectoryCB->ObjectInformation->FileId.Cell,
+ DirectoryCB->ObjectInformation->FileId.Volume,
+ DirectoryCB->ObjectInformation->FileId.Vnode,
+ DirectoryCB->ObjectInformation->FileId.Unique,
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB->ObjectInformation->FileType);
+ //
+ // Dereference previous name array contents
+ //
- while( TRUE)
+ for ( lElement = 0; lElement < NameArray->Count; lElement++)
{
- if( pCurrentElement->DirectoryCB == NULL)
- {
-
- break;
- }
+ pCurrentElement = &NameArray->ElementArray[ lElement];
- InterlockedDecrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pCurrentElement->DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSResetNameArray Decrement count on %wZ DE %p Cnt %d\n",
&pCurrentElement->DirectoryCB->NameInformation.FileName,
pCurrentElement->DirectoryCB,
- pCurrentElement->DirectoryCB->OpenReferenceCount);
-
- pCurrentElement++;
+ lCount);
}
RtlZeroMemory( NameArray,
NameArray->MaxElementCount = pDevExt->Specific.RDR.NameArrayLength;
- if( DirEntry != NULL)
+ if( DirectoryCB != NULL)
{
- NameArray->CurrentEntry = &NameArray->ElementArray[ 0];
+ pCurrentElement = &NameArray->ElementArray[ 0];
+
+ NameArray->CurrentEntry = pCurrentElement;
+
+ NameArray->Count = 1;
- InterlockedIncrement( &NameArray->Count);
+ NameArray->LinkCount = 0;
- InterlockedIncrement( &DirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &DirectoryCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSResetNameArray Increment count on %wZ DE %p Cnt %d\n",
- &DirEntry->NameInformation.FileName,
- DirEntry,
- DirEntry->OpenReferenceCount);
+ &DirectoryCB->NameInformation.FileName,
+ DirectoryCB,
+ lCount);
+
+ pCurrentElement->DirectoryCB = DirectoryCB;
+
+ pCurrentElement->Component = DirectoryCB->NameInformation.FileName;
- NameArray->CurrentEntry->DirectoryCB = DirEntry;
+ pCurrentElement->FileId = DirectoryCB->ObjectInformation->FileId;
- NameArray->CurrentEntry->Component = DirEntry->NameInformation.FileName;
+ pCurrentElement->Flags = 0;
- NameArray->CurrentEntry->FileId = DirEntry->ObjectInformation->FileId;
+ if( pCurrentElement->FileId.Vnode == 1)
+ {
+
+ SetFlag( pCurrentElement->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT);
+ }
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_NAME_ARRAY_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSResetNameArray [NA:%p] Element[0] DE %p FID %08lX-%08lX-%08lX-%08lX %wZ Type %d\n",
+ NameArray,
+ pCurrentElement->DirectoryCB,
+ pCurrentElement->FileId.Cell,
+ pCurrentElement->FileId.Volume,
+ pCurrentElement->FileId.Vnode,
+ pCurrentElement->FileId.Unique,
+ &pCurrentElement->DirectoryCB->NameInformation.FileName,
+ pCurrentElement->DirectoryCB->ObjectInformation->FileType);
}
}
void
AFSSetEnumerationEvent( IN AFSFcb *Fcb)
{
+ LONG lCount;
//
// Depending on the type of node, set the event
{
case AFS_DIRECTORY_FCB:
- {
-
- KeSetEvent( &Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent,
- 0,
- FALSE);
-
- InterlockedIncrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount);
-
- break;
- }
-
case AFS_ROOT_FCB:
case AFS_ROOT_ALL:
{
- KeSetEvent( &Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent,
- 0,
- FALSE);
-
- InterlockedIncrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount);
+ lCount = InterlockedIncrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount);
break;
}
AFSClearEnumerationEvent( IN AFSFcb *Fcb)
{
+ LONG lCount;
+
//
// Depending on the type of node, set the event
//
{
case AFS_DIRECTORY_FCB:
- {
-
- ASSERT( Fcb->NPFcb->Specific.Directory.DirectoryEnumCount > 0);
-
- if( InterlockedDecrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount) == 0)
- {
-
- KeClearEvent( &Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent);
- }
-
- break;
- }
-
case AFS_ROOT_FCB:
case AFS_ROOT_ALL:
{
ASSERT( Fcb->NPFcb->Specific.Directory.DirectoryEnumCount > 0);
- if( InterlockedDecrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount) == 0)
- {
-
- KeClearEvent( &Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent);
- }
+ lCount = InterlockedDecrement( &Fcb->NPFcb->Specific.Directory.DirectoryEnumCount);
break;
}
try_return( bIsInProcess);
}
- //
- // Depending on the type of node, set the event
- //
-
switch( ObjectInfo->Fcb->Header.NodeTypeCode)
{
case AFS_DIRECTORY_FCB:
- {
-
- if( KeReadStateEvent( &ObjectInfo->Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent))
- {
-
- bIsInProcess = TRUE;
- }
-
- break;
- }
-
case AFS_ROOT_FCB:
case AFS_ROOT_ALL:
{
- if( KeReadStateEvent( &ObjectInfo->Fcb->NPFcb->Specific.Directory.DirectoryEnumEvent))
+ if( ObjectInfo->Fcb->NPFcb->Specific.Directory.DirectoryEnumCount > 0)
{
bIsInProcess = TRUE;
AFSDirectoryCB *pDirNode = NULL;
ULONG ulEntryLength = 0;
AFSNonPagedDirectoryCB *pNonPagedDirEntry = NULL;
+ LONG lCount;
__Enter
{
pDirNode->NameInformation.FileName.Buffer = (WCHAR *)((char *)pDirNode + sizeof( AFSDirectoryCB));
- RtlCopyMemory( pDirNode->NameInformation.FileName.Buffer,
- AFSPIOCtlName.Buffer,
- pDirNode->NameInformation.FileName.Length);
+ RtlCopyMemory( pDirNode->NameInformation.FileName.Buffer,
+ AFSPIOCtlName.Buffer,
+ pDirNode->NameInformation.FileName.Length);
+
+ pDirNode->CaseInsensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pDirNode->NameInformation.FileName,
+ TRUE);
+
+ if ( InterlockedCompareExchangePointer( (PVOID *)&ObjectInfo->Specific.Directory.PIOCtlDirectoryCB, pDirNode, NULL) != NULL)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSInitPIOCtlDirectoryCB Raced PIOCtlDirectoryCB %08lX pFcb %08lX\n",
+ ObjectInfo->Specific.Directory.PIOCtlDirectoryCB,
+ pDirNode);
+
+ //
+ // Increment the open reference and handle on the node
+ //
+
+ lCount = InterlockedIncrement( &pDirNode->ObjectInformation->ObjectReferenceCount);
- pDirNode->CaseInsensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pDirNode->NameInformation.FileName,
- TRUE);
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSInitPIOCtlDirectoryCB Increment count on Object %08lX Cnt %d\n",
+ pDirNode->ObjectInformation,
+ lCount);
- ObjectInfo->Specific.Directory.PIOCtlDirectoryCB = pDirNode;
+ try_return( ntStatus = STATUS_REPARSE);
+ }
try_exit:
- if ( !NT_SUCCESS( ntStatus))
+ if ( ntStatus != STATUS_SUCCESS)
{
if ( pDirNode != NULL)
IN AFSDirectoryCB *DirectoryCB,
IN UNICODE_STRING *ParentPathName,
IN AFSNameArrayHdr *RelatedNameArray,
+ IN GUID *AuthGroup,
OUT AFSFileInfoCB *FileInfo)
{
WCHAR *pwchBuffer = NULL;
UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
ULONG ulNameDifference = 0;
- GUID *pAuthGroup = NULL;
+ LONG lCount;
__Enter
{
AFSReleaseResource( &DirectoryCB->NonPaged->Lock);
- if( ParentDirectoryCB->ObjectInformation->Fcb != NULL)
- {
- pAuthGroup = &ParentDirectoryCB->ObjectInformation->Fcb->AuthGroup;
- }
- else if( DirectoryCB->ObjectInformation->Fcb != NULL)
- {
- pAuthGroup = &DirectoryCB->ObjectInformation->Fcb->AuthGroup;
- }
-
ntStatus = AFSEvaluateTargetByID( DirectoryCB->ObjectInformation,
- pAuthGroup,
+ AuthGroup,
FALSE,
&pDirEntry);
if( pDirEntry != NULL)
{
- ntStatus = STATUS_ACCESS_DENIED;
+ ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED;
}
try_return( ntStatus);
pVolumeCB = ParentDirectoryCB->ObjectInformation->VolumeCB;
- AFSAcquireShared( pVolumeCB->VolumeLock,
- TRUE);
-
pParentDirEntry = ParentDirectoryCB;
}
else
pVolumeCB = AFSGlobalRoot;
- AFSAcquireShared( pVolumeCB->VolumeLock,
- TRUE);
-
pParentDirEntry = AFSGlobalRoot->DirectoryCB;
}
// Increment the ref count on the volume and dir entry for correct processing below
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSRetrieveFileAttributes Increment count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
- InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
ntStatus = AFSLocateNameEntry( NULL,
NULL,
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSRetrieveFileAttributes Decrement count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ lCount);
}
if( pDirectoryEntry != NULL)
{
- InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirectoryEntry->NameInformation.FileName,
pDirectoryEntry,
NULL,
- pDirectoryEntry->OpenReferenceCount);
+ lCount);
}
else
{
- InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
}
}
// Remove the reference made above
//
- InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirectoryEntry->NameInformation.FileName,
pDirectoryEntry,
NULL,
- pDirectoryEntry->OpenReferenceCount);
+ lCount);
try_exit:
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSRetrieveFileAttributes Decrement2 count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ lCount);
}
if( pNameArray != NULL)
NTSTATUS ntStatus = STATUS_SUCCESS;
AFSObjectInfoCB *pObjectInfo = NULL;
+ LONG lCount;
__Enter
{
if( ParentObjectInfo != NULL)
{
- InterlockedIncrement( &ParentObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &ParentObjectInfo->ObjectReferenceCount);
}
//
{
BOOLEAN bAcquiredTreeLock = FALSE;
+ LONG lCount;
if( !ExIsResourceAcquiredExclusiveLite( ObjectInfo->VolumeCB->ObjectInfoTree.TreeLock))
{
if( ObjectInfo->ParentObjectInformation != NULL)
{
- InterlockedDecrement( &ObjectInfo->ParentObjectInformation->ObjectReferenceCount);
+
+ lCount = InterlockedDecrement( &ObjectInfo->ParentObjectInformation->ObjectReferenceCount);
}
if( bAcquiredTreeLock)
WCHAR *pwchBuffer = NULL;
UNICODE_STRING uniComponentName, uniRemainingPath, uniParsedName;
ULONG ulNameDifference = 0;
- GUID *pAuthGroup = NULL;
+ GUID stAuthGroup;
+ LONG lCount;
__Enter
{
+ ntStatus = AFSRetrieveValidAuthGroup( NULL,
+ DirectoryCB->ObjectInformation,
+ FALSE,
+ &stAuthGroup);
+
+ if( !NT_SUCCESS( ntStatus))
+ {
+ try_return( ntStatus);
+ }
+
//
// Retrieve a target name for the entry
//
AFSReleaseResource( &DirectoryCB->NonPaged->Lock);
- if( DirectoryCB->ObjectInformation->Fcb != NULL)
- {
- pAuthGroup = &DirectoryCB->ObjectInformation->Fcb->AuthGroup;
- }
-
ntStatus = AFSEvaluateTargetByID( DirectoryCB->ObjectInformation,
- pAuthGroup,
+ &stAuthGroup,
FALSE,
&pDirEntry);
if( pDirEntry != NULL)
{
- ntStatus = STATUS_ACCESS_DENIED;
+ ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED;
}
try_return( ntStatus);
pVolumeCB = AFSGlobalRoot;
- AFSAcquireShared( pVolumeCB->VolumeLock,
- TRUE);
-
pParentDirEntry = AFSGlobalRoot->DirectoryCB;
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSEvaluateRootEntry Increment count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
- InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
ntStatus = AFSLocateNameEntry( NULL,
NULL,
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSEvaluateRootEntry Decrement count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ lCount);
}
if( pDirectoryEntry != NULL)
{
- InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirectoryEntry->NameInformation.FileName,
pDirectoryEntry,
NULL,
- pDirectoryEntry->OpenReferenceCount);
+ lCount);
}
else
{
- InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
}
}
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSEvaluateRootEntry2 Decrement count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ lCount);
}
if( pNameArray != NULL)
// Now perform another flush on the file
//
- if( !NT_SUCCESS( AFSFlushExtents( Fcb)))
+ if( !NT_SUCCESS( AFSFlushExtents( Fcb,
+ NULL)))
{
- AFSReleaseExtentsWithFlush( Fcb);
+ AFSReleaseExtentsWithFlush( Fcb,
+ NULL);
}
}
BooleanFlagOn( Fcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DELETED))
{
- AFSTearDownFcbExtents( Fcb);
+ AFSTearDownFcbExtents( Fcb,
+ NULL);
}
try_return( ntStatus);
(liTime.QuadPart - Fcb->Specific.File.LastServerFlush.QuadPart)
>= pControlDeviceExt->Specific.Control.FcbFlushTimeCount.QuadPart))
{
-
- if( !NT_SUCCESS( AFSFlushExtents( Fcb)) &&
+ if( !NT_SUCCESS( AFSFlushExtents( Fcb,
+ NULL)) &&
Fcb->OpenReferenceCount == 0)
{
- AFSReleaseExtentsWithFlush( Fcb);
+ AFSReleaseExtentsWithFlush( Fcb,
+ NULL);
}
}
else if( BooleanFlagOn( Fcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_OBJECT_INVALID) ||
// The file has been marked as invalid. Dump it
//
- AFSTearDownFcbExtents( Fcb);
+ AFSTearDownFcbExtents( Fcb,
+ NULL);
}
//
// Tear em down we'll not be needing them again
//
- AFSTearDownFcbExtents( Fcb);
+ AFSTearDownFcbExtents( Fcb,
+ NULL);
}
}
ulTimeIncrement = KeQueryTimeIncrement();
pControlDevExt->Specific.Control.ObjectLifeTimeCount.QuadPart = (ULONGLONG)((ULONGLONG)AFS_OBJECT_LIFETIME / (ULONGLONG)ulTimeIncrement);
- pControlDevExt->Specific.Control.FcbPurgeTimeCount.QuadPart = AFS_ONE_SECOND;
- pControlDevExt->Specific.Control.FcbPurgeTimeCount.QuadPart *= AFS_SERVER_PURGE_DELAY;
+ pControlDevExt->Specific.Control.FcbPurgeTimeCount.QuadPart = AFS_SERVER_PURGE_DELAY;
pControlDevExt->Specific.Control.FcbPurgeTimeCount.QuadPart /= ulTimeIncrement;
- pControlDevExt->Specific.Control.FcbFlushTimeCount.QuadPart = (ULONGLONG)((ULONGLONG)(AFS_ONE_SECOND * AFS_SERVER_FLUSH_DELAY) / (ULONGLONG)ulTimeIncrement);
+ pControlDevExt->Specific.Control.FcbFlushTimeCount.QuadPart = (ULONGLONG)((ULONGLONG)AFS_SERVER_FLUSH_DELAY / (ULONGLONG)ulTimeIncrement);
pControlDevExt->Specific.Control.ExtentRequestTimeCount.QuadPart = (ULONGLONG)((ULONGLONG)AFS_EXTENT_REQUEST_TIME/(ULONGLONG)ulTimeIncrement);
//
SetFlag( AFSGlobalRoot->Flags, AFS_VOLUME_ACTIVE_GLOBAL_ROOT);
//
+ // Invalidate all known volumes since contact with the service and therefore
+ // the file server was lost.
+ //
+
+ AFSInvalidateAllVolumes();
+
+ //
// Drop the locks acquired above
//
UNICODE_STRING uniFullPathName, uniRemainingPath, uniComponentName, uniParsedName;
AFSNameArrayHdr *pNameArray = NULL;
AFSDirectoryCB *pDirectoryEntry = NULL, *pParentDirEntry = NULL;
+ LONG lCount;
__Enter
{
if( pVolumeCB != NULL)
{
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSGetObjectStatus Increment count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
}
AFSReleaseResource( &pDevExt->Specific.RDR.VolumeTreeLock);
pObjectInfo = &pVolumeCB->ObjectInformation;
- InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
}
else
{
AFSAcquireShared( pVolumeCB->ObjectInfoTree.TreeLock,
TRUE);
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSGetObjectStatus Decrement count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
ullIndex = AFSCreateLowIndex( &GetStatusInfo->FileID);
// Reference the node so it won't be torn down
//
- InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSGetObjectStatus Increment count on object %08lX Cnt %d\n",
pObjectInfo,
- pObjectInfo->ObjectReferenceCount);
+ lCount);
}
AFSReleaseResource( pVolumeCB->ObjectInfoTree.TreeLock);
pVolumeCB = AFSGlobalRoot;
- AFSAcquireShared( pVolumeCB->VolumeLock,
- TRUE);
-
pParentDirEntry = AFSGlobalRoot->DirectoryCB;
//
// Increment the ref count on the volume and dir entry for correct processing below
//
- InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSGetObjectStatus Increment count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
+ lCount);
- InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
ntStatus = AFSLocateNameEntry( NULL,
NULL,
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSGetObjectStatus Decrement count on volume %08lX Cnt %d\n",
pVolumeCB,
- pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
+ lCount);
}
if( pDirectoryEntry != NULL)
{
- InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pDirectoryEntry->NameInformation.FileName,
pDirectoryEntry,
NULL,
- pDirectoryEntry->OpenReferenceCount);
+ lCount);
}
else
{
- InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pParentDirEntry->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
&pParentDirEntry->NameInformation.FileName,
pParentDirEntry,
NULL,
- pParentDirEntry->OpenReferenceCount);
+ lCount);
}
}
// Remove the reference made above
//
- InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirectoryEntry->OpenReferenceCount);
pObjectInfo = pDirectoryEntry->ObjectInformation;
- InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
if( pVolumeCB != NULL)
{
- InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
+ lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSRetrieveFileAttributes Decrement2 count on volume %08lX Cnt %d\n",
pVolumeCB,
pVolumeCB->VolumeReferenceCount);
-
- AFSReleaseResource( pVolumeCB->VolumeLock);
}
}
if( pObjectInfo != NULL)
{
- InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
}
if( pNameArray != NULL)
NTSTATUS ntStatus = STATUS_SUCCESS;
AFSDirectoryCB *pDirEntry = NULL;
ULONG ulCRC = 0;
+ LONG lCount;
__Enter
{
if( pDirEntry != NULL)
{
- InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedIncrement( &pDirEntry->OpenReferenceCount);
}
AFSReleaseResource( ParentDirectoryCB->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
- "AFSCheckSymlinkAccess Failing symlink access to entry %wZ ACCESS_DENIED\n",
+ "AFSCheckSymlinkAccess Failing symlink access to entry %wZ REPARSE_POINT_NOT_RESOLVED\n",
ComponentName);
- ntStatus = STATUS_ACCESS_DENIED;
+ ntStatus = STATUS_REPARSE_POINT_NOT_RESOLVED;
- InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+ lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
try_exit:
SECURITY_DESCRIPTOR *pSecurityDescr = NULL;
ULONG ulSDLength = 0;
SECURITY_DESCRIPTOR *pRelativeSecurityDescr = NULL;
+ PSID pWorldSID = NULL;
+ ULONG *pulSubAuthority = NULL;
+ ULONG ulWorldSIDLEngth = 0;
__Enter
{
+ ulWorldSIDLEngth = RtlLengthRequiredSid( 1);
+
+ pWorldSID = (PSID)ExAllocatePoolWithTag( PagedPool,
+ ulWorldSIDLEngth,
+ AFS_GENERIC_MEMORY_29_TAG);
+
+ if( pWorldSID == NULL)
+ {
+ AFSPrint( "AFSCreateDefaultSecurityDescriptor unable to allocate World SID\n");
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+ }
+
+ RtlZeroMemory( pWorldSID,
+ ulWorldSIDLEngth);
+
+ RtlInitializeSid( pWorldSID,
+ &SeWorldSidAuthority,
+ 1);
+
+ pulSubAuthority = RtlSubAuthoritySid(pWorldSID, 0);
+ *pulSubAuthority = SECURITY_WORLD_RID;
+
if( AFSRtlSetSaclSecurityDescriptor == NULL)
{
}
}
+ //
+ // Add in the group and owner to the SD
+ //
+
+ if( AFSRtlSetGroupSecurityDescriptor != NULL)
+ {
+ ntStatus = AFSRtlSetGroupSecurityDescriptor( pSecurityDescr,
+ pWorldSID,
+ FALSE);
+
+ if( !NT_SUCCESS( ntStatus))
+ {
+
+ AFSPrint( "AFSCreateDefaultSecurityDescriptor RtlSetGroupSecurityDescriptor failed ntStatus %08lX\n",
+ ntStatus);
+
+ try_return( ntStatus);
+ }
+ }
+
+ ntStatus = RtlSetOwnerSecurityDescriptor( pSecurityDescr,
+ pWorldSID,
+ FALSE);
+
+ if( !NT_SUCCESS( ntStatus))
+ {
+
+ AFSPrint( "AFSCreateDefaultSecurityDescriptor RtlSetOwnerSecurityDescriptor failed ntStatus %08lX\n",
+ ntStatus);
+
+ try_return( ntStatus);
+ }
+
if( !RtlValidSecurityDescriptor( pSecurityDescr))
{
{
ExFreePool( pACE);
}
+
+ if( pWorldSID != NULL)
+ {
+ ExFreePool( pWorldSID);
+ }
}
return ntStatus;
return;
}
+
+NTSTATUS
+AFSRetrieveValidAuthGroup( IN AFSFcb *Fcb,
+ IN AFSObjectInfoCB *ObjectInfo,
+ IN BOOLEAN WriteAccess,
+ OUT GUID *AuthGroup)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ GUID stAuthGroup, stZeroAuthGroup;
+ BOOLEAN bFoundAuthGroup = FALSE;
+ AFSCcb *pCcb = NULL;
+ AFSFcb *pFcb = Fcb;
+
+ __Enter
+ {
+
+ RtlZeroMemory( &stAuthGroup,
+ sizeof( GUID));
+
+ RtlZeroMemory( &stZeroAuthGroup,
+ sizeof( GUID));
+
+ if( Fcb == NULL)
+ {
+
+ if( ObjectInfo != NULL &&
+ ObjectInfo->Fcb != NULL)
+ {
+ pFcb = ObjectInfo->Fcb;
+ }
+ }
+
+ if( pFcb != NULL)
+ {
+
+ AFSAcquireShared( &Fcb->NPFcb->CcbListLock,
+ TRUE);
+
+ pCcb = Fcb->CcbListHead;
+
+ while( pCcb != NULL)
+ {
+
+ if( WriteAccess &&
+ pCcb->GrantedAccess & FILE_WRITE_DATA)
+ {
+ RtlCopyMemory( &stAuthGroup,
+ &pCcb->AuthGroup,
+ sizeof( GUID));
+
+ bFoundAuthGroup = TRUE;
+
+ break;
+ }
+ else if( pCcb->GrantedAccess & FILE_READ_DATA)
+ {
+ //
+ // At least get the read-only access
+ //
+
+ RtlCopyMemory( &stAuthGroup,
+ &pCcb->AuthGroup,
+ sizeof( GUID));
+
+ bFoundAuthGroup = TRUE;
+ }
+
+ pCcb = (AFSCcb *)pCcb->ListEntry.fLink;
+ }
+
+ AFSReleaseResource( &Fcb->NPFcb->CcbListLock);
+ }
+
+ if( !bFoundAuthGroup)
+ {
+
+ AFSRetrieveAuthGroupFnc( (ULONGLONG)PsGetCurrentProcessId(),
+ (ULONGLONG)PsGetCurrentThreadId(),
+ &stAuthGroup);
+
+ if( RtlCompareMemory( &stZeroAuthGroup,
+ &stAuthGroup,
+ sizeof( GUID)) == sizeof( GUID))
+ {
+
+ DbgPrint("AFSRetrieveValidAuthGroup Failed to locate PAG\n");
+
+ try_return( ntStatus = STATUS_ACCESS_DENIED);
+ }
+ }
+
+ RtlCopyMemory( AuthGroup,
+ &stAuthGroup,
+ sizeof( GUID));
+
+try_exit:
+
+ NOTHING;
+ }
+
+ return ntStatus;
+}
+
+NTSTATUS
+AFSPerformObjectInvalidate( IN AFSObjectInfoCB *ObjectInfo,
+ IN ULONG InvalidateReason)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ IO_STATUS_BLOCK stIoStatus;
+ LIST_ENTRY *le;
+ AFSExtent *pEntry;
+ ULONG ulProcessCount = 0;
+ ULONG ulCount = 0;
+
+ __Enter
+ {
+
+ switch( InvalidateReason)
+ {
+
+ case AFS_INVALIDATE_DELETED:
+ {
+
+ if( ObjectInfo->FileType == AFS_FILE_TYPE_FILE &&
+ ObjectInfo->Fcb != NULL)
+ {
+
+
+ //
+ // Clear out the extents
+ // And get rid of them (note this involves waiting
+ // for any writes or reads to the cache to complete)
+ //
+
+ (VOID) AFSTearDownFcbExtents( ObjectInfo->Fcb,
+ NULL);
+ }
+
+ break;
+ }
+
+ case AFS_INVALIDATE_DATA_VERSION:
+ {
+
+ LARGE_INTEGER liCurrentOffset = {0,0};
+ LARGE_INTEGER liFlushLength = {0,0};
+ ULONG ulFlushLength = 0;
+ BOOLEAN bLocked = FALSE;
+ BOOLEAN bExtentsLocked = FALSE;
+ BOOLEAN bCleanExtents = FALSE;
+
+ if( ObjectInfo->FileType == AFS_FILE_TYPE_FILE &&
+ ObjectInfo->Fcb != NULL)
+ {
+
+ AFSAcquireExcl( &ObjectInfo->Fcb->NPFcb->Resource,
+ TRUE);
+
+ bLocked = TRUE;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSPerformObjectInvalidate Acquiring Fcb extents lock %08lX SHARED %08lX\n",
+ &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
+ PsGetCurrentThread());
+
+ AFSAcquireShared( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
+ TRUE);
+
+ bExtentsLocked = TRUE;
+
+ //
+ // There are several possibilities here:
+ //
+ // 0. If there are no extents or all of the extents are dirty, do nothing.
+ //
+ // 1. There could be nothing dirty and an open reference count of zero
+ // in which case we can just tear down all of the extents without
+ // holding any resources.
+ //
+ // 2. There could be nothing dirty and a non-zero open reference count
+ // in which case we can issue a CcPurge against the entire file
+ // while holding just the Fcb Resource.
+ //
+ // 3. There can be dirty extents in which case we need to identify
+ // the non-dirty ranges and then perform a CcPurge on just the
+ // non-dirty ranges while holding just the Fcb Resource.
+ //
+
+ if ( ObjectInfo->Fcb->Specific.File.ExtentCount != ObjectInfo->Fcb->Specific.File.ExtentsDirtyCount)
+ {
+
+ if ( ObjectInfo->Fcb->Specific.File.ExtentsDirtyCount == 0)
+ {
+
+ if ( ObjectInfo->Fcb->OpenReferenceCount == 0)
+ {
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource );
+
+ bExtentsLocked = FALSE;
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Resource);
+
+ bLocked = FALSE;
+
+ (VOID) AFSTearDownFcbExtents( ObjectInfo->Fcb,
+ NULL);
+ }
+ else
+ {
+
+ __try
+ {
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource );
+
+ bExtentsLocked = FALSE;
+
+ if( !CcPurgeCacheSection( &ObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ NULL,
+ 0,
+ FALSE))
+ {
+ SetFlag( ObjectInfo->Fcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+ }
+ else
+ {
+
+ bCleanExtents = TRUE;
+ }
+ }
+ __except( EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ ntStatus = GetExceptionCode();
+
+ AFSDbgLogMsg( 0,
+ 0,
+ "EXCEPTION - AFSPerformObjectInvalidate Status %08lX\n",
+ ntStatus);
+ }
+ }
+ }
+ else
+ {
+
+ //
+ // Must build a list of non-dirty ranges from the beginning of the file
+ // to the end. There can be at most (Fcb->Specific.File.ExtentsDirtyCount + 1)
+ // ranges. In all but the most extreme random data write scenario there will
+ // be significantly fewer.
+ //
+ // For each range we need offset and size.
+ //
+
+ AFSByteRange * ByteRangeList = NULL;
+ ULONG ulByteRangeCount = 0;
+ ULONG ulIndex;
+ BOOLEAN bPurgeOnClose = FALSE;
+
+ __try
+ {
+
+ ulByteRangeCount = AFSConstructCleanByteRangeList( ObjectInfo->Fcb,
+ &ByteRangeList);
+
+ if ( ByteRangeList != NULL ||
+ ulByteRangeCount == 0)
+ {
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource );
+
+ bExtentsLocked = FALSE;
+
+ for ( ulIndex = 0; ulIndex < ulByteRangeCount; ulIndex++)
+ {
+
+ ULONG ulSize;
+
+ do {
+
+ ulSize = ByteRangeList[ulIndex].Length.QuadPart > DWORD_MAX ? DWORD_MAX : ByteRangeList[ulIndex].Length.LowPart;
+
+ if( !CcPurgeCacheSection( &ObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ &ByteRangeList[ulIndex].FileOffset,
+ ulSize,
+ FALSE))
+ {
+
+ bPurgeOnClose = TRUE;
+ }
+ else
+ {
+
+ bCleanExtents = TRUE;
+ }
+
+ ByteRangeList[ulIndex].Length.QuadPart -= ulSize;
+
+ ByteRangeList[ulIndex].FileOffset.QuadPart += ulSize;
+
+ } while ( ByteRangeList[ulIndex].Length.QuadPart > 0);
+ }
+ }
+ else
+ {
+
+ //
+ // We couldn't allocate the memory to build the purge list
+ // so just walk the extent list while holding the ExtentsList Resource.
+ // This could deadlock but we do not have much choice.
+ //
+
+ le = ObjectInfo->Fcb->Specific.File.ExtentsLists[AFS_EXTENTS_LIST].Flink;
+
+ ulProcessCount = 0;
+
+ ulCount = (ULONG)ObjectInfo->Fcb->Specific.File.ExtentCount;
+
+ if( ulCount > 0)
+ {
+ pEntry = ExtentFor( le, AFS_EXTENTS_LIST );
+
+ while( ulProcessCount < ulCount)
+ {
+ pEntry = ExtentFor( le, AFS_EXTENTS_LIST );
+
+ if( !BooleanFlagOn( pEntry->Flags, AFS_EXTENT_DIRTY))
+ {
+ if( !CcPurgeCacheSection( &ObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ &pEntry->FileOffset,
+ pEntry->Size,
+ FALSE))
+ {
+
+ bPurgeOnClose = TRUE;
+ }
+ else
+ {
+
+ bCleanExtents = TRUE;
+ }
+ }
+
+ if( liCurrentOffset.QuadPart < pEntry->FileOffset.QuadPart)
+ {
+
+ liFlushLength.QuadPart = pEntry->FileOffset.QuadPart - liCurrentOffset.QuadPart;
+
+ while( liFlushLength.QuadPart > 0)
+ {
+
+ if( liFlushLength.QuadPart > 512 * 1024000)
+ {
+ ulFlushLength = 512 * 1024000;
+ }
+ else
+ {
+ ulFlushLength = liFlushLength.LowPart;
+ }
+
+ if( !CcPurgeCacheSection( &ObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ &liCurrentOffset,
+ ulFlushLength,
+ FALSE))
+ {
+
+ bPurgeOnClose = TRUE;
+ }
+ else
+ {
+
+ bCleanExtents = TRUE;
+ }
+
+ liFlushLength.QuadPart -= ulFlushLength;
+ }
+ }
+
+ liCurrentOffset.QuadPart = pEntry->FileOffset.QuadPart + pEntry->Size;
+
+ ulProcessCount++;
+ le = le->Flink;
+ }
+ }
+ else
+ {
+ if( !CcPurgeCacheSection( &ObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+ NULL,
+ 0,
+ FALSE))
+ {
+
+ bPurgeOnClose = TRUE;
+ }
+ else
+ {
+
+ bCleanExtents = TRUE;
+ }
+ }
+
+ if ( bPurgeOnClose)
+ {
+
+ SetFlag( ObjectInfo->Fcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+ }
+ }
+ }
+ __except( EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ ntStatus = GetExceptionCode();
+
+ AFSDbgLogMsg( 0,
+ 0,
+ "EXCEPTION - AFSPerformObjectInvalidate Status %08lX\n",
+ ntStatus);
+ }
+ }
+ }
+
+ if ( bExtentsLocked)
+ {
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource );
+ }
+
+ if ( bLocked)
+ {
+
+ AFSReleaseResource( &ObjectInfo->Fcb->NPFcb->Resource);
+ }
+
+ if ( bCleanExtents)
+ {
+
+ AFSReleaseCleanExtents( ObjectInfo->Fcb,
+ NULL);
+ }
+ }
+
+ break;
+ }
+ }
+
+ if( ObjectInfo != NULL)
+ {
+ InterlockedDecrement( &ObjectInfo->ObjectReferenceCount);
+ }
+ }
+
+ return ntStatus;
+}