ReactOS  0.4.11-dev-791-gf6f1255
copy.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/copy.c
5  * PURPOSE: Implements cache managers copy interface
6  *
7  * PROGRAMMERS: Some people?
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 #define MAX_ZERO_LENGTH (256 * 1024)
22 
23 typedef enum _CC_COPY_OPERATION
24 {
29 
30 typedef enum _CC_CAN_WRITE_RETRY
31 {
32  FirstTry = 0,
37 
45 
46 /* Counters:
47  * - Amount of pages flushed to the disk
48  * - Number of flush operations
49  */
52 
53 /* FUNCTIONS *****************************************************************/
54 
55 VOID
56 NTAPI
58  IN PFN_NUMBER PageFrameIndex
59 );
60 
61 VOID
62 NTAPI
64  VOID)
65 {
67 
69  //MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
71  if (!NT_SUCCESS(Status))
72  {
73  DbgPrint("Can't allocate CcZeroPage.\n");
74  KeBugCheck(CACHE_MANAGER);
75  }
77 }
78 
80 NTAPI
82  PROS_VACB Vacb)
83 {
84  ULONG Size;
85  PMDL Mdl;
88  KEVENT Event;
89  ULARGE_INTEGER LargeSize;
90 
92  if (LargeSize.QuadPart > VACB_MAPPING_GRANULARITY)
93  {
95  }
96  Size = LargeSize.LowPart;
97 
98  Size = ROUND_TO_PAGES(Size);
100  ASSERT(Size > 0);
101 
102  Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
103  if (!Mdl)
104  {
106  }
107 
108  Status = STATUS_SUCCESS;
109  _SEH2_TRY
110  {
112  }
114  {
115  Status = _SEH2_GetExceptionCode();
116  DPRINT1("MmProbeAndLockPages failed with: %lx for %p (%p, %p)\n", Status, Mdl, Vacb, Vacb->BaseAddress);
117  KeBugCheck(CACHE_MANAGER);
118  } _SEH2_END;
119 
120  if (NT_SUCCESS(Status))
121  {
122  Mdl->MdlFlags |= MDL_IO_PAGE_READ;
124  Status = IoPageRead(Vacb->SharedCacheMap->FileObject, Mdl, &Vacb->FileOffset, &Event, &IoStatus);
125  if (Status == STATUS_PENDING)
126  {
128  Status = IoStatus.Status;
129  }
130 
131  MmUnlockPages(Mdl);
132  }
133 
134  IoFreeMdl(Mdl);
135 
136  if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
137  {
138  DPRINT1("IoPageRead failed, Status %x\n", Status);
139  return Status;
140  }
141 
142  if (Size < VACB_MAPPING_GRANULARITY)
143  {
144  RtlZeroMemory((char*)Vacb->BaseAddress + Size,
145  VACB_MAPPING_GRANULARITY - Size);
146  }
147 
148  return STATUS_SUCCESS;
149 }
150 
151 NTSTATUS
152 NTAPI
154  PROS_VACB Vacb)
155 {
156  ULONG Size;
157  PMDL Mdl;
160  KEVENT Event;
161  ULARGE_INTEGER LargeSize;
162 
163  LargeSize.QuadPart = Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart;
164  if (LargeSize.QuadPart > VACB_MAPPING_GRANULARITY)
165  {
167  }
168  Size = LargeSize.LowPart;
169  //
170  // Nonpaged pool PDEs in ReactOS must actually be synchronized between the
171  // MmGlobalPageDirectory and the real system PDE directory. What a mess...
172  //
173  {
174  ULONG i = 0;
175  do
176  {
178  } while (++i < (Size >> PAGE_SHIFT));
179  }
180 
181  Size = ROUND_TO_PAGES(Size);
183  ASSERT(Size > 0);
184 
185  Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
186  if (!Mdl)
187  {
189  }
190 
191  Status = STATUS_SUCCESS;
192  _SEH2_TRY
193  {
195  }
197  {
198  Status = _SEH2_GetExceptionCode();
199  DPRINT1("MmProbeAndLockPages failed with: %lx for %p (%p, %p)\n", Status, Mdl, Vacb, Vacb->BaseAddress);
200  KeBugCheck(CACHE_MANAGER);
201  } _SEH2_END;
202 
203  if (NT_SUCCESS(Status))
204  {
206  Status = IoSynchronousPageWrite(Vacb->SharedCacheMap->FileObject, Mdl, &Vacb->FileOffset, &Event, &IoStatus);
207  if (Status == STATUS_PENDING)
208  {
210  Status = IoStatus.Status;
211  }
212 
213  MmUnlockPages(Mdl);
214  }
215  IoFreeMdl(Mdl);
216  if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
217  {
218  DPRINT1("IoPageWrite failed, Status %x\n", Status);
219  return Status;
220  }
221 
222  return STATUS_SUCCESS;
223 }
224 
225 NTSTATUS
229  _In_ ULONG Length,
231 {
233 
234  if (Operation == CcOperationZero)
235  {
236  /* Zero */
237  RtlZeroMemory(BaseAddress, Length);
238  }
239  else
240  {
241  _SEH2_TRY
242  {
243  if (Operation == CcOperationWrite)
244  RtlCopyMemory(BaseAddress, Buffer, Length);
245  else
246  RtlCopyMemory(Buffer, BaseAddress, Length);
247  }
249  {
250  Status = _SEH2_GetExceptionCode();
251  }
252  _SEH2_END;
253  }
254  return Status;
255 }
256 
257 BOOLEAN
264  _In_ BOOLEAN Wait,
266 {
268  LONGLONG CurrentOffset;
270  KIRQL OldIrql;
271  PROS_SHARED_CACHE_MAP SharedCacheMap;
272  PLIST_ENTRY ListEntry;
273  PROS_VACB Vacb;
274  ULONG PartialLength;
276  BOOLEAN Valid;
277  PPRIVATE_CACHE_MAP PrivateCacheMap;
278 
279  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
280  PrivateCacheMap = FileObject->PrivateCacheMap;
281  CurrentOffset = FileOffset;
282  BytesCopied = 0;
283 
284  if (!Wait)
285  {
286  /* test if the requested data is available */
287  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
288  /* FIXME: this loop doesn't take into account areas that don't have
289  * a VACB in the list yet */
290  ListEntry = SharedCacheMap->CacheMapVacbListHead.Flink;
291  while (ListEntry != &SharedCacheMap->CacheMapVacbListHead)
292  {
293  Vacb = CONTAINING_RECORD(ListEntry,
294  ROS_VACB,
295  CacheMapVacbListEntry);
296  ListEntry = ListEntry->Flink;
297  if (!Vacb->Valid &&
300  CurrentOffset, Length))
301  {
302  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
303  /* data not available */
304  return FALSE;
305  }
306  if (Vacb->FileOffset.QuadPart >= CurrentOffset + Length)
307  break;
308  }
309  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
310  }
311 
312  PartialLength = CurrentOffset % VACB_MAPPING_GRANULARITY;
313  if (PartialLength != 0)
314  {
315  PartialLength = min(Length, VACB_MAPPING_GRANULARITY - PartialLength);
316  Status = CcRosRequestVacb(SharedCacheMap,
317  ROUND_DOWN(CurrentOffset,
319  &BaseAddress,
320  &Valid,
321  &Vacb);
322  if (!NT_SUCCESS(Status))
323  ExRaiseStatus(Status);
324  if (!Valid)
325  {
326  Status = CcReadVirtualAddress(Vacb);
327  if (!NT_SUCCESS(Status))
328  {
329  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
330  ExRaiseStatus(Status);
331  }
332  }
333  Status = ReadWriteOrZero((PUCHAR)BaseAddress + CurrentOffset % VACB_MAPPING_GRANULARITY,
334  Buffer,
335  PartialLength,
336  Operation);
337 
338  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, Operation != CcOperationRead, FALSE);
339 
340  if (!NT_SUCCESS(Status))
342 
343  Length -= PartialLength;
344  CurrentOffset += PartialLength;
345  BytesCopied += PartialLength;
346 
347  if (Operation != CcOperationZero)
348  Buffer = (PVOID)((ULONG_PTR)Buffer + PartialLength);
349  }
350 
351  while (Length > 0)
352  {
353  ASSERT(CurrentOffset % VACB_MAPPING_GRANULARITY == 0);
354  PartialLength = min(VACB_MAPPING_GRANULARITY, Length);
355  Status = CcRosRequestVacb(SharedCacheMap,
356  CurrentOffset,
357  &BaseAddress,
358  &Valid,
359  &Vacb);
360  if (!NT_SUCCESS(Status))
361  ExRaiseStatus(Status);
362  if (!Valid &&
363  (Operation == CcOperationRead ||
364  PartialLength < VACB_MAPPING_GRANULARITY))
365  {
366  Status = CcReadVirtualAddress(Vacb);
367  if (!NT_SUCCESS(Status))
368  {
369  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
370  ExRaiseStatus(Status);
371  }
372  }
373  Status = ReadWriteOrZero(BaseAddress, Buffer, PartialLength, Operation);
374 
375  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, Operation != CcOperationRead, FALSE);
376 
377  if (!NT_SUCCESS(Status))
379 
380  Length -= PartialLength;
381  CurrentOffset += PartialLength;
382  BytesCopied += PartialLength;
383 
384  if (Operation != CcOperationZero)
385  Buffer = (PVOID)((ULONG_PTR)Buffer + PartialLength);
386  }
387 
388  /* If that was a successful sync read operation, let's handle read ahead */
389  if (Operation == CcOperationRead && Length == 0 && Wait)
390  {
391  /* If file isn't random access and next read may get us cross VACB boundary,
392  * schedule next read
393  */
394  if (!BooleanFlagOn(FileObject->Flags, FO_RANDOM_ACCESS) &&
395  (CurrentOffset - 1) / VACB_MAPPING_GRANULARITY != (CurrentOffset + BytesCopied - 1) / VACB_MAPPING_GRANULARITY)
396  {
397  CcScheduleReadAhead(FileObject, (PLARGE_INTEGER)&FileOffset, BytesCopied);
398  }
399 
400  /* And update read history in private cache map */
401  PrivateCacheMap->FileOffset1.QuadPart = PrivateCacheMap->FileOffset2.QuadPart;
402  PrivateCacheMap->BeyondLastByte1.QuadPart = PrivateCacheMap->BeyondLastByte2.QuadPart;
403  PrivateCacheMap->FileOffset2.QuadPart = FileOffset;
404  PrivateCacheMap->BeyondLastByte2.QuadPart = FileOffset + BytesCopied;
405  }
406 
407  IoStatus->Status = STATUS_SUCCESS;
408  IoStatus->Information = BytesCopied;
409  return TRUE;
410 }
411 
412 VOID
414 {
415  ULONG WrittenBytes;
416 
417  /* We'll try to write as much as we can */
418  WrittenBytes = 0;
419  while (TRUE)
420  {
421  KIRQL OldIrql;
422  PLIST_ENTRY ListEntry;
423  PDEFERRED_WRITE DeferredWrite;
424 
425  DeferredWrite = NULL;
426 
427  /* Lock our deferred writes list */
429  for (ListEntry = CcDeferredWrites.Flink;
430  ListEntry != &CcDeferredWrites;
431  ListEntry = ListEntry->Flink)
432  {
433  /* Extract an entry */
434  DeferredWrite = CONTAINING_RECORD(ListEntry, DEFERRED_WRITE, DeferredWriteLinks);
435 
436  /* Compute the modified bytes, based on what we already wrote */
437  WrittenBytes += DeferredWrite->BytesToWrite;
438  /* We overflowed, give up */
439  if (WrittenBytes < DeferredWrite->BytesToWrite)
440  {
441  DeferredWrite = NULL;
442  break;
443  }
444 
445  /* Check we can write */
446  if (CcCanIWrite(DeferredWrite->FileObject, WrittenBytes, FALSE, RetryForceCheckPerFile))
447  {
448  /* We can, so remove it from the list and stop looking for entry */
449  RemoveEntryList(&DeferredWrite->DeferredWriteLinks);
450  break;
451  }
452 
453  /* If we don't accept modified pages, stop here */
454  if (!DeferredWrite->LimitModifiedPages)
455  {
456  DeferredWrite = NULL;
457  break;
458  }
459 
460  /* Reset count as nothing was written yet */
461  WrittenBytes -= DeferredWrite->BytesToWrite;
462  DeferredWrite = NULL;
463  }
465 
466  /* Nothing to write found, give up */
467  if (DeferredWrite == NULL)
468  {
469  break;
470  }
471 
472  /* If we have an event, set it and quit */
473  if (DeferredWrite->Event)
474  {
475  KeSetEvent(DeferredWrite->Event, IO_NO_INCREMENT, FALSE);
476  }
477  /* Otherwise, call the write routine and free the context */
478  else
479  {
480  DeferredWrite->PostRoutine(DeferredWrite->Context1, DeferredWrite->Context2);
481  ExFreePoolWithTag(DeferredWrite, 'CcDw');
482  }
483  }
484 }
485 
486 VOID
489 {
491  LONGLONG CurrentOffset;
492  KIRQL OldIrql;
493  PROS_SHARED_CACHE_MAP SharedCacheMap;
494  PROS_VACB Vacb;
495  ULONG PartialLength;
497  BOOLEAN Valid;
498  ULONG Length;
499  PPRIVATE_CACHE_MAP PrivateCacheMap;
500  BOOLEAN Locked;
501 
502  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
503 
504  /* Critical:
505  * PrivateCacheMap might disappear in-between if the handle
506  * to the file is closed (private is attached to the handle not to
507  * the file), so we need to lock the master lock while we deal with
508  * it. It won't disappear without attempting to lock such lock.
509  */
511  PrivateCacheMap = FileObject->PrivateCacheMap;
512  /* If the handle was closed since the read ahead was scheduled, just quit */
513  if (PrivateCacheMap == NULL)
514  {
516  ObDereferenceObject(FileObject);
517  return;
518  }
519  /* Otherwise, extract read offset and length and release private map */
520  else
521  {
523  CurrentOffset = PrivateCacheMap->ReadAheadOffset[1].QuadPart;
524  Length = PrivateCacheMap->ReadAheadLength[1];
526  }
528 
529  /* Time to go! */
530  DPRINT("Doing ReadAhead for %p\n", FileObject);
531  /* Lock the file, first */
532  if (!SharedCacheMap->Callbacks->AcquireForReadAhead(SharedCacheMap->LazyWriteContext, FALSE))
533  {
534  Locked = FALSE;
535  goto Clear;
536  }
537 
538  /* Remember it's locked */
539  Locked = TRUE;
540 
541  /* Don't read past the end of the file */
542  if (CurrentOffset >= SharedCacheMap->FileSize.QuadPart)
543  {
544  goto Clear;
545  }
546  if (CurrentOffset + Length > SharedCacheMap->FileSize.QuadPart)
547  {
548  Length = SharedCacheMap->FileSize.QuadPart - CurrentOffset;
549  }
550 
551  /* Next of the algorithm will lock like CcCopyData with the slight
552  * difference that we don't copy data back to an user-backed buffer
553  * We just bring data into Cc
554  */
555  PartialLength = CurrentOffset % VACB_MAPPING_GRANULARITY;
556  if (PartialLength != 0)
557  {
558  PartialLength = min(Length, VACB_MAPPING_GRANULARITY - PartialLength);
559  Status = CcRosRequestVacb(SharedCacheMap,
560  ROUND_DOWN(CurrentOffset,
562  &BaseAddress,
563  &Valid,
564  &Vacb);
565  if (!NT_SUCCESS(Status))
566  {
567  DPRINT1("Failed to request VACB: %lx!\n", Status);
568  goto Clear;
569  }
570 
571  if (!Valid)
572  {
573  Status = CcReadVirtualAddress(Vacb);
574  if (!NT_SUCCESS(Status))
575  {
576  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
577  DPRINT1("Failed to read data: %lx!\n", Status);
578  goto Clear;
579  }
580  }
581 
582  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
583 
584  Length -= PartialLength;
585  CurrentOffset += PartialLength;
586  }
587 
588  while (Length > 0)
589  {
590  ASSERT(CurrentOffset % VACB_MAPPING_GRANULARITY == 0);
591  PartialLength = min(VACB_MAPPING_GRANULARITY, Length);
592  Status = CcRosRequestVacb(SharedCacheMap,
593  CurrentOffset,
594  &BaseAddress,
595  &Valid,
596  &Vacb);
597  if (!NT_SUCCESS(Status))
598  {
599  DPRINT1("Failed to request VACB: %lx!\n", Status);
600  goto Clear;
601  }
602 
603  if (!Valid)
604  {
605  Status = CcReadVirtualAddress(Vacb);
606  if (!NT_SUCCESS(Status))
607  {
608  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
609  DPRINT1("Failed to read data: %lx!\n", Status);
610  goto Clear;
611  }
612  }
613 
614  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
615 
616  Length -= PartialLength;
617  CurrentOffset += PartialLength;
618  }
619 
620 Clear:
621  /* See previous comment about private cache map */
623  PrivateCacheMap = FileObject->PrivateCacheMap;
624  if (PrivateCacheMap != NULL)
625  {
626  /* Mark read ahead as unactive */
628  InterlockedAnd((volatile long *)&PrivateCacheMap->UlongFlags, ~PRIVATE_CACHE_MAP_READ_AHEAD_ACTIVE);
630  }
632 
633  /* If file was locked, release it */
634  if (Locked)
635  {
636  SharedCacheMap->Callbacks->ReleaseFromReadAhead(SharedCacheMap->LazyWriteContext);
637  }
638 
639  /* And drop our extra reference (See: CcScheduleReadAhead) */
640  ObDereferenceObject(FileObject);
641 
642  return;
643 }
644 
645 /*
646  * @unimplemented
647  */
648 BOOLEAN
649 NTAPI
652  IN ULONG BytesToWrite,
653  IN BOOLEAN Wait,
654  IN BOOLEAN Retrying)
655 {
656  KIRQL OldIrql;
657  KEVENT WaitEvent;
658  ULONG Length, Pages;
659  BOOLEAN PerFileDefer;
662  CC_CAN_WRITE_RETRY TryContext;
663  PROS_SHARED_CACHE_MAP SharedCacheMap;
664 
665  CCTRACE(CC_API_DEBUG, "FileObject=%p BytesToWrite=%lu Wait=%d Retrying=%d\n",
666  FileObject, BytesToWrite, Wait, Retrying);
667 
668  /* Write through is always OK */
669  if (BooleanFlagOn(FileObject->Flags, FO_WRITE_THROUGH))
670  {
671  return TRUE;
672  }
673 
674  TryContext = Retrying;
675  /* Allow remote file if not from posted */
676  if (IoIsFileOriginRemote(FileObject) && TryContext < RetryAllowRemote)
677  {
678  return TRUE;
679  }
680 
681  /* Don't exceed max tolerated size */
682  Length = MAX_ZERO_LENGTH;
683  if (BytesToWrite < MAX_ZERO_LENGTH)
684  {
685  Length = BytesToWrite;
686  }
687 
688  /* Convert it to pages count */
689  Pages = (Length + PAGE_SIZE - 1) >> PAGE_SHIFT;
690 
691  /* By default, assume limits per file won't be hit */
692  PerFileDefer = FALSE;
693  Fcb = FileObject->FsContext;
694  /* Do we have to check for limits per file? */
695  if (TryContext >= RetryForceCheckPerFile ||
697  {
698  /* If master is not locked, lock it now */
699  if (TryContext != RetryMasterLocked)
700  {
702  }
703 
704  /* Let's not assume the file is cached... */
705  if (FileObject->SectionObjectPointer != NULL &&
706  FileObject->SectionObjectPointer->SharedCacheMap != NULL)
707  {
708  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
709  /* Do we have limits per file set? */
710  if (SharedCacheMap->DirtyPageThreshold != 0 &&
711  SharedCacheMap->DirtyPages != 0)
712  {
713  /* Yes, check whether they are blocking */
714  if (Pages + SharedCacheMap->DirtyPages > SharedCacheMap->DirtyPageThreshold)
715  {
716  PerFileDefer = TRUE;
717  }
718  }
719  }
720 
721  /* And don't forget to release master */
722  if (TryContext != RetryMasterLocked)
723  {
725  }
726  }
727 
728  /* So, now allow write if:
729  * - Not the first try or we have no throttling yet
730  * AND:
731  * - We don't exceed threshold!
732  * - We don't exceed what Mm can allow us to use
733  * + If we're above top, that's fine
734  * + If we're above bottom with limited modified pages, that's fine
735  * + Otherwise, throttle!
736  */
737  if ((TryContext != FirstTry || IsListEmpty(&CcDeferredWrites)) &&
741  !PerFileDefer)
742  {
743  return TRUE;
744  }
745 
746  /* If we can wait, we'll start the wait loop for waiting till we can
747  * write for real
748  */
749  if (!Wait)
750  {
751  return FALSE;
752  }
753 
754  /* Otherwise, if there are no deferred writes yet, start the lazy writer */
756  {
757  KIRQL OldIrql;
758 
762  }
763 
764  /* Initialize our wait event */
766 
767  /* And prepare a dummy context */
769  Context.NodeByteSize = sizeof(DEFERRED_WRITE);
770  Context.FileObject = FileObject;
771  Context.BytesToWrite = BytesToWrite;
773  Context.Event = &WaitEvent;
774 
775  /* And queue it */
776  if (Retrying)
777  {
778  /* To the top, if that's a retry */
780  &Context.DeferredWriteLinks,
782  }
783  else
784  {
785  /* To the bottom, if that's a first time */
787  &Context.DeferredWriteLinks,
789  }
790 
791  DPRINT1("Actively deferring write for: %p\n", FileObject);
792  /* Now, we'll loop until our event is set. When it is set, it means that caller
793  * can immediately write, and has to
794  */
795  do
796  {
799 
800  return TRUE;
801 }
802 
803 /*
804  * @implemented
805  */
806 BOOLEAN
807 NTAPI
811  IN ULONG Length,
812  IN BOOLEAN Wait,
813  OUT PVOID Buffer,
815 {
816  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d\n",
817  FileObject, FileOffset->QuadPart, Length, Wait);
818 
819  DPRINT("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
820  "Length %lu, Wait %u, Buffer 0x%p, IoStatus 0x%p)\n",
821  FileObject, FileOffset->QuadPart, Length, Wait,
822  Buffer, IoStatus);
823 
824  return CcCopyData(FileObject,
825  FileOffset->QuadPart,
826  Buffer,
827  Length,
829  Wait,
830  IoStatus);
831 }
832 
833 /*
834  * @implemented
835  */
836 BOOLEAN
837 NTAPI
841  IN ULONG Length,
842  IN BOOLEAN Wait,
843  IN PVOID Buffer)
844 {
846 
847  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d Buffer=%p\n",
848  FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
849 
850  DPRINT("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
851  "Length %lu, Wait %u, Buffer 0x%p)\n",
852  FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
853 
854  return CcCopyData(FileObject,
855  FileOffset->QuadPart,
856  Buffer,
857  Length,
859  Wait,
860  &IoStatus);
861 }
862 
863 /*
864  * @implemented
865  */
866 VOID
867 NTAPI
870  IN PCC_POST_DEFERRED_WRITE PostRoutine,
871  IN PVOID Context1,
872  IN PVOID Context2,
873  IN ULONG BytesToWrite,
874  IN BOOLEAN Retrying)
875 {
876  KIRQL OldIrql;
879 
880  CCTRACE(CC_API_DEBUG, "FileObject=%p PostRoutine=%p Context1=%p Context2=%p BytesToWrite=%lu Retrying=%d\n",
881  FileObject, PostRoutine, Context1, Context2, BytesToWrite, Retrying);
882 
883  /* Try to allocate a context for queueing the write operation */
884  Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEFERRED_WRITE), 'CcDw');
885  /* If it failed, immediately execute the operation! */
886  if (Context == NULL)
887  {
888  PostRoutine(Context1, Context2);
889  return;
890  }
891 
892  Fcb = FileObject->FsContext;
893 
894  /* Otherwise, initialize the context */
895  RtlZeroMemory(Context, sizeof(DEFERRED_WRITE));
897  Context->NodeByteSize = sizeof(DEFERRED_WRITE);
898  Context->FileObject = FileObject;
899  Context->PostRoutine = PostRoutine;
900  Context->Context1 = Context1;
901  Context->Context2 = Context2;
902  Context->BytesToWrite = BytesToWrite;
904 
905  /* And queue it */
906  if (Retrying)
907  {
908  /* To the top, if that's a retry */
910  &Context->DeferredWriteLinks,
912  }
913  else
914  {
915  /* To the bottom, if that's a first time */
917  &Context->DeferredWriteLinks,
919  }
920 
921  /* Try to execute the posted writes */
923 
924  /* Schedule a lazy writer run to handle deferred writes */
926  if (!LazyWriter.ScanActive)
927  {
929  }
931 }
932 
933 /*
934  * @unimplemented
935  */
936 VOID
937 NTAPI
941  IN ULONG Length,
942  IN ULONG PageCount,
943  OUT PVOID Buffer,
945 {
946  LARGE_INTEGER LargeFileOffset;
948 
949  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%lu Length=%lu PageCount=%lu Buffer=%p\n",
950  FileObject, FileOffset, Length, PageCount, Buffer);
951 
952  DBG_UNREFERENCED_PARAMETER(PageCount);
953 
954  LargeFileOffset.QuadPart = FileOffset;
955  Success = CcCopyRead(FileObject,
956  &LargeFileOffset,
957  Length,
958  TRUE,
959  Buffer,
960  IoStatus);
961  ASSERT(Success == TRUE);
962 }
963 
964 /*
965  * @unimplemented
966  */
967 VOID
968 NTAPI
972  IN ULONG Length,
973  IN PVOID Buffer)
974 {
975  LARGE_INTEGER LargeFileOffset;
977 
978  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%lu Length=%lu Buffer=%p\n",
979  FileObject, FileOffset, Length, Buffer);
980 
981  LargeFileOffset.QuadPart = FileOffset;
982  Success = CcCopyWrite(FileObject,
983  &LargeFileOffset,
984  Length,
985  TRUE,
986  Buffer);
987  ASSERT(Success == TRUE);
988 }
989 
990 /*
991  * @implemented
992  */
993 BOOLEAN
994 NTAPI
997  IN PLARGE_INTEGER StartOffset,
998  IN PLARGE_INTEGER EndOffset,
999  IN BOOLEAN Wait)
1000 {
1001  NTSTATUS Status;
1002  LARGE_INTEGER WriteOffset;
1003  LONGLONG Length;
1004  ULONG CurrentLength;
1005  PMDL Mdl;
1006  ULONG i;
1008  KEVENT Event;
1009 
1010  CCTRACE(CC_API_DEBUG, "FileObject=%p StartOffset=%I64u EndOffset=%I64u Wait=%d\n",
1011  FileObject, StartOffset->QuadPart, EndOffset->QuadPart, Wait);
1012 
1013  DPRINT("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
1014  "Wait %u)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart,
1015  Wait);
1016 
1017  Length = EndOffset->QuadPart - StartOffset->QuadPart;
1018  WriteOffset.QuadPart = StartOffset->QuadPart;
1019 
1020  if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
1021  {
1022  /* File is not cached */
1023 
1024  Mdl = _alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
1025 
1026  while (Length > 0)
1027  {
1028  if (Length + WriteOffset.QuadPart % PAGE_SIZE > MAX_ZERO_LENGTH)
1029  {
1030  CurrentLength = MAX_ZERO_LENGTH - WriteOffset.QuadPart % PAGE_SIZE;
1031  }
1032  else
1033  {
1034  CurrentLength = Length;
1035  }
1036  MmInitializeMdl(Mdl, (PVOID)(ULONG_PTR)WriteOffset.QuadPart, CurrentLength);
1037  Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
1038  for (i = 0; i < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); i++)
1039  {
1040  ((PPFN_NUMBER)(Mdl + 1))[i] = CcZeroPage;
1041  }
1043  Status = IoSynchronousPageWrite(FileObject, Mdl, &WriteOffset, &Event, &Iosb);
1044  if (Status == STATUS_PENDING)
1045  {
1047  Status = Iosb.Status;
1048  }
1049  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
1050  {
1051  MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
1052  }
1053  if (!NT_SUCCESS(Status))
1054  {
1055  return FALSE;
1056  }
1057  WriteOffset.QuadPart += CurrentLength;
1058  Length -= CurrentLength;
1059  }
1060  }
1061  else
1062  {
1064 
1065  return CcCopyData(FileObject,
1066  WriteOffset.QuadPart,
1067  NULL,
1068  Length,
1070  Wait,
1071  &IoStatus);
1072  }
1073 
1074  return TRUE;
1075 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
DWORD *typedef PVOID
Definition: winlogon.h:61
BOOLEAN CcCopyData(_In_ PFILE_OBJECT FileObject, _In_ LONGLONG FileOffset, _Inout_ PVOID Buffer, _In_ LONGLONG Length, _In_ CC_COPY_OPERATION Operation, _In_ BOOLEAN Wait, _Out_ PIO_STATUS_BLOCK IoStatus)
Definition: copy.c:258
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define IN
Definition: typedefs.h:38
#define InterlockedAnd
Definition: interlocked.h:62
BOOLEAN LimitModifiedPages
Definition: cctypes.h:178
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
CSHORT NodeByteSize
Definition: cctypes.h:170
Definition: cc.h:202
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG CcDirtyPageThreshold
Definition: view.c:61
PVOID BaseAddress
Definition: cc.h:205
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
#define DbgPrint
Definition: loader.c:25
LARGE_INTEGER SectionSize
Definition: cc.h:177
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
LARGE_INTEGER BeyondLastByte2
Definition: cctypes.h:80
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
ULONG CcDataFlushes
Definition: copy.c:51
CSHORT NodeTypeCode
Definition: cctypes.h:169
BOOLEAN NTAPI CcCanIWrite(IN PFILE_OBJECT FileObject, IN ULONG BytesToWrite, IN BOOLEAN Wait, IN BOOLEAN Retrying)
Definition: copy.c:650
unsigned char * PUCHAR
Definition: retypes.h:3
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
#define FO_RANDOM_ACCESS
Definition: iotypes.h:1752
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:229
#define ExRaiseStatus
Definition: ntoskrnl.h:94
ULONG CcRosTraceLevel
Definition: copy.c:38
$ULONG LowPart
Definition: ntbasedef.h:576
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
#define MC_SYSTEM
Definition: mm.h:95
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1091
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
PVOID PMDL
Definition: usb.h:39
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
ULONG CcFastMdlReadWait
Definition: copy.c:39
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
VOID CcPostDeferredWrites(VOID)
Definition: copy.c:413
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copy.c:808
_SEH2_TRY
Definition: create.c:4250
VOID NTAPI CcScheduleReadAhead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length)
Definition: cachesub.c:92
#define STATUS_END_OF_FILE
Definition: shellext.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID CcPerformReadAhead(IN PFILE_OBJECT FileObject)
Definition: copy.c:487
ACPI_EFI_EVENT Event
Definition: acefiex.h:633
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG * PPFN_NUMBER
Definition: ke.h:8
VOID NTAPI CcFastCopyRead(IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN ULONG PageCount, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copy.c:938
GLenum GLclampf GLint i
Definition: glfuncs.h:14
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:114
ULONG PFN_NUMBER
Definition: ke.h:8
LAZY_WRITER LazyWriter
Definition: lazywrite.c:37
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
BOOLEAN NTAPI IoIsFileOriginRemote(IN PFILE_OBJECT FileObject)
Definition: file.c:3278
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
ULONG CcFastReadResourceMiss
Definition: copy.c:44
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:260
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
LARGE_INTEGER BeyondLastByte1
Definition: cctypes.h:78
VOID NTAPI CcFastCopyWrite(IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN PVOID Buffer)
Definition: copy.c:969
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3149
smooth NULL
Definition: ftsmooth.c:416
#define NODE_TYPE_DEFERRED_WRITE
Definition: cc.h:287
#define _Out_
Definition: no_sal2.h:323
_In_ PLARGE_INTEGER _In_ ULONG _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ PVOID _In_ PVOID Context2
Definition: cctypes.h:53
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
Definition: bufpool.h:45
#define MI_SET_USAGE(x)
Definition: mm.h:253
PCACHE_MANAGER_CALLBACKS Callbacks
Definition: cc.h:182
ULONG CcFastReadNotPossible
Definition: copy.c:41
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
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
UINTN Size
Definition: acefiex.h:555
LIST_ENTRY CacheMapVacbListHead
Definition: cc.h:190
KSPIN_LOCK ReadAheadSpinLock
Definition: cctypes.h:83
VOID NTAPI CcDeferWrite(IN PFILE_OBJECT FileObject, IN PCC_POST_DEFERRED_WRITE PostRoutine, IN PVOID Context1, IN PVOID Context2, IN ULONG BytesToWrite, IN BOOLEAN Retrying)
Definition: copy.c:868
int64_t LONGLONG
Definition: typedefs.h:66
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
unsigned char BOOLEAN
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
ULONG CcDataPages
Definition: copy.c:50
#define CC_API_DEBUG
Definition: cc.h:11
LONG NTSTATUS
Definition: precomp.h:26
LIST_ENTRY DeferredWriteLinks
Definition: cctypes.h:173
return Iosb
Definition: create.c:4426
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:412
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
struct _DEFERRED_WRITE DEFERRED_WRITE
enum _CC_CAN_WRITE_RETRY CC_CAN_WRITE_RETRY
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LIST_ENTRY CcDeferredWrites
Definition: view.c:63
BOOLEAN ScanActive
Definition: cc.h:247
ULONG CcFastReadNoWait
Definition: copy.c:43
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
MMPFNLIST MmModifiedPageListHead
Definition: pfnlist.c:45
#define _Inout_
Definition: no_sal2.h:244
static PFN_NUMBER CcZeroPage
Definition: copy.c:19
* PFILE_OBJECT
Definition: iotypes.h:1954
#define FSRTL_FLAG_LIMIT_MODIFIED_PAGES
Definition: fsrtltypes.h:47
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
KSPIN_LOCK CcDeferredWriteSpinLock
Definition: view.c:64
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG MmThrottleBottom
Definition: mminit.c:397
ULONG CcTotalDirtyPages
Definition: view.c:62
_CC_CAN_WRITE_RETRY
Definition: copy.c:30
MDL
Definition: mmtypes.h:117
VOID UINTN Length
Definition: acefiex.h:744
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead
Definition: cctypes.h:42
LARGE_INTEGER FileOffset1
Definition: cctypes.h:77
SIZE_T NTAPI MmSizeOfMdl(IN PVOID Base, IN SIZE_T Length)
Definition: mdlsup.c:413
#define PAGE_SIZE
Definition: env_spec_w32.h:49
ULONG CcFastReadWait
Definition: copy.c:42
Definition: typedefs.h:117
Definition: copy.c:32
VOID NTAPI CcInitCacheZeroPage(VOID)
Definition: copy.c:63
NTSTATUS NTAPI CcWriteVirtualAddress(PROS_VACB Vacb)
Definition: copy.c:153
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
ULONG MmThrottleTop
Definition: mminit.c:396
Status
Definition: gdiplustypes.h:24
VOID CcScheduleLazyWriteScan(IN BOOLEAN NoDelay)
Definition: lazywrite.c:181
PFILE_OBJECT FileObject
Definition: cctypes.h:171
FORCEINLINE BOOLEAN DoRangesIntersect(_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Offset2, _In_ LONGLONG Length2)
Definition: cc.h:478
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
PVOID Context1
Definition: cctypes.h:176
ULONG CcFastMdlReadNotPossible
Definition: copy.c:40
#define _In_
Definition: no_sal2.h:204
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:30
_SEH2_END
Definition: create.c:4424
_In_ PLARGE_INTEGER _In_ ULONG _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ PVOID Context1
Definition: cctypes.h:53
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
LARGE_INTEGER ReadAheadOffset[2]
Definition: cctypes.h:81
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define ROUND_TO_PAGES(Size)
PFN_NUMBER NTAPI MmGetPfnForProcess(struct _EPROCESS *Process, PVOID Address)
NTSTATUS ReadWriteOrZero(_Inout_ PVOID BaseAddress, _Inout_opt_ PVOID Buffer, _In_ ULONG Length, _In_ CC_COPY_OPERATION Operation)
Definition: copy.c:226
enum _CC_COPY_OPERATION CC_COPY_OPERATION
BOOLEAN Valid
Definition: cc.h:209
PFN_NUMBER Total
Definition: mm.h:371
#define min(a, b)
Definition: monoChain.cc:55
NTSTATUS NTAPI IoSynchronousPageWrite(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1036
PCC_POST_DEFERRED_WRITE PostRoutine
Definition: cctypes.h:175
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_ BOOLEAN Wait
Definition: cctypes.h:23
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER CcIdleDelay
Definition: lazywrite.c:46
LARGE_INTEGER FileOffset
Definition: cc.h:222
_In_ PLARGE_INTEGER FileOffset
Definition: cctypes.h:53
LARGE_INTEGER FileOffset2
Definition: cctypes.h:79
#define VACB_MAPPING_GRANULARITY
_CC_COPY_OPERATION
Definition: copy.c:23
BOOLEAN NTAPI CcZeroData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
Definition: copy.c:995
PVOID LazyWriteContext
Definition: cc.h:183
#define OUT
Definition: typedefs.h:39
LARGE_INTEGER FileSize
Definition: cc.h:175
BOOLEAN NTAPI CcCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
Definition: copy.c:838
struct tagContext Context
Definition: acpixf.h:1027
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
ULONG BytesToWrite
Definition: cctypes.h:172
void Clear(USHORT Window)
Definition: hardware.c:705
KSPIN_LOCK CacheMapLock
Definition: cc.h:193
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
PFILE_OBJECT FileObject
Definition: cc.h:178
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG UlongFlags
Definition: cctypes.h:73
#define PRIVATE_CACHE_MAP_READ_AHEAD_ACTIVE
Definition: cctypes.h:64
return STATUS_SUCCESS
Definition: btrfs.c:2710
NTSTATUS NTAPI CcRosRequestVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
Definition: view.c:989
PKEVENT Event
Definition: cctypes.h:174
ULONG DirtyPageThreshold
Definition: cc.h:185
NTSTATUS NTAPI CcReadVirtualAddress(PROS_VACB Vacb)
Definition: copy.c:81
PVOID Context2
Definition: cctypes.h:177
ULONG DirtyPages
Definition: cc.h:179
ULONG ReadAheadLength[2]
Definition: cctypes.h:82
LONGLONG QuadPart
Definition: typedefs.h:112
#define FO_WRITE_THROUGH
Definition: iotypes.h:1735
#define _Inout_opt_
Definition: no_sal2.h:258
#define MAX_ZERO_LENGTH
Definition: copy.c:21