sys: FspFileNodeFlushAndPurgeCache

This commit is contained in:
Bill Zissimopoulos
2016-03-17 10:13:52 -07:00
parent df85107c42
commit b734e6968d
6 changed files with 157 additions and 22 deletions

View File

@ -252,18 +252,42 @@ NTSTATUS FspFsvolReadPrepare(
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = IrpSp->FileObject;
FSP_FILE_NODE *FileNode = FileObject->FsContext;
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
FSP_SAFE_MDL *SafeMdl = 0;
PVOID Address;
PEPROCESS Process;
BOOLEAN FlushCache;
BOOLEAN Success;
Success = DEBUGTEST(90, TRUE) && FspFileNodeTryAcquireShared(FileNode, Full);
FlushCache = !PagingIo && 0 != FileObject->SectionObjectPointer->DataSectionObject;
/* !!!: DataSectionObject accessed outside a lock. Hmmm! */
if (FlushCache)
Success = DEBUGTEST(90, TRUE) && FspFileNodeTryAcquireExclusive(FileNode, Full);
else
Success = DEBUGTEST(90, TRUE) && FspFileNodeTryAcquireShared(FileNode, Full);
if (!Success)
{
FspIopRetryPrepareIrp(Irp, &Result);
return Result;
}
/* if this is a non-cached transfer on a cached file then flush the file */
if (FlushCache)
{
Result = FspFileNodeFlushAndPurgeCache(FileNode,
IrpSp->Parameters.Read.ByteOffset.QuadPart,
IrpSp->Parameters.Read.Length,
FALSE);
if (!NT_SUCCESS(Result))
{
FspFileNodeRelease(FileNode, Full);
return Result;
}
FspFileNodeConvertExclusiveToShared(FileNode, Full);
}
/* create a "safe" MDL if necessary */
if (!FspSafeMdlCheck(Irp->MdlAddress))
{