sys: FspFsvolReadCached, FspFsvolWriteCached: cleanup improvements

This commit is contained in:
Bill Zissimopoulos
2016-03-11 15:47:27 -08:00
parent 151247f1e6
commit d6403780a3
2 changed files with 40 additions and 32 deletions

View File

@ -139,6 +139,10 @@ static NTSTATUS FspFsvolReadCached(
}
}
/*
* From this point forward we must jump to the CLEANUP label on failure.
*/
/* are we using the copy or MDL interface? */
if (!FlagOn(IrpSp->MinorFunction, IRP_MN_MDL))
{
@ -148,22 +152,14 @@ static NTSTATUS FspFsvolReadCached(
Irp->UserBuffer : MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
if (0 == Buffer)
{
FspFileNodeRelease(FileNode, Main);
return STATUS_INSUFFICIENT_RESOURCES;
Result = STATUS_INSUFFICIENT_RESOURCES;
goto cleanup;
}
Result = FspCcCopyRead(FileObject, &ReadOffset, ReadLength, CanWait, Buffer,
&Irp->IoStatus);
if (!NT_SUCCESS(Result))
{
FspFileNodeRelease(FileNode, Main);
return Result;
}
if (STATUS_PENDING == Result)
{
FspFileNodeRelease(FileNode, Main);
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadCached, 0);
}
if (!NT_SUCCESS(Result) || STATUS_PENDING == Result)
goto cleanup;
}
else
{
@ -172,10 +168,8 @@ static NTSTATUS FspFsvolReadCached(
Result = FspCcMdlRead(FileObject, &ReadOffset, ReadLength, &Irp->MdlAddress,
&Irp->IoStatus);
if (!NT_SUCCESS(Result))
{
FspFileNodeRelease(FileNode, Main);
return Result;
}
goto cleanup;
ASSERT(STATUS_PENDING != Result);
}
/* update the current file offset if synchronous I/O */
@ -185,6 +179,14 @@ static NTSTATUS FspFsvolReadCached(
FspFileNodeRelease(FileNode, Main);
return STATUS_SUCCESS;
cleanup:
FspFileNodeRelease(FileNode, Main);
if (STATUS_PENDING == Result)
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadCached, 0);
return Result;
}
static NTSTATUS FspFsvolReadNonCached(