https://git.reactos.org/?p=reactos.git;a=commitdiff;h=347a4f146b8245dd6753e39365aafe492d37ca60

commit 347a4f146b8245dd6753e39365aafe492d37ca60
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Mon Dec 21 18:47:32 2020 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Feb 3 09:41:23 2021 +0100

    [NTOS] Loop again and again until the whole cache is empty when sutting down
---
 ntoskrnl/cc/view.c  | 11 ++++++++++-
 ntoskrnl/po/power.c |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 3952986dc44..35d0df31545 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -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);
diff --git a/ntoskrnl/po/power.c b/ntoskrnl/po/power.c
index 7d2f4d7114a..6dee7054c02 100644
--- a/ntoskrnl/po/power.c
+++ b/ntoskrnl/po/power.c
@@ -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

Reply via email to