sys: FspFsvolWriteCached: move CcCanIWrite outside the locks

This eliminates the deadlock described in PR #677 while at the same time
ensuring that CcDeferWrite is called after the file's cache map has been
initialized.
This commit is contained in:
Bill Zissimopoulos
2026-07-11 14:05:26 +03:00
parent e7c7ccc5c4
commit 83aa54b4ab
+6 -2
View File
@@ -247,8 +247,13 @@ static NTSTATUS FspFsvolWriteCached(
FILE_END_OF_FILE_INFORMATION EndOfFileInformation;
UINT64 WriteEndOffset;
BOOLEAN ExtendingFile;
BOOLEAN DeferWrite;
BOOLEAN Success;
/* should we defer the write? */
Success = DEBUGTEST(90) && CcCanIWrite(FileObject, WriteLength, CanWait, Retrying);
DeferWrite = !Success;
/* try to acquire the FileNode Main exclusive */
Success = DEBUGTEST(90) &&
FspFileNodeTryAcquireExclusiveF(FileNode, FspFileNodeAcquireMain, CanWait);
@@ -306,8 +311,7 @@ static NTSTATUS FspFsvolWriteCached(
}
/* should we defer the write? */
Success = DEBUGTEST(90) && CcCanIWrite(FileObject, WriteLength, CanWait, Retrying);
if (!Success)
if (DeferWrite)
{
Result = FspWqCreateIrpWorkItem(Irp, FspFsvolWriteCached, 0);
if (NT_SUCCESS(Result))