ReactOS 0.4.16-dev-290-g89a3b8f
fssup.c File Reference
#include <ntoskrnl.h>
#include "newcc.h"
#include "section/newmm.h"
#include <debug.h>
Include dependency graph for fssup.c:

Go to the source code of this file.

Classes

struct  _NOCC_PRIVATE_CACHE_MAP
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _NOCC_PRIVATE_CACHE_MAP NOCC_PRIVATE_CACHE_MAP
 
typedef struct _NOCC_PRIVATE_CACHE_MAPPNOCC_PRIVATE_CACHE_MAP
 

Functions

VOID NTAPI CcpUnmapThread (PVOID Unused)
 
VOID NTAPI CcpLazyWriteThread (PVOID Unused)
 
BOOLEAN NTAPI CcInitializeCacheManager (VOID)
 
VOID NTAPI CcPfInitializePrefetcher (VOID)
 
BOOLEAN NTAPI CcpAcquireFileLock (PNOCC_CACHE_MAP Map)
 
VOID NTAPI CcpReleaseFileLock (PNOCC_CACHE_MAP Map)
 
PFILE_OBJECT CcpFindOtherStreamFileObject (PFILE_OBJECT FileObject)
 
VOID NTAPI CcInitializeCacheMap (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
 
ULONG NTAPI CcpCountCacheSections (IN PNOCC_CACHE_MAP Map)
 
BOOLEAN NTAPI CcUninitializeCacheMap (IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
 
VOID NTAPI CcSetFileSizes (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
 
BOOLEAN NTAPI CcGetFileSizes (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
 
BOOLEAN NTAPI CcPurgeCacheSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
 
VOID NTAPI CcSetDirtyPageThreshold (IN PFILE_OBJECT FileObject, IN ULONG DirtyPageThreshold)
 
BOOLEAN NTAPI CcZeroData (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
 
PFILE_OBJECT NTAPI CcGetFileObjectFromSectionPtrs (IN PSECTION_OBJECT_POINTERS SectionObjectPointer)
 
PFILE_OBJECT NTAPI CcGetFileObjectFromBcb (PVOID Bcb)
 

Variables

PFSN_PREFETCHER_GLOBALS CcPfGlobals
 
LONG CcOutstandingDeletes
 
KEVENT CcpLazyWriteEvent
 
KEVENT CcFinalizeEvent
 
HANDLE CcUnmapThreadHandle
 
HANDLE CcLazyWriteThreadHandle
 
CLIENT_ID CcUnmapThreadId
 
CLIENT_ID CcLazyWriteThreadId
 
FAST_MUTEX GlobalPageOperation
 
LIST_ENTRY CcpAllSharedCacheMaps
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file fssup.c.

Typedef Documentation

◆ NOCC_PRIVATE_CACHE_MAP

◆ PNOCC_PRIVATE_CACHE_MAP

Function Documentation

◆ CcGetFileObjectFromBcb()

PFILE_OBJECT NTAPI CcGetFileObjectFromBcb ( PVOID  Bcb)

Definition at line 625 of file fssup.c.

626{
627 PNOCC_BCB RealBcb = (PNOCC_BCB)Bcb;
628 DPRINT("BCB #%x\n", RealBcb - CcCacheSections);
629 return MmGetFileObjectForSection((PROS_SECTION_OBJECT)RealBcb->SectionObject);
630}
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:415
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
struct _NOCC_BCB * PNOCC_BCB
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1541
#define DPRINT
Definition: sndvol32.h:73
Definition: newcc.h:4
PSECTION SectionObject
Definition: newcc.h:9

Referenced by FatUnpinRepinnedBcbs().

◆ CcGetFileObjectFromSectionPtrs()

PFILE_OBJECT NTAPI CcGetFileObjectFromSectionPtrs ( IN PSECTION_OBJECT_POINTERS  SectionObjectPointer)

Definition at line 606 of file fssup.c.

607{
609 PNOCC_CACHE_MAP Map = SectionObjectPointer->SharedCacheMap;
610 CcpLock();
611 if (!IsListEmpty(&Map->AssociatedBcb))
612 {
614 NOCC_BCB,
615 ThisFileList);
616
617 Result = MmGetFileObjectForSection((PROS_SECTION_OBJECT)Bcb->SectionObject);
618 }
619 CcpUnlock();
620 return Result;
621}
#define NULL
Definition: types.h:112
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer
Definition: fsrtlfuncs.h:1369
#define CcpLock()
Definition: newcc.h:138
#define CcpUnlock()
Definition: newcc.h:139
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY AssociatedBcb
Definition: newcc.h:29
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
* PFILE_OBJECT
Definition: iotypes.h:1998

◆ CcGetFileSizes()

BOOLEAN NTAPI CcGetFileSizes ( IN PFILE_OBJECT  FileObject,
IN PCC_FILE_SIZES  FileSizes 
)

Definition at line 375 of file fssup.c.

377{
378 PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
379 if (!Map) return FALSE;
380 *FileSizes = Map->FileSizes;
381 return TRUE;
382}
static CC_FILE_SIZES FileSizes
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
if(dx< 0)
Definition: linetemp.h:194
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP
CC_FILE_SIZES FileSizes
Definition: newcc.h:33
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

◆ CcInitializeCacheManager()

BOOLEAN NTAPI CcInitializeCacheManager ( VOID  )

Definition at line 83 of file fssup.c.

84{
85 int i;
86
87 DPRINT("Initialize\n");
88 for (i = 0; i < CACHE_NUM_SECTIONS; i++)
89 {
90 KeInitializeEvent(&CcCacheSections[i].ExclusiveWait,
92 FALSE);
93
94 InitializeListHead(&CcCacheSections[i].ThisFileList);
95 }
96
98
102
105 DPRINT1("Cache has %d entries\n", CcCacheBitmap->SizeOfBitMap);
107
108 return TRUE;
109}
#define DPRINT1
Definition: precomp.h:8
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
KEVENT CcpLazyWriteEvent
Definition: lazyrite.c:18
KEVENT CcFinalizeEvent
Definition: pinsup.c:103
LIST_ENTRY CcpAllSharedCacheMaps
Definition: fssup.c:76
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
Definition: glfuncs.h:248
FAST_MUTEX CcMutex
Definition: pinsup.c:101
PRTL_BITMAP CcCacheBitmap
Definition: pinsup.c:100
KEVENT CcDeleteEvent
Definition: pinsup.c:102
#define CACHE_NUM_SECTIONS
Definition: newcc.h:125
@ SynchronizationEvent
ULONG SizeOfBitMap
Definition: typedefs.h:90
PULONG Buffer
Definition: typedefs.h:91
uint32_t * PULONG
Definition: typedefs.h:59
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274

Referenced by Phase1InitializationDiscard().

◆ CcInitializeCacheMap()

VOID NTAPI CcInitializeCacheMap ( IN PFILE_OBJECT  FileObject,
IN PCC_FILE_SIZES  FileSizes,
IN BOOLEAN  PinAccess,
IN PCACHE_MANAGER_CALLBACKS  Callbacks,
IN PVOID  LazyWriteContext 
)

Definition at line 195 of file fssup.c.

200{
201 PNOCC_CACHE_MAP Map = FileObject->SectionObjectPointer->SharedCacheMap;
202 PNOCC_PRIVATE_CACHE_MAP PrivateCacheMap = FileObject->PrivateCacheMap;
203
204 CcpLock();
205 /* We don't have a shared cache map. First find out if we have a sibling
206 stream file object we can take it from. */
207 if (!Map && FileObject->Flags & FO_STREAM_FILE)
208 {
209 PFILE_OBJECT IdenticalStreamFileObject = CcpFindOtherStreamFileObject(FileObject);
210 if (IdenticalStreamFileObject)
211 Map = IdenticalStreamFileObject->SectionObjectPointer->SharedCacheMap;
212 if (Map)
213 {
214 DPRINT1("Linking SFO %x to previous SFO %x through cache map %x #\n",
216 IdenticalStreamFileObject,
217 Map);
218 }
219 }
220 /* We still don't have a shared cache map. We need to create one. */
221 if (!Map)
222 {
223 DPRINT("Initializing file object for (%p) %wZ\n",
225 &FileObject->FileName);
226
228 FileObject->SectionObjectPointer->SharedCacheMap = Map;
229 Map->FileSizes = *FileSizes;
230 Map->LazyContext = LazyWriteContext;
232 RtlCopyMemory(&Map->Callbacks, Callbacks, sizeof(*Callbacks));
233
234 /* For now ... */
235 DPRINT("FileSizes->ValidDataLength %I64x\n",
237
241 DPRINT("New Map %p\n", Map);
242 }
243 /* We don't have a private cache map. Link it with the shared cache map
244 to serve as a held reference. When the list in the shared cache map
245 is empty, we know we can delete it. */
246 if (!PrivateCacheMap)
247 {
248 PrivateCacheMap = ExAllocatePool(NonPagedPool,
249 sizeof(*PrivateCacheMap));
250
251 FileObject->PrivateCacheMap = PrivateCacheMap;
252 PrivateCacheMap->FileObject = FileObject;
253 ObReferenceObject(PrivateCacheMap->FileObject);
254 }
255
256 PrivateCacheMap->Map = Map;
257 InsertTailList(&Map->PrivateCacheMaps, &PrivateCacheMap->ListEntry);
258
259 CcpUnlock();
260}
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
#define InsertTailList(ListHead, Entry)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PFILE_OBJECT CcpFindOtherStreamFileObject(PFILE_OBJECT FileObject)
Definition: fssup.c:160
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
CACHE_MANAGER_CALLBACKS Callbacks
Definition: newcc.h:34
PVOID LazyContext
Definition: newcc.h:35
LIST_ENTRY Entry
Definition: newcc.h:28
ULONG ReadAheadGranularity
Definition: newcc.h:38
LIST_ENTRY PrivateCacheMaps
Definition: newcc.h:30
PNOCC_CACHE_MAP Map
Definition: fssup.c:73
LIST_ENTRY ListEntry
Definition: fssup.c:71
PFILE_OBJECT FileObject
Definition: fssup.c:72
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LONGLONG QuadPart
Definition: typedefs.h:114
#define FO_STREAM_FILE
Definition: iotypes.h:1783
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by _Requires_lock_held_(), CdCreateInternalStream(), Ext2InitializeVcb(), Ext2ReadFile(), Ext2WriteFile(), FatInitializeCacheMap(), init_file_cache(), mount_vol(), NtfsAttachFCBToFileObject(), NtfsFCBInitializeCache(), NtfsMountVolume(), PerformTest(), RxCommonRead(), RxCommonWrite(), TestIrpHandler(), UDFCommonRead(), UDFCommonWrite(), UDFSetAllocationInformation(), UDFSetEOF(), VfatCommonRead(), vfatFCBInitializeCacheFromVolume(), VfatMount(), and VfatWrite().

◆ CcpAcquireFileLock()

BOOLEAN NTAPI CcpAcquireFileLock ( PNOCC_CACHE_MAP  Map)

Definition at line 131 of file fssup.c.

132{
133 DPRINT("Calling AcquireForLazyWrite: %x\n", Map->LazyContext);
135}
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39

◆ CcpCountCacheSections()

ULONG NTAPI CcpCountCacheSections ( IN PNOCC_CACHE_MAP  Map)

Definition at line 272 of file fssup.c.

273{
275 ULONG Count;
276
277 for (Count = 0, Entry = Map->AssociatedBcb.Flink;
278 Entry != &Map->AssociatedBcb;
279 Entry = Entry->Flink, Count++);
280
281 return Count;
282}
int Count
Definition: noreturn.cpp:7
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
uint32_t ULONG
Definition: typedefs.h:59

◆ CcpFindOtherStreamFileObject()

PFILE_OBJECT CcpFindOtherStreamFileObject ( PFILE_OBJECT  FileObject)

Definition at line 160 of file fssup.c.

161{
162 PLIST_ENTRY Entry, Private;
165 Entry = Entry->Flink)
166 {
167 /* 'Identical' test for other stream file object */
169 for (Private = Map->PrivateCacheMaps.Flink;
170 Private != &Map->PrivateCacheMaps;
171 Private = Private->Flink)
172 {
173 PNOCC_PRIVATE_CACHE_MAP PrivateMap = CONTAINING_RECORD(Private,
175 ListEntry);
176
177 if (PrivateMap->FileObject->Flags & FO_STREAM_FILE &&
178 PrivateMap->FileObject->DeviceObject == FileObject->DeviceObject &&
179 PrivateMap->FileObject->Vpb == FileObject->Vpb &&
180 PrivateMap->FileObject->FsContext == FileObject->FsContext &&
181 PrivateMap->FileObject->FsContext2 == FileObject->FsContext2 &&
182 1)
183 {
184 return PrivateMap->FileObject;
185 }
186 }
187 }
188 return 0;
189}

Referenced by CcInitializeCacheMap().

◆ CcPfInitializePrefetcher()

VOID NTAPI CcPfInitializePrefetcher ( VOID  )

Definition at line 114 of file fssup.c.

115{
116 /* Notify debugger */
119 "CCPF: InitializePrefetecher()\n");
120
121 /* Setup the Prefetcher Data */
125
126 /* FIXME: Setup the rest of the prefetecher */
127}
@ DPFLTR_PREFETCHER_ID
Definition: dpfilter.h:91
PFSN_PREFETCHER_GLOBALS CcPfGlobals
Definition: fssup.c:20
#define DPFLTR_TRACE_LEVEL
Definition: kdtypes.h:32
NTSYSAPI ULONG __cdecl DbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ _Printf_format_string_ PCSTR Format,...)
LIST_ENTRY ActiveTraces
Definition: cc.h:160
LIST_ENTRY CompletedTraces
Definition: cc.h:163
FAST_MUTEX CompletedTracesLock
Definition: cc.h:164

Referenced by Phase1InitializationDiscard().

◆ CcpLazyWriteThread()

VOID NTAPI CcpLazyWriteThread ( PVOID  Unused)

Definition at line 23 of file lazyrite.c.

24{
25 /* Not implemented */
26}

◆ CcpReleaseFileLock()

VOID NTAPI CcpReleaseFileLock ( PNOCC_CACHE_MAP  Map)

Definition at line 139 of file fssup.c.

140{
141 DPRINT("Releasing Lazy Write %x\n", Map->LazyContext);
143}
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40

◆ CcpUnmapThread()

VOID NTAPI CcpUnmapThread ( PVOID  Unused)

◆ CcPurgeCacheSection()

◆ CcSetDirtyPageThreshold()

VOID NTAPI CcSetDirtyPageThreshold ( IN PFILE_OBJECT  FileObject,
IN ULONG  DirtyPageThreshold 
)

Definition at line 399 of file fssup.c.

401{
403}
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ CcSetFileSizes()

VOID NTAPI CcSetFileSizes ( IN PFILE_OBJECT  FileObject,
IN PCC_FILE_SIZES  FileSizes 
)

Definition at line 356 of file fssup.c.

358{
359 PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
361
362 if (!Map) return;
363 Map->FileSizes = *FileSizes;
364 Bcb = Map->AssociatedBcb.Flink == &Map->AssociatedBcb ?
365 NULL : CONTAINING_RECORD(Map->AssociatedBcb.Flink, NOCC_BCB, ThisFileList);
366 if (!Bcb) return;
367 MmExtendCacheSection(Bcb->SectionObject, &FileSizes->FileSize, FALSE);
368 DPRINT("FileSizes->FileSize %x\n", FileSizes->FileSize.LowPart);
369 DPRINT("FileSizes->AllocationSize %x\n", FileSizes->AllocationSize.LowPart);
370 DPRINT("FileSizes->ValidDataLength %x\n", FileSizes->ValidDataLength.LowPart);
371}
NTSTATUS NTAPI MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile)
LARGE_INTEGER FileSize
Definition: cctypes.h:16
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
ULONG LowPart
Definition: typedefs.h:106

Referenced by __attribute__(), _Requires_lock_held_(), CdCreateInternalStream(), delete_fileref_fcb(), Ext2Cleanup(), Ext2SetFileInformation(), Ext2SupersedeOrOverWriteFile(), Ext2WriteFile(), FatSetupAllocationSupport(), PerformTest(), RxCollapseOrCreateSrvOpen(), RxCommonWrite(), set_end_of_file_information(), set_valid_data_length_information(), SetAttributeDataLength(), TestIrpHandler(), UDFCommonCleanup(), UDFCommonCreate(), UDFCommonWrite(), UDFSetAllocationInformation(), UDFSetEOF(), and UpdateFileSize().

◆ CcUninitializeCacheMap()

BOOLEAN NTAPI CcUninitializeCacheMap ( IN PFILE_OBJECT  FileObject,
IN OPTIONAL PLARGE_INTEGER TruncateSize  ,
IN OPTIONAL PCACHE_UNINITIALIZE_EVENT  UninitializeEvent 
)

Definition at line 286 of file fssup.c.

289{
290 BOOLEAN LastMap = FALSE;
291 PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
292 PNOCC_PRIVATE_CACHE_MAP PrivateCacheMap = FileObject->PrivateCacheMap;
293
294 DPRINT("Uninitializing file object for %wZ SectionObjectPointer %x\n",
295 &FileObject->FileName,
296 FileObject->SectionObjectPointer);
297
298 ASSERT(UninitializeEvent == NULL);
299
300 /* It may not be strictly necessary to flush here, but we do just for
301 kicks. */
302 if (Map)
303 CcpFlushCache(Map, NULL, 0, NULL, FALSE);
304
305 CcpLock();
306 /* We have a private cache map, so we've been initialized and haven't been
307 * uninitialized. */
308 if (PrivateCacheMap)
309 {
310 ASSERT(!Map || Map == PrivateCacheMap->Map);
311 ASSERT(PrivateCacheMap->FileObject == FileObject);
312
313 RemoveEntryList(&PrivateCacheMap->ListEntry);
314 /* That was the last private cache map. It's time to delete all
315 cache stripes and all aspects of caching on the file. */
316 if (IsListEmpty(&PrivateCacheMap->Map->PrivateCacheMaps))
317 {
318 /* Get rid of all the cache stripes. */
319 while (!IsListEmpty(&PrivateCacheMap->Map->AssociatedBcb))
320 {
321 PNOCC_BCB Bcb = CONTAINING_RECORD(PrivateCacheMap->Map->AssociatedBcb.Flink,
322 NOCC_BCB,
323 ThisFileList);
324
325 DPRINT("Evicting cache stripe #%x\n", Bcb - CcCacheSections);
326 Bcb->RefCount = 1;
328 }
329 RemoveEntryList(&PrivateCacheMap->Map->Entry);
330 ExFreePool(PrivateCacheMap->Map);
331 FileObject->SectionObjectPointer->SharedCacheMap = NULL;
332 LastMap = TRUE;
333 }
334 ObDereferenceObject(PrivateCacheMap->FileObject);
335 FileObject->PrivateCacheMap = NULL;
336 ExFreePool(PrivateCacheMap);
337 }
338 CcpUnlock();
339
340 DPRINT("Uninit complete\n");
341
342 /* The return from CcUninitializeCacheMap means that 'caching was stopped'. */
343 return LastMap;
344}
unsigned char BOOLEAN
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ASSERT(a)
Definition: mode.c:44
VOID CcpDereferenceCache(ULONG Sector, BOOLEAN Immediate)
Definition: pinsup.c:213
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by _Dispatch_type_(), _Requires_lock_held_(), CdDeleteInternalStream(), CleanupTest(), close_file(), delete_fileref(), Ext2Cleanup(), Ext2SyncUninitializeCacheMap(), FatSetRenameInfo(), FatSyncUninitializeCacheMap(), FatTearDownVcb(), NtfsCleanupFile(), NtfsReleaseFCB(), RxUninitializeCacheMap(), TestIrpHandler(), UDFCommonCleanup(), UDFSetAllocationInformation(), UDFSetEOF(), VfatCheckForDismount(), VfatCleanupFile(), VfatCommonCloseFile(), VfatMount(), and vfatReleaseFCB().

◆ CcZeroData()

BOOLEAN NTAPI CcZeroData ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  StartOffset,
IN PLARGE_INTEGER  EndOffset,
IN BOOLEAN  Wait 
)

Definition at line 414 of file fssup.c.

418{
420 PLIST_ENTRY ListEntry = NULL;
421 LARGE_INTEGER LowerBound = *StartOffset;
422 LARGE_INTEGER UpperBound = *EndOffset;
424 PVOID PinnedBcb, PinnedBuffer;
425 PNOCC_CACHE_MAP Map = FileObject->SectionObjectPointer->SharedCacheMap;
426
427 DPRINT("S %I64x E %I64x\n",
428 StartOffset->QuadPart,
429 EndOffset->QuadPart);
430
431 if (!Map)
432 {
434 IO_STATUS_BLOCK IOSB;
436 ULONG ToWrite;
437
439 DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, PAGE_SIZE);
440 RtlZeroMemory(ZeroBuf, PAGE_SIZE);
441
442 Target.QuadPart = PAGE_ROUND_DOWN(LowerBound.QuadPart);
443 End.QuadPart = PAGE_ROUND_UP(UpperBound.QuadPart);
444
445 // Handle leading page
446 if (LowerBound.QuadPart != Target.QuadPart)
447 {
448 ToWrite = MIN(UpperBound.QuadPart - LowerBound.QuadPart,
449 (PAGE_SIZE - LowerBound.QuadPart) & (PAGE_SIZE - 1));
450
451 DPRINT("Zero last half %I64x %lx\n",
452 Target.QuadPart,
453 ToWrite);
454
456 &Target,
457 ZeroBuf,
458 PAGE_SIZE,
459 TRUE,
460 &IOSB);
461
462 if (!NT_SUCCESS(Status))
463 {
464 ExFreePool(ZeroBuf);
466 }
467
468 DPRINT1("RtlZeroMemory(%p, %lx)\n",
469 ZeroBuf + LowerBound.QuadPart - Target.QuadPart,
470 ToWrite);
471
472 RtlZeroMemory(ZeroBuf + LowerBound.QuadPart - Target.QuadPart,
473 ToWrite);
474
476 &Target,
477 ZeroBuf,
479 UpperBound.QuadPart-Target.QuadPart),
480 &IOSB);
481
482 if (!NT_SUCCESS(Status))
483 {
484 ExFreePool(ZeroBuf);
486 }
487 Target.QuadPart += PAGE_SIZE;
488 }
489
490 DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, PAGE_SIZE);
491 RtlZeroMemory(ZeroBuf, PAGE_SIZE);
492
493 while (UpperBound.QuadPart - Target.QuadPart > PAGE_SIZE)
494 {
495 DPRINT("Zero full page %I64x\n",
496 Target.QuadPart);
497
499 &Target,
500 ZeroBuf,
501 PAGE_SIZE,
502 &IOSB);
503
504 if (!NT_SUCCESS(Status))
505 {
506 ExFreePool(ZeroBuf);
508 }
509 Target.QuadPart += PAGE_SIZE;
510 }
511
512 if (UpperBound.QuadPart > Target.QuadPart)
513 {
514 ToWrite = UpperBound.QuadPart - Target.QuadPart;
515 DPRINT("Zero first half %I64x %lx\n",
516 Target.QuadPart,
517 ToWrite);
518
520 &Target,
521 ZeroBuf,
522 PAGE_SIZE,
523 TRUE,
524 &IOSB);
525
526 if (!NT_SUCCESS(Status))
527 {
528 ExFreePool(ZeroBuf);
530 }
531 DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, ToWrite);
532 RtlZeroMemory(ZeroBuf, ToWrite);
534 &Target,
535 ZeroBuf,
537 UpperBound.QuadPart-Target.QuadPart),
538 &IOSB);
539 if (!NT_SUCCESS(Status))
540 {
541 ExFreePool(ZeroBuf);
543 }
544 Target.QuadPart += PAGE_SIZE;
545 }
546
547 ExFreePool(ZeroBuf);
548 return TRUE;
549 }
550
551 CcpLock();
552 ListEntry = Map->AssociatedBcb.Flink;
553
554 while (ListEntry != &Map->AssociatedBcb)
555 {
556 Bcb = CONTAINING_RECORD(ListEntry, NOCC_BCB, ThisFileList);
558
559 if (Bcb->FileOffset.QuadPart + Bcb->Length >= LowerBound.QuadPart &&
560 Bcb->FileOffset.QuadPart < UpperBound.QuadPart)
561 {
562 DPRINT("Bcb #%x (@%I64x)\n",
564 Bcb->FileOffset.QuadPart);
565
566 Target.QuadPart = MAX(Bcb->FileOffset.QuadPart,
567 LowerBound.QuadPart);
568
570 UpperBound.QuadPart);
571
572 End.QuadPart = MIN(End.QuadPart,
573 Bcb->FileOffset.QuadPart + Bcb->Length);
574
575 CcpUnlock();
576
578 &Target,
579 End.QuadPart - Target.QuadPart,
580 TRUE,
581 Wait,
582 &PinnedBcb,
583 &PinnedBuffer))
584 {
585 return FALSE;
586 }
587
588 ASSERT(PinnedBcb == Bcb);
589
590 CcpLock();
591 ListEntry = ListEntry->Flink;
592 /* Return from pin state */
593 CcpUnpinData(PinnedBcb, TRUE);
594 }
595
597 }
598
599 CcpUnlock();
600
601 return TRUE;
602}
LONG NTSTATUS
Definition: precomp.h:26
#define MIN(x, y)
Definition: rdesktop.h:171
#define MAX(x, y)
Definition: rdesktop.h:175
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
BOOLEAN NTAPI CcpUnpinData(PNOCC_BCB Bcb, BOOLEAN ActuallyRelease)
VOID CcpReferenceCache(ULONG Sector)
Definition: pinsup.c:368
#define MiSimpleWrite(F, O, B, L, R)
Definition: newmm.h:145
NTSTATUS NTAPI MiSimpleRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
Definition: io.c:109
BOOLEAN NTAPI CcPreparePinWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Zero, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:827
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by Ext2Cleanup(), Ext2ZeroData(), FatZeroData(), FsRtlCopyWrite(), FsRtlCopyWrite2(), FsRtlPrepareMdlWriteDev(), and VfatWrite().

Variable Documentation

◆ CcFinalizeEvent

KEVENT CcFinalizeEvent
extern

Definition at line 103 of file pinsup.c.

Referenced by CcInitializeCacheManager().

◆ CcLazyWriteThreadHandle

HANDLE CcLazyWriteThreadHandle

Definition at line 26 of file fssup.c.

◆ CcLazyWriteThreadId

CLIENT_ID CcLazyWriteThreadId

Definition at line 27 of file fssup.c.

◆ CcOutstandingDeletes

LONG CcOutstandingDeletes
extern

Definition at line 105 of file pinsup.c.

◆ CcpAllSharedCacheMaps

LIST_ENTRY CcpAllSharedCacheMaps

◆ CcPfGlobals

Definition at line 20 of file fssup.c.

Referenced by CcPfInitializePrefetcher().

◆ CcpLazyWriteEvent

KEVENT CcpLazyWriteEvent
extern

Definition at line 18 of file lazyrite.c.

Referenced by CcInitializeCacheManager().

◆ CcUnmapThreadHandle

HANDLE CcUnmapThreadHandle

Definition at line 26 of file fssup.c.

◆ CcUnmapThreadId

CLIENT_ID CcUnmapThreadId

Definition at line 27 of file fssup.c.

◆ GlobalPageOperation

FAST_MUTEX GlobalPageOperation

Definition at line 28 of file fssup.c.