sys: CcDeferWrite fix

This commit is contained in:
Bill Zissimopoulos 2025-05-15 12:46:00 +01:00
parent d75e9f7ee6
commit a2cd6978be

View File

@ -249,22 +249,6 @@ static NTSTATUS FspFsvolWriteCached(
BOOLEAN ExtendingFile; BOOLEAN ExtendingFile;
BOOLEAN Success; BOOLEAN Success;
/* should we defer the write? */
Success = DEBUGTEST(90) && CcCanIWrite(FileObject, WriteLength, CanWait, Retrying);
if (!Success)
{
Result = FspWqCreateIrpWorkItem(Irp, FspFsvolWriteCached, 0);
if (NT_SUCCESS(Result))
{
IoMarkIrpPending(Irp);
CcDeferWrite(FileObject, FspFsvolWriteCachedDeferred, Irp, 0, WriteLength, Retrying);
return STATUS_PENDING;
}
/* if we are unable to defer we will go ahead and (try to) service the IRP now! */
}
/* try to acquire the FileNode Main exclusive */ /* try to acquire the FileNode Main exclusive */
Success = DEBUGTEST(90) && Success = DEBUGTEST(90) &&
FspFileNodeTryAcquireExclusiveF(FileNode, FspFileNodeAcquireMain, CanWait); FspFileNodeTryAcquireExclusiveF(FileNode, FspFileNodeAcquireMain, CanWait);
@ -321,6 +305,22 @@ static NTSTATUS FspFsvolWriteCached(
} }
} }
/* should we defer the write? */
Success = DEBUGTEST(90) && CcCanIWrite(FileObject, WriteLength, CanWait, Retrying);
if (!Success)
{
Result = FspWqCreateIrpWorkItem(Irp, FspFsvolWriteCached, 0);
if (NT_SUCCESS(Result))
{
FspFileNodeRelease(FileNode, Main);
IoMarkIrpPending(Irp);
CcDeferWrite(FileObject, FspFsvolWriteCachedDeferred, Irp, 0, WriteLength, Retrying);
return STATUS_PENDING;
}
/* if we are unable to defer we will go ahead and (try to) service the IRP now! */
}
/* are we extending the file? */ /* are we extending the file? */
if (ExtendingFile) if (ExtendingFile)
{ {