diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index e194074d59a..b9e8893b879 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 e846130c792..2520cab53d2 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 a85df9da613..949fe7d56b1 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(