[NTOS:CC] Wake up lazy scan after inserting elements in the list.
authorJérôme Gardou <jerome.gardou@reactos.org>
Tue, 16 Feb 2021 16:17:57 +0000 (17:17 +0100)
committerJérôme Gardou <jerome.gardou@reactos.org>
Wed, 24 Mar 2021 14:28:04 +0000 (15:28 +0100)
ntoskrnl/cc/copy.c

index 30864bc..09af125 100644 (file)
@@ -381,16 +381,6 @@ CcCanIWrite (
         return FALSE;
     }
 
-    /* Otherwise, if there are no deferred writes yet, start the lazy writer */
-    if (IsListEmpty(&CcDeferredWrites))
-    {
-        KIRQL OldIrql;
-
-        OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
-        CcScheduleLazyWriteScan(TRUE);
-        KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
-    }
-
     /* Initialize our wait event */
     KeInitializeEvent(&WaitEvent, NotificationEvent, FALSE);
 
@@ -418,6 +408,12 @@ CcCanIWrite (
                                     &CcDeferredWriteSpinLock);
     }
 
+    /* Now make sure that the lazy scan writer will be active */
+    OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
+    if (!LazyWriter.ScanActive)
+        CcScheduleLazyWriteScan(TRUE);
+    KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
+
 #if DBG
     DPRINT1("Actively deferring write for: %p\n", FileObject);
     DPRINT1("Because:\n");