69 DbgPrint(
"(%s:%i) VACB %p ++RefCount=%lu, Dirty %u, PageOut %lu\n",
83 ASSERT(!(Refs == 0 && VacbDirty));
86 DbgPrint(
"(%s:%i) VACB %p --RefCount=%lu, Dirty %u, PageOut %lu\n",
87 file,
line, vacb, Refs, VacbDirty, VacbPageOut);
104 DbgPrint(
"(%s:%i) VACB %p ==RefCount=%lu, Dirty %u, PageOut %lu\n",
128 SharedCacheMap->Trace =
Trace;
132 DPRINT1(
"Enabling Tracing for CacheMap 0x%p:\n", SharedCacheMap);
141 current_entry = current_entry->
Flink;
143 DPRINT1(
" VACB 0x%p enabled, RefCount %lu, Dirty %u, PageOut %lu, BaseAddress %p, FileOffset %I64d\n",
152 DPRINT1(
"Disabling Tracing for CacheMap 0x%p:\n", SharedCacheMap);
239 current_entry = current_entry->
Flink;
267 DPRINT1(
"Failed to flush VACB to disk while deleting the cache entry. Status: 0x%08x\n",
Status);
277 DPRINT1(
"There are: %d references left\n", RefCount);
286 DPRINT1(
"No name for the file\n");
329 DPRINT(
"No Dirty pages\n");
349 current_entry = current_entry->
Flink;
353 SharedCacheMap =
current->SharedCacheMap;
392 SharedCacheMap->
Flags &= ~SHARED_CACHE_MAP_IN_LAZYWRITE;
412 SharedCacheMap->
Flags &= ~SHARED_CACHE_MAP_IN_LAZYWRITE;
420 DPRINT1(
"CC: Failed to flush VACB.\n");
428 (*Count) += PagesFreed;
451 DPRINT(
"CcRosFlushDirtyPages() finished\n");
502 DPRINT1(
"MmPageOutPhysicalAddress unexpectedly called\n");
527 current_entry = current_entry->
Flink;
547 (*NrFreed) += PagesFreed;
556 if ((
Target > 0) && !FlushedPages)
569 DPRINT(
"Flushed %lu dirty cache pages to disk\n", PagesFreed);
581 CacheMapVacbListEntry);
587 DPRINT(
"Evicted %lu cache pages\n", (*NrFreed));
600 DPRINT(
"CcRosReleaseVacb(SharedCacheMap 0x%p, Vacb 0x%p)\n", SharedCacheMap, Vacb);
602 if (Dirty && !Vacb->
Dirty)
633 DPRINT(
"CcRosLookupVacb(SharedCacheMap 0x%p, FileOffset %I64u)\n",
644 CacheMapVacbListEntry);
656 current_entry = current_entry->
Flink;
778 current_entry = current_entry->
Flink;
812 DPRINT(
"CcRosCreateVacb()\n");
823 current->SharedCacheMap = SharedCacheMap;
853 if (SharedCacheMap->Trace)
855 DPRINT1(
"CacheMap 0x%p: new VACB: 0x%p, file offset %I64d, BaseAddress %p\n",
875 CacheMapVacbListEntry);
883 if (SharedCacheMap->Trace)
885 DPRINT1(
"CacheMap 0x%p: deleting newly created VACB 0x%p ( found existing one 0x%p )\n",
907 current_entry = current_entry->
Flink;
946 DPRINT1(
"Vacb read beyond the file size!\n");
953 Vacb->FileOffset.QuadPart +
Offset,
964 Vacb->FileOffset.QuadPart +
Offset,
989 DPRINT(
"CcRosGetVacb()\n");
1041 DPRINT1(
"Bad fileoffset %I64x should be multiple of %x",
1060 DPRINT(
"Freeing VACB 0x%p\n", Vacb);
1086 DPRINT1(
"Failed to unmap VACB from System address space! Status 0x%08X\n",
Status);
1114 if (!SectionObjectPointers)
1120 if (!SectionObjectPointers->SharedCacheMap)
1127 SharedCacheMap = SectionObjectPointers->SharedCacheMap;
1132 Status = RtlLongLongAdd(FlushStart,
Length, &FlushEnd);
1155 while (FlushStart < FlushEnd)
1244 SharedCacheMap =
FileObject->SectionObjectPointer->SharedCacheMap;
1254 if (PrivateMap !=
NULL)
1290 PVOID LazyWriterContext)
1304 SharedCacheMap =
FileObject->SectionObjectPointer->SharedCacheMap;
1305 if (SharedCacheMap ==
NULL)
1308 if (SharedCacheMap ==
NULL)
1315 SharedCacheMap->
NodeByteSize =
sizeof(*SharedCacheMap);
1339 FileObject->SectionObjectPointer->SharedCacheMap = SharedCacheMap;
1376 if (PrivateMap ==
NULL)
1438 SharedCacheMap->
Flags &= ~SHARED_CACHE_MAP_IN_CREATION;
1464 if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
1466 SharedCacheMap = SectionObjectPointers->SharedCacheMap;
1479 DPRINT(
"CcInitView()\n");
1511#if DBG && defined(KDBG)
1522 KdbpPrint(
"Shared\t\tMapped\tDirty\tName\n");
1526 ListEntry = ListEntry->
Flink)
1529 ULONG Mapped = 0, Dirty = 0;
1542 Vacbs = Vacbs->
Flink)
1549 SharedCacheMap->
FileObject->FileName.Length != 0)
1560 Extra =
L" (FastFAT)";
1568 KdbpPrint(
"%p\t%d\t%d\t%wZ%S\n", SharedCacheMap, Mapped, Dirty,
FileName, Extra);
1592 KdbpPrint(
"CcTotalDirtyPages above the threshold, writes should be throttled\n");
1596 KdbpPrint(
"CcTotalDirtyPages within 64 (max charge) pages of the threshold, writes may be throttled\n");
1600 KdbpPrint(
"CcTotalDirtyPages below the threshold, writes should not be throttled\n");
NTSTATUS NTAPI MmUnmapViewInSystemSpace(IN PVOID MappedBase)
static CC_FILE_SIZES FileSizes
#define InterlockedIncrement
#define InterlockedDecrement
void quit(int argc, const char *argv[])
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
_In_ PFCB _In_ LONGLONG FileOffset
#define NT_SUCCESS(StatCode)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
UNICODE_STRING * PUNICODE_STRING
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
struct _FSRTL_COMMON_FCB_HEADER * PFSRTL_COMMON_FCB_HEADER
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
#define ROUND_DOWN(n, align)
#define BooleanFlagOn(F, SF)
IN PFCB IN VBO OUT PLBO OUT PULONG OUT PBOOLEAN Allocated
struct _FileName FileName
#define FSRTL_CACHE_TOP_LEVEL_IRP
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
#define RtlFillMemory(Dest, Length, Fill)
#define InterlockedCompareExchange
VOID KdbpPrint(_In_ PSTR Format, _In_ ...)
Prints the given string with printf-like formatting.
BOOLEAN ExpKdbgExtDefWrites(ULONG Argc, PCHAR Argv[])
BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[])
#define KeLeaveCriticalRegion()
#define KeEnterCriticalRegion()
VOID CcScheduleLazyWriteScan(IN BOOLEAN NoDelay)
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
struct task_struct * current
#define ExFreePoolWithTag(_P, _T)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
VOID NTAPI CcInitCacheZeroPage(VOID)
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
#define SECTION_ALL_ACCESS
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
VOID CcRosTraceCacheMap(PROS_SHARED_CACHE_MAP SharedCacheMap, BOOLEAN Trace)
static NTSTATUS CcRosDeleteFileCache(PFILE_OBJECT FileObject, PROS_SHARED_CACHE_MAP SharedCacheMap, PKIRQL OldIrql)
VOID CcRosMarkDirtyVacb(PROS_VACB Vacb)
NTSTATUS CcRosInitializeFileCache(PFILE_OBJECT FileObject, PCC_FILE_SIZES FileSizes, BOOLEAN PinAccess, PCACHE_MANAGER_CALLBACKS CallBacks, PVOID LazyWriterContext)
LIST_ENTRY CcCleanSharedCacheMapList
static LIST_ENTRY VacbLruListHead
KSPIN_LOCK CcDeferredWriteSpinLock
NTSTATUS CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Dirty, BOOLEAN Mapped)
NTSTATUS CcRosFlushVacb(_In_ PROS_VACB Vacb, _Out_opt_ PIO_STATUS_BLOCK Iosb)
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers, IN PLARGE_INTEGER FileOffset OPTIONAL, IN ULONG Length, OUT PIO_STATUS_BLOCK IoStatus)
NTSTATUS CcRosRequestVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PROS_VACB *Vacb)
LIST_ENTRY CcDeferredWrites
NPAGED_LOOKASIDE_LIST iBcbLookasideList
BOOLEAN CcRosEnsureVacbResident(_In_ PROS_VACB Vacb, _In_ BOOLEAN Wait, _In_ BOOLEAN NoRead, _In_ ULONG Offset, _In_ ULONG Length)
PROS_VACB CcRosLookupVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
NTSTATUS CcRosReleaseFileCache(PFILE_OBJECT FileObject)
PFILE_OBJECT NTAPI CcGetFileObjectFromSectionPtrs(IN PSECTION_OBJECT_POINTERS SectionObjectPointers)
VOID NTAPI CcInitView(VOID)
VOID CcRosTrimCache(_In_ ULONG Target, _Out_ PULONG NrFreed)
LIST_ENTRY DirtyVacbListHead
static NPAGED_LOOKASIDE_LIST SharedCacheMapLookasideList
NTSTATUS CcRosInternalFreeVacb(PROS_VACB Vacb)
NTSTATUS CcRosGetVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PROS_VACB *Vacb)
static NPAGED_LOOKASIDE_LIST VacbLookasideList
BOOLEAN CcRosFreeOneUnusedVacb(VOID)
ULONG CcDirtyPageThreshold
VOID CcRosUnmarkDirtyVacb(PROS_VACB Vacb, BOOLEAN LockViews)
NTSTATUS CcRosFlushDirtyPages(ULONG Target, PULONG Count, BOOLEAN Wait, BOOLEAN CalledFromLazy)
static NTSTATUS CcRosCreateVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PROS_VACB *Vacb)
NTSTATUS NTAPI FsRtlAcquireFileForCcFlushEx(IN PFILE_OBJECT FileObject)
VOID NTAPI FsRtlReleaseFileForCcFlush(IN PFILE_OBJECT FileObject)
#define CcRosVacbIncRefCount(vacb)
FORCEINLINE BOOLEAN IsPointInRange(_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Point)
#define WRITEBEHIND_DISABLED
#define CcRosVacbGetRefCount(vacb)
#define NODE_TYPE_PRIVATE_MAP
#define SHARED_CACHE_MAP_IN_CREATION
#define CCTRACE(x, fmt,...)
#define SHARED_CACHE_MAP_IN_LAZYWRITE
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
#define NODE_TYPE_SHARED_MAP
MMPFNLIST MmModifiedPageListHead
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
BOOLEAN NTAPI MmIsDataSectionResident(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_ LONGLONG Offset, _In_ ULONG Length)
NTSTATUS NTAPI MmFlushSegment(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER Offset, _In_ ULONG Length, _Out_opt_ PIO_STATUS_BLOCK Iosb)
PFN_NUMBER MmAvailablePages
NTSTATUS NTAPI MmMakeDataSectionResident(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_ LONGLONG Offset, _In_ ULONG Length, _In_ PLARGE_INTEGER ValidDataLength)
NTSTATUS NTAPI MmMapViewInSystemSpaceEx(_In_ PVOID Section, _Outptr_result_bytebuffer_(*ViewSize) PVOID *MappedBase, _Inout_ PSIZE_T ViewSize, _Inout_ PLARGE_INTEGER SectionOffset, _In_ ULONG_PTR Flags)
NTSTATUS NTAPI MmPageOutPhysicalAddress(PFN_NUMBER Page)
PIRP NTAPI IoGetTopLevelIrp(VOID)
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
NTSTATUS NTAPI MmCreateSection(OUT PVOID *Section, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT FileObject OPTIONAL)
#define STATUS_END_OF_FILE
PULONG MinorVersion OPTIONAL
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
LARGE_INTEGER ValidDataLength
LARGE_INTEGER AllocationSize
struct _LIST_ENTRY * Flink
KSPIN_LOCK ReadAheadSpinLock
LIST_ENTRY CacheMapVacbListHead
PRIVATE_CACHE_MAP PrivateCacheMap
LARGE_INTEGER ValidDataLength
PCACHE_MANAGER_CALLBACKS Callbacks
LIST_ENTRY SharedCacheMapLinks
LARGE_INTEGER SectionSize
KGUARDED_MUTEX FlushCacheLock
LIST_ENTRY CacheMapVacbListEntry
PROS_SHARED_CACHE_MAP SharedCacheMap
volatile ULONG ReferenceCount
LIST_ENTRY DirtyVacbListEntry
LIST_ENTRY VacbLruListEntry
#define TAG_PRIVATE_CACHE_MAP
#define TAG_SHARED_CACHE_MAP
#define RTL_CONSTANT_STRING(s)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_MEDIA_WRITE_PROTECTED
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_In_ WDFDPC _In_ BOOLEAN Wait
#define VACB_MAPPING_GRANULARITY
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
#define FO_TEMPORARY_FILE
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define ObDereferenceObject