mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
[NTOSKRNL]
- Add a wait parameter to CcRosFlushDirtyPages and only block on the segment locks of it is safe svn path=/trunk/; revision=54730
This commit is contained in:
parent
80ee75c141
commit
274217e861
4 changed files with 20 additions and 38 deletions
|
@ -175,43 +175,23 @@ CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PCACHE_SEGMENT current;
|
PCACHE_SEGMENT current;
|
||||||
ULONG PagesPerSegment;
|
ULONG PagesPerSegment;
|
||||||
BOOLEAN Locked;
|
BOOLEAN Locked;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
static ULONG WriteCount[4] = {0, 0, 0, 0};
|
LARGE_INTEGER ZeroTimeout;
|
||||||
ULONG NewTarget;
|
|
||||||
|
|
||||||
DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target);
|
DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target);
|
||||||
|
|
||||||
(*Count) = 0;
|
(*Count) = 0;
|
||||||
|
ZeroTimeout.QuadPart = 0;
|
||||||
|
|
||||||
KeEnterCriticalRegion();
|
KeEnterCriticalRegion();
|
||||||
KeAcquireGuardedMutex(&ViewLock);
|
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;
|
current_entry = DirtySegmentListHead.Flink;
|
||||||
if (current_entry == &DirtySegmentListHead)
|
if (current_entry == &DirtySegmentListHead)
|
||||||
{
|
{
|
||||||
|
@ -225,17 +205,23 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
|
|
||||||
Locked = current->Bcb->Callbacks->AcquireForLazyWrite(
|
Locked = current->Bcb->Callbacks->AcquireForLazyWrite(
|
||||||
current->Bcb->LazyWriteContext, TRUE);
|
current->Bcb->LazyWriteContext, Wait);
|
||||||
if (!Locked)
|
if (!Locked)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeWaitForSingleObject(¤t->Mutex,
|
Status = KeWaitForSingleObject(¤t->Mutex,
|
||||||
Executive,
|
Executive,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
Wait ? NULL : &ZeroTimeout);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
current->Bcb->Callbacks->ReleaseFromLazyWrite(
|
||||||
|
current->Bcb->LazyWriteContext);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(current->Dirty);
|
ASSERT(current->Dirty);
|
||||||
if (current->ReferenceCount > 1)
|
if (current->ReferenceCount > 1)
|
||||||
|
@ -270,11 +256,6 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||||
current_entry = DirtySegmentListHead.Flink;
|
current_entry = DirtySegmentListHead.Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*Count < NewTarget)
|
|
||||||
{
|
|
||||||
WriteCount[1] += (NewTarget - *Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseGuardedMutex(&ViewLock);
|
KeReleaseGuardedMutex(&ViewLock);
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
|
|
||||||
|
@ -374,7 +355,7 @@ retry:
|
||||||
if (Target > 0 && !FlushedPages)
|
if (Target > 0 && !FlushedPages)
|
||||||
{
|
{
|
||||||
/* Flush dirty pages to disk */
|
/* Flush dirty pages to disk */
|
||||||
CcRosFlushDirtyPages(Target, &PagesFreed);
|
CcRosFlushDirtyPages(Target, &PagesFreed, FALSE);
|
||||||
FlushedPages = TRUE;
|
FlushedPages = TRUE;
|
||||||
|
|
||||||
/* We can only swap as many pages as we flushed */
|
/* We can only swap as many pages as we flushed */
|
||||||
|
|
|
@ -261,7 +261,8 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CcRosFlushDirtyPages(
|
CcRosFlushDirtyPages(
|
||||||
ULONG Target,
|
ULONG Target,
|
||||||
PULONG Count
|
PULONG Count,
|
||||||
|
BOOLEAN Wait
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -306,7 +306,7 @@ MmMpwThreadMain(PVOID Ignored)
|
||||||
#ifndef NEWCC
|
#ifndef NEWCC
|
||||||
// XXX arty -- we flush when evicting pages or destorying cache
|
// XXX arty -- we flush when evicting pages or destorying cache
|
||||||
// sections.
|
// sections.
|
||||||
CcRosFlushDirtyPages(128, &PagesWritten);
|
CcRosFlushDirtyPages(128, &PagesWritten, FALSE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,7 +902,7 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
|
||||||
|
|
||||||
#ifndef NEWCC
|
#ifndef NEWCC
|
||||||
/* Flush dirty cache pages */
|
/* Flush dirty cache pages */
|
||||||
CcRosFlushDirtyPages(-1, &Dummy);
|
CcRosFlushDirtyPages(-1, &Dummy, TRUE);
|
||||||
#else
|
#else
|
||||||
Dummy = 0;
|
Dummy = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue