[NTOS] Loop again and again until the whole cache is empty when sutting down
authorJérôme Gardou <jerome.gardou@reactos.org>
Mon, 21 Dec 2020 17:47:32 +0000 (18:47 +0100)
committerJérôme Gardou <jerome.gardou@reactos.org>
Wed, 3 Feb 2021 08:41:23 +0000 (09:41 +0100)
ntoskrnl/cc/view.c
ntoskrnl/po/power.c

index 3952986..35d0df3 100644 (file)
@@ -212,6 +212,7 @@ CcRosFlushDirtyPages (
     BOOLEAN Locked;
     NTSTATUS Status;
     KIRQL OldIrql;
+    BOOLEAN FlushAll = (Target == MAXULONG);
 
     DPRINT("CcRosFlushDirtyPages(Target %lu)\n", Target);
 
@@ -226,8 +227,16 @@ CcRosFlushDirtyPages (
         DPRINT("No Dirty pages\n");
     }
 
-    while ((current_entry != &DirtyVacbListHead) && (Target > 0))
+    while (((current_entry != &DirtyVacbListHead) && (Target > 0)) || FlushAll)
     {
+        if (current_entry == &DirtyVacbListHead)
+        {
+            ASSERT(FlushAll);
+            if (IsListEmpty(&DirtyVacbListHead))
+                break;
+            current_entry = DirtyVacbListHead.Flink;
+        }
+
         current = CONTAINING_RECORD(current_entry,
                                     ROS_VACB,
                                     DirtyVacbListEntry);
index 7d2f4d7..6dee705 100644 (file)
@@ -1075,7 +1075,7 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
 #ifndef NEWCC
         /* Flush dirty cache pages */
         /* XXX: Is that still mandatory? As now we'll wait on lazy writer to complete? */
-        CcRosFlushDirtyPages(-1, &Dummy, TRUE, FALSE); //HACK: We really should wait here!
+        CcRosFlushDirtyPages(MAXULONG, &Dummy, TRUE, FALSE); //HACK: We really should wait here!
 #else
         Dummy = 0;
 #endif