ReactOS  0.4.14-dev-114-gc8cbd56
copy.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for copy.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MAX_ZERO_LENGTH   (256 * 1024)
 

Typedefs

typedef enum _CC_COPY_OPERATION CC_COPY_OPERATION
 
typedef enum _CC_CAN_WRITE_RETRY CC_CAN_WRITE_RETRY
 

Enumerations

enum  _CC_COPY_OPERATION { CcOperationRead, CcOperationWrite, CcOperationZero }
 
enum  _CC_CAN_WRITE_RETRY { FirstTry = 0, RetryAllowRemote = 253, RetryForceCheckPerFile = 254, RetryMasterLocked = 255 }
 

Functions

VOID NTAPI MiZeroPhysicalPage (IN PFN_NUMBER PageFrameIndex)
 
VOID NTAPI CcInitCacheZeroPage (VOID)
 
NTSTATUS NTAPI CcReadVirtualAddress (PROS_VACB Vacb)
 
NTSTATUS NTAPI CcWriteVirtualAddress (PROS_VACB Vacb)
 
NTSTATUS ReadWriteOrZero (_Inout_ PVOID BaseAddress, _Inout_opt_ PVOID Buffer, _In_ ULONG Length, _In_ CC_COPY_OPERATION Operation)
 
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)
 
VOID CcPostDeferredWrites (VOID)
 
VOID CcPerformReadAhead (IN PFILE_OBJECT FileObject)
 
BOOLEAN NTAPI CcCanIWrite (IN PFILE_OBJECT FileObject, IN ULONG BytesToWrite, IN BOOLEAN Wait, IN BOOLEAN Retrying)
 
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)
 
BOOLEAN NTAPI CcCopyWrite (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
 
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)
 
VOID NTAPI CcFastCopyRead (IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN ULONG PageCount, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
 
VOID NTAPI CcFastCopyWrite (IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN PVOID Buffer)
 
BOOLEAN NTAPI CcZeroData (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
 

Variables

static PFN_NUMBER CcZeroPage = 0
 
ULONG CcRosTraceLevel = 0
 
ULONG CcFastMdlReadWait
 
ULONG CcFastMdlReadNotPossible
 
ULONG CcFastReadNotPossible
 
ULONG CcFastReadWait
 
ULONG CcFastReadNoWait
 
ULONG CcFastReadResourceMiss
 
ULONG CcDataPages = 0
 
ULONG CcDataFlushes = 0
 

Macro Definition Documentation

◆ MAX_ZERO_LENGTH

#define MAX_ZERO_LENGTH   (256 * 1024)

Definition at line 21 of file copy.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file copy.c.

Typedef Documentation

◆ CC_CAN_WRITE_RETRY

◆ CC_COPY_OPERATION

Enumeration Type Documentation

◆ _CC_CAN_WRITE_RETRY

Enumerator
FirstTry 
RetryAllowRemote 
RetryForceCheckPerFile 
RetryMasterLocked 

Definition at line 30 of file copy.c.

31 {
32  FirstTry = 0,
33  RetryAllowRemote = 253,
35  RetryMasterLocked = 255,
enum _CC_CAN_WRITE_RETRY CC_CAN_WRITE_RETRY
Definition: copy.c:32

◆ _CC_COPY_OPERATION

Enumerator
CcOperationRead 
CcOperationWrite 
CcOperationZero 

Definition at line 23 of file copy.c.

24 {
enum _CC_COPY_OPERATION CC_COPY_OPERATION

Function Documentation

◆ CcCanIWrite()

BOOLEAN NTAPI CcCanIWrite ( IN PFILE_OBJECT  FileObject,
IN ULONG  BytesToWrite,
IN BOOLEAN  Wait,
IN BOOLEAN  Retrying 
)

Definition at line 649 of file copy.c.

654 {
655  KIRQL OldIrql;
656  KEVENT WaitEvent;
657  ULONG Length, Pages;
658  BOOLEAN PerFileDefer;
661  CC_CAN_WRITE_RETRY TryContext;
662  PROS_SHARED_CACHE_MAP SharedCacheMap;
663 
664  CCTRACE(CC_API_DEBUG, "FileObject=%p BytesToWrite=%lu Wait=%d Retrying=%d\n",
665  FileObject, BytesToWrite, Wait, Retrying);
666 
667  /* Write through is always OK */
669  {
670  return TRUE;
671  }
672 
673  TryContext = Retrying;
674  /* Allow remote file if not from posted */
675  if (IoIsFileOriginRemote(FileObject) && TryContext < RetryAllowRemote)
676  {
677  return TRUE;
678  }
679 
680  /* Don't exceed max tolerated size */
682  if (BytesToWrite < MAX_ZERO_LENGTH)
683  {
684  Length = BytesToWrite;
685  }
686 
687  Pages = BYTES_TO_PAGES(Length);
688 
689  /* By default, assume limits per file won't be hit */
690  PerFileDefer = FALSE;
691  Fcb = FileObject->FsContext;
692  /* Do we have to check for limits per file? */
693  if (TryContext >= RetryForceCheckPerFile ||
695  {
696  /* If master is not locked, lock it now */
697  if (TryContext != RetryMasterLocked)
698  {
700  }
701 
702  /* Let's not assume the file is cached... */
703  if (FileObject->SectionObjectPointer != NULL &&
704  FileObject->SectionObjectPointer->SharedCacheMap != NULL)
705  {
706  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
707  /* Do we have limits per file set? */
708  if (SharedCacheMap->DirtyPageThreshold != 0 &&
709  SharedCacheMap->DirtyPages != 0)
710  {
711  /* Yes, check whether they are blocking */
712  if (Pages + SharedCacheMap->DirtyPages > SharedCacheMap->DirtyPageThreshold)
713  {
714  PerFileDefer = TRUE;
715  }
716  }
717  }
718 
719  /* And don't forget to release master */
720  if (TryContext != RetryMasterLocked)
721  {
723  }
724  }
725 
726  /* So, now allow write if:
727  * - Not the first try or we have no throttling yet
728  * AND:
729  * - We don't exceed threshold!
730  * - We don't exceed what Mm can allow us to use
731  * + If we're above top, that's fine
732  * + If we're above bottom with limited modified pages, that's fine
733  * + Otherwise, throttle!
734  */
735  if ((TryContext != FirstTry || IsListEmpty(&CcDeferredWrites)) &&
739  !PerFileDefer)
740  {
741  return TRUE;
742  }
743 
744  /* If we can wait, we'll start the wait loop for waiting till we can
745  * write for real
746  */
747  if (!Wait)
748  {
749  return FALSE;
750  }
751 
752  /* Otherwise, if there are no deferred writes yet, start the lazy writer */
754  {
755  KIRQL OldIrql;
756 
760  }
761 
762  /* Initialize our wait event */
764 
765  /* And prepare a dummy context */
766  Context.NodeTypeCode = NODE_TYPE_DEFERRED_WRITE;
767  Context.NodeByteSize = sizeof(DEFERRED_WRITE);
768  Context.FileObject = FileObject;
769  Context.BytesToWrite = BytesToWrite;
771  Context.Event = &WaitEvent;
772 
773  /* And queue it */
774  if (Retrying)
775  {
776  /* To the top, if that's a retry */
778  &Context.DeferredWriteLinks,
780  }
781  else
782  {
783  /* To the bottom, if that's a first time */
785  &Context.DeferredWriteLinks,
787  }
788 
789  DPRINT1("Actively deferring write for: %p\n", FileObject);
790  /* Now, we'll loop until our event is set. When it is set, it means that caller
791  * can immediately write, and has to
792  */
793  do
794  {
797 
798  return TRUE;
799 }
#define TRUE
Definition: types.h:120
ULONG CcDirtyPageThreshold
Definition: view.c:59
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
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
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID CcPostDeferredWrites(VOID)
Definition: copy.c:412
UCHAR KIRQL
Definition: env_spec_w32.h:591
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:114
BOOLEAN NTAPI IoIsFileOriginRemote(IN PFILE_OBJECT FileObject)
Definition: file.c:3277
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define NODE_TYPE_DEFERRED_WRITE
Definition: cc.h:285
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
struct _DEFERRED_WRITE DEFERRED_WRITE
enum _CC_CAN_WRITE_RETRY CC_CAN_WRITE_RETRY
LIST_ENTRY CcDeferredWrites
Definition: view.c:61
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define FSRTL_FLAG_LIMIT_MODIFIED_PAGES
Definition: fsrtltypes.h:47
KSPIN_LOCK CcDeferredWriteSpinLock
Definition: view.c:62
ULONG Flags
Definition: ntfs.h:532
ULONG MmThrottleBottom
Definition: mminit.c:397
#define BYTES_TO_PAGES(Size)
ULONG CcTotalDirtyPages
Definition: view.c:60
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: copy.c:32
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
ULONG MmThrottleTop
Definition: mminit.c:396
VOID CcScheduleLazyWriteScan(IN BOOLEAN NoDelay)
Definition: lazywrite.c:200
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PFN_NUMBER Total
Definition: mm.h:371
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER CcIdleDelay
Definition: lazywrite.c:46
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
ULONG DirtyPageThreshold
Definition: cc.h:185
ULONG DirtyPages
Definition: cc.h:179
#define FO_WRITE_THROUGH
Definition: iotypes.h:1736
IN BOOLEAN Wait
Definition: fatprocs.h:1529
#define MAX_ZERO_LENGTH
Definition: copy.c:21

Referenced by CcPostDeferredWrites().

◆ CcCopyData()

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 at line 257 of file copy.c.

265 {
267  LONGLONG CurrentOffset;
269  KIRQL OldIrql;
270  PROS_SHARED_CACHE_MAP SharedCacheMap;
271  PLIST_ENTRY ListEntry;
272  PROS_VACB Vacb;
273  ULONG PartialLength;
275  BOOLEAN Valid;
276  PPRIVATE_CACHE_MAP PrivateCacheMap;
277 
278  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
279  PrivateCacheMap = FileObject->PrivateCacheMap;
280  CurrentOffset = FileOffset;
281  BytesCopied = 0;
282 
283  if (!Wait)
284  {
285  /* test if the requested data is available */
286  KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
287  /* FIXME: this loop doesn't take into account areas that don't have
288  * a VACB in the list yet */
289  ListEntry = SharedCacheMap->CacheMapVacbListHead.Flink;
290  while (ListEntry != &SharedCacheMap->CacheMapVacbListHead)
291  {
292  Vacb = CONTAINING_RECORD(ListEntry,
293  ROS_VACB,
294  CacheMapVacbListEntry);
295  ListEntry = ListEntry->Flink;
296  if (!Vacb->Valid &&
299  CurrentOffset, Length))
300  {
301  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
302  /* data not available */
303  return FALSE;
304  }
305  if (Vacb->FileOffset.QuadPart >= CurrentOffset + Length)
306  break;
307  }
308  KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
309  }
310 
311  PartialLength = CurrentOffset % VACB_MAPPING_GRANULARITY;
312  if (PartialLength != 0)
313  {
314  PartialLength = min(Length, VACB_MAPPING_GRANULARITY - PartialLength);
315  Status = CcRosRequestVacb(SharedCacheMap,
316  ROUND_DOWN(CurrentOffset,
318  &BaseAddress,
319  &Valid,
320  &Vacb);
321  if (!NT_SUCCESS(Status))
323  if (!Valid)
324  {
326  if (!NT_SUCCESS(Status))
327  {
328  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
330  }
331  }
333  Buffer,
334  PartialLength,
335  Operation);
336 
337  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, Operation != CcOperationRead, FALSE);
338 
339  if (!NT_SUCCESS(Status))
341 
342  Length -= PartialLength;
343  CurrentOffset += PartialLength;
344  BytesCopied += PartialLength;
345 
346  if (Operation != CcOperationZero)
347  Buffer = (PVOID)((ULONG_PTR)Buffer + PartialLength);
348  }
349 
350  while (Length > 0)
351  {
352  ASSERT(CurrentOffset % VACB_MAPPING_GRANULARITY == 0);
353  PartialLength = min(VACB_MAPPING_GRANULARITY, Length);
354  Status = CcRosRequestVacb(SharedCacheMap,
355  CurrentOffset,
356  &BaseAddress,
357  &Valid,
358  &Vacb);
359  if (!NT_SUCCESS(Status))
361  if (!Valid &&
363  PartialLength < VACB_MAPPING_GRANULARITY))
364  {
366  if (!NT_SUCCESS(Status))
367  {
368  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
370  }
371  }
372  Status = ReadWriteOrZero(BaseAddress, Buffer, PartialLength, Operation);
373 
374  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, Operation != CcOperationRead, FALSE);
375 
376  if (!NT_SUCCESS(Status))
378 
379  Length -= PartialLength;
380  CurrentOffset += PartialLength;
381  BytesCopied += PartialLength;
382 
383  if (Operation != CcOperationZero)
384  Buffer = (PVOID)((ULONG_PTR)Buffer + PartialLength);
385  }
386 
387  /* If that was a successful sync read operation, let's handle read ahead */
388  if (Operation == CcOperationRead && Length == 0 && Wait)
389  {
390  /* If file isn't random access and next read may get us cross VACB boundary,
391  * schedule next read
392  */
393  if (!BooleanFlagOn(FileObject->Flags, FO_RANDOM_ACCESS) &&
394  (CurrentOffset - 1) / VACB_MAPPING_GRANULARITY != (CurrentOffset + BytesCopied - 1) / VACB_MAPPING_GRANULARITY)
395  {
397  }
398 
399  /* And update read history in private cache map */
400  PrivateCacheMap->FileOffset1.QuadPart = PrivateCacheMap->FileOffset2.QuadPart;
401  PrivateCacheMap->BeyondLastByte1.QuadPart = PrivateCacheMap->BeyondLastByte2.QuadPart;
402  PrivateCacheMap->FileOffset2.QuadPart = FileOffset;
403  PrivateCacheMap->BeyondLastByte2.QuadPart = FileOffset + BytesCopied;
404  }
405 
406  IoStatus->Status = STATUS_SUCCESS;
407  IoStatus->Information = BytesCopied;
408  return TRUE;
409 }
#define TRUE
Definition: types.h:120
Definition: cc.h:201
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
LARGE_INTEGER BeyondLastByte2
Definition: cctypes.h:80
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define FO_RANDOM_ACCESS
Definition: iotypes.h:1753
#define ExRaiseStatus
Definition: ntoskrnl.h:96
VOID NTAPI CcScheduleReadAhead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length)
Definition: cachesub.c:92
uint32_t ULONG_PTR
Definition: typedefs.h:63
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
LARGE_INTEGER BeyondLastByte1
Definition: cctypes.h:78
unsigned char BOOLEAN
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3167
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
_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
LIST_ENTRY CacheMapVacbListHead
Definition: cc.h:190
int64_t LONGLONG
Definition: typedefs.h:66
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
LARGE_INTEGER FileOffset1
Definition: cctypes.h:77
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
FORCEINLINE BOOLEAN DoRangesIntersect(_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Offset2, _In_ LONGLONG Length2)
Definition: cc.h:479
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:30
NTSTATUS ReadWriteOrZero(_Inout_ PVOID BaseAddress, _Inout_opt_ PVOID Buffer, _In_ ULONG Length, _In_ CC_COPY_OPERATION Operation)
Definition: copy.c:225
BOOLEAN Valid
Definition: cc.h:208
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define min(a, b)
Definition: monoChain.cc:55
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
LARGE_INTEGER FileOffset
Definition: cc.h:221
LARGE_INTEGER FileOffset2
Definition: cctypes.h:79
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSTATUS NTAPI CcRosRequestVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
Definition: view.c:996
NTSTATUS NTAPI CcReadVirtualAddress(PROS_VACB Vacb)
Definition: copy.c:81
LONGLONG QuadPart
Definition: typedefs.h:112
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by CcCopyRead(), CcCopyWrite(), and CcZeroData().

◆ CcCopyRead()

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 at line 806 of file copy.c.

813 {
814  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d\n",
815  FileObject, FileOffset->QuadPart, Length, Wait);
816 
817  DPRINT("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
818  "Length %lu, Wait %u, Buffer 0x%p, IoStatus 0x%p)\n",
819  FileObject, FileOffset->QuadPart, Length, Wait,
820  Buffer, IoStatus);
821 
822  return CcCopyData(FileObject,
823  FileOffset->QuadPart,
824  Buffer,
825  Length,
827  Wait,
828  IoStatus);
829 }
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:257
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by CcFastCopyRead().

◆ CcCopyWrite()

BOOLEAN NTAPI CcCopyWrite ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN PVOID  Buffer 
)

Definition at line 836 of file copy.c.

842 {
844 
845  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d Buffer=%p\n",
846  FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
847 
848  DPRINT("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
849  "Length %lu, Wait %u, Buffer 0x%p)\n",
850  FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
851 
852  return CcCopyData(FileObject,
853  FileOffset->QuadPart,
854  Buffer,
855  Length,
857  Wait,
858  &IoStatus);
859 }
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:257
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by CcFastCopyWrite().

◆ CcDeferWrite()

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 at line 866 of file copy.c.

873 {
874  KIRQL OldIrql;
877 
878  CCTRACE(CC_API_DEBUG, "FileObject=%p PostRoutine=%p Context1=%p Context2=%p BytesToWrite=%lu Retrying=%d\n",
879  FileObject, PostRoutine, Context1, Context2, BytesToWrite, Retrying);
880 
881  /* Try to allocate a context for queueing the write operation */
883  /* If it failed, immediately execute the operation! */
884  if (Context == NULL)
885  {
886  PostRoutine(Context1, Context2);
887  return;
888  }
889 
890  Fcb = FileObject->FsContext;
891 
892  /* Otherwise, initialize the context */
894  Context->NodeTypeCode = NODE_TYPE_DEFERRED_WRITE;
895  Context->NodeByteSize = sizeof(DEFERRED_WRITE);
896  Context->FileObject = FileObject;
897  Context->PostRoutine = PostRoutine;
898  Context->Context1 = Context1;
899  Context->Context2 = Context2;
900  Context->BytesToWrite = BytesToWrite;
902 
903  /* And queue it */
904  if (Retrying)
905  {
906  /* To the top, if that's a retry */
908  &Context->DeferredWriteLinks,
910  }
911  else
912  {
913  /* To the bottom, if that's a first time */
915  &Context->DeferredWriteLinks,
917  }
918 
919  /* Try to execute the posted writes */
921 
922  /* Schedule a lazy writer run to handle deferred writes */
924  if (!LazyWriter.ScanActive)
925  {
927  }
929 }
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
VOID CcPostDeferredWrites(VOID)
Definition: copy.c:412
UCHAR KIRQL
Definition: env_spec_w32.h:591
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:114
LAZY_WRITER LazyWriter
Definition: lazywrite.c:37
smooth NULL
Definition: ftsmooth.c:416
#define NODE_TYPE_DEFERRED_WRITE
Definition: cc.h:285
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
struct _DEFERRED_WRITE DEFERRED_WRITE
LIST_ENTRY CcDeferredWrites
Definition: view.c:61
BOOLEAN ScanActive
Definition: cc.h:245
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
#define FSRTL_FLAG_LIMIT_MODIFIED_PAGES
Definition: fsrtltypes.h:47
KSPIN_LOCK CcDeferredWriteSpinLock
Definition: view.c:62
ULONG Flags
Definition: ntfs.h:532
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT _In_ PTDI_PNP_CONTEXT Context2
Definition: tdikrnl.h:1094
VOID CcScheduleLazyWriteScan(IN BOOLEAN NoDelay)
Definition: lazywrite.c:200
_In_ PNET_PNP_EVENT _In_ PTDI_PNP_CONTEXT Context1
Definition: tdikrnl.h:1094
struct tagContext Context
Definition: acpixf.h:1024
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ CcFastCopyRead()

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 at line 936 of file copy.c.

943 {
944  LARGE_INTEGER LargeFileOffset;
946 
947  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%lu Length=%lu PageCount=%lu Buffer=%p\n",
948  FileObject, FileOffset, Length, PageCount, Buffer);
949 
950  DBG_UNREFERENCED_PARAMETER(PageCount);
951 
952  LargeFileOffset.QuadPart = FileOffset;
954  &LargeFileOffset,
955  Length,
956  TRUE,
957  Buffer,
958  IoStatus);
959  ASSERT(Success == TRUE);
960 }
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
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:806
unsigned char BOOLEAN
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
LONGLONG QuadPart
Definition: typedefs.h:112

◆ CcFastCopyWrite()

VOID NTAPI CcFastCopyWrite ( IN PFILE_OBJECT  FileObject,
IN ULONG  FileOffset,
IN ULONG  Length,
IN PVOID  Buffer 
)

Definition at line 967 of file copy.c.

972 {
973  LARGE_INTEGER LargeFileOffset;
975 
976  CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%lu Length=%lu Buffer=%p\n",
978 
979  LargeFileOffset.QuadPart = FileOffset;
981  &LargeFileOffset,
982  Length,
983  TRUE,
984  Buffer);
985  ASSERT(Success == TRUE);
986 }
#define TRUE
Definition: types.h:120
unsigned char BOOLEAN
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CC_API_DEBUG
Definition: cc.h:11
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
BOOLEAN NTAPI CcCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN PVOID Buffer)
Definition: copy.c:836
LONGLONG QuadPart
Definition: typedefs.h:112

◆ CcInitCacheZeroPage()

VOID NTAPI CcInitCacheZeroPage ( VOID  )

Definition at line 63 of file copy.c.

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 }
#define TRUE
Definition: types.h:120
#define DbgPrint
Definition: loader.c:25
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:229
#define MC_SYSTEM
Definition: mm.h:95
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
#define MI_SET_USAGE(x)
Definition: mm.h:253
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static PFN_NUMBER CcZeroPage
Definition: copy.c:19
Status
Definition: gdiplustypes.h:24

Referenced by CcInitView().

◆ CcPerformReadAhead()

VOID CcPerformReadAhead ( IN PFILE_OBJECT  FileObject)

Definition at line 486 of file copy.c.

488 {
490  LONGLONG CurrentOffset;
491  KIRQL OldIrql;
492  PROS_SHARED_CACHE_MAP SharedCacheMap;
493  PROS_VACB Vacb;
494  ULONG PartialLength;
496  BOOLEAN Valid;
497  ULONG Length;
498  PPRIVATE_CACHE_MAP PrivateCacheMap;
499  BOOLEAN Locked;
500 
501  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
502 
503  /* Critical:
504  * PrivateCacheMap might disappear in-between if the handle
505  * to the file is closed (private is attached to the handle not to
506  * the file), so we need to lock the master lock while we deal with
507  * it. It won't disappear without attempting to lock such lock.
508  */
510  PrivateCacheMap = FileObject->PrivateCacheMap;
511  /* If the handle was closed since the read ahead was scheduled, just quit */
512  if (PrivateCacheMap == NULL)
513  {
516  return;
517  }
518  /* Otherwise, extract read offset and length and release private map */
519  else
520  {
522  CurrentOffset = PrivateCacheMap->ReadAheadOffset[1].QuadPart;
523  Length = PrivateCacheMap->ReadAheadLength[1];
525  }
527 
528  /* Time to go! */
529  DPRINT("Doing ReadAhead for %p\n", FileObject);
530  /* Lock the file, first */
531  if (!SharedCacheMap->Callbacks->AcquireForReadAhead(SharedCacheMap->LazyWriteContext, FALSE))
532  {
533  Locked = FALSE;
534  goto Clear;
535  }
536 
537  /* Remember it's locked */
538  Locked = TRUE;
539 
540  /* Don't read past the end of the file */
541  if (CurrentOffset >= SharedCacheMap->FileSize.QuadPart)
542  {
543  goto Clear;
544  }
545  if (CurrentOffset + Length > SharedCacheMap->FileSize.QuadPart)
546  {
547  Length = SharedCacheMap->FileSize.QuadPart - CurrentOffset;
548  }
549 
550  /* Next of the algorithm will lock like CcCopyData with the slight
551  * difference that we don't copy data back to an user-backed buffer
552  * We just bring data into Cc
553  */
554  PartialLength = CurrentOffset % VACB_MAPPING_GRANULARITY;
555  if (PartialLength != 0)
556  {
557  PartialLength = min(Length, VACB_MAPPING_GRANULARITY - PartialLength);
558  Status = CcRosRequestVacb(SharedCacheMap,
559  ROUND_DOWN(CurrentOffset,
561  &BaseAddress,
562  &Valid,
563  &Vacb);
564  if (!NT_SUCCESS(Status))
565  {
566  DPRINT1("Failed to request VACB: %lx!\n", Status);
567  goto Clear;
568  }
569 
570  if (!Valid)
571  {
573  if (!NT_SUCCESS(Status))
574  {
575  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
576  DPRINT1("Failed to read data: %lx!\n", Status);
577  goto Clear;
578  }
579  }
580 
581  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
582 
583  Length -= PartialLength;
584  CurrentOffset += PartialLength;
585  }
586 
587  while (Length > 0)
588  {
589  ASSERT(CurrentOffset % VACB_MAPPING_GRANULARITY == 0);
590  PartialLength = min(VACB_MAPPING_GRANULARITY, Length);
591  Status = CcRosRequestVacb(SharedCacheMap,
592  CurrentOffset,
593  &BaseAddress,
594  &Valid,
595  &Vacb);
596  if (!NT_SUCCESS(Status))
597  {
598  DPRINT1("Failed to request VACB: %lx!\n", Status);
599  goto Clear;
600  }
601 
602  if (!Valid)
603  {
605  if (!NT_SUCCESS(Status))
606  {
607  CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
608  DPRINT1("Failed to read data: %lx!\n", Status);
609  goto Clear;
610  }
611  }
612 
613  CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
614 
615  Length -= PartialLength;
616  CurrentOffset += PartialLength;
617  }
618 
619 Clear:
620  /* See previous comment about private cache map */
622  PrivateCacheMap = FileObject->PrivateCacheMap;
623  if (PrivateCacheMap != NULL)
624  {
625  /* Mark read ahead as unactive */
627  InterlockedAnd((volatile long *)&PrivateCacheMap->UlongFlags, ~PRIVATE_CACHE_MAP_READ_AHEAD_ACTIVE);
629  }
631 
632  /* If file was locked, release it */
633  if (Locked)
634  {
635  SharedCacheMap->Callbacks->ReleaseFromReadAhead(SharedCacheMap->LazyWriteContext);
636  }
637 
638  /* And drop our extra reference (See: CcScheduleReadAhead) */
640 
641  return;
642 }
#define InterlockedAnd
Definition: interlocked.h:62
#define TRUE
Definition: types.h:120
Definition: cc.h:201
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:260
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PCACHE_MANAGER_CALLBACKS Callbacks
Definition: cc.h:182
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
KSPIN_LOCK ReadAheadSpinLock
Definition: cctypes.h:83
int64_t LONGLONG
Definition: typedefs.h:66
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:421
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead
Definition: cctypes.h:41
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
Status
Definition: gdiplustypes.h:24
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:30
LARGE_INTEGER ReadAheadOffset[2]
Definition: cctypes.h:81
#define min(a, b)
Definition: monoChain.cc:55
#define DPRINT1
Definition: precomp.h:8
#define VACB_MAPPING_GRANULARITY
PVOID LazyWriteContext
Definition: cc.h:183
LARGE_INTEGER FileSize
Definition: cc.h:175
unsigned int ULONG
Definition: retypes.h:1
void Clear(USHORT Window)
Definition: hardware.c:705
ULONG UlongFlags
Definition: cctypes.h:73
#define PRIVATE_CACHE_MAP_READ_AHEAD_ACTIVE
Definition: cctypes.h:64
NTSTATUS NTAPI CcRosRequestVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
Definition: view.c:996
NTSTATUS NTAPI CcReadVirtualAddress(PROS_VACB Vacb)
Definition: copy.c:81
ULONG ReadAheadLength[2]
Definition: cctypes.h:82
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CcWorkerThread().

◆ CcPostDeferredWrites()

VOID CcPostDeferredWrites ( VOID  )

Definition at line 412 of file copy.c.

413 {
414  ULONG WrittenBytes;
415 
416  /* We'll try to write as much as we can */
417  WrittenBytes = 0;
418  while (TRUE)
419  {
420  KIRQL OldIrql;
421  PLIST_ENTRY ListEntry;
422  PDEFERRED_WRITE DeferredWrite;
423 
424  DeferredWrite = NULL;
425 
426  /* Lock our deferred writes list */
428  for (ListEntry = CcDeferredWrites.Flink;
429  ListEntry != &CcDeferredWrites;
430  ListEntry = ListEntry->Flink)
431  {
432  /* Extract an entry */
433  DeferredWrite = CONTAINING_RECORD(ListEntry, DEFERRED_WRITE, DeferredWriteLinks);
434 
435  /* Compute the modified bytes, based on what we already wrote */
436  WrittenBytes += DeferredWrite->BytesToWrite;
437  /* We overflowed, give up */
438  if (WrittenBytes < DeferredWrite->BytesToWrite)
439  {
440  DeferredWrite = NULL;
441  break;
442  }
443 
444  /* Check we can write */
445  if (CcCanIWrite(DeferredWrite->FileObject, WrittenBytes, FALSE, RetryForceCheckPerFile))
446  {
447  /* We can, so remove it from the list and stop looking for entry */
448  RemoveEntryList(&DeferredWrite->DeferredWriteLinks);
449  break;
450  }
451 
452  /* If we don't accept modified pages, stop here */
453  if (!DeferredWrite->LimitModifiedPages)
454  {
455  DeferredWrite = NULL;
456  break;
457  }
458 
459  /* Reset count as nothing was written yet */
460  WrittenBytes -= DeferredWrite->BytesToWrite;
461  DeferredWrite = NULL;
462  }
464 
465  /* Nothing to write found, give up */
466  if (DeferredWrite == NULL)
467  {
468  break;
469  }
470 
471  /* If we have an event, set it and quit */
472  if (DeferredWrite->Event)
473  {
474  KeSetEvent(DeferredWrite->Event, IO_NO_INCREMENT, FALSE);
475  }
476  /* Otherwise, call the write routine and free the context */
477  else
478  {
479  DeferredWrite->PostRoutine(DeferredWrite->Context1, DeferredWrite->Context2);
480  ExFreePoolWithTag(DeferredWrite, 'CcDw');
481  }
482  }
483 }
BOOLEAN LimitModifiedPages
Definition: cctypes.h:178
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI CcCanIWrite(IN PFILE_OBJECT FileObject, IN ULONG BytesToWrite, IN BOOLEAN Wait, IN BOOLEAN Retrying)
Definition: copy.c:649
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY DeferredWriteLinks
Definition: cctypes.h:173
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LIST_ENTRY CcDeferredWrites
Definition: view.c:61
KSPIN_LOCK CcDeferredWriteSpinLock
Definition: view.c:62
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
PFILE_OBJECT FileObject
Definition: cctypes.h:171
PVOID Context1
Definition: cctypes.h:176
PCC_POST_DEFERRED_WRITE PostRoutine
Definition: cctypes.h:175
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
ULONG BytesToWrite
Definition: cctypes.h:172
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PKEVENT Event
Definition: cctypes.h:174
PVOID Context2
Definition: cctypes.h:177

Referenced by CcCanIWrite(), CcDeferWrite(), and CcLazyWriteScan().

◆ CcReadVirtualAddress()

NTSTATUS NTAPI CcReadVirtualAddress ( PROS_VACB  Vacb)

Definition at line 81 of file copy.c.

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 
100  ASSERT(Size > 0);
101 
102  Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
103  if (!Mdl)
104  {
106  }
107 
109  _SEH2_TRY
110  {
112  }
114  {
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;
125  if (Status == STATUS_PENDING)
126  {
128  Status = IoStatus.Status;
129  }
130 
131  MmUnlockPages(Mdl);
132  }
133 
134  IoFreeMdl(Mdl);
135 
137  {
138  DPRINT1("IoPageRead failed, Status %x\n", Status);
139  return Status;
140  }
141 
143  {
144  RtlZeroMemory((char*)Vacb->BaseAddress + Size,
146  }
147 
148  return STATUS_SUCCESS;
149 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PVOID BaseAddress
Definition: cc.h:204
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
LONG NTSTATUS
Definition: precomp.h:26
$ULONG LowPart
Definition: ntbasedef.h:576
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
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:1199
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
_SEH2_TRY
Definition: create.c:4250
#define STATUS_END_OF_FILE
Definition: shellext.h:62
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define ROUND_TO_PAGES(Size)
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER FileOffset
Definition: cc.h:221
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
PFILE_OBJECT FileObject
Definition: cc.h:178
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CcCopyData(), CcPerformReadAhead(), CcpMapData(), and MiReadPage().

◆ CcWriteVirtualAddress()

NTSTATUS NTAPI CcWriteVirtualAddress ( PROS_VACB  Vacb)

Definition at line 153 of file copy.c.

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 
182  ASSERT(Size > 0);
183 
184  Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
185  if (!Mdl)
186  {
188  }
189 
191  _SEH2_TRY
192  {
194  }
196  {
198  DPRINT1("MmProbeAndLockPages failed with: %lx for %p (%p, %p)\n", Status, Mdl, Vacb, Vacb->BaseAddress);
199  KeBugCheck(CACHE_MANAGER);
200  } _SEH2_END;
201 
202  if (NT_SUCCESS(Status))
203  {
206  if (Status == STATUS_PENDING)
207  {
209  Status = IoStatus.Status;
210  }
211 
212  MmUnlockPages(Mdl);
213  }
214  IoFreeMdl(Mdl);
216  {
217  DPRINT1("IoPageWrite failed, Status %x\n", Status);
218  return Status;
219  }
220 
221  return STATUS_SUCCESS;
222 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PVOID BaseAddress
Definition: cc.h:204
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
LONG NTSTATUS
Definition: precomp.h:26
$ULONG LowPart
Definition: ntbasedef.h:576
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
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
_SEH2_TRY
Definition: create.c:4250
#define STATUS_END_OF_FILE
Definition: shellext.h:62
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
PFN_NUMBER NTAPI MmGetPfnForProcess(struct _EPROCESS *Process, PVOID Address)
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:1144
#define DPRINT1
Definition: precomp.h:8
LARGE_INTEGER FileOffset
Definition: cc.h:221
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
PFILE_OBJECT FileObject
Definition: cc.h:178
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CcRosFlushVacb().

◆ CcZeroData()

BOOLEAN NTAPI CcZeroData ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  StartOffset,
IN PLARGE_INTEGER  EndOffset,
IN BOOLEAN  Wait 
)

Definition at line 993 of file copy.c.

998 {
1000  LARGE_INTEGER WriteOffset;
1001  LONGLONG Length;
1002  ULONG CurrentLength;
1003  PMDL Mdl;
1004  ULONG i;
1006  KEVENT Event;
1007 
1008  CCTRACE(CC_API_DEBUG, "FileObject=%p StartOffset=%I64u EndOffset=%I64u Wait=%d\n",
1009  FileObject, StartOffset->QuadPart, EndOffset->QuadPart, Wait);
1010 
1011  DPRINT("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
1012  "Wait %u)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart,
1013  Wait);
1014 
1015  Length = EndOffset->QuadPart - StartOffset->QuadPart;
1016  WriteOffset.QuadPart = StartOffset->QuadPart;
1017 
1018  if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
1019  {
1020  /* File is not cached */
1021 
1022  Mdl = _alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
1023 
1024  while (Length > 0)
1025  {
1026  if (Length + WriteOffset.QuadPart % PAGE_SIZE > MAX_ZERO_LENGTH)
1027  {
1028  CurrentLength = MAX_ZERO_LENGTH - WriteOffset.QuadPart % PAGE_SIZE;
1029  }
1030  else
1031  {
1032  CurrentLength = Length;
1033  }
1034  MmInitializeMdl(Mdl, (PVOID)(ULONG_PTR)WriteOffset.QuadPart, CurrentLength);
1035  Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
1036  for (i = 0; i < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); i++)
1037  {
1038  ((PPFN_NUMBER)(Mdl + 1))[i] = CcZeroPage;
1039  }
1041  Status = IoSynchronousPageWrite(FileObject, Mdl, &WriteOffset, &Event, &Iosb);
1042  if (Status == STATUS_PENDING)
1043  {
1045  Status = Iosb.Status;
1046  }
1047  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
1048  {
1049  MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
1050  }
1051  if (!NT_SUCCESS(Status))
1052  {
1053  return FALSE;
1054  }
1055  WriteOffset.QuadPart += CurrentLength;
1056  Length -= CurrentLength;
1057  }
1058  }
1059  else
1060  {
1062 
1063  return CcCopyData(FileObject,
1064  WriteOffset.QuadPart,
1065  NULL,
1066  Length,
1068  Wait,
1069  &IoStatus);
1070  }
1071 
1072  return TRUE;
1073 }
#define MDL_IO_PAGE_READ
Definition: mmtypes.h:24
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:257
#define TRUE
Definition: types.h:120
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
LONG NTSTATUS
Definition: precomp.h:26
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
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG * PPFN_NUMBER
Definition: ke.h:8
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
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
int64_t LONGLONG
Definition: typedefs.h:66
#define CC_API_DEBUG
Definition: cc.h:11
return Iosb
Definition: create.c:4426
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define CCTRACE(x, fmt,...)
Definition: cc.h:36
static PFN_NUMBER CcZeroPage
Definition: copy.c:19
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
MDL
Definition: mmtypes.h:117
SIZE_T NTAPI MmSizeOfMdl(IN PVOID Base, IN SIZE_T Length)
Definition: mdlsup.c:413
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
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:1144
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:112
IN BOOLEAN Wait
Definition: fatprocs.h:1529
#define MAX_ZERO_LENGTH
Definition: copy.c:21

◆ MiZeroPhysicalPage()

VOID NTAPI MiZeroPhysicalPage ( IN PFN_NUMBER  PageFrameIndex)

Definition at line 122 of file pfnlist.c.

123 {
124  KIRQL OldIrql;
127 
128  /* Map in hyperspace, then wipe it using XMMI or MEMSET */
133 }
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PVOID NTAPI MiMapPageInHyperSpace(IN PEPROCESS Process, IN PFN_NUMBER Page, IN PKIRQL OldIrql)
Definition: hypermap.c:30
VOID FASTCALL KeZeroPages(IN PVOID Address, IN ULONG Size)
Definition: stubs.c:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI MiUnmapPageInHyperSpace(IN PEPROCESS Process, IN PVOID Address, IN KIRQL OldIrql)
Definition: hypermap.c:93
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define PAGE_SIZE
Definition: env_spec_w32.h:49
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by CcInitCacheZeroPage(), MiAllocatePagesForMdl(), MiSessionCreateInternal(), MiSessionInitializeWorkingSetList(), and MmCreateProcessAddressSpace().

◆ ReadWriteOrZero()

NTSTATUS ReadWriteOrZero ( _Inout_ PVOID  BaseAddress,
_Inout_opt_ PVOID  Buffer,
_In_ ULONG  Length,
_In_ CC_COPY_OPERATION  Operation 
)

Definition at line 225 of file copy.c.

230 {
232 
233  if (Operation == CcOperationZero)
234  {
235  /* Zero */
237  }
238  else
239  {
240  _SEH2_TRY
241  {
244  else
246  }
248  {
250  }
251  _SEH2_END;
252  }
253  return Status;
254 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
Definition: bufpool.h:45
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
#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
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by CcCopyData().

Variable Documentation

◆ CcDataFlushes

ULONG CcDataFlushes = 0

Definition at line 51 of file copy.c.

Referenced by IoSynchronousPageWrite(), and QSI_DEF().

◆ CcDataPages

ULONG CcDataPages = 0

Definition at line 50 of file copy.c.

Referenced by IoSynchronousPageWrite(), and QSI_DEF().

◆ CcFastMdlReadNotPossible

ULONG CcFastMdlReadNotPossible

Definition at line 40 of file copy.c.

◆ CcFastMdlReadWait

ULONG CcFastMdlReadWait

Definition at line 39 of file copy.c.

◆ CcFastReadNotPossible

ULONG CcFastReadNotPossible

Definition at line 41 of file copy.c.

◆ CcFastReadNoWait

ULONG CcFastReadNoWait

Definition at line 43 of file copy.c.

◆ CcFastReadResourceMiss

ULONG CcFastReadResourceMiss

Definition at line 44 of file copy.c.

◆ CcFastReadWait

ULONG CcFastReadWait

Definition at line 42 of file copy.c.

◆ CcRosTraceLevel

ULONG CcRosTraceLevel = 0

Definition at line 38 of file copy.c.

◆ CcZeroPage

PFN_NUMBER CcZeroPage = 0
static

Definition at line 19 of file copy.c.

Referenced by CcInitCacheZeroPage(), and CcZeroData().