1 #ifndef __INCLUDE_INTERNAL_CC_H
2 #define __INCLUDE_INTERNAL_CC_H
4 typedef struct _PF_SCENARIO_ID
8 } PF_SCENARIO_ID
, *PPF_SCENARIO_ID
;
10 typedef struct _PF_LOG_ENTRY
17 ULONG FileSequenceNumber
;
19 } PF_LOG_ENTRY
, *PPF_LOG_ENTRY
;
21 typedef struct _PFSN_LOG_ENTRIES
23 LIST_ENTRY TraceBuffersLink
;
26 PF_LOG_ENTRY Entries
[ANYSIZE_ARRAY
];
27 } PFSN_LOG_ENTRIES
, *PPFSN_LOG_ENTRIES
;
29 typedef struct _PF_SECTION_INFO
32 ULONG FileSequenceNumber
;
35 } PF_SECTION_INFO
, *PPF_SECTION_INFO
;
37 typedef struct _PF_TRACE_HEADER
42 PF_SCENARIO_ID ScenarioId
;
43 ULONG ScenarioType
; // PF_SCENARIO_TYPE
44 ULONG EventEntryIdxs
[8];
45 ULONG NumEventEntryIdxs
;
46 ULONG TraceBufferOffset
;
48 ULONG SectionInfoOffset
;
50 ULONG FaultsPerPeriod
[10];
51 LARGE_INTEGER LaunchTime
;
52 ULONGLONG Reserved
[5];
53 } PF_TRACE_HEADER
, *PPF_TRACE_HEADER
;
55 typedef struct _PFSN_TRACE_DUMP
57 LIST_ENTRY CompletedTracesLink
;
58 PF_TRACE_HEADER Trace
;
59 } PFSN_TRACE_DUMP
, *PPFSN_TRACE_DUMP
;
61 typedef struct _PFSN_TRACE_HEADER
64 LIST_ENTRY ActiveTracesLink
;
65 PF_SCENARIO_ID ScenarioId
;
66 ULONG ScenarioType
; // PF_SCENARIO_TYPE
67 ULONG EventEntryIdxs
[8];
68 ULONG NumEventEntryIdxs
;
69 PPFSN_LOG_ENTRIES CurrentTraceBuffer
;
70 LIST_ENTRY TraceBuffersList
;
71 ULONG NumTraceBuffers
;
72 KSPIN_LOCK TraceBufferSpinLock
;
74 LARGE_INTEGER TraceTimerPeriod
;
76 KSPIN_LOCK TraceTimerSpinLock
;
77 ULONG FaultsPerPeriod
[10];
83 EX_RUNDOWN_REF RefCount
;
84 WORK_QUEUE_ITEM EndTraceWorkItem
;
86 PPFSN_TRACE_DUMP TraceDump
;
87 NTSTATUS TraceDumpStatus
;
88 LARGE_INTEGER LaunchTime
;
89 PPF_SECTION_INFO SectionInfo
;
90 ULONG SectionInfoCount
;
91 } PFSN_TRACE_HEADER
, *PPFSN_TRACE_HEADER
;
93 typedef struct _PFSN_PREFETCHER_GLOBALS
95 LIST_ENTRY ActiveTraces
;
96 KSPIN_LOCK ActiveTracesLock
;
97 PPFSN_TRACE_HEADER SystemWideTrace
;
98 LIST_ENTRY CompletedTraces
;
99 FAST_MUTEX CompletedTracesLock
;
100 LONG NumCompletedTraces
;
101 PKEVENT CompletedTracesEvent
;
102 LONG ActivePrefetches
;
103 } PFSN_PREFETCHER_GLOBALS
, *PPFSN_PREFETCHER_GLOBALS
;
107 LIST_ENTRY BcbSegmentListHead
;
108 LIST_ENTRY BcbRemoveListEntry
;
109 BOOLEAN RemoveOnClose
;
111 PFILE_OBJECT FileObject
;
112 ULONG CacheSegmentSize
;
113 LARGE_INTEGER AllocationSize
;
114 LARGE_INTEGER FileSize
;
115 PCACHE_MANAGER_CALLBACKS Callbacks
;
116 PVOID LazyWriteContext
;
120 BOOLEAN Trace
; /* enable extra trace output for this BCB and it's cache segments */
124 typedef struct _CACHE_SEGMENT
126 /* Base address of the region where the cache segment data is mapped. */
129 * Memory area representing the region where the cache segment data is
132 struct _MEMORY_AREA
* MemoryArea
;
133 /* Are the contents of the cache segment data valid. */
135 /* Are the contents of the cache segment data newer than those on disk. */
137 /* Page out in progress */
140 /* Entry in the list of segments for this BCB. */
141 LIST_ENTRY BcbSegmentListEntry
;
142 /* Entry in the list of segments which are dirty. */
143 LIST_ENTRY DirtySegmentListEntry
;
144 /* Entry in the list of segments. */
145 LIST_ENTRY CacheSegmentListEntry
;
146 LIST_ENTRY CacheSegmentLRUListEntry
;
147 /* Offset in the file which this cache segment maps. */
151 /* Number of references. */
152 ULONG ReferenceCount
;
153 /* Pointer to the BCB for the file which this cache segment maps data for. */
155 /* Pointer to the next cache segment in a chain. */
156 struct _CACHE_SEGMENT
* NextInChain
;
157 } CACHE_SEGMENT
, *PCACHE_SEGMENT
;
159 typedef struct _INTERNAL_BCB
162 PCACHE_SEGMENT CacheSegment
;
164 CSHORT RefCount
; /* (At offset 0x34 on WinNT4) */
165 } INTERNAL_BCB
, *PINTERNAL_BCB
;
169 CcPfInitializePrefetcher(
176 IN PMDL MemoryDescriptorList
,
177 IN PFILE_OBJECT FileObject
183 IN PFILE_OBJECT FileObject
,
184 IN PLARGE_INTEGER FileOffset
,
190 CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment
);
194 CcRosGetCacheSegment(
200 PCACHE_SEGMENT
*CacheSeg
209 CcRosFreeCacheSegment(
216 ReadCacheSegment(PCACHE_SEGMENT CacheSeg
);
220 WriteCacheSegment(PCACHE_SEGMENT CacheSeg
);
224 CcInitializeCacheManager(VOID
);
228 CcRosUnmapCacheSegment(
236 CcRosLookupCacheSegment(
243 CcRosGetCacheSegmentChain(
247 PCACHE_SEGMENT
* CacheSeg
252 CcInitCacheZeroPage(VOID
);
256 CcRosMarkDirtyCacheSegment(
263 CcRosFlushDirtyPages(
270 CcRosDereferenceCache(PFILE_OBJECT FileObject
);
274 CcRosReferenceCache(PFILE_OBJECT FileObject
);
278 CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer
);
282 CcRosReleaseCacheSegment(
284 CACHE_SEGMENT
*CacheSeg
,
292 CcRosRequestCacheSegment(
297 CACHE_SEGMENT
**CacheSeg
302 CcRosInitializeFileCache(
303 PFILE_OBJECT FileObject
,
304 ULONG CacheSegmentSize
,
305 PCACHE_MANAGER_CALLBACKS CallBacks
,
306 PVOID LazyWriterContext
311 CcRosReleaseFileCache(
312 PFILE_OBJECT FileObject
317 CcTryToInitializeFileCache(PFILE_OBJECT FileObject
);