ReactOS  0.4.15-dev-2091-gc14c9ca
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 384 of file fs.c.

387 {
388  PROS_SHARED_CACHE_MAP SharedCacheMap;
389 
390  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
391 
392  if (!SharedCacheMap)
393  return FALSE;
394 
395  FileSizes->AllocationSize = SharedCacheMap->SectionSize;
396  FileSizes->FileSize = FileSizes->ValidDataLength = SharedCacheMap->FileSize;
397  return TRUE;
398 }
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:104
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:45
#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:1185

◆ 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:627
#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:1788
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  LONGLONG StartOffset;
165  LONGLONG EndOffset;
167  KIRQL OldIrql;
168  PLIST_ENTRY ListEntry;
169  PROS_VACB Vacb;
170  LONGLONG ViewEnd;
172 
173  CCTRACE(CC_API_DEBUG, "SectionObjectPointer=%p\n FileOffset=%p Length=%lu UninitializeCacheMaps=%d",
174  SectionObjectPointer, FileOffset, Length, UninitializeCacheMaps);
175 
176  if (UninitializeCacheMaps)
177  {
178  DPRINT1("FIXME: CcPurgeCacheSection not uninitializing private cache maps\n");
179  }
180 
181  SharedCacheMap = SectionObjectPointer->SharedCacheMap;
182  if (!SharedCacheMap)
183  {
184  Success = TRUE;
185  goto purgeMm;
186  }
187 
188  StartOffset = FileOffset != NULL ? FileOffset->QuadPart : 0;
189  if (Length == 0 || FileOffset == NULL)
190  {
191  EndOffset = MAXLONGLONG;
192  }
193  else
194  {
195  EndOffset = StartOffset + Length;
196  ASSERT(EndOffset > StartOffset);
197  }
198 
200 
201  /* Assume success */
202  Success = TRUE;
203 
205  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
206  ListEntry = SharedCacheMap->CacheMapVacbListHead.Flink;
207  while (ListEntry != &SharedCacheMap->CacheMapVacbListHead)
208  {
209  ULONG Refs;
210 
211  Vacb = CONTAINING_RECORD(ListEntry, ROS_VACB, CacheMapVacbListEntry);
212  ListEntry = ListEntry->Flink;
213 
214  /* Skip VACBs outside the range, or only partially in range */
215  if (Vacb->FileOffset.QuadPart < StartOffset)
216  {
217  continue;
218  }
220  SharedCacheMap->SectionSize.QuadPart);
221  if (ViewEnd >= EndOffset)
222  {
223  break;
224  }
225 
226  /* Still in use, it cannot be purged, fail
227  * Allow one ref: VACB is supposed to be always 1-referenced
228  */
229  Refs = CcRosVacbGetRefCount(Vacb);
230  if ((Refs > 1 && !Vacb->Dirty) ||
231  (Refs > 2 && Vacb->Dirty))
232  {
233  Success = FALSE;
234  break;
235  }
236 
237  /* This VACB is in range, so unlink it and mark for free */
238  ASSERT(Refs == 1 || Vacb->Dirty);
241  if (Vacb->Dirty)
242  {
244  }
247  }
250 
251  while (!IsListEmpty(&FreeList))
252  {
253  ULONG Refs;
254 
256  ROS_VACB,
257  CacheMapVacbListEntry);
259  Refs = CcRosVacbDecRefCount(Vacb);
260  ASSERT(Refs == 0);
261  }
262 
263  /* Now make sure that Mm doesn't hold some pages here. */
264 purgeMm:
265  if (Success)
267 
268  return Success;
269 }
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
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
BOOLEAN NTAPI MmPurgeSegment(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER Offset, _In_ ULONG Length)
Definition: section.c:4624
#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:504
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:45
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
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:492
BOOLEAN Dirty
Definition: cc.h:211
MmuFreePage * FreeList
Definition: mmuobject.c:60
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: typedefs.h:119
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
_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
#define DPRINT1
Definition: precomp.h:8
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 276 of file fs.c.

279 {
280  KIRQL OldIrql;
281  PROS_SHARED_CACHE_MAP SharedCacheMap;
282  LARGE_INTEGER OldSectionSize;
283 
284  CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p\n",
286 
287  DPRINT("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n",
289  DPRINT("AllocationSize %I64d, FileSize %I64d, ValidDataLength %I64d\n",
293 
294  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
295 
296  /*
297  * It is valid to call this function on file objects that weren't
298  * initialized for caching. In this case it's simple no-op.
299  */
300  if (SharedCacheMap == NULL)
301  return;
302 
303  /* Update the relevant fields */
304  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
305  OldSectionSize = SharedCacheMap->SectionSize;
306  SharedCacheMap->SectionSize = FileSizes->AllocationSize;
307  SharedCacheMap->FileSize = FileSizes->FileSize;
308  SharedCacheMap->ValidDataLength = FileSizes->ValidDataLength;
309  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
310 
311  if (FileSizes->AllocationSize.QuadPart < OldSectionSize.QuadPart)
312  {
313  CcPurgeCacheSection(FileObject->SectionObjectPointer,
315  0,
316  FALSE);
317  }
318  else
319  {
320  /* Extend our section object */
321  MmExtendSection(SharedCacheMap->Section, &SharedCacheMap->SectionSize);
322  }
323 }
NTSTATUS NTAPI MmExtendSection(_In_ PVOID Section, _Inout_ PLARGE_INTEGER NewSize)
Definition: section.c:5034
LARGE_INTEGER SectionSize
Definition: cc.h:177
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 KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
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 330 of file fs.c.

334 {
335  CCTRACE(CC_API_DEBUG, "FileObject=%p LogHandle=%p FlushToLsnRoutine=%p\n",
336  FileObject, LogHandle, FlushToLsnRoutine);
337 
339 }
_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 346 of file fs.c.

350 {
352  PROS_SHARED_CACHE_MAP SharedCacheMap;
353  KIRQL OldIrql;
354 
355  CCTRACE(CC_API_DEBUG, "FileObject=%p TruncateSize=%p UninitializeCompleteEvent=%p\n",
356  FileObject, TruncateSize, UninitializeCompleteEvent);
357 
358  if (TruncateSize != NULL &&
359  FileObject->SectionObjectPointer->SharedCacheMap != NULL)
360  {
361  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
362  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
363  if (SharedCacheMap->FileSize.QuadPart > TruncateSize->QuadPart)
364  {
365  SharedCacheMap->FileSize = *TruncateSize;
366  }
367  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
368  CcPurgeCacheSection(FileObject->SectionObjectPointer,
369  TruncateSize,
370  0,
371  FALSE);
372  }
373 
375  if (UninitializeCompleteEvent)
376  {
377  KeSetEvent(&UninitializeCompleteEvent->Event, IO_NO_INCREMENT, FALSE);
378  }
379  return NT_SUCCESS(Status);
380 }
LONG NTSTATUS
Definition: precomp.h:26
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 KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
NTSTATUS CcRosReleaseFileCache(PFILE_OBJECT FileObject)
Definition: view.c:1129
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
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