[NTOSKRNL]
authorpschweitzer <pschweitzer@97493ccd-5924-5043-b1f5-66cb403b36ce>
Wed, 13 Sep 2017 16:13:21 +0000 (16:13 +0000)
committerpschweitzer <pschweitzer@97493ccd-5924-5043-b1f5-66cb403b36ce>
Wed, 13 Sep 2017 16:13:21 +0000 (16:13 +0000)
Don't call MmBuildMdlForNonPagedPool in CcWriteVirtualAddress():
- BaseAddress comes from PagedPood
- Windows returns a locked MDL from paged pool
- See tests from r75833 that are getting fixed with that revision

This fixes assertions failures on BtrFS write.

CORE-13763
CORE-13769

git-svn-id: file:///srv/svn/reactos/trunk@75834 97493ccd-5924-5043-b1f5-66cb403b36ce

reactos/ntoskrnl/cc/copy.c

index 7575991..2e2f962 100644 (file)
@@ -147,14 +147,30 @@ CcWriteVirtualAddress (
     {
         return STATUS_INSUFFICIENT_RESOURCES;
     }
-    MmBuildMdlForNonPagedPool(Mdl);
-    Mdl->MdlFlags |= MDL_IO_PAGE_READ;
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-    Status = IoSynchronousPageWrite(Vacb->SharedCacheMap->FileObject, Mdl, &Vacb->FileOffset, &Event, &IoStatus);
-    if (Status == STATUS_PENDING)
+
+    Status = STATUS_SUCCESS;
+    _SEH2_TRY
     {
-        KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
-        Status = IoStatus.Status;
+        MmProbeAndLockPages(Mdl, KernelMode, IoReadAccess);
+    }
+    _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = _SEH2_GetExceptionCode();
+        KeBugCheck(CACHE_MANAGER);
+    } _SEH2_END;
+
+    if (NT_SUCCESS(Status))
+    {
+        Mdl->MdlFlags |= MDL_IO_PAGE_READ;
+        KeInitializeEvent(&Event, NotificationEvent, FALSE);
+        Status = IoSynchronousPageWrite(Vacb->SharedCacheMap->FileObject, Mdl, &Vacb->FileOffset, &Event, &IoStatus);
+        if (Status == STATUS_PENDING)
+        {
+            KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+            Status = IoStatus.Status;
+        }
+
+        MmUnlockPages(Mdl);
     }
     IoFreeMdl(Mdl);
     if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))