Author: cgutman
Date: Wed Dec 21 19:46:07 2011
New Revision: 54730
URL:
http://svn.reactos.org/svn/reactos?rev=54730&view=rev
Log:
[NTOSKRNL]
- Add a wait parameter to CcRosFlushDirtyPages and only block on the segment locks of it
is safe
Modified:
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/include/internal/cc.h
trunk/reactos/ntoskrnl/mm/mminit.c
trunk/reactos/ntoskrnl/po/power.c
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=547…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Wed Dec 21 19:46:07 2011
@@ -175,43 +175,23 @@
NTSTATUS
NTAPI
-CcRosFlushDirtyPages(ULONG Target, PULONG Count)
+CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
{
PLIST_ENTRY current_entry;
PCACHE_SEGMENT current;
ULONG PagesPerSegment;
BOOLEAN Locked;
NTSTATUS Status;
- static ULONG WriteCount[4] = {0, 0, 0, 0};
- ULONG NewTarget;
+ LARGE_INTEGER ZeroTimeout;
DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target);
(*Count) = 0;
+ ZeroTimeout.QuadPart = 0;
KeEnterCriticalRegion();
KeAcquireGuardedMutex(&ViewLock);
- WriteCount[0] = WriteCount[1];
- WriteCount[1] = WriteCount[2];
- WriteCount[2] = WriteCount[3];
- WriteCount[3] = 0;
-
- NewTarget = WriteCount[0] + WriteCount[1] + WriteCount[2];
-
- if (NewTarget < DirtyPageCount)
- {
- NewTarget = (DirtyPageCount - NewTarget + 3) / 4;
- WriteCount[0] += NewTarget;
- WriteCount[1] += NewTarget;
- WriteCount[2] += NewTarget;
- WriteCount[3] += NewTarget;
- }
-
- NewTarget = WriteCount[0];
-
- Target = max(NewTarget, Target);
-
current_entry = DirtySegmentListHead.Flink;
if (current_entry == &DirtySegmentListHead)
{
@@ -225,17 +205,23 @@
current_entry = current_entry->Flink;
Locked = current->Bcb->Callbacks->AcquireForLazyWrite(
- current->Bcb->LazyWriteContext, TRUE);
+ current->Bcb->LazyWriteContext, Wait);
if (!Locked)
{
continue;
}
- KeWaitForSingleObject(¤t->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ Status = KeWaitForSingleObject(¤t->Mutex,
+ Executive,
+ KernelMode,
+ FALSE,
+ Wait ? NULL : &ZeroTimeout);
+ if (Status != STATUS_SUCCESS)
+ {
+ current->Bcb->Callbacks->ReleaseFromLazyWrite(
+ current->Bcb->LazyWriteContext);
+ continue;
+ }
ASSERT(current->Dirty);
if (current->ReferenceCount > 1)
@@ -268,11 +254,6 @@
KeAcquireGuardedMutex(&ViewLock);
current_entry = DirtySegmentListHead.Flink;
- }
-
- if (*Count < NewTarget)
- {
- WriteCount[1] += (NewTarget - *Count);
}
KeReleaseGuardedMutex(&ViewLock);
@@ -374,7 +355,7 @@
if (Target > 0 && !FlushedPages)
{
/* Flush dirty pages to disk */
- CcRosFlushDirtyPages(Target, &PagesFreed);
+ CcRosFlushDirtyPages(Target, &PagesFreed, FALSE);
FlushedPages = TRUE;
/* We can only swap as many pages as we flushed */
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Wed Dec 21 19:46:07 2011
@@ -261,7 +261,8 @@
NTAPI
CcRosFlushDirtyPages(
ULONG Target,
- PULONG Count
+ PULONG Count,
+ BOOLEAN Wait
);
VOID
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=5…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Wed Dec 21 19:46:07 2011
@@ -306,7 +306,7 @@
#ifndef NEWCC
// XXX arty -- we flush when evicting pages or destorying cache
// sections.
- CcRosFlushDirtyPages(128, &PagesWritten);
+ CcRosFlushDirtyPages(128, &PagesWritten, FALSE);
#endif
}
}
Modified: trunk/reactos/ntoskrnl/po/power.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=54…
==============================================================================
--- trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] Wed Dec 21 19:46:07 2011
@@ -902,7 +902,7 @@
#ifndef NEWCC
/* Flush dirty cache pages */
- CcRosFlushDirtyPages(-1, &Dummy);
+ CcRosFlushDirtyPages(-1, &Dummy, TRUE);
#else
Dummy = 0;
#endif