https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a3d78067abce395b79065…
commit a3d78067abce395b7906598da0d85c20abd49d59
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Jan 27 10:57:50 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Jan 27 10:59:27 2018 +0100
[NTOSKRNL] When marking a VACB dirty on unmap/unpin, use CcRosMarkDirtyVacb().
This should help reducing race conditions with lazy writer, and thus reduce random
BSODs.
CORE-14263
---
ntoskrnl/cc/view.c | 50 ++++++++++++++++++++++----------------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 0340c68407..706623b0a5 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -517,26 +517,25 @@ CcRosReleaseVacb (
BOOLEAN Mapped)
{
BOOLEAN WasDirty;
- KIRQL oldIrql;
ASSERT(SharedCacheMap);
DPRINT("CcRosReleaseVacb(SharedCacheMap 0x%p, Vacb 0x%p, Valid %u)\n",
SharedCacheMap, Vacb, Valid);
- KeAcquireGuardedMutex(&ViewLock);
- KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
-
Vacb->Valid = Valid;
- WasDirty = Vacb->Dirty;
- Vacb->Dirty = Vacb->Dirty || Dirty;
-
- if (!WasDirty && Vacb->Dirty)
+ WasDirty = FALSE;
+ if (Dirty)
{
- InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry);
- CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ if (!Vacb->Dirty && Dirty)
+ {
+ CcRosMarkDirtyVacb(Vacb);
+ }
+ else
+ {
+ WasDirty = TRUE;
+ }
}
if (Mapped)
@@ -553,8 +552,6 @@ CcRosReleaseVacb (
CcRosVacbIncRefCount(Vacb);
}
- KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
- KeReleaseGuardedMutex(&ViewLock);
CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;
@@ -676,7 +673,6 @@ CcRosUnmapVacb (
{
PROS_VACB Vacb;
BOOLEAN WasDirty;
- KIRQL oldIrql;
ASSERT(SharedCacheMap);
@@ -689,21 +685,21 @@ CcRosUnmapVacb (
return STATUS_UNSUCCESSFUL;
}
- KeAcquireGuardedMutex(&ViewLock);
- KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
-
- WasDirty = Vacb->Dirty;
- Vacb->Dirty = Vacb->Dirty || NowDirty;
-
- Vacb->MappedCount--;
-
- if (!WasDirty && NowDirty)
+ WasDirty = FALSE;
+ if (NowDirty)
{
- InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry);
- CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ if (!Vacb->Dirty && NowDirty)
+ {
+ CcRosMarkDirtyVacb(Vacb);
+ }
+ else
+ {
+ WasDirty = TRUE;
+ }
}
+ Vacb->MappedCount--;
+
CcRosVacbDecRefCount(Vacb);
if (!WasDirty && NowDirty)
{
@@ -714,8 +710,6 @@ CcRosUnmapVacb (
CcRosVacbDecRefCount(Vacb);
}
- KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
- KeReleaseGuardedMutex(&ViewLock);
CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;