Skip to content

Commit

Permalink
[NTOS:CC] Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TAN-Gaming committed Nov 16, 2024
1 parent 0e15795 commit 5e938c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
36 changes: 2 additions & 34 deletions ntoskrnl/cc/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -313,42 +310,12 @@ CcRosFlushDirtyPages (
if (BooleanFlagOn(current->Flags, SHARED_CACHE_MAP_IN_LAZYWRITE))
continue;

KeAcquireSpinLockAtDpcLevel(&current->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(&current->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)
{
Expand All @@ -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);

Expand Down
1 change: 0 additions & 1 deletion ntoskrnl/include/internal/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 5e938c4

Please sign in to comment.