ReactOS  0.4.15-dev-1386-g5cb9f87
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);
630 }
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1681
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
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 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 
618  }
619  CcpUnlock();
620  return Result;
621 }
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1681
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
#define CcpLock()
Definition: newcc.h:140
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
_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:121
* PFILE_OBJECT
Definition: iotypes.h:1978
#define NULL
Definition: types.h:112
#define CcpUnlock()
Definition: newcc.h:141

◆ 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 }
#define TRUE
Definition: types.h:120
static CC_FILE_SIZES FileSizes
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
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 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 }
KEVENT CcpLazyWriteEvent
Definition: lazyrite.c:18
PULONG Buffer
Definition: typedefs.h:91
FAST_MUTEX CcMutex
Definition: pinsup.c:101
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
#define TRUE
Definition: types.h:120
#define CACHE_NUM_SECTIONS
Definition: newcc.h:127
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
#define FALSE
Definition: types.h:117
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:90
LIST_ENTRY CcpAllSharedCacheMaps
Definition: fssup.c:76
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
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
#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 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",
215  FileObject,
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",
224  FileObject,
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 }
PFILE_OBJECT CcpFindOtherStreamFileObject(PFILE_OBJECT FileObject)
Definition: fssup.c:160
#define CcpLock()
Definition: newcc.h:140
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
LIST_ENTRY Entry
Definition: newcc.h:28
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
* PFILE_OBJECT
Definition: iotypes.h:1978
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 RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define CcpUnlock()
Definition: newcc.h:141
ULONG ReadAheadGranularity
Definition: newcc.h:38
#define FO_STREAM_FILE
Definition: iotypes.h:1763
LONGLONG QuadPart
Definition: typedefs.h:114

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

132 {
133  DPRINT("Calling AcquireForLazyWrite: %x\n", Map->LazyContext);
134  return Map->Callbacks.AcquireForLazyWrite(Map->LazyContext, TRUE);
135 }
PVOID LazyContext
Definition: newcc.h:35
#define TRUE
Definition: types.h:120
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 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 }
struct _Entry Entry
Definition: kefuncs.h:627
int Count
Definition: noreturn.cpp:7
Definition: typedefs.h:119
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 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 }
struct _Entry Entry
Definition: kefuncs.h:627
PFILE_OBJECT FileObject
Definition: fssup.c:72
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY PrivateCacheMaps
Definition: newcc.h:30
Definition: typedefs.h:119
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:1763

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

140 {
141  DPRINT("Releasing Lazy Write %x\n", Map->LazyContext);
143 }
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 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;
360  PNOCC_BCB Bcb;
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 }
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
static CC_FILE_SIZES FileSizes
Definition: newcc.h:3
LARGE_INTEGER FileSize
Definition: cctypes.h:16
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
if(!(yy_init))
Definition: macro.lex.yy.c:714
ULONG LowPart
Definition: typedefs.h:106
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
#define NULL
Definition: types.h:112
struct _NOCC_CACHE_MAP * PNOCC_CACHE_MAP

Referenced by _Requires_lock_held_(), CdCreateInternalStream(), delete_fileref_fcb(), 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 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 }
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
#define CcpLock()
Definition: newcc.h:140
#define TRUE
Definition: types.h:120
#define CcpFlushCache(M, F, L, I, D)
Definition: newcc.h:93
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
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define ASSERT(a)
Definition: mode.c:45
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID CcpDereferenceCache(ULONG Sector, BOOLEAN Immediate)
Definition: pinsup.c:213
#define NULL
Definition: types.h:112
#define CcpUnlock()
Definition: newcc.h:141
#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 414 of file fssup.c.

418 {
419  PNOCC_BCB Bcb = NULL;
420  PLIST_ENTRY ListEntry = NULL;
421  LARGE_INTEGER LowerBound = *StartOffset;
422  LARGE_INTEGER UpperBound = *EndOffset;
423  LARGE_INTEGER Target, End;
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,
478  MIN(PAGE_SIZE,
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,
536  MIN(PAGE_SIZE,
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 }
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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
#define CcpLock()
Definition: newcc.h:140
#define TRUE
Definition: types.h:120
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
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
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
T MIN(T a, T b)
Definition: polytest.cpp:79
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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:119
T MAX(T a, T b)
Definition: polytest.cpp:85
CC_FILE_SIZES FileSizes
Definition: newcc.h:33
#define NULL
Definition: types.h:112
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CcpUnlock()
Definition: newcc.h:141
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:114
NTSTATUS NTAPI MiSimpleRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
Definition: io.c:109

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.