From 5e938c4c2511613667802aaab360054ed94ab12d Mon Sep 17 00:00:00 2001 From: Thamatip Chitpong Date: Sat, 16 Nov 2024 22:34:53 +0700 Subject: [PATCH] [NTOS:CC] Fix --- ntoskrnl/cc/view.c | 36 ++-------------------------------- ntoskrnl/include/internal/cc.h | 1 - 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 6108317b59b32..724d85e73f545 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -282,9 +282,6 @@ CcRosFlushDirtyPages ( { PROS_SHARED_CACHE_MAP current; BOOLEAN Locked; - LARGE_INTEGER FlushOffset; - LONGLONG ValidDataGoal; - ULONG FlushLength; IO_STATUS_BLOCK FlushIosb; ULONG FlushedPages; @@ -313,42 +310,12 @@ CcRosFlushDirtyPages ( if (BooleanFlagOn(current->Flags, SHARED_CACHE_MAP_IN_LAZYWRITE)) continue; - KeAcquireSpinLockAtDpcLevel(¤t->CacheMapLock); - - ASSERT(current->DirtyPages != 0); - - /* A file system may indicate that the Cache Manager should not attempt - * to track valid data by using the special value of MAXLONGLONG as the - * valid data length in a CcSetFileSizes call. - */ - if (current->ValidDataLength.QuadPart == MAXLONGLONG) - { - FlushOffset.QuadPart = 0; - ValidDataGoal = current->FileSize.QuadPart; - } - else - { - FlushOffset = current->ValidDataLength; - ValidDataGoal = current->FileSize.QuadPart - current->ValidDataLength.QuadPart; - } - - KeReleaseSpinLockFromDpcLevel(¤t->CacheMapLock); - /* Mark for lazy write and keep a ref on the shared cache map */ SetFlag(current->Flags, SHARED_CACHE_MAP_IN_LAZYWRITE); current->OpenCount++; KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql); - if (FlushAll) - { - FlushLength = min(ValidDataGoal, MAX_FLUSH_LENGTH); - } - else - { - FlushLength = min(min((LONGLONG)Target * PAGE_SIZE, ValidDataGoal), MAX_FLUSH_LENGTH); - } - Locked = current->Callbacks->AcquireForLazyWrite(current->LazyWriteContext, Wait); if (!Locked) { @@ -365,7 +332,8 @@ CcRosFlushDirtyPages ( continue; } - CcpFlushFileCache(current, &FlushOffset, FlushLength, TRUE, &FlushIosb); + /* FIXME: Take ValidDataLength into account */ + CcpFlushFileCache(current, NULL, 0, TRUE, &FlushIosb); current->Callbacks->ReleaseFromLazyWrite(current->LazyWriteContext); diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index f42f815101f8e..a8dc60d67975a 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -203,7 +203,6 @@ typedef struct _ROS_SHARED_CACHE_MAP #define WRITEBEHIND_DISABLED 0x2 #define SHARED_CACHE_MAP_IN_CREATION 0x4 #define SHARED_CACHE_MAP_IN_LAZYWRITE 0x8 -#define MAX_FLUSH_LENGTH ((MAXULONG >> PAGE_SHIFT) * PAGE_SIZE) typedef struct _ROS_VACB {