mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
[NTOSKRNL]
- Reference the cache segment when flushing to avoid a race between deleting the file cache and the balancer flushing pages to disk which causes random cache segments to be freed while we're holding a lock on it - Fixes a crash in KeReleaseMutex (used to be a crash in ExReleasePushLock) during periods of high memory load svn path=/trunk/; revision=54745
This commit is contained in:
@@ -204,10 +204,13 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||
DirtySegmentListEntry);
|
||||
current_entry = current_entry->Flink;
|
||||
|
||||
CcRosCacheSegmentIncRefCount(current);
|
||||
|
||||
Locked = current->Bcb->Callbacks->AcquireForLazyWrite(
|
||||
current->Bcb->LazyWriteContext, Wait);
|
||||
if (!Locked)
|
||||
{
|
||||
CcRosCacheSegmentDecRefCount(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -220,6 +223,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||
{
|
||||
current->Bcb->Callbacks->ReleaseFromLazyWrite(
|
||||
current->Bcb->LazyWriteContext);
|
||||
CcRosCacheSegmentDecRefCount(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -229,6 +233,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||
KeReleaseMutex(¤t->Mutex, 0);
|
||||
current->Bcb->Callbacks->ReleaseFromLazyWrite(
|
||||
current->Bcb->LazyWriteContext);
|
||||
CcRosCacheSegmentDecRefCount(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -241,6 +246,9 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||
KeReleaseMutex(¤t->Mutex, 0);
|
||||
current->Bcb->Callbacks->ReleaseFromLazyWrite(
|
||||
current->Bcb->LazyWriteContext);
|
||||
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
CcRosCacheSegmentDecRefCount(current);
|
||||
|
||||
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
|
||||
{
|
||||
@@ -251,8 +259,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait)
|
||||
(*Count) += PagesPerSegment;
|
||||
Target -= PagesPerSegment;
|
||||
}
|
||||
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
|
||||
current_entry = DirtySegmentListHead.Flink;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user