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

commit b49a2d635663986915d16a92ca2092b4a98a2c9c
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Sun Jan 28 11:55:40 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Sun Jan 28 11:55:40 2018 +0100

    [NTOSKRNL] Drop ROS_DEFERRED_WRITE_CONTEXT in favor of DEFERRED_WRITE
    that was introduced in d3e0eb2.
    
    CORE-14235
---
 ntoskrnl/cc/copy.c             | 12 +++++++-----
 ntoskrnl/cc/view.c             |  9 +++++----
 ntoskrnl/include/internal/cc.h | 13 ++-----------
 3 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index e194074d59..b9e8893b87 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -496,13 +496,13 @@ CcDeferWrite (
     IN ULONG BytesToWrite,
     IN BOOLEAN Retrying)
 {
-    PROS_DEFERRED_WRITE_CONTEXT Context;
+    PDEFERRED_WRITE Context;
 
     CCTRACE(CC_API_DEBUG, "FileObject=%p PostRoutine=%p Context1=%p 
Context2=%p BytesToWrite=%lu Retrying=%d\n",
         FileObject, PostRoutine, Context1, Context2, BytesToWrite, Retrying);
 
     /* Try to allocate a context for queueing the write operation */
-    Context = ExAllocatePoolWithTag(NonPagedPool, 
sizeof(ROS_DEFERRED_WRITE_CONTEXT), 'CcDw');
+    Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEFERRED_WRITE), 
'CcDw');
     /* If it failed, immediately execute the operation! */
     if (Context == NULL)
     {
@@ -511,26 +511,28 @@ CcDeferWrite (
     }
 
     /* Otherwise, initialize the context */
+    RtlZeroMemory(Context, sizeof(DEFERRED_WRITE));
+    Context->NodeTypeCode = NODE_TYPE_DEFERRED_WRITE;
+    Context->NodeByteSize = sizeof(DEFERRED_WRITE);
     Context->FileObject = FileObject;
     Context->PostRoutine = PostRoutine;
     Context->Context1 = Context1;
     Context->Context2 = Context2;
     Context->BytesToWrite = BytesToWrite;
-    Context->Retrying = Retrying;
 
     /* And queue it */
     if (Retrying)
     {
         /* To the top, if that's a retry */
         ExInterlockedInsertHeadList(&CcDeferredWrites,
-                                    &Context->CcDeferredWritesEntry,
+                                    &Context->DeferredWriteLinks,
                                     &CcDeferredWriteSpinLock);
     }
     else
     {
         /* To the bottom, if that's a first time */
         ExInterlockedInsertTailList(&CcDeferredWrites,
-                                    &Context->CcDeferredWritesEntry,
+                                    &Context->DeferredWriteLinks,
                                     &CcDeferredWriteSpinLock);
     }
 }
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index e846130c79..2520cab53d 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -362,13 +362,14 @@ CciLazyWriter(PVOID Unused)
         ListEntry = ExInterlockedRemoveHeadList(&CcDeferredWrites, 
&CcDeferredWriteSpinLock);
         if (ListEntry != NULL)
         {
-            PROS_DEFERRED_WRITE_CONTEXT Context;
+            PDEFERRED_WRITE Context;
 
             /* Extract the context */
-            Context = CONTAINING_RECORD(ListEntry, ROS_DEFERRED_WRITE_CONTEXT, 
CcDeferredWritesEntry);
+            Context = CONTAINING_RECORD(ListEntry, DEFERRED_WRITE, 
DeferredWriteLinks);
+            ASSERT(Context->NodeTypeCode == NODE_TYPE_DEFERRED_WRITE);
 
             /* Can we write now? */
-            if (CcCanIWrite(Context->FileObject, Context->BytesToWrite, FALSE, 
Context->Retrying))
+            if (CcCanIWrite(Context->FileObject, Context->BytesToWrite, FALSE, 
TRUE))
             {
                 /* Yes! Do it, and destroy the associated context */
                 Context->PostRoutine(Context->Context1, Context->Context2);
@@ -381,7 +382,7 @@ CciLazyWriter(PVOID Unused)
                  * It's better than nothing!
                  */
                 ExInterlockedInsertTailList(&CcDeferredWrites,
-                                            &Context->CcDeferredWritesEntry,
+                                            &Context->DeferredWriteLinks,
                                             &CcDeferredWriteSpinLock);
             }
         }
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index a85df9da61..949fe7d56b 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -200,17 +200,6 @@ typedef struct _ROS_VACB
     /* Pointer to the next VACB in a chain. */
 } ROS_VACB, *PROS_VACB;
 
-typedef struct _ROS_DEFERRED_WRITE_CONTEXT
-{
-    LIST_ENTRY CcDeferredWritesEntry;
-    PFILE_OBJECT FileObject;
-    PCC_POST_DEFERRED_WRITE PostRoutine;
-    PVOID Context1;
-    PVOID Context2;
-    ULONG BytesToWrite;
-    BOOLEAN Retrying;
-} ROS_DEFERRED_WRITE_CONTEXT, *PROS_DEFERRED_WRITE_CONTEXT;
-
 typedef struct _INTERNAL_BCB
 {
     /* Lock */
@@ -222,6 +211,8 @@ typedef struct _INTERNAL_BCB
     CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
 } INTERNAL_BCB, *PINTERNAL_BCB;
 
+#define NODE_TYPE_DEFERRED_WRITE 0x02FC
+
 VOID
 NTAPI
 CcPfInitializePrefetcher(

Reply via email to