From 5cc0668b213b361f96ba713ecaef5bc5274775d9 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Fri, 26 Jan 2018 10:40:05 +0100 Subject: [PATCH] [NTOSKRNL] Store the total dirty pages per shared cache map in it. --- ntoskrnl/cc/fs.c | 1 + ntoskrnl/cc/view.c | 6 ++++++ ntoskrnl/include/internal/cc.h | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c index d068f96eb24..9e9ff1a4dc0 100644 --- a/ntoskrnl/cc/fs.c +++ b/ntoskrnl/cc/fs.c @@ -235,6 +235,7 @@ CcPurgeCacheSection ( { RemoveEntryList(&Vacb->DirtyVacbListEntry); CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE; + Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE; } RemoveEntryList(&Vacb->CacheMapVacbListEntry); InsertHeadList(&FreeList, &Vacb->CacheMapVacbListEntry); diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index e8da9a51c80..b08210c2419 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -175,6 +175,7 @@ CcRosFlushVacb ( 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); @@ -535,6 +536,7 @@ CcRosReleaseVacb ( { InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry); CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; + Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; } if (Mapped) @@ -621,6 +623,7 @@ CcRosMarkDirtyVacb ( { InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry); CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; + Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; } else { @@ -698,6 +701,7 @@ CcRosUnmapVacb ( { InsertTailList(&DirtyVacbListHead, &Vacb->DirtyVacbListEntry); CcTotalDirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; + Vacb->SharedCacheMap->DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE; } CcRosVacbDecRefCount(Vacb); @@ -1162,6 +1166,7 @@ CcRosDeleteFileCache ( { RemoveEntryList(¤t->DirtyVacbListEntry); CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE; + current->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE; DPRINT1("Freeing dirty VACB\n"); } InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry); @@ -1349,6 +1354,7 @@ CcRosInitializeFileCache ( SharedCacheMap->FileSize = FileSizes->FileSize; SharedCacheMap->PinAccess = PinAccess; SharedCacheMap->DirtyPageThreshold = 0; + SharedCacheMap->DirtyPages = 0; KeInitializeSpinLock(&SharedCacheMap->CacheMapLock); InitializeListHead(&SharedCacheMap->CacheMapVacbListHead); FileObject->SectionObjectPointer->SharedCacheMap = SharedCacheMap; diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index 913517a762a..a85df9da613 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -159,8 +159,9 @@ typedef struct _ROS_SHARED_CACHE_MAP PVOID LazyWriteContext; KSPIN_LOCK CacheMapLock; ULONG OpenCount; - ULONG DirtyPageThreshold; + ULONG DirtyPages; LIST_ENTRY SharedCacheMapLinks; + ULONG DirtyPageThreshold; #if DBG BOOLEAN Trace; /* enable extra trace output for this cache map and it's VACBs */ #endif