https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9d1e16663ad086e4aadcb6f2bfdca34989da09e5

commit 9d1e16663ad086e4aadcb6f2bfdca34989da09e5
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Wed Jan 24 21:24:05 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Wed Jan 24 21:46:16 2018 +0100

    [NTOSKRNL] Link all the shared cache map together.
---
 ntoskrnl/cc/view.c             | 19 +++++++++++++++++++
 ntoskrnl/include/internal/cc.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 5588a912db..a9e83bb5b1 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -63,18 +63,22 @@ ULONG CcLazyWriteIos = 0;
  * - Amount of dirty pages
  * - List for deferred writes
  * - Spinlock when dealing with the deferred list
+ * - List for "clean" shared cache maps
  */
 ULONG CcDirtyPageThreshold = 0;
 ULONG CcTotalDirtyPages = 0;
 LIST_ENTRY CcDeferredWrites;
 KSPIN_LOCK CcDeferredWriteSpinLock;
+LIST_ENTRY CcCleanSharedCacheMapList;
 
 /* Internal vars (ROS):
  * - Event to notify lazy writer to shutdown
  * - Event to inform watchers lazy writer is done for this loop
+ * - Lock for the CcCleanSharedCacheMapList list
  */
 KEVENT iLazyWriterShutdown;
 KEVENT iLazyWriterNotify;
+KSPIN_LOCK iSharedCacheMapLock;
 
 #if DBG
 static void CcRosVacbIncRefCount_(PROS_VACB vacb, const char* file, int line)
@@ -1139,6 +1143,8 @@ CcRosDeleteFileCache (
     SharedCacheMap->OpenCount--;
     if (SharedCacheMap->OpenCount == 0)
     {
+        KIRQL OldIrql;
+
         FileObject->SectionObjectPointer->SharedCacheMap = NULL;
 
         /*
@@ -1173,6 +1179,11 @@ CcRosDeleteFileCache (
             current = CONTAINING_RECORD(current_entry, ROS_VACB, 
CacheMapVacbListEntry);
             CcRosInternalFreeVacb(current);
         }
+
+        KeAcquireSpinLock(&iSharedCacheMapLock, &OldIrql);
+        RemoveEntryList(&SharedCacheMap->SharedCacheMapLinks);
+        KeReleaseSpinLock(&iSharedCacheMapLock, OldIrql);
+
         ExFreeToNPagedLookasideList(&SharedCacheMapLookasideList, 
SharedCacheMap);
         KeAcquireGuardedMutex(&ViewLock);
     }
@@ -1317,6 +1328,8 @@ CcRosInitializeFileCache (
     KeAcquireGuardedMutex(&ViewLock);
     if (SharedCacheMap == NULL)
     {
+        KIRQL OldIrql;
+
         SharedCacheMap = 
ExAllocateFromNPagedLookasideList(&SharedCacheMapLookasideList);
         if (SharedCacheMap == NULL)
         {
@@ -1338,6 +1351,10 @@ CcRosInitializeFileCache (
         KeInitializeSpinLock(&SharedCacheMap->CacheMapLock);
         InitializeListHead(&SharedCacheMap->CacheMapVacbListHead);
         FileObject->SectionObjectPointer->SharedCacheMap = SharedCacheMap;
+
+        KeAcquireSpinLock(&iSharedCacheMapLock, &OldIrql);
+        InsertTailList(&CcCleanSharedCacheMapList, 
&SharedCacheMap->SharedCacheMapLinks);
+        KeReleaseSpinLock(&iSharedCacheMapLock, OldIrql);
     }
     if (FileObject->PrivateCacheMap == NULL)
     {
@@ -1395,7 +1412,9 @@ CcInitView (
     InitializeListHead(&DirtyVacbListHead);
     InitializeListHead(&VacbLruListHead);
     InitializeListHead(&CcDeferredWrites);
+    InitializeListHead(&CcCleanSharedCacheMapList);
     KeInitializeSpinLock(&CcDeferredWriteSpinLock);
+    KeInitializeSpinLock(&iSharedCacheMapLock);
     KeInitializeGuardedMutex(&ViewLock);
     ExInitializeNPagedLookasideList(&iBcbLookasideList,
                                     NULL,
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 2699dfcf43..913517a762 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -160,6 +160,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
     KSPIN_LOCK CacheMapLock;
     ULONG OpenCount;
     ULONG DirtyPageThreshold;
+    LIST_ENTRY SharedCacheMapLinks;
 #if DBG
     BOOLEAN Trace; /* enable extra trace output for this cache map and it's 
VACBs */
 #endif

Reply via email to