[0.4.9] cherry-pick [FASTFAT] Properly handle IRPs that can wait and these that cannot.

CORE-14634

(cherry picked from commit b4363068d1)
This commit is contained in:
Pierre Schweitzer 2018-05-22 21:29:10 +02:00 committed by Joachim Henze
parent 07a13ca67c
commit bf2d787a94
3 changed files with 31 additions and 35 deletions

View file

@ -50,17 +50,8 @@ VfatCleanupFile(
}
else
{
if(!ExAcquireResourceExclusiveLite(&pFcb->MainResource,
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
{
return STATUS_PENDING;
}
if(!ExAcquireResourceExclusiveLite(&pFcb->PagingIoResource,
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
{
ExReleaseResourceLite(&pFcb->MainResource);
return STATUS_PENDING;
}
ExAcquireResourceExclusiveLite(&pFcb->MainResource, TRUE);
ExAcquireResourceExclusiveLite(&pFcb->PagingIoResource, TRUE);
pCcb = FileObject->FsContext2;
if (BooleanFlagOn(pCcb->Flags, CCB_DELETE_ON_CLOSE))
@ -173,21 +164,10 @@ VfatCleanup(
return STATUS_SUCCESS;
}
if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource,
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
{
return VfatMarkIrpContextForQueue(IrpContext);
}
ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, TRUE);
Status = VfatCleanupFile(IrpContext);
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
if (Status == STATUS_PENDING)
{
return VfatMarkIrpContextForQueue(IrpContext);
}
IrpContext->Irp->IoStatus.Information = 0;
return Status;
}

View file

@ -1059,11 +1059,6 @@ VfatCreate(
return STATUS_SUCCESS;
}
if (!BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))
{
return VfatMarkIrpContextForQueue(IrpContext);
}
IrpContext->Irp->IoStatus.Information = 0;
ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, TRUE);
Status = VfatCreateFile(IrpContext->DeviceObject, IrpContext->Irp);

View file

@ -287,18 +287,39 @@ VfatAllocateIrpContext(
IrpContext->MinorFunction = IrpContext->Stack->MinorFunction;
IrpContext->FileObject = IrpContext->Stack->FileObject;
IrpContext->Flags = IRPCONTEXT_COMPLETE;
if (MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
MajorFunction == IRP_MJ_DEVICE_CONTROL ||
MajorFunction == IRP_MJ_SHUTDOWN)
/* Easy cases that can wait */
if (MajorFunction == IRP_MJ_CLEANUP ||
MajorFunction == IRP_MJ_CREATE ||
MajorFunction == IRP_MJ_SHUTDOWN ||
MajorFunction == IRP_MJ_CLOSE /* likely to be fixed */)
{
IrpContext->Flags |= IRPCONTEXT_CANWAIT;
SetFlag(IrpContext->Flags, IRPCONTEXT_CANWAIT);
}
else if (MajorFunction != IRP_MJ_CLEANUP &&
MajorFunction != IRP_MJ_CLOSE &&
/* Cases that can wait if synchronous IRP */
else if ((MajorFunction == IRP_MJ_DEVICE_CONTROL ||
MajorFunction == IRP_MJ_QUERY_INFORMATION ||
MajorFunction == IRP_MJ_SET_INFORMATION ||
MajorFunction == IRP_MJ_FLUSH_BUFFERS ||
MajorFunction == IRP_MJ_LOCK_CONTROL ||
MajorFunction == IRP_MJ_QUERY_VOLUME_INFORMATION ||
MajorFunction == IRP_MJ_SET_VOLUME_INFORMATION ||
MajorFunction == IRP_MJ_DIRECTORY_CONTROL ||
MajorFunction == IRP_MJ_WRITE ||
MajorFunction == IRP_MJ_READ) &&
IoIsOperationSynchronous(Irp))
{
IrpContext->Flags |= IRPCONTEXT_CANWAIT;
SetFlag(IrpContext->Flags, IRPCONTEXT_CANWAIT);
}
/* Cases that can wait if synchronous or if no FO */
else if ((MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
MajorFunction == IRP_MJ_PNP) &&
(IoGetCurrentIrpStackLocation(Irp)->FileObject == NULL ||
IoIsOperationSynchronous(Irp)))
{
SetFlag(IrpContext->Flags, IRPCONTEXT_CANWAIT);
}
KeInitializeEvent(&IrpContext->Event, NotificationEvent, FALSE);
IrpContext->RefCount = 0;
IrpContext->PriorityBoost = IO_NO_INCREMENT;