https://git.reactos.org/?p=reactos.git;a=commitdiff;h=78664ebe156f557b1f37b…
commit 78664ebe156f557b1f37bec8c31039d3bf91561e
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Jan 27 18:37:34 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Jan 27 18:37:34 2018 +0100
[NTOSKRNL] On file cache deletion, only manipulate VACB once locked.
Should help avoiding race conditions with lazy write.
CORE-14263
---
ntoskrnl/cc/view.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 706623b0a5..1268fb5203 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -528,7 +528,7 @@ CcRosReleaseVacb (
WasDirty = FALSE;
if (Dirty)
{
- if (!Vacb->Dirty && Dirty)
+ if (!Vacb->Dirty)
{
CcRosMarkDirtyVacb(Vacb);
}
@@ -658,7 +658,6 @@ CcRosMarkDirtyFile (
CcRosMarkDirtyVacb(Vacb);
-
CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;
@@ -688,7 +687,7 @@ CcRosUnmapVacb (
WasDirty = FALSE;
if (NowDirty)
{
- if (!Vacb->Dirty && NowDirty)
+ if (!Vacb->Dirty)
{
CcRosMarkDirtyVacb(Vacb);
}
@@ -1154,7 +1153,10 @@ CcRosDeleteFileCache (
while (!IsListEmpty(&SharedCacheMap->CacheMapVacbListHead))
{
current_entry =
RemoveTailList(&SharedCacheMap->CacheMapVacbListHead);
+ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
+
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
+ CcRosAcquireVacbLock(current, NULL);
RemoveEntryList(¤t->VacbLruListEntry);
if (current->Dirty)
{
@@ -1164,6 +1166,9 @@ CcRosDeleteFileCache (
DPRINT1("Freeing dirty VACB\n");
}
InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry);
+ CcRosReleaseVacbLock(current);
+
+ KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
}
#if DBG
SharedCacheMap->Trace = FALSE;