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

commit df5839db5b174754659b0f990410eb345dc1c243
Author:     Pierre Schweitzer <pie...@reactos.org>
AuthorDate: Thu Feb 8 11:49:22 2018 +0100
Commit:     Pierre Schweitzer <pie...@reactos.org>
CommitDate: Thu Feb 8 11:49:22 2018 +0100

    [NTOSKRNL] Implement CcSetAdditionalCacheAttributes()
---
 ntoskrnl/cc/cacheman.c         | 31 ++++++++++++++++++++++++++++---
 ntoskrnl/include/internal/cc.h |  4 ++++
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/ntoskrnl/cc/cacheman.c b/ntoskrnl/cc/cacheman.c
index 5d7ff571e6..abfb5e425c 100644
--- a/ntoskrnl/cc/cacheman.c
+++ b/ntoskrnl/cc/cacheman.c
@@ -164,7 +164,7 @@ CcScheduleReadAhead (
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 NTAPI
@@ -174,10 +174,35 @@ CcSetAdditionalCacheAttributes (
        IN      BOOLEAN         DisableWriteBehind
        )
 {
+    KIRQL OldIrql;
+    PROS_SHARED_CACHE_MAP SharedCacheMap;
+
     CCTRACE(CC_API_DEBUG, "FileObject=%p DisableReadAhead=%d 
DisableWriteBehind=%d\n",
         FileObject, DisableReadAhead, DisableWriteBehind);
 
-       UNIMPLEMENTED;
+    SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
+
+    OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
+
+    if (DisableReadAhead)
+    {
+        SetFlag(SharedCacheMap->Flags, READAHEAD_DISABLED);
+    }
+    else
+    {
+        ClearFlag(SharedCacheMap->Flags, READAHEAD_DISABLED);
+    }
+
+    if (DisableWriteBehind)
+    {
+        /* FIXME: also set flag 0x200 */
+        SetFlag(SharedCacheMap->Flags, WRITEBEHIND_DISABLED);
+    }
+    else
+    {
+        ClearFlag(SharedCacheMap->Flags, WRITEBEHIND_DISABLED);
+    }
+    KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
 }
 
 /*
@@ -234,7 +259,7 @@ CcSetDirtyPageThreshold (
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 NTAPI
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 63b6bc44f1..51dea091e3 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -163,6 +163,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
     PFILE_OBJECT FileObject;
     ULONG DirtyPages;
     LIST_ENTRY SharedCacheMapLinks;
+    ULONG Flags;
     PCACHE_MANAGER_CALLBACKS Callbacks;
     PVOID LazyWriteContext;
     LIST_ENTRY PrivateList;
@@ -178,6 +179,9 @@ typedef struct _ROS_SHARED_CACHE_MAP
 #endif
 } ROS_SHARED_CACHE_MAP, *PROS_SHARED_CACHE_MAP;
 
+#define READAHEAD_DISABLED 0x1
+#define WRITEBEHIND_DISABLED 0x2
+
 typedef struct _ROS_VACB
 {
     /* Base address of the region where the view's data is mapped. */

Reply via email to