ReactOS  0.4.13-dev-73-gcfe54aa
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

NTSTATUS CcRosInternalFreeVacb (PROS_VACB Vacb)
 
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 13 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 27 of file fs.c.

32 {
34 
35  CCTRACE(CC_API_DEBUG, "LogHandle=%p DirtyPageRoutine=%p Context1=%p Context2=%p\n",
36  LogHandle, DirtyPageRoutine, Context1, Context2);
37 
39  i.QuadPart = 0;
40  return i;
41 }
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 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
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
#define UNIMPLEMENTED
Definition: debug.h:114
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5363

◆ CcGetFileObjectFromBcb()

PFILE_OBJECT NTAPI CcGetFileObjectFromBcb ( IN PVOID  Bcb)

Definition at line 48 of file fs.c.

50 {
52 
53  CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb);
54 
55  return iBcb->Vacb->SharedCacheMap->FileObject;
56 }
struct _INTERNAL_BCB * PINTERNAL_BCB
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
PFILE_OBJECT FileObject
Definition: cc.h:178
PROS_VACB Vacb
Definition: cc.h:234

◆ CcGetFileSizes()

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

Definition at line 407 of file fs.c.

410 {
411  PROS_SHARED_CACHE_MAP SharedCacheMap;
412 
413  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
414 
415  if (!SharedCacheMap)
416  return FALSE;
417 
418  FileSizes->AllocationSize = SharedCacheMap->SectionSize;
419  FileSizes->FileSize = FileSizes->ValidDataLength = SharedCacheMap->FileSize;
420  return TRUE;
421 }
#define TRUE
Definition: types.h:120
LARGE_INTEGER SectionSize
Definition: cc.h:177
static CC_FILE_SIZES FileSizes
LARGE_INTEGER FileSize
Definition: cctypes.h:16
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
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 63 of file fs.c.

66 {
68 
69  CCTRACE(CC_API_DEBUG, "FileObject=%p\n", FileObject);
70 
72  i.QuadPart = 0;
73  return i;
74 }
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
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 81 of file fs.c.

87 {
89 
92 
93  CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p PinAccess=%d CallBacks=%p LazyWriterContext=%p\n",
94  FileObject, FileSizes, PinAccess, CallBacks, LazyWriterContext);
95 
96  /* Call old ROS cache init function */
98  FileSizes,
99  PinAccess,
100  CallBacks,
101  LazyWriterContext);
102  if (!NT_SUCCESS(Status))
104 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI CcRosInitializeFileCache(PFILE_OBJECT FileObject, PCC_FILE_SIZES FileSizes, BOOLEAN PinAccess, PCACHE_MANAGER_CALLBACKS CallBacks, PVOID LazyWriterContext)
Definition: view.c:1399
#define ExRaiseStatus
Definition: ntoskrnl.h:95
static CC_FILE_SIZES FileSizes
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24

◆ CcIsThereDirtyData()

BOOLEAN NTAPI CcIsThereDirtyData ( IN PVPB  Vpb)

Definition at line 111 of file fs.c.

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

◆ CcPurgeCacheSection()

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

Definition at line 160 of file fs.c.

165 {
166  PROS_SHARED_CACHE_MAP SharedCacheMap;
167  LONGLONG StartOffset;
168  LONGLONG EndOffset;
170  KIRQL OldIrql;
171  PLIST_ENTRY ListEntry;
172  PROS_VACB Vacb;
173  LONGLONG ViewEnd;
175 
176  CCTRACE(CC_API_DEBUG, "SectionObjectPointer=%p\n FileOffset=%p Length=%lu UninitializeCacheMaps=%d",
177  SectionObjectPointer, FileOffset, Length, UninitializeCacheMaps);
178 
179  if (UninitializeCacheMaps)
180  {
181  DPRINT1("FIXME: CcPurgeCacheSection not uninitializing private cache maps\n");
182  }
183 
184  SharedCacheMap = SectionObjectPointer->SharedCacheMap;
185  if (!SharedCacheMap)
186  return FALSE;
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  return Success;
264 }
#define TRUE
Definition: types.h:120
Definition: cc.h:201
LARGE_INTEGER SectionSize
Definition: cc.h:177
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
#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
LIST_ENTRY CacheMapVacbListEntry
Definition: cc.h:215
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define CcRosVacbGetRefCount(vacb)
Definition: cc.h:543
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:190
int64_t LONGLONG
Definition: typedefs.h:66
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define CC_API_DEBUG
Definition: cc.h:11
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:531
BOOLEAN Dirty
Definition: cc.h:210
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
MmuFreePage * FreeList
Definition: mmuobject.c:60
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define min(a, b)
Definition: monoChain.cc:55
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER FileOffset
Definition: cc.h:221
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI CcRosUnmarkDirtyVacb(PROS_VACB Vacb, BOOLEAN LockViews)
Definition: view.c:538
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
LIST_ENTRY VacbLruListEntry
Definition: cc.h:219
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CcSetFileSizes(), and CcUninitializeCacheMap().

◆ CcRosInternalFreeVacb()

NTSTATUS CcRosInternalFreeVacb ( PROS_VACB  Vacb)

Definition at line 1044 of file view.c.

1049 {
1050  DPRINT("Freeing VACB 0x%p\n", Vacb);
1051 #if DBG
1052  if (Vacb->SharedCacheMap->Trace)
1053  {
1054  DPRINT1("CacheMap 0x%p: deleting VACB: 0x%p\n", Vacb->SharedCacheMap, Vacb);
1055  }
1056 #endif
1057 
1060  Vacb->MemoryArea,
1062  NULL);
1064 
1065  if (Vacb->ReferenceCount != 0)
1066  {
1067  DPRINT1("Invalid free: %ld\n", Vacb->ReferenceCount);
1068  if (Vacb->SharedCacheMap->FileObject && Vacb->SharedCacheMap->FileObject->FileName.Length)
1069  {
1070  DPRINT1("For file: %wZ\n", &Vacb->SharedCacheMap->FileObject->FileName);
1071  }
1072  }
1073 
1074  ASSERT(Vacb->ReferenceCount == 0);
1078  RtlFillMemory(Vacb, sizeof(*Vacb), 0xfd);
1079  ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb);
1080  return STATUS_SUCCESS;
1081 }
static VOID CcFreeCachePage(PVOID Context, MEMORY_AREA *MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
Definition: view.c:1027
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1423
static NPAGED_LOOKASIDE_LIST VacbLookasideList
Definition: view.c:50
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LIST_ENTRY CacheMapVacbListEntry
Definition: cc.h:215
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
NTSTATUS NTAPI MmFreeMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
Definition: marea.c:278
volatile ULONG ReferenceCount
Definition: cc.h:223
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _MEMORY_AREA * MemoryArea
Definition: cc.h:206
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1445
#define DPRINT1
Definition: precomp.h:8
LIST_ENTRY DirtyVacbListEntry
Definition: cc.h:217
PFILE_OBJECT FileObject
Definition: cc.h:178
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1416
LIST_ENTRY VacbLruListEntry
Definition: cc.h:219

◆ CcSetFileSizes()

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

Definition at line 271 of file fs.c.

274 {
275  KIRQL oldirql;
276  PROS_SHARED_CACHE_MAP SharedCacheMap;
277 
278  CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p\n",
280 
281  DPRINT("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n",
283  DPRINT("AllocationSize %I64d, FileSize %I64d, ValidDataLength %I64d\n",
287 
288  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
289 
290  /*
291  * It is valid to call this function on file objects that weren't
292  * initialized for caching. In this case it's simple no-op.
293  */
294  if (SharedCacheMap == NULL)
295  return;
296 
297  if (FileSizes->AllocationSize.QuadPart < SharedCacheMap->SectionSize.QuadPart)
298  {
299  CcPurgeCacheSection(FileObject->SectionObjectPointer,
301  0,
302  FALSE);
303  }
304  else
305  {
306  PROS_VACB LastVacb;
307 
308  /*
309  * If file (allocation) size has increased, then we need to check whether
310  * it just grows in a single VACB (the last one).
311  * If so, we must mark the VACB as invalid to trigger a read to the
312  * FSD at the next VACB usage, and thus avoid returning garbage
313  */
314 
315  /* Check for allocation size and the last VACB */
316  if (SharedCacheMap->SectionSize.QuadPart < FileSizes->AllocationSize.QuadPart &&
318  {
319  LastVacb = CcRosLookupVacb(SharedCacheMap,
320  SharedCacheMap->SectionSize.QuadPart);
321  if (LastVacb != NULL)
322  {
323  /* Mark it as invalid */
324  CcRosReleaseVacb(SharedCacheMap, LastVacb, LastVacb->Dirty ? LastVacb->Valid : FALSE, FALSE, FALSE);
325  }
326  }
327 
328  /* Check for file size and the last VACB */
329  if (SharedCacheMap->FileSize.QuadPart < FileSizes->FileSize.QuadPart &&
330  SharedCacheMap->FileSize.QuadPart % VACB_MAPPING_GRANULARITY)
331  {
332  LastVacb = CcRosLookupVacb(SharedCacheMap,
333  SharedCacheMap->FileSize.QuadPart);
334  if (LastVacb != NULL)
335  {
336  /* Mark it as invalid */
337  CcRosReleaseVacb(SharedCacheMap, LastVacb, LastVacb->Dirty ? LastVacb->Valid : FALSE, FALSE, FALSE);
338  }
339  }
340  }
341 
342  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldirql);
343  SharedCacheMap->SectionSize = FileSizes->AllocationSize;
344  SharedCacheMap->FileSize = FileSizes->FileSize;
345  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldirql);
346 }
Definition: cc.h:201
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
NTSTATUS NTAPI CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:421
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
BOOLEAN Dirty
Definition: cc.h:210
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:160
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
BOOLEAN Valid
Definition: cc.h:208
PROS_VACB NTAPI CcRosLookupVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
Definition: view.c:458
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define VACB_MAPPING_GRANULARITY
LARGE_INTEGER FileSize
Definition: cc.h:175
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
LONGLONG QuadPart
Definition: typedefs.h:112

◆ CcSetLogHandleForFile()

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

Definition at line 353 of file fs.c.

357 {
358  CCTRACE(CC_API_DEBUG, "FileObject=%p LogHandle=%p FlushToLsnRoutine=%p\n",
359  FileObject, LogHandle, FlushToLsnRoutine);
360 
362 }
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
#define UNIMPLEMENTED
Definition: debug.h:114
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5363

◆ CcUninitializeCacheMap()

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

Definition at line 369 of file fs.c.

373 {
375  PROS_SHARED_CACHE_MAP SharedCacheMap;
376  KIRQL OldIrql;
377 
378  CCTRACE(CC_API_DEBUG, "FileObject=%p TruncateSize=%p UninitializeCompleteEvent=%p\n",
379  FileObject, TruncateSize, UninitializeCompleteEvent);
380 
381  if (TruncateSize != NULL &&
382  FileObject->SectionObjectPointer->SharedCacheMap != NULL)
383  {
384  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
385  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
386  if (SharedCacheMap->FileSize.QuadPart > TruncateSize->QuadPart)
387  {
388  SharedCacheMap->FileSize = *TruncateSize;
389  }
390  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
391  CcPurgeCacheSection(FileObject->SectionObjectPointer,
392  TruncateSize,
393  0,
394  FALSE);
395  }
396 
398  if (UninitializeCompleteEvent)
399  {
400  KeSetEvent(&UninitializeCompleteEvent->Event, IO_NO_INCREMENT, FALSE);
401  }
402  return NT_SUCCESS(Status);
403 }
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
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#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
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER FileOffset OPTIONAL, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fs.c:160
Status
Definition: gdiplustypes.h:24
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
NTSTATUS NTAPI CcRosReleaseFileCache(PFILE_OBJECT FileObject)
Definition: view.c:1334
LARGE_INTEGER FileSize
Definition: cc.h:175
#define IO_NO_INCREMENT
Definition: iotypes.h:565
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
LONGLONG QuadPart
Definition: typedefs.h:112