https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3f8788d6e54ee97cc02e4…
commit 3f8788d6e54ee97cc02e4ed26352efdc0dd6e6a2
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Thu Feb 1 08:35:27 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Thu Feb 1 08:36:17 2018 +0100
[NTOSKRNL] Add an helper for marking a VACB clean (ie, not dirty).
CORE-14263
---
ntoskrnl/cc/fs.c | 4 +---
ntoskrnl/cc/view.c | 52 ++++++++++++++++++++++++++++++------------
ntoskrnl/include/internal/cc.h | 6 +++++
3 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c
index 9e9ff1a4dc..38c9ae527c 100644
--- a/ntoskrnl/cc/fs.c
+++ b/ntoskrnl/cc/fs.c
@@ -233,9 +233,7 @@ CcPurgeCacheSection (
RemoveEntryList(&Vacb->VacbLruListEntry);
if (Vacb->Dirty)
{
- RemoveEntryList(&Vacb->DirtyVacbListEntry);
- CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY /
PAGE_SIZE;
+ CcRosUnmarkDirtyVacb(Vacb, FALSE);
}
RemoveEntryList(&Vacb->CacheMapVacbListEntry);
InsertHeadList(&FreeList, &Vacb->CacheMapVacbListEntry);
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 003c5d81de..f66f230c2d 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -167,22 +167,11 @@ CcRosFlushVacb (
PROS_VACB Vacb)
{
NTSTATUS Status;
- KIRQL oldIrql;
Status = CcWriteVirtualAddress(Vacb);
if (NT_SUCCESS(Status))
{
- KeAcquireGuardedMutex(&ViewLock);
- KeAcquireSpinLock(&Vacb->SharedCacheMap->CacheMapLock, &oldIrql);
-
- Vacb->Dirty = FALSE;
- RemoveEntryList(&Vacb->DirtyVacbListEntry);
- CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- CcRosVacbDecRefCount(Vacb);
-
- KeReleaseSpinLock(&Vacb->SharedCacheMap->CacheMapLock, oldIrql);
- KeReleaseGuardedMutex(&ViewLock);
+ CcRosUnmarkDirtyVacb(Vacb, TRUE);
}
return Status;
@@ -619,6 +608,39 @@ CcRosMarkDirtyVacb (
KeReleaseGuardedMutex(&ViewLock);
}
+VOID
+NTAPI
+CcRosUnmarkDirtyVacb (
+ PROS_VACB Vacb,
+ BOOLEAN LockViews)
+{
+ KIRQL oldIrql;
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
+
+ SharedCacheMap = Vacb->SharedCacheMap;
+
+ if (LockViews)
+ {
+ KeAcquireGuardedMutex(&ViewLock);
+ KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
+ }
+
+ ASSERT(Vacb->Dirty);
+
+ Vacb->Dirty = FALSE;
+
+ RemoveEntryList(&Vacb->DirtyVacbListEntry);
+ CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
+ CcRosVacbDecRefCount(Vacb);
+
+ if (LockViews)
+ {
+ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
+ }
+}
+
NTSTATUS
NTAPI
CcRosMarkDirtyFile (
@@ -1132,9 +1154,9 @@ CcRosDeleteFileCache (
RemoveEntryList(¤t->VacbLruListEntry);
if (current->Dirty)
{
- RemoveEntryList(¤t->DirtyVacbListEntry);
- CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
- current->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY /
PAGE_SIZE;
+ KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
+ CcRosUnmarkDirtyVacb(current, FALSE);
+ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
DPRINT1("Freeing dirty VACB\n");
}
InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry);
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 949fe7d56b..3787563941 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -300,6 +300,12 @@ NTAPI
CcRosMarkDirtyVacb(
PROS_VACB Vacb);
+VOID
+NTAPI
+CcRosUnmarkDirtyVacb(
+ PROS_VACB Vacb,
+ BOOLEAN LockViews);
+
NTSTATUS
NTAPI
CcRosFlushDirtyPages(