https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cd23d6e19aef6daf321f0…
commit cd23d6e19aef6daf321f0d6a5e021e58a09982ef
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Dec 4 15:45:04 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:22 2021 +0100
[NTOS:CC] Honor FO_WRITE_THROUGH flag in CcCopyWrite and fix it in CcZeroData
---
ntoskrnl/cc/copy.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index d228a981ea2..357e98162e6 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -556,16 +556,13 @@ CcCopyWrite (
if (!SharedCacheMap)
return FALSE;
- /* FIXME: Honor FileObject FO_WRITE_THROUGH flag */
ASSERT((FileOffset->QuadPart + Length) <=
SharedCacheMap->SectionSize.QuadPart);
- ASSERT((FileObject->Flags & FO_WRITE_THROUGH) == 0);
-
CurrentOffset = FileOffset->QuadPart;
while(CurrentOffset < WriteEnd)
{
ULONG VacbOffset = CurrentOffset % VACB_MAPPING_GRANULARITY;
- ULONG VacbLength = min(Length, VACB_MAPPING_GRANULARITY - VacbOffset);
+ ULONG VacbLength = min(WriteEnd - CurrentOffset, VACB_MAPPING_GRANULARITY -
VacbOffset);
Status = CcRosGetVacb(SharedCacheMap, CurrentOffset, &Vacb);
if (!NT_SUCCESS(Status))
@@ -585,7 +582,6 @@ CcCopyWrite (
Buffer = (PVOID)((ULONG_PTR)Buffer + VacbLength);
CurrentOffset += VacbLength;
- Length -= VacbLength;
/* Tell Mm */
Status = MmMakePagesDirty(NULL, Add2Ptr(Vacb->BaseAddress, VacbOffset),
VacbLength);
@@ -600,6 +596,10 @@ CcCopyWrite (
_SEH2_END;
}
+ /* Flush if needed */
+ if (FileObject->Flags & FO_WRITE_THROUGH)
+ CcFlushCache(FileObject->SectionObjectPointer, FileOffset, Length, NULL);
+
return TRUE;
}
@@ -757,7 +757,7 @@ CcZeroData (
Length = EndOffset->QuadPart - StartOffset->QuadPart;
WriteOffset.QuadPart = StartOffset->QuadPart;
- if (!SharedCacheMap || (FileObject->Flags & FO_WRITE_THROUGH))
+ if (!SharedCacheMap)
{
/* Make this a non-cached write */
IO_STATUS_BLOCK Iosb;
@@ -848,5 +848,9 @@ CcZeroData (
_SEH2_END;
}
+ /* Flush if needed */
+ if (FileObject->Flags & FO_WRITE_THROUGH)
+ CcFlushCache(FileObject->SectionObjectPointer, StartOffset,
EndOffset->QuadPart - StartOffset->QuadPart, NULL);
+
return TRUE;
}