[NTOSKRNL] When marking a BCB dirty, also mark the underlying VACB dirty.
authorPierre Schweitzer <pierre@reactos.org>
Tue, 23 Jan 2018 20:48:29 +0000 (21:48 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 23 Jan 2018 22:25:26 +0000 (23:25 +0100)
Experiment and MSDN tend to show that a dirty BCB is queued for lazy write.
This will do the job here!

Also, renamed CcRosMarkDirtyFile() which is more accurate, and added a new
function CcRosMarkDirtyVacb() which just takes a VACB as arg (expected locked)
and marks it dirty (using previous implementation). Make CcRosMarkDirtyFile()
use it.

CORE-14235

ntoskrnl/cc/pin.c
ntoskrnl/cc/view.c
ntoskrnl/include/internal/cc.h
ntoskrnl/mm/section.c

index 0241927..393b206 100644 (file)
@@ -247,6 +247,7 @@ CcSetDirtyPinnedData (
         Bcb, Lsn);
 
     iBcb->Dirty = TRUE;
+    CcRosMarkDirtyVacb(iBcb->Vacb);
 }
 
 
index 0d1822c..465fffa 100644 (file)
@@ -565,25 +565,15 @@ CcRosLookupVacb (
     return NULL;
 }
 
-NTSTATUS
+VOID
 NTAPI
 CcRosMarkDirtyVacb (
-    PROS_SHARED_CACHE_MAP SharedCacheMap,
-    LONGLONG FileOffset)
+    PROS_VACB Vacb)
 {
-    PROS_VACB Vacb;
     KIRQL oldIrql;
+    PROS_SHARED_CACHE_MAP SharedCacheMap;
 
-    ASSERT(SharedCacheMap);
-
-    DPRINT("CcRosMarkDirtyVacb(SharedCacheMap 0x%p, FileOffset %I64u)\n",
-           SharedCacheMap, FileOffset);
-
-    Vacb = CcRosLookupVacb(SharedCacheMap, FileOffset);
-    if (Vacb == NULL)
-    {
-        KeBugCheck(CACHE_MANAGER);
-    }
+    SharedCacheMap = Vacb->SharedCacheMap;
 
     KeAcquireGuardedMutex(&ViewLock);
     KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
@@ -606,6 +596,30 @@ CcRosMarkDirtyVacb (
 
     KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
     KeReleaseGuardedMutex(&ViewLock);
+}
+
+NTSTATUS
+NTAPI
+CcRosMarkDirtyFile (
+    PROS_SHARED_CACHE_MAP SharedCacheMap,
+    LONGLONG FileOffset)
+{
+    PROS_VACB Vacb;
+
+    ASSERT(SharedCacheMap);
+
+    DPRINT("CcRosMarkDirtyVacb(SharedCacheMap 0x%p, FileOffset %I64u)\n",
+           SharedCacheMap, FileOffset);
+
+    Vacb = CcRosLookupVacb(SharedCacheMap, FileOffset);
+    if (Vacb == NULL)
+    {
+        KeBugCheck(CACHE_MANAGER);
+    }
+
+    CcRosMarkDirtyVacb(Vacb);
+
+
     CcRosReleaseVacbLock(Vacb);
 
     return STATUS_SUCCESS;
index b1bb1ab..cc62381 100644 (file)
@@ -281,11 +281,16 @@ CcInitCacheZeroPage(VOID);
 
 NTSTATUS
 NTAPI
-CcRosMarkDirtyVacb(
+CcRosMarkDirtyFile(
     PROS_SHARED_CACHE_MAP SharedCacheMap,
     LONGLONG FileOffset
 );
 
+VOID
+NTAPI
+CcRosMarkDirtyVacb(
+    PROS_VACB Vacb);
+
 NTSTATUS
 NTAPI
 CcRosFlushDirtyPages(
index 66fa6d2..5c95439 100644 (file)
@@ -2374,7 +2374,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
         ASSERT(SwapEntry == 0);
         //SOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset;
 #ifndef NEWCC
-        CcRosMarkDirtyVacb(SharedCacheMap, Offset.QuadPart);
+        CcRosMarkDirtyFile(SharedCacheMap, Offset.QuadPart);
 #endif
         MmLockSectionSegment(Segment);
         MmSetPageEntrySectionSegment(Segment, &Offset, PageEntry);
@@ -4006,7 +4006,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
 #ifndef NEWCC
             FileObject = MemoryArea->Data.SectionData.Section->FileObject;
             SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
-            CcRosMarkDirtyVacb(SharedCacheMap, Offset.QuadPart + Segment->Image.FileOffset);
+            CcRosMarkDirtyFile(SharedCacheMap, Offset.QuadPart + Segment->Image.FileOffset);
 #endif
             ASSERT(SwapEntry == 0);
         }