ReactOS  0.4.15-dev-3451-gf606fec
pin.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: ntoskrnl/cc/pin.c
5  * PURPOSE: Implements cache managers pinning interface
6  *
7  * PROGRAMMERS: ?
8  Pierre Schweitzer (pierre@reactos.org)
9  */
10 
11 /* INCLUDES ******************************************************************/
12 
13 #include <ntoskrnl.h>
14 #define NDEBUG
15 #include <debug.h>
16 
17 /* GLOBALS *******************************************************************/
18 
20 
21 /* Counters:
22  * - Number of calls to CcMapData that could wait
23  * - Number of calls to CcMapData that couldn't wait
24  * - Number of calls to CcPinRead that could wait
25  * - Number of calls to CcPinRead that couldn't wait
26  * - Number of calls to CcPinMappedDataCount
27  */
33 
34 /* FUNCTIONS *****************************************************************/
35 
36 static
38 NTAPI
40  IN PROS_SHARED_CACHE_MAP SharedCacheMap,
42  IN ULONG Length,
43  IN BOOLEAN Pinned)
44 {
47  PLIST_ENTRY NextEntry;
48 
49  for (NextEntry = SharedCacheMap->BcbList.Flink;
50  NextEntry != &SharedCacheMap->BcbList;
51  NextEntry = NextEntry->Flink)
52  {
53  Bcb = CONTAINING_RECORD(NextEntry, INTERNAL_BCB, BcbEntry);
54 
55  if (Bcb->PFCB.MappedFileOffset.QuadPart <= FileOffset->QuadPart &&
56  (Bcb->PFCB.MappedFileOffset.QuadPart + Bcb->PFCB.MappedLength) >=
57  (FileOffset->QuadPart + Length))
58  {
59  if ((Pinned && Bcb->PinCount > 0) || (!Pinned && Bcb->PinCount == 0))
60  {
61  Found = TRUE;
62  break;
63  }
64  }
65  }
66 
67  return (Found ? Bcb : NULL);
68 }
69 
70 static
71 VOID
73  IN PROS_SHARED_CACHE_MAP SharedCacheMap,
75 {
76  ULONG RefCount;
77  KIRQL OldIrql;
78 
79  KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
80  RefCount = --Bcb->RefCount;
81  if (RefCount == 0)
82  {
83  RemoveEntryList(&Bcb->BcbEntry);
84  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
85 
86  ASSERT(Bcb->PinCount == 0);
87  /*
88  * Don't mark dirty, if it was dirty,
89  * the VACB was already marked as such
90  * following the call to CcSetDirtyPinnedData
91  */
92  CcRosReleaseVacb(SharedCacheMap,
93  Bcb->Vacb,
94  FALSE,
95  FALSE);
96 
97  ExDeleteResourceLite(&Bcb->Lock);
98  ExFreeToNPagedLookasideList(&iBcbLookasideList, Bcb);
99  }
100  else
101  {
102  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
103  }
104 }
105 
106 static
107 PVOID
109  IN PROS_SHARED_CACHE_MAP SharedCacheMap,
110  IN PROS_VACB Vacb,
112  IN ULONG Length,
113  IN ULONG PinFlags,
114  IN BOOLEAN ToPin)
115 {
116  KIRQL OldIrql;
117  BOOLEAN Result;
118  PINTERNAL_BCB iBcb, DupBcb;
119 
120  iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
121  if (iBcb == NULL)
122  {
123  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE);
124  return NULL;
125  }
126 
127  RtlZeroMemory(iBcb, sizeof(*iBcb));
128  iBcb->PFCB.NodeTypeCode = 0x2FD; /* As per KMTests */
129  iBcb->PFCB.NodeByteSize = 0;
130  iBcb->PFCB.MappedLength = Length;
131  iBcb->PFCB.MappedFileOffset = *FileOffset;
132  iBcb->Vacb = Vacb;
133  iBcb->PinCount = 0;
134  iBcb->RefCount = 1;
136 
137  KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
138 
139  /* Check if we raced with another BCB creation */
140  DupBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, ToPin);
141  /* Yes, and we've lost */
142  if (DupBcb != NULL)
143  {
144  /* We will return that BCB */
145  ++DupBcb->RefCount;
146  Result = TRUE;
147  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
148 
149  if (ToPin)
150  {
151  if (BooleanFlagOn(PinFlags, PIN_EXCLUSIVE))
152  {
154  }
155  else
156  {
158  }
159 
160  if (Result)
161  {
162  DupBcb->PinCount++;
163  }
164  else
165  {
166  CcpDereferenceBcb(SharedCacheMap, DupBcb);
167  DupBcb = NULL;
168  }
169  }
170 
171  if (DupBcb != NULL)
172  {
173  /* Delete the loser */
174  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE);
175  ExDeleteResourceLite(&iBcb->Lock);
176  ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
177  }
178 
179  /* Return the winner - no need to update buffer address, it's
180  * relative to the VACB, which is unchanged.
181  */
182  iBcb = DupBcb;
183  }
184  /* Nope, insert ourselves */
185  else
186  {
187  if (ToPin)
188  {
189  iBcb->PinCount++;
190 
191  if (BooleanFlagOn(PinFlags, PIN_EXCLUSIVE))
192  {
194  }
195  else
196  {
198  }
199 
200  ASSERT(Result);
201  }
202 
203  InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry);
204  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
205  }
206 
207  return iBcb;
208 }
209 
210 static
211 BOOLEAN
213  IN PROS_SHARED_CACHE_MAP SharedCacheMap,
215  IN ULONG Length,
216  IN ULONG Flags,
217  OUT PVOID * Bcb,
218  OUT PVOID * Buffer)
219 {
220  PINTERNAL_BCB NewBcb;
221  KIRQL OldIrql;
222  ULONG VacbOffset;
224  BOOLEAN Result;
225 
226  VacbOffset = (ULONG)(FileOffset->QuadPart % VACB_MAPPING_GRANULARITY);
227 
228  if ((VacbOffset + Length) > VACB_MAPPING_GRANULARITY)
229  {
230  /* Complain loudly, we shoud pin the whole range */
231  DPRINT1("TRUNCATING DATA PIN FROM %lu to %lu!\n", Length, VACB_MAPPING_GRANULARITY - VacbOffset);
232  Length = VACB_MAPPING_GRANULARITY - VacbOffset;
233  }
234 
235  KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
236  NewBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE);
237 
238  if (NewBcb != NULL)
239  {
240  BOOLEAN Result;
241 
242  ++NewBcb->RefCount;
243  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
244 
247  else
249 
250  if (!Result)
251  {
252  CcpDereferenceBcb(SharedCacheMap, NewBcb);
253  return FALSE;
254  }
255 
256  NewBcb->PinCount++;
257  }
258  else
259  {
260  LONGLONG ROffset;
261  PROS_VACB Vacb;
262 
263  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
264 
266  {
267  return FALSE;
268  }
269 
270  /* Properly round offset and call internal helper for getting a VACB */
271  ROffset = ROUND_DOWN(FileOffset->QuadPart, VACB_MAPPING_GRANULARITY);
272  Status = CcRosGetVacb(SharedCacheMap, ROffset, &Vacb);
273  if (!NT_SUCCESS(Status))
274  {
275  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n",
276  SharedCacheMap->FileObject, FileOffset, Length, Flags);
278  return FALSE;
279  }
280 
281  NewBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, Flags, TRUE);
282  if (NewBcb == NULL)
283  {
284  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE);
285  return FALSE;
286  }
287  }
288 
289  Result = FALSE;
290  _SEH2_TRY
291  {
292  /* Ensure the pages are resident */
296  VacbOffset, Length);
297  }
299  {
300  if (!Result)
301  {
302  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n",
303  SharedCacheMap->FileObject, FileOffset, Length, Flags);
304  CcUnpinData(&NewBcb->PFCB);
305  return FALSE;
306  }
307  }
308  _SEH2_END;
309 
310  *Bcb = &NewBcb->PFCB;
311  *Buffer = (PVOID)((ULONG_PTR)NewBcb->Vacb->BaseAddress + VacbOffset);
312 
313  return TRUE;
314 }
315 
316 /*
317  * @implemented
318  */
319 BOOLEAN
320 NTAPI
324  IN ULONG Length,
325  IN ULONG Flags,
326  OUT PVOID *pBcb,
327  OUT PVOID *pBuffer)
328 {
329  KIRQL OldIrql;
330  PINTERNAL_BCB iBcb;
331  PROS_VACB Vacb;
332  PROS_SHARED_CACHE_MAP SharedCacheMap;
333  ULONG VacbOffset;
335  BOOLEAN Result;
336 
337  CCTRACE(CC_API_DEBUG, "CcMapData(FileObject 0x%p, FileOffset 0x%I64x, Length %lu, Flags 0x%lx,"
338  " pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
339  Length, Flags, pBcb, pBuffer);
340 
342  ASSERT(FileObject->SectionObjectPointer);
343  ASSERT(FileObject->SectionObjectPointer->SharedCacheMap);
344 
345  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
346  ASSERT(SharedCacheMap);
347 
348  if (Flags & MAP_WAIT)
349  {
350  ++CcMapDataWait;
351  }
352  else
353  {
354  ++CcMapDataNoWait;
355  }
356 
357  VacbOffset = (ULONG)(FileOffset->QuadPart % VACB_MAPPING_GRANULARITY);
358  /* KMTests seem to show that it is allowed to call accross mapping granularity */
359  if ((VacbOffset + Length) > VACB_MAPPING_GRANULARITY)
360  {
361  DPRINT1("TRUNCATING DATA MAP FROM %lu to %lu!\n", Length, VACB_MAPPING_GRANULARITY - VacbOffset);
362  Length = VACB_MAPPING_GRANULARITY - VacbOffset;
363  }
364 
365  KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
366  iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, FALSE);
367 
368  if (iBcb == NULL)
369  {
370  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
371 
372  /* Call internal helper for getting a VACB */
373  Status = CcRosGetVacb(SharedCacheMap, FileOffset->QuadPart, &Vacb);
374  if (!NT_SUCCESS(Status))
375  {
376  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n",
377  SharedCacheMap->FileObject, FileOffset, Length, Flags);
379  }
380 
381  iBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, 0, FALSE);
382  if (iBcb == NULL)
383  {
384  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE);
385  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n",
386  SharedCacheMap->FileObject, FileOffset, Length, Flags);
387  *pBcb = NULL; // If you ever remove this for compat, make sure to review all callers for using an unititialized value
389  }
390  }
391  else
392  {
393  ++iBcb->RefCount;
394  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
395  }
396 
397  _SEH2_TRY
398  {
399  Result = FALSE;
400  /* Ensure the pages are resident */
402  BooleanFlagOn(Flags, MAP_NO_READ), VacbOffset, Length);
403  }
405  {
406  if (!Result)
407  {
408  CcpDereferenceBcb(SharedCacheMap, iBcb);
409  return FALSE;
410  }
411  }
412  _SEH2_END;
413 
414  *pBcb = &iBcb->PFCB;
415  *pBuffer = (PVOID)((ULONG_PTR)iBcb->Vacb->BaseAddress + VacbOffset);
416 
417  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> TRUE Bcb=%p, Buffer %p\n",
419  return Result;
420 }
421 
422 /*
423  * @unimplemented
424  */
425 BOOLEAN
426 NTAPI
430  IN ULONG Length,
431  IN ULONG Flags,
432  OUT PVOID * Bcb)
433 {
434  BOOLEAN Result;
435  PVOID Buffer;
436  PINTERNAL_BCB iBcb;
437  PROS_SHARED_CACHE_MAP SharedCacheMap;
438 
439  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx\n",
441 
443  ASSERT(FileObject->SectionObjectPointer);
444  ASSERT(FileObject->SectionObjectPointer->SharedCacheMap);
445 
446  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
447  ASSERT(SharedCacheMap);
448  if (!SharedCacheMap->PinAccess)
449  {
450  DPRINT1("FIXME: Pinning a file with no pin access!\n");
451  return FALSE;
452  }
453 
454  iBcb = *Bcb ? CONTAINING_RECORD(*Bcb, INTERNAL_BCB, PFCB) : NULL;
455 
457 
458  Result = CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, &Buffer);
459  if (Result)
460  {
461  CcUnpinData(&iBcb->PFCB);
462  }
463 
464  return Result;
465 }
466 
467 /*
468  * @unimplemented
469  */
470 BOOLEAN
471 NTAPI
475  IN ULONG Length,
476  IN ULONG Flags,
477  OUT PVOID * Bcb,
478  OUT PVOID * Buffer)
479 {
480  PROS_SHARED_CACHE_MAP SharedCacheMap;
481 
482  CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n",
484 
486  ASSERT(FileObject->SectionObjectPointer);
487  ASSERT(FileObject->SectionObjectPointer->SharedCacheMap);
488 
489  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
490  ASSERT(SharedCacheMap);
491  if (!SharedCacheMap->PinAccess)
492  {
493  DPRINT1("FIXME: Pinning a file with no pin access!\n");
494  return FALSE;
495  }
496 
497  if (Flags & PIN_WAIT)
498  {
499  ++CcPinReadWait;
500  }
501  else
502  {
503  ++CcPinReadNoWait;
504  }
505 
506  return CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, Buffer);
507 }
508 
509 /*
510  * @unimplemented
511  */
512 BOOLEAN
513 NTAPI
517  IN ULONG Length,
518  IN BOOLEAN Zero,
519  IN ULONG Flags,
520  OUT PVOID * Bcb,
521  OUT PVOID * Buffer)
522 {
523  CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Zero=%d Flags=0x%lx\n",
525 
526  /*
527  * FIXME: This is function is similar to CcPinRead, but doesn't
528  * read the data if they're not present. Instead it should just
529  * prepare the VACBs and zero them out if Zero != FALSE.
530  *
531  * For now calling CcPinRead is better than returning error or
532  * just having UNIMPLEMENTED here.
533  */
535 }
536 
537 /*
538  * @implemented
539  */
540 VOID NTAPI
542  IN PVOID Bcb,
543  IN PLARGE_INTEGER Lsn)
544 {
546 
547  CCTRACE(CC_API_DEBUG, "Bcb=%p Lsn=%p\n", Bcb, Lsn);
548 
549  /* Tell Mm */
551  Add2Ptr(iBcb->Vacb->BaseAddress, iBcb->PFCB.MappedFileOffset.QuadPart - iBcb->Vacb->FileOffset.QuadPart),
552  iBcb->PFCB.MappedLength);
553 
554  if (!iBcb->Vacb->Dirty)
555  {
556  CcRosMarkDirtyVacb(iBcb->Vacb);
557  }
558 }
559 
560 
561 /*
562  * @implemented
563  */
564 VOID NTAPI
566  IN PVOID Bcb)
567 {
568  CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb);
569 
571 }
572 
573 /*
574  * @unimplemented
575  */
576 VOID
577 NTAPI
579  IN PVOID Bcb,
581 {
583 
584  CCTRACE(CC_API_DEBUG, "Bcb=%p ResourceThreadId=%lu\n", Bcb, ResourceThreadId);
585 
586  if (iBcb->PinCount != 0)
587  {
589  iBcb->PinCount--;
590  }
591 
592  CcpDereferenceBcb(iBcb->Vacb->SharedCacheMap, iBcb);
593 }
594 
595 /*
596  * @implemented
597  */
598 VOID
599 NTAPI
601  IN PVOID Bcb)
602 {
604 
605  CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb);
606 
607  iBcb->RefCount++;
608 }
609 
610 /*
611  * @unimplemented
612  */
613 VOID
614 NTAPI
616  IN PVOID Bcb,
617  IN BOOLEAN WriteThrough,
619 {
621  KIRQL OldIrql;
622  PROS_SHARED_CACHE_MAP SharedCacheMap;
623 
624  CCTRACE(CC_API_DEBUG, "Bcb=%p WriteThrough=%d\n", Bcb, WriteThrough);
625 
626  SharedCacheMap = iBcb->Vacb->SharedCacheMap;
627  IoStatus->Status = STATUS_SUCCESS;
628 
629  if (WriteThrough)
630  {
631  CcFlushCache(iBcb->Vacb->SharedCacheMap->FileObject->SectionObjectPointer,
632  &iBcb->PFCB.MappedFileOffset,
633  iBcb->PFCB.MappedLength,
634  IoStatus);
635  }
636  else
637  {
638  IoStatus->Status = STATUS_SUCCESS;
639  IoStatus->Information = 0;
640  }
641 
642  KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
643  if (--iBcb->RefCount == 0)
644  {
645  RemoveEntryList(&iBcb->BcbEntry);
646  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
647 
648  if (iBcb->PinCount != 0)
649  {
650  ExReleaseResourceLite(&iBcb->Lock);
651  iBcb->PinCount--;
652  ASSERT(iBcb->PinCount == 0);
653  }
654 
655  /*
656  * Don't mark dirty, if it was dirty,
657  * the VACB was already marked as such
658  * following the call to CcSetDirtyPinnedData
659  */
661  iBcb->Vacb,
662  FALSE,
663  FALSE);
664 
665  ExDeleteResourceLite(&iBcb->Lock);
666  ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
667  }
668  else
669  {
670  KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
671  }
672 }
BOOLEAN PinAccess
Definition: cc.h:194
LIST_ENTRY BcbEntry
Definition: cc.h:238
ULONG_PTR ERESOURCE_THREAD
Definition: extypes.h:208
#define IN
Definition: typedefs.h:39
static BOOLEAN CcpPinData(IN PROS_SHARED_CACHE_MAP SharedCacheMap, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pin.c:212
Definition: cc.h:206
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define Add2Ptr(PTR, INC)
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:411
VOID NTAPI CcUnpinDataForThread(IN PVOID Bcb, IN ERESOURCE_THREAD ResourceThreadId)
Definition: pin.c:578
PVOID BaseAddress
Definition: cc.h:209
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: pin.c:514
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
Definition: cdstruc.h:902
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
KSPIN_LOCK BcbSpinLock
Definition: cc.h:189
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
#define ExRaiseStatus
Definition: ntoskrnl.h:104
#define MAP_WAIT
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
#define PIN_WAIT
#define InsertTailList(ListHead, Entry)
NTSTATUS CcRosGetVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PROS_VACB *Vacb)
Definition: view.c:863
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *pBcb, OUT PVOID *pBuffer)
Definition: pin.c:321
PUBLIC_BCB PFCB
Definition: cc.h:234
ULONG PinCount
Definition: cc.h:236
unsigned char BOOLEAN
ULONG CcMapDataWait
Definition: pin.c:28
PVOID pBuffer
_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
Definition: bufpool.h:45
return Found
Definition: dirsup.c:1270
void * PVOID
Definition: retypes.h:9
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
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:226
VOID NTAPI CcRepinBcb(IN PVOID Bcb)
Definition: pin.c:600
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static PVOID CcpGetAppropriateBcb(IN PROS_SHARED_CACHE_MAP SharedCacheMap, IN PROS_VACB Vacb, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG PinFlags, IN BOOLEAN ToPin)
Definition: pin.c:108
#define CC_API_DEBUG
Definition: cc.h:11
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG CcPinReadNoWait
Definition: pin.c:31
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pin.c:565
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1998
_In_ ERESOURCE_THREAD ResourceThreadId
Definition: exfuncs.h:1052
VOID CcRosMarkDirtyVacb(PROS_VACB Vacb)
Definition: view.c:528
BOOLEAN Dirty
Definition: cc.h:211
ULONG CcMapDataNoWait
Definition: pin.c:29
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
VOID NTAPI CcUnpinRepinnedBcb(IN PVOID Bcb, IN BOOLEAN WriteThrough, IN PIO_STATUS_BLOCK IoStatus)
Definition: pin.c:615
Definition: typedefs.h:119
ULONG CcPinMappedDataCount
Definition: pin.c:32
static PINTERNAL_BCB NTAPI CcpFindBcb(IN PROS_SHARED_CACHE_MAP SharedCacheMap, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Pinned)
Definition: pin.c:39
BOOLEAN NTAPI CcPinMappedData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb)
Definition: pin.c:427
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:30
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1063
NPAGED_LOOKASIDE_LIST iBcbLookasideList
Definition: view.c:44
_SEH2_END
Definition: create.c:4400
NTSTATUS NTAPI MmMakePagesDirty(_In_ PEPROCESS Process, _In_ PVOID Address, _In_ ULONG Length)
Definition: section.c:5053
BOOLEAN CcRosEnsureVacbResident(_In_ PROS_VACB Vacb, _In_ BOOLEAN Wait, _In_ BOOLEAN NoRead, _In_ ULONG Offset, _In_ ULONG Length)
Definition: view.c:816
#define PIN_IF_BCB
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define MAP_NO_READ
ULONG CcPinReadWait
Definition: pin.c:30
_SEH2_FINALLY
Definition: create.c:4371
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
static VOID CcpDereferenceBcb(IN PROS_SHARED_CACHE_MAP SharedCacheMap, IN PINTERNAL_BCB Bcb)
Definition: pin.c:72
#define PIN_EXCLUSIVE
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:411
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER FileOffset
Definition: cc.h:222
#define VACB_MAPPING_GRANULARITY
#define OUT
Definition: typedefs.h:40
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155
unsigned int ULONG
Definition: retypes.h:1
ERESOURCE Lock
Definition: cc.h:233
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
CSHORT RefCount
Definition: cc.h:237
NTSTATUS CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:453
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define STATUS_SUCCESS
Definition: shellext.h:65
PFILE_OBJECT FileObject
Definition: cc.h:179
VOID NTAPI CcSetDirtyPinnedData(IN PVOID Bcb, IN PLARGE_INTEGER Lsn)
Definition: pin.c:541
#define PIN_NO_READ
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pin.c:472
LONGLONG QuadPart
Definition: typedefs.h:114
PROS_VACB Vacb
Definition: cc.h:235