Skip to content

Commit

Permalink
[NTOS:CC] Add CcDirtySharedCacheMapList
Browse files Browse the repository at this point in the history
Also rewrite CcIsThereDirtyData to use CcDirtySharedCacheMapList.
  • Loading branch information
TAN-Gaming committed Nov 19, 2024
1 parent fa8f3ea commit d19e883
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
23 changes: 7 additions & 16 deletions ntoskrnl/cc/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ NTAPI
CcIsThereDirtyData (
IN PVPB Vpb)
{
PROS_VACB Vacb;
PROS_SHARED_CACHE_MAP SharedCacheMap;
PLIST_ENTRY Entry;
KIRQL oldIrql;
/* Assume no dirty data */
Expand All @@ -118,26 +118,17 @@ CcIsThereDirtyData (

oldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);

/* Browse dirty VACBs */
for (Entry = DirtyVacbListHead.Flink; Entry != &DirtyVacbListHead; Entry = Entry->Flink)
/* Browse dirty files */
for (Entry = CcDirtySharedCacheMapList.Flink; Entry != &CcDirtySharedCacheMapList; Entry = Entry->Flink)
{
Vacb = CONTAINING_RECORD(Entry, ROS_VACB, DirtyVacbListEntry);
/* Look for these associated with our volume */
if (Vacb->SharedCacheMap->FileObject->Vpb != Vpb)
{
continue;
}

/* From now on, we are associated with our VPB */
SharedCacheMap = CONTAINING_RECORD(Entry, ROS_SHARED_CACHE_MAP, SharedCacheMapLinks);

/* Temporary files are not counted as dirty */
if (BooleanFlagOn(Vacb->SharedCacheMap->FileObject->Flags, FO_TEMPORARY_FILE))
{
if (BooleanFlagOn(SharedCacheMap->FileObject->Flags, FO_TEMPORARY_FILE))
continue;
}

/* A single dirty VACB is enough to have dirty data */
if (Vacb->Dirty)
/* A single dirty file in our volume is enough to have dirty data */
if (SharedCacheMap->FileObject->Vpb == Vpb)
{
Dirty = TRUE;
break;
Expand Down
3 changes: 3 additions & 0 deletions ntoskrnl/cc/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ static NPAGED_LOOKASIDE_LIST VacbLookasideList;
* - List for deferred writes
* - Spinlock when dealing with the deferred list
* - List for "clean" shared cache maps
* - List for "dirty" shared cache maps
*/
ULONG CcDirtyPageThreshold = 0;
ULONG CcTotalDirtyPages = 0;
LIST_ENTRY CcDeferredWrites;
KSPIN_LOCK CcDeferredWriteSpinLock;
LIST_ENTRY CcCleanSharedCacheMapList;
LIST_ENTRY CcDirtySharedCacheMapList;

#if DBG
ULONG CcRosVacbIncRefCount_(PROS_VACB vacb, PCSTR file, INT line)
Expand Down Expand Up @@ -1481,6 +1483,7 @@ CcInitView (
InitializeListHead(&VacbLruListHead);
InitializeListHead(&CcDeferredWrites);
InitializeListHead(&CcCleanSharedCacheMapList);
InitializeListHead(&CcDirtySharedCacheMapList);
KeInitializeSpinLock(&CcDeferredWriteSpinLock);
ExInitializeNPagedLookasideList(&iBcbLookasideList,
NULL,
Expand Down
1 change: 1 addition & 0 deletions ntoskrnl/include/internal/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
//
extern ULONG CcRosTraceLevel;
extern LIST_ENTRY DirtyVacbListHead;
extern LIST_ENTRY CcDirtySharedCacheMapList;
extern ULONG CcDirtyPageThreshold;
extern ULONG CcTotalDirtyPages;
extern LIST_ENTRY CcDeferredWrites;
Expand Down

0 comments on commit d19e883

Please sign in to comment.