ReactOS  0.4.15-dev-4610-g11e0ed3
fs.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for fs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

LARGE_INTEGER NTAPI CcGetDirtyPages (IN PVOID LogHandle, IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, IN PVOID Context1, IN PVOID Context2)
 
PFILE_OBJECT NTAPI CcGetFileObjectFromBcb (IN PVOID Bcb)
 
LARGE_INTEGER NTAPI CcGetLsnForFileObject (IN PFILE_OBJECT FileObject, OUT PLARGE_INTEGER OldestLsn OPTIONAL)
 
VOID NTAPI CcInitializeCacheMap (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS CallBacks, IN PVOID LazyWriterContext)
 
BOOLEAN NTAPI CcIsThereDirtyData (IN PVPB Vpb)
 
BOOLEAN NTAPI CcPurgeCacheSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER FileOffset OPTIONAL, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
 
VOID NTAPI CcSetFileSizes (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
 
VOID NTAPI CcSetLogHandleForFile (IN PFILE_OBJECT FileObject, IN PVOID LogHandle, IN PFLUSH_TO_LSN FlushToLsnRoutine)
 
BOOLEAN NTAPI CcUninitializeCacheMap (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER TruncateSize OPTIONAL, IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL)
 
BOOLEAN NTAPI CcGetFileSizes (IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file fs.c.

Function Documentation

◆ CcGetDirtyPages()

LARGE_INTEGER NTAPI CcGetDirtyPages ( IN PVOID  LogHandle,
IN PDIRTY_PAGE_ROUTINE  DirtyPageRoutine,
IN PVOID  Context1,
IN PVOID  Context2 
)

Definition at line 24 of file fs.c.

29 {
31 
32  CCTRACE(CC_API_DEBUG, "LogHandle=%p DirtyPageRoutine=%p Context1=%p Context2=%p\n",
33  LogHandle, DirtyPageRoutine, Context1, Context2);
34 
36  i.QuadPart = 0;
37  return i;
38 }
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
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
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
#define UNIMPLEMENTED
Definition: debug.h:115
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5381

◆ CcGetFileObjectFromBcb()

PFILE_OBJECT NTAPI CcGetFileObjectFromBcb ( IN PVOID  Bcb)

Definition at line 45 of file fs.c.

47 {
49 
50  CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb);
51 
52  return iBcb->Vacb->SharedCacheMap->FileObject;
53 }
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
Definition: cdstruc.h:902
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
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:226
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
PFILE_OBJECT FileObject
Definition: cc.h:179
PROS_VACB Vacb
Definition: cc.h:235

◆ CcGetFileSizes()

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

Definition at line 403 of file fs.c.

406 {
407  PROS_SHARED_CACHE_MAP SharedCacheMap;
408 
409  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
410 
411  if (!SharedCacheMap)
412  return FALSE;
413 
414  FileSizes->AllocationSize = SharedCacheMap->SectionSize;
415  FileSizes->FileSize = FileSizes->ValidDataLength = SharedCacheMap->FileSize;
416  return TRUE;
417 }
LARGE_INTEGER SectionSize
Definition: cc.h:177
#define TRUE
Definition: types.h:120
static CC_FILE_SIZES FileSizes
LARGE_INTEGER FileSize
Definition: cctypes.h:16
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
LARGE_INTEGER FileSize
Definition: cc.h:175

◆ CcGetLsnForFileObject()

LARGE_INTEGER NTAPI CcGetLsnForFileObject ( IN PFILE_OBJECT  FileObject,
OUT PLARGE_INTEGER OldestLsn  OPTIONAL 
)

Definition at line 60 of file fs.c.

63 {
65 
66  CCTRACE(CC_API_DEBUG, "FileObject=%p\n", FileObject);
67 
69  i.QuadPart = 0;
70  return i;
71 }
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
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 UNIMPLEMENTED
Definition: debug.h:115

◆ CcInitializeCacheMap()

VOID NTAPI CcInitializeCacheMap ( IN PFILE_OBJECT  FileObject,
IN PCC_FILE_SIZES  FileSizes,
IN BOOLEAN  PinAccess,
IN PCACHE_MANAGER_CALLBACKS  CallBacks,
IN PVOID  LazyWriterContext 
)

Definition at line 78 of file fs.c.

84 {
86 
89 
90  CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p PinAccess=%d CallBacks=%p LazyWriterContext=%p\n",
91  FileObject, FileSizes, PinAccess, CallBacks, LazyWriterContext);
92 
93  /* Call old ROS cache init function */
95  FileSizes,
96  PinAccess,
97  CallBacks,
98  LazyWriterContext);
99  if (!NT_SUCCESS(Status))
101 }
LONG NTSTATUS
Definition: precomp.h:26
#define ExRaiseStatus
Definition: ntoskrnl.h:108
static CC_FILE_SIZES FileSizes
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define CC_API_DEBUG
Definition: cc.h:11
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
NTSTATUS CcRosInitializeFileCache(PFILE_OBJECT FileObject, PCC_FILE_SIZES FileSizes, BOOLEAN PinAccess, PCACHE_MANAGER_CALLBACKS CallBacks, PVOID LazyWriterContext)
Definition: view.c:1166

◆ CcIsThereDirtyData()

BOOLEAN NTAPI CcIsThereDirtyData ( IN PVPB  Vpb)

Definition at line 108 of file fs.c.

110 {
111  PROS_VACB Vacb;
113  KIRQL oldIrql;
114  /* Assume no dirty data */
115  BOOLEAN Dirty = FALSE;
116 
117  CCTRACE(CC_API_DEBUG, "Vpb=%p\n", Vpb);
118 
120 
121  /* Browse dirty VACBs */
123  {
124  Vacb = CONTAINING_RECORD(Entry, ROS_VACB, DirtyVacbListEntry);
125  /* Look for these associated with our volume */
126  if (Vacb->SharedCacheMap->FileObject->Vpb != Vpb)
127  {
128  continue;
129  }
130 
131  /* From now on, we are associated with our VPB */
132 
133  /* Temporary files are not counted as dirty */
135  {
136  continue;
137  }
138 
139  /* A single dirty VACB is enough to have dirty data */
140  if (Vacb->Dirty)
141  {
142  Dirty = TRUE;
143  break;
144  }
145  }
146 
148 
149  return Dirty;
150 }
Definition: cc.h:206
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
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
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:226
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CC_API_DEBUG
Definition: cc.h:11
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
BOOLEAN Dirty
Definition: cc.h:211
Definition: typedefs.h:119
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
#define FO_TEMPORARY_FILE
Definition: iotypes.h:1791
PFILE_OBJECT FileObject
Definition: cc.h:179
LIST_ENTRY DirtyVacbListHead
Definition: view.c:41
base of all file and directory entries
Definition: entries.h:82
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1673

◆ CcPurgeCacheSection()

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

Definition at line 157 of file fs.c.

162 {
163  PROS_SHARED_CACHE_MAP SharedCacheMap;
164  PPRIVATE_CACHE_MAP PrivateCacheMap;
165  LONGLONG StartOffset;
166  LONGLONG EndOffset;
167  LIST_ENTRY FreeList;
168  KIRQL OldIrql;
169  PLIST_ENTRY ListEntry;
170  PROS_VACB Vacb;
171  LONGLONG ViewEnd;
173 
174  CCTRACE(CC_API_DEBUG, "SectionObjectPointer=%p\n FileOffset=%p Length=%lu UninitializeCacheMaps=%d",
175  SectionObjectPointer, FileOffset, Length, UninitializeCacheMaps);
176 
177  /* Obtain the shared cache from the section */
178  SharedCacheMap = SectionObjectPointer->SharedCacheMap;
179  if (!SharedCacheMap)
180  {
181  Success = TRUE;
182  goto purgeMm;
183  }
184 
185  if (UninitializeCacheMaps)
186  {
187  /*
188  * We have gotten the acknowledgement that
189  * the caller wants to unintialize the private
190  * cache maps so let's do this. Since we already
191  * have the shared cache map from above, iterate
192  * over that cache's private lists.
193  */
194  while (!IsListEmpty(&SharedCacheMap->PrivateList))
195  {
196  /*
197  * This list is not empty, grab the
198  * private cache map.
199  */
200  PrivateCacheMap = CONTAINING_RECORD(SharedCacheMap->PrivateList.Flink, PRIVATE_CACHE_MAP, PrivateLinks);
201 
202  /* Unintialize the private cache now */
203  CcUninitializeCacheMap(PrivateCacheMap->FileObject, NULL, NULL);
204  }
205  }
206 
207  StartOffset = FileOffset != NULL ? FileOffset->QuadPart : 0;
208  if (Length == 0 || FileOffset == NULL)
209  {
210  EndOffset = MAXLONGLONG;
211  }
212  else
213  {
214  EndOffset = StartOffset + Length;
215  ASSERT(EndOffset > StartOffset);
216  }
217 
218  InitializeListHead(&FreeList);
219 
220  /* Assume success */
221  Success = TRUE;
222 
224  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
225  ListEntry = SharedCacheMap->CacheMapVacbListHead.Flink;
226  while (ListEntry != &SharedCacheMap->CacheMapVacbListHead)
227  {
228  ULONG Refs;
229 
230  Vacb = CONTAINING_RECORD(ListEntry, ROS_VACB, CacheMapVacbListEntry);
231  ListEntry = ListEntry->Flink;
232 
233  /* Skip VACBs outside the range, or only partially in range */
234  if (Vacb->FileOffset.QuadPart < StartOffset)
235  {
236  continue;
237  }
239  SharedCacheMap->SectionSize.QuadPart);
240  if (ViewEnd >= EndOffset)
241  {
242  break;
243  }
244 
245  /* Still in use, it cannot be purged, fail
246  * Allow one ref: VACB is supposed to be always 1-referenced
247  */
248  Refs = CcRosVacbGetRefCount(Vacb);
249  if ((Refs > 1 && !Vacb->Dirty) ||
250  (Refs > 2 && Vacb->Dirty))
251  {
252  Success = FALSE;
253  break;
254  }
255 
256  /* This VACB is in range, so unlink it and mark for free */
257  ASSERT(Refs == 1 || Vacb->Dirty);
260  if (Vacb->Dirty)
261  {
263  }
265  InsertHeadList(&FreeList, &Vacb->CacheMapVacbListEntry);
266  }
269 
270  while (!IsListEmpty(&FreeList))
271  {
272  ULONG Refs;
273 
274  Vacb = CONTAINING_RECORD(RemoveHeadList(&FreeList),
275  ROS_VACB,
276  CacheMapVacbListEntry);
278  Refs = CcRosVacbDecRefCount(Vacb);
279  ASSERT(Refs == 0);
280  }
281 
282  /* Now make sure that Mm doesn't hold some pages here. */
283 purgeMm:
284  if (Success)
286 
287  return Success;
288 }
LIST_ENTRY PrivateList
Definition: cc.h:187
Definition: cc.h:206
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LARGE_INTEGER SectionSize
Definition: cc.h:177
#define TRUE
Definition: types.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER TruncateSize OPTIONAL, IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL)
Definition: fs.c:365
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
BOOLEAN NTAPI MmPurgeSegment(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER Offset, _In_ ULONG Length)
Definition: section.c:4718
#define MAXLONGLONG
_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
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
LIST_ENTRY CacheMapVacbListEntry
Definition: cc.h:216
VOID CcRosUnmarkDirtyVacb(PROS_VACB Vacb, BOOLEAN LockViews)
Definition: view.c:564
unsigned char BOOLEAN
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define CcRosVacbGetRefCount(vacb)
Definition: cc.h:510
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
LIST_ENTRY CacheMapVacbListHead
Definition: cc.h:193
int64_t LONGLONG
Definition: typedefs.h:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CC_API_DEBUG
Definition: cc.h:11
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:498
BOOLEAN Dirty
Definition: cc.h:211
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
Definition: typedefs.h:119
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
PFILE_OBJECT FileObject
Definition: cctypes.h:76
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
LARGE_INTEGER FileOffset
Definition: cc.h:222
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
KSPIN_LOCK CacheMapLock
Definition: cc.h:195
LIST_ENTRY VacbLruListEntry
Definition: cc.h:220
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by CcSetFileSizes(), and CcUninitializeCacheMap().

◆ CcSetFileSizes()

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

Definition at line 295 of file fs.c.

298 {
299  KIRQL OldIrql;
300  PROS_SHARED_CACHE_MAP SharedCacheMap;
301  LARGE_INTEGER OldSectionSize;
302 
303  CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p\n",
305 
306  DPRINT("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n",
308  DPRINT("AllocationSize %I64d, FileSize %I64d, ValidDataLength %I64d\n",
312 
313  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
314 
315  /*
316  * It is valid to call this function on file objects that weren't
317  * initialized for caching. In this case it's simple no-op.
318  */
319  if (SharedCacheMap == NULL)
320  return;
321 
322  /* Update the relevant fields */
323  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
324  OldSectionSize = SharedCacheMap->SectionSize;
325  SharedCacheMap->SectionSize = FileSizes->AllocationSize;
326  SharedCacheMap->FileSize = FileSizes->FileSize;
327  SharedCacheMap->ValidDataLength = FileSizes->ValidDataLength;
328  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
329 
330  if (FileSizes->AllocationSize.QuadPart < OldSectionSize.QuadPart)
331  {
332  CcPurgeCacheSection(FileObject->SectionObjectPointer,
334  0,
335  FALSE);
336  }
337  else
338  {
339  /* Extend our section object */
340  MmExtendSection(SharedCacheMap->Section, &SharedCacheMap->SectionSize);
341  }
342 }
NTSTATUS NTAPI MmExtendSection(_In_ PVOID Section, _Inout_ PLARGE_INTEGER NewSize)
Definition: section.c:5124
LARGE_INTEGER SectionSize
Definition: cc.h:177
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
static CC_FILE_SIZES FileSizes
LARGE_INTEGER FileSize
Definition: cctypes.h:16
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER FileOffset OPTIONAL, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fs.c:157
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
LARGE_INTEGER FileSize
Definition: cc.h:175
LARGE_INTEGER ValidDataLength
Definition: cc.h:178
KSPIN_LOCK CacheMapLock
Definition: cc.h:195
#define DPRINT
Definition: sndvol32.h:71
LONGLONG QuadPart
Definition: typedefs.h:114

◆ CcSetLogHandleForFile()

VOID NTAPI CcSetLogHandleForFile ( IN PFILE_OBJECT  FileObject,
IN PVOID  LogHandle,
IN PFLUSH_TO_LSN  FlushToLsnRoutine 
)

Definition at line 349 of file fs.c.

353 {
354  CCTRACE(CC_API_DEBUG, "FileObject=%p LogHandle=%p FlushToLsnRoutine=%p\n",
355  FileObject, LogHandle, FlushToLsnRoutine);
356 
358 }
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
#define UNIMPLEMENTED
Definition: debug.h:115
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5381

◆ CcUninitializeCacheMap()

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

Definition at line 365 of file fs.c.

369 {
371  PROS_SHARED_CACHE_MAP SharedCacheMap;
372  KIRQL OldIrql;
373 
374  CCTRACE(CC_API_DEBUG, "FileObject=%p TruncateSize=%p UninitializeCompleteEvent=%p\n",
375  FileObject, TruncateSize, UninitializeCompleteEvent);
376 
377  if (TruncateSize != NULL &&
378  FileObject->SectionObjectPointer->SharedCacheMap != NULL)
379  {
380  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
381  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
382  if (SharedCacheMap->FileSize.QuadPart > TruncateSize->QuadPart)
383  {
384  SharedCacheMap->FileSize = *TruncateSize;
385  }
386  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
387  CcPurgeCacheSection(FileObject->SectionObjectPointer,
388  TruncateSize,
389  0,
390  FALSE);
391  }
392 
394  if (UninitializeCompleteEvent)
395  {
396  KeSetEvent(&UninitializeCompleteEvent->Event, IO_NO_INCREMENT, FALSE);
397  }
398  return NT_SUCCESS(Status);
399 }
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define CC_API_DEBUG
Definition: cc.h:11
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
NTSTATUS CcRosReleaseFileCache(PFILE_OBJECT FileObject)
Definition: view.c:1110
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER FileOffset OPTIONAL, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fs.c:157
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
LARGE_INTEGER FileSize
Definition: cc.h:175
#define IO_NO_INCREMENT
Definition: iotypes.h:598
KSPIN_LOCK CacheMapLock
Definition: cc.h:195
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by CcPurgeCacheSection().