https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a52bc6d1799385726097e…
commit a52bc6d1799385726097ecf701f833b7a327a08e
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Dec 11 14:31:08 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:22 2021 +0100
[NTOS:CC] Restore read-ahead behaviour in CcCopyRead
---
ntoskrnl/cc/copy.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index 315e9f1f1b0..3dd172fa9db 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -556,6 +556,27 @@ CcCopyRead (
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = ReadLength;
+ /* If that was a successful sync read operation, let's handle read ahead */
+ if (Length == 0 && Wait)
+ {
+ PPRIVATE_CACHE_MAP PrivateCacheMap = FileObject->PrivateCacheMap;
+
+ /* If file isn't random access and next read may get us cross VACB boundary,
+ * schedule next read
+ */
+ if (!BooleanFlagOn(FileObject->Flags, FO_RANDOM_ACCESS) &&
+ (CurrentOffset - 1) / VACB_MAPPING_GRANULARITY != (CurrentOffset + ReadLength
- 1) / VACB_MAPPING_GRANULARITY)
+ {
+ CcScheduleReadAhead(FileObject, FileOffset, ReadLength);
+ }
+
+ /* And update read history in private cache map */
+ PrivateCacheMap->FileOffset1.QuadPart =
PrivateCacheMap->FileOffset2.QuadPart;
+ PrivateCacheMap->BeyondLastByte1.QuadPart =
PrivateCacheMap->BeyondLastByte2.QuadPart;
+ PrivateCacheMap->FileOffset2.QuadPart = FileOffset->QuadPart;
+ PrivateCacheMap->BeyondLastByte2.QuadPart = FileOffset->QuadPart +
ReadLength;
+ }
+
return TRUE;
}