ReactOS  0.4.13-dev-52-g0efcfec
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 623 of file fssup.c.

624 {
625  PNOCC_BCB RealBcb = (PNOCC_BCB)Bcb;
626  DPRINT("BCB #%x\n", RealBcb - CcCacheSections);
628 }
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1681
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
Definition: newcc.h:3
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
void DPRINT(...)
Definition: polytest.cpp:61
PROS_SECTION_OBJECT SectionObject
Definition: newcc.h:9
struct _NOCC_BCB * PNOCC_BCB

Referenced by FatUnpinRepinnedBcbs(), FFSUnpinRepinnedBcbs(), and RfsdUnpinRepinnedBcbs().

◆ CcGetFileObjectFromSectionPtrs()

PFILE_OBJECT NTAPI CcGetFileObjectFromSectionPtrs ( IN PSECTION_OBJECT_POINTERS  SectionObjectPointer)

Definition at line 604 of file fssup.c.

605 {
607  PNOCC_CACHE_MAP Map = SectionObjectPointer->SharedCacheMap;
608  CcpLock();
609  if (!IsListEmpty(&Map->AssociatedBcb))
610  {
612  NOCC_BCB,
613  ThisFileList);
614 
616  }
617  CcpUnlock();
618  return Result;
619 }
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1681
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
#define CcpLock()
Definition: newcc.h:143
Definition: newcc.h:3
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer
Definition: fsrtlfuncs.h:1368
smooth NULL
Definition: ftsmooth.c:416
_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:426
LIST_ENTRY AssociatedBcb
Definition: newcc.h:29
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
* PFILE_OBJECT
Definition: iotypes.h:1954
#define CcpUnlock()
Definition: newcc.h:144

◆ CcGetFileSizes()

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

Definition at line 373 of file fssup.c.

375 {
376  PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
377  if (!Map) return FALSE;
378  *FileSizes = Map->FileSizes;
379  return TRUE;
380 }
#define TRUE
Definition: types.h:120
static CC_FILE_SIZES FileSizes
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
if(!(yy_init))
Definition: macro.lex.yy.c:714
CC_FILE_SIZES FileSizes
Definition: newcc.h:33
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP

Referenced by MmCanFileBeTruncated(), and MmCreateCacheSection().

◆ CcInitializeCacheManager()

BOOLEAN NTAPI CcInitializeCacheManager ( VOID  )

Definition at line 82 of file fssup.c.

83 {
84  int i;
85 
86  DPRINT("Initialize\n");
87  for (i = 0; i < CACHE_NUM_SECTIONS; i++)
88  {
89  KeInitializeEvent(&CcCacheSections[i].ExclusiveWait,
91  FALSE);
92 
93  InitializeListHead(&CcCacheSections[i].ThisFileList);
94  }
95 
97 
101 
104  DPRINT1("Cache has %d entries\n", CcCacheBitmap->SizeOfBitMap);
106 
107  return TRUE;
108 }
KEVENT CcpLazyWriteEvent
Definition: lazyrite.c:18
PULONG Buffer
Definition: typedefs.h:89
#define TRUE
Definition: types.h:120
FAST_MUTEX CcMutex
Definition: pinsup.c:101
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
#define CACHE_NUM_SECTIONS
Definition: newcc.h:130
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
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
KEVENT CcDeleteEvent
Definition: pinsup.c:102
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
KEVENT CcFinalizeEvent
Definition: pinsup.c:103
PRTL_BITMAP CcCacheBitmap
Definition: pinsup.c:100
ULONG SizeOfBitMap
Definition: typedefs.h:88
LIST_ENTRY CcpAllSharedCacheMaps
Definition: fssup.c:76
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8

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 193 of file fssup.c.

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

Referenced by _Requires_lock_held_(), CdCreateInternalStream(), Ext2InitializeVcb(), Ext2ReadFile(), Ext2WriteFile(), FatInitializeCacheMap(), FFSInitializeVcb(), FFSReadFile(), FFSSetInformation(), FFSWriteFile(), init_file_cache(), mount_vol(), NtfsAttachFCBToFileObject(), NtfsFCBInitializeCache(), NtfsMountVolume(), PerformTest(), RfsdInitializeVcb(), RfsdReadFile(), RfsdSetInformation(), RfsdWriteFile(), RxCommonRead(), RxCommonWrite(), TestIrpHandler(), UDFCommonRead(), UDFCommonWrite(), UDFSetAllocationInformation(), UDFSetEOF(), VfatCommonRead(), vfatFCBInitializeCacheFromVolume(), VfatMount(), and VfatWrite().

◆ CcpAcquireFileLock()

BOOLEAN NTAPI CcpAcquireFileLock ( PNOCC_CACHE_MAP  Map)

Definition at line 129 of file fssup.c.

130 {
131  DPRINT("Calling AcquireForLazyWrite: %x\n", Map->LazyContext);
132  return Map->Callbacks.AcquireForLazyWrite(Map->LazyContext, TRUE);
133 }
#define TRUE
Definition: types.h:120
PVOID LazyContext
Definition: newcc.h:35
void DPRINT(...)
Definition: polytest.cpp:61
PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite
Definition: cctypes.h:39
CACHE_MANAGER_CALLBACKS Callbacks
Definition: newcc.h:34

◆ CcpCountCacheSections()

ULONG NTAPI CcpCountCacheSections ( IN PNOCC_CACHE_MAP  Map)

Definition at line 270 of file fssup.c.

271 {
273  ULONG Count;
274 
275  for (Count = 0, Entry = Map->AssociatedBcb.Flink;
276  Entry != &Map->AssociatedBcb;
277  Entry = Entry->Flink, Count++);
278 
279  return Count;
280 }
struct _Entry Entry
Definition: kefuncs.h:640
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
Definition: typedefs.h:117
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82

Referenced by MmCanFileBeTruncated(), and MmFlushImageSection().

◆ CcpFindOtherStreamFileObject()

PFILE_OBJECT CcpFindOtherStreamFileObject ( PFILE_OBJECT  FileObject)

Definition at line 158 of file fssup.c.

159 {
160  PLIST_ENTRY Entry, Private;
163  Entry = Entry->Flink)
164  {
165  /* 'Identical' test for other stream file object */
167  for (Private = Map->PrivateCacheMaps.Flink;
168  Private != &Map->PrivateCacheMaps;
169  Private = Private->Flink)
170  {
171  PNOCC_PRIVATE_CACHE_MAP PrivateMap = CONTAINING_RECORD(Private,
173  ListEntry);
174 
175  if (PrivateMap->FileObject->Flags & FO_STREAM_FILE &&
176  PrivateMap->FileObject->DeviceObject == FileObject->DeviceObject &&
177  PrivateMap->FileObject->Vpb == FileObject->Vpb &&
178  PrivateMap->FileObject->FsContext == FileObject->FsContext &&
179  PrivateMap->FileObject->FsContext2 == FileObject->FsContext2 &&
180  1)
181  {
182  return PrivateMap->FileObject;
183  }
184  }
185  }
186  return 0;
187 }
struct _Entry Entry
Definition: kefuncs.h:640
PFILE_OBJECT FileObject
Definition: fssup.c:72
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY PrivateCacheMaps
Definition: newcc.h:30
Definition: typedefs.h:117
LIST_ENTRY CcpAllSharedCacheMaps
Definition: fssup.c:76
base of all file and directory entries
Definition: entries.h:82
#define FO_STREAM_FILE
Definition: iotypes.h:1739

Referenced by CcInitializeCacheMap().

◆ CcPfInitializePrefetcher()

VOID NTAPI CcPfInitializePrefetcher ( VOID  )

Definition at line 112 of file fssup.c.

113 {
114  /* Notify debugger */
117  "CCPF: InitializePrefetecher()\n");
118 
119  /* Setup the Prefetcher Data */
123 
124  /* FIXME: Setup the rest of the prefetecher */
125 }
FAST_MUTEX CompletedTracesLock
Definition: cc.h:164
NTSYSAPI ULONG __cdecl DbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ _Printf_format_string_ PCSTR Format,...)
LIST_ENTRY CompletedTraces
Definition: cc.h:163
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
PFSN_PREFETCHER_GLOBALS CcPfGlobals
Definition: fssup.c:20
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ActiveTraces
Definition: cc.h:160
#define DPFLTR_TRACE_LEVEL
Definition: kdtypes.h:32

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 137 of file fssup.c.

138 {
139  DPRINT("Releasing Lazy Write %x\n", Map->LazyContext);
141 }
PVOID LazyContext
Definition: newcc.h:35
void DPRINT(...)
Definition: polytest.cpp:61
CACHE_MANAGER_CALLBACKS Callbacks
Definition: newcc.h:34
PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite
Definition: cctypes.h:40

◆ CcpUnmapThread()

VOID NTAPI CcpUnmapThread ( PVOID  Unused)

◆ CcPurgeCacheSection()

BOOLEAN NTAPI CcPurgeCacheSection ( IN PSECTION_OBJECT_POINTERS  SectionObjectPointer,
IN OPTIONAL PLARGE_INTEGER FileOffset  ,
IN ULONG  Length,
IN BOOLEAN  UninitializeCacheMaps 
)

◆ CcSetDirtyPageThreshold()

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

Definition at line 397 of file fssup.c.

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

◆ CcSetFileSizes()

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

Definition at line 354 of file fssup.c.

356 {
357  PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
358  PNOCC_BCB Bcb;
359 
360  if (!Map) return;
361  Map->FileSizes = *FileSizes;
362  Bcb = Map->AssociatedBcb.Flink == &Map->AssociatedBcb ?
363  NULL : CONTAINING_RECORD(Map->AssociatedBcb.Flink, NOCC_BCB, ThisFileList);
364  if (!Bcb) return;
365  MmExtendCacheSection(Bcb->SectionObject, &FileSizes->FileSize, FALSE);
366  DPRINT("FileSizes->FileSize %x\n", FileSizes->FileSize.LowPart);
367  DPRINT("FileSizes->AllocationSize %x\n", FileSizes->AllocationSize.LowPart);
368  DPRINT("FileSizes->ValidDataLength %x\n", FileSizes->ValidDataLength.LowPart);
369 }
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
static CC_FILE_SIZES FileSizes
Definition: newcc.h:3
LARGE_INTEGER FileSize
Definition: cctypes.h:16
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LIST_ENTRY AssociatedBcb
Definition: newcc.h:29
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
if(!(yy_init))
Definition: macro.lex.yy.c:714
ULONG LowPart
Definition: typedefs.h:104
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
NTSTATUS NTAPI MmExtendCacheSection(PROS_SECTION_OBJECT Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile)
Definition: data.c:758
CC_FILE_SIZES FileSizes
Definition: newcc.h:33
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP

Referenced by _Requires_lock_held_(), CdCreateInternalStream(), delete_fileref(), Ext2Cleanup(), Ext2SetFileInformation(), Ext2SupersedeOrOverWriteFile(), Ext2WriteFile(), FatSetupAllocationSupport(), FFSSetInformation(), FFSWriteFile(), PerformTest(), RfsdCleanup(), RfsdSetInformation(), RfsdWriteFile(), RxCollapseOrCreateSrvOpen(), RxCommonWrite(), set_end_of_file_information(), set_valid_data_length_information(), SetAttributeDataLength(), TestIrpHandler(), UDFCommonCleanup(), UDFCommonCreate(), UDFCommonWrite(), UDFSetAllocationInformation(), UDFSetEOF(), UpdateFileSize(), and write_file2().

◆ CcUninitializeCacheMap()

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

Definition at line 284 of file fssup.c.

287 {
288  BOOLEAN LastMap = FALSE;
289  PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap;
290  PNOCC_PRIVATE_CACHE_MAP PrivateCacheMap = FileObject->PrivateCacheMap;
291 
292  DPRINT("Uninitializing file object for %wZ SectionObjectPointer %x\n",
293  &FileObject->FileName,
294  FileObject->SectionObjectPointer);
295 
296  ASSERT(UninitializeEvent == NULL);
297 
298  /* It may not be strictly necessary to flush here, but we do just for
299  kicks. */
300  if (Map)
301  CcpFlushCache(Map, NULL, 0, NULL, FALSE);
302 
303  CcpLock();
304  /* We have a private cache map, so we've been initialized and haven't been
305  * uninitialized. */
306  if (PrivateCacheMap)
307  {
308  ASSERT(!Map || Map == PrivateCacheMap->Map);
309  ASSERT(PrivateCacheMap->FileObject == FileObject);
310 
311  RemoveEntryList(&PrivateCacheMap->ListEntry);
312  /* That was the last private cache map. It's time to delete all
313  cache stripes and all aspects of caching on the file. */
314  if (IsListEmpty(&PrivateCacheMap->Map->PrivateCacheMaps))
315  {
316  /* Get rid of all the cache stripes. */
317  while (!IsListEmpty(&PrivateCacheMap->Map->AssociatedBcb))
318  {
319  PNOCC_BCB Bcb = CONTAINING_RECORD(PrivateCacheMap->Map->AssociatedBcb.Flink,
320  NOCC_BCB,
321  ThisFileList);
322 
323  DPRINT("Evicting cache stripe #%x\n", Bcb - CcCacheSections);
324  Bcb->RefCount = 1;
326  }
327  RemoveEntryList(&PrivateCacheMap->Map->Entry);
328  ExFreePool(PrivateCacheMap->Map);
329  FileObject->SectionObjectPointer->SharedCacheMap = NULL;
330  LastMap = TRUE;
331  }
332  ObDereferenceObject(PrivateCacheMap->FileObject);
333  FileObject->PrivateCacheMap = NULL;
334  ExFreePool(PrivateCacheMap);
335  }
336  CcpUnlock();
337 
338  DPRINT("Uninit complete\n");
339 
340  /* The return from CcUninitializeCacheMap means that 'caching was stopped'. */
341  return LastMap;
342 }
#define TRUE
Definition: types.h:120
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
#define CcpLock()
Definition: newcc.h:143
#define CcpFlushCache(M, F, L, I, D)
Definition: newcc.h:96
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
Definition: newcc.h:3
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID CcpDereferenceCache(ULONG Sector, BOOLEAN Immediate)
Definition: pinsup.c:213
#define CcpUnlock()
Definition: newcc.h:144
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP

Referenced by _Dispatch_type_(), _Requires_lock_held_(), CdDeleteInternalStream(), CleanupTest(), close_file(), delete_fileref(), Ext2Cleanup(), Ext2SyncUninitializeCacheMap(), FatSetRenameInfo(), FatSyncUninitializeCacheMap(), FatTearDownVcb(), FFSCleanup(), FFSSyncUninitializeCacheMap(), NtfsCleanupFile(), NtfsReleaseFCB(), RfsdCleanup(), RfsdSyncUninitializeCacheMap(), 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 412 of file fssup.c.

416 {
417  PNOCC_BCB Bcb = NULL;
418  PLIST_ENTRY ListEntry = NULL;
419  LARGE_INTEGER LowerBound = *StartOffset;
420  LARGE_INTEGER UpperBound = *EndOffset;
421  LARGE_INTEGER Target, End;
422  PVOID PinnedBcb, PinnedBuffer;
423  PNOCC_CACHE_MAP Map = FileObject->SectionObjectPointer->SharedCacheMap;
424 
425  DPRINT("S %I64x E %I64x\n",
426  StartOffset->QuadPart,
427  EndOffset->QuadPart);
428 
429  if (!Map)
430  {
432  IO_STATUS_BLOCK IOSB;
434  ULONG ToWrite;
435 
437  DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, PAGE_SIZE);
438  RtlZeroMemory(ZeroBuf, PAGE_SIZE);
439 
440  Target.QuadPart = PAGE_ROUND_DOWN(LowerBound.QuadPart);
441  End.QuadPart = PAGE_ROUND_UP(UpperBound.QuadPart);
442 
443  // Handle leading page
444  if (LowerBound.QuadPart != Target.QuadPart)
445  {
446  ToWrite = MIN(UpperBound.QuadPart - LowerBound.QuadPart,
447  (PAGE_SIZE - LowerBound.QuadPart) & (PAGE_SIZE - 1));
448 
449  DPRINT("Zero last half %I64x %lx\n",
450  Target.QuadPart,
451  ToWrite);
452 
454  &Target,
455  ZeroBuf,
456  PAGE_SIZE,
457  TRUE,
458  &IOSB);
459 
460  if (!NT_SUCCESS(Status))
461  {
462  ExFreePool(ZeroBuf);
464  }
465 
466  DPRINT1("RtlZeroMemory(%p, %lx)\n",
467  ZeroBuf + LowerBound.QuadPart - Target.QuadPart,
468  ToWrite);
469 
470  RtlZeroMemory(ZeroBuf + LowerBound.QuadPart - Target.QuadPart,
471  ToWrite);
472 
474  &Target,
475  ZeroBuf,
476  MIN(PAGE_SIZE,
477  UpperBound.QuadPart-Target.QuadPart),
478  &IOSB);
479 
480  if (!NT_SUCCESS(Status))
481  {
482  ExFreePool(ZeroBuf);
484  }
485  Target.QuadPart += PAGE_SIZE;
486  }
487 
488  DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, PAGE_SIZE);
489  RtlZeroMemory(ZeroBuf, PAGE_SIZE);
490 
491  while (UpperBound.QuadPart - Target.QuadPart > PAGE_SIZE)
492  {
493  DPRINT("Zero full page %I64x\n",
494  Target.QuadPart);
495 
497  &Target,
498  ZeroBuf,
499  PAGE_SIZE,
500  &IOSB);
501 
502  if (!NT_SUCCESS(Status))
503  {
504  ExFreePool(ZeroBuf);
506  }
507  Target.QuadPart += PAGE_SIZE;
508  }
509 
510  if (UpperBound.QuadPart > Target.QuadPart)
511  {
512  ToWrite = UpperBound.QuadPart - Target.QuadPart;
513  DPRINT("Zero first half %I64x %lx\n",
514  Target.QuadPart,
515  ToWrite);
516 
518  &Target,
519  ZeroBuf,
520  PAGE_SIZE,
521  TRUE,
522  &IOSB);
523 
524  if (!NT_SUCCESS(Status))
525  {
526  ExFreePool(ZeroBuf);
528  }
529  DPRINT1("RtlZeroMemory(%x,%x)\n", ZeroBuf, ToWrite);
530  RtlZeroMemory(ZeroBuf, ToWrite);
532  &Target,
533  ZeroBuf,
534  MIN(PAGE_SIZE,
535  UpperBound.QuadPart-Target.QuadPart),
536  &IOSB);
537  if (!NT_SUCCESS(Status))
538  {
539  ExFreePool(ZeroBuf);
541  }
542  Target.QuadPart += PAGE_SIZE;
543  }
544 
545  ExFreePool(ZeroBuf);
546  return TRUE;
547  }
548 
549  CcpLock();
550  ListEntry = Map->AssociatedBcb.Flink;
551 
552  while (ListEntry != &Map->AssociatedBcb)
553  {
554  Bcb = CONTAINING_RECORD(ListEntry, NOCC_BCB, ThisFileList);
556 
557  if (Bcb->FileOffset.QuadPart + Bcb->Length >= LowerBound.QuadPart &&
558  Bcb->FileOffset.QuadPart < UpperBound.QuadPart)
559  {
560  DPRINT("Bcb #%x (@%I64x)\n",
562  Bcb->FileOffset.QuadPart);
563 
564  Target.QuadPart = MAX(Bcb->FileOffset.QuadPart,
565  LowerBound.QuadPart);
566 
568  UpperBound.QuadPart);
569 
570  End.QuadPart = MIN(End.QuadPart,
571  Bcb->FileOffset.QuadPart + Bcb->Length);
572 
573  CcpUnlock();
574 
576  &Target,
577  End.QuadPart - Target.QuadPart,
578  TRUE,
579  Wait,
580  &PinnedBcb,
581  &PinnedBuffer))
582  {
583  return FALSE;
584  }
585 
586  ASSERT(PinnedBcb == Bcb);
587 
588  CcpLock();
589  ListEntry = ListEntry->Flink;
590  /* Return from pin state */
591  CcpUnpinData(PinnedBcb, TRUE);
592  }
593 
595  }
596 
597  CcpUnlock();
598 
599  return TRUE;
600 }
BOOLEAN NTAPI CcpUnpinData(PNOCC_BCB Bcb, BOOLEAN ActuallyRelease)
signed char * PCHAR
Definition: retypes.h:7
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
#define CcpLock()
Definition: newcc.h:143
LONG NTSTATUS
Definition: precomp.h:26
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
VOID CcpReferenceCache(ULONG Sector)
Definition: pinsup.c:368
Definition: newcc.h:3
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
T MIN(T a, T b)
Definition: polytest.cpp:79
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LIST_ENTRY AssociatedBcb
Definition: newcc.h:29
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MiSimpleWrite(F, O, B, L, R)
Definition: newmm.h:198
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
T MAX(T a, T b)
Definition: polytest.cpp:85
CC_FILE_SIZES FileSizes
Definition: newcc.h:33
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define CcpUnlock()
Definition: newcc.h:144
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 ExFreePool(addr)
Definition: env_spec_w32.h:352
LONGLONG QuadPart
Definition: typedefs.h:112
IN BOOLEAN Wait
Definition: fatprocs.h:1529
NTSTATUS NTAPI MiSimpleRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
Definition: io.c:114

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

Variable Documentation

◆ CcFinalizeEvent

KEVENT CcFinalizeEvent

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

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

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.