ReactOS  0.4.14-dev-337-gf981a68
cc.h File Reference

Go to the source code of this file.

Classes

struct  _PF_SCENARIO_ID
 
struct  _PF_LOG_ENTRY
 
struct  _PFSN_LOG_ENTRIES
 
struct  _PF_SECTION_INFO
 
struct  _PF_TRACE_HEADER
 
struct  _PFSN_TRACE_DUMP
 
struct  _PFSN_TRACE_HEADER
 
struct  _PFSN_PREFETCHER_GLOBALS
 
struct  _ROS_SHARED_CACHE_MAP
 
struct  _ROS_VACB
 
struct  _INTERNAL_BCB
 
struct  _LAZY_WRITER
 
struct  _WORK_QUEUE_ENTRY
 

Macros

#define _CC_DEBUG_   0x00
 
#define CC_API_DEBUG   0x01
 
#define CCTRACE(x, fmt, ...)   DPRINT(fmt, ##__VA_ARGS__)
 
#define READAHEAD_DISABLED   0x1
 
#define WRITEBEHIND_DISABLED   0x2
 
#define NODE_TYPE_DEFERRED_WRITE   0x02FC
 
#define NODE_TYPE_PRIVATE_MAP   0x02FE
 
#define NODE_TYPE_SHARED_MAP   0x02FF
 
#define CcBugCheck(A, B, C)   KeBugCheckEx(CACHE_MANAGER, BugCheckFileId | ((ULONG)(__LINE__)), A, B, C)
 
#define CcRosVacbIncRefCount(vacb)   InterlockedIncrement((PLONG)&(vacb)->ReferenceCount)
 
#define CcRosVacbGetRefCount(vacb)   InterlockedCompareExchange((PLONG)&(vacb)->ReferenceCount, 0, 0)
 

Typedefs

typedef struct _PF_SCENARIO_ID PF_SCENARIO_ID
 
typedef struct _PF_SCENARIO_IDPPF_SCENARIO_ID
 
typedef struct _PF_LOG_ENTRY PF_LOG_ENTRY
 
typedef struct _PF_LOG_ENTRYPPF_LOG_ENTRY
 
typedef struct _PFSN_LOG_ENTRIES PFSN_LOG_ENTRIES
 
typedef struct _PFSN_LOG_ENTRIESPPFSN_LOG_ENTRIES
 
typedef struct _PF_SECTION_INFO PF_SECTION_INFO
 
typedef struct _PF_SECTION_INFOPPF_SECTION_INFO
 
typedef struct _PF_TRACE_HEADER PF_TRACE_HEADER
 
typedef struct _PF_TRACE_HEADERPPF_TRACE_HEADER
 
typedef struct _PFSN_TRACE_DUMP PFSN_TRACE_DUMP
 
typedef struct _PFSN_TRACE_DUMPPPFSN_TRACE_DUMP
 
typedef struct _PFSN_TRACE_HEADER PFSN_TRACE_HEADER
 
typedef struct _PFSN_TRACE_HEADERPPFSN_TRACE_HEADER
 
typedef struct _PFSN_PREFETCHER_GLOBALS PFSN_PREFETCHER_GLOBALS
 
typedef struct _PFSN_PREFETCHER_GLOBALSPPFSN_PREFETCHER_GLOBALS
 
typedef struct _ROS_SHARED_CACHE_MAP ROS_SHARED_CACHE_MAP
 
typedef struct _ROS_SHARED_CACHE_MAPPROS_SHARED_CACHE_MAP
 
typedef struct _ROS_VACB ROS_VACB
 
typedef struct _ROS_VACBPROS_VACB
 
typedef struct _INTERNAL_BCB INTERNAL_BCB
 
typedef struct _INTERNAL_BCBPINTERNAL_BCB
 
typedef struct _LAZY_WRITER LAZY_WRITER
 
typedef struct _LAZY_WRITERPLAZY_WRITER
 
typedef struct _WORK_QUEUE_ENTRY WORK_QUEUE_ENTRY
 
typedef struct _WORK_QUEUE_ENTRYPWORK_QUEUE_ENTRY
 
typedef enum _WORK_QUEUE_FUNCTIONS WORK_QUEUE_FUNCTIONS
 
typedef enum _WORK_QUEUE_FUNCTIONSPWORK_QUEUE_FUNCTIONS
 

Enumerations

enum  _WORK_QUEUE_FUNCTIONS { ReadAhead = 1, WriteBehind = 2, LazyScan = 3, SetDone = 4 }
 

Functions

INIT_FUNCTION VOID NTAPI CcPfInitializePrefetcher (VOID)
 
VOID NTAPI CcMdlReadComplete2 (IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList)
 
VOID NTAPI CcMdlWriteComplete2 (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain)
 
NTSTATUS NTAPI CcRosFlushVacb (PROS_VACB Vacb)
 
NTSTATUS NTAPI CcRosGetVacb (PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PLONGLONG BaseOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
 
INIT_FUNCTION VOID NTAPI CcInitView (VOID)
 
VOID NTAPI CcShutdownLazyWriter (VOID)
 
NTSTATUS NTAPI CcReadVirtualAddress (PROS_VACB Vacb)
 
NTSTATUS NTAPI CcWriteVirtualAddress (PROS_VACB Vacb)
 
INIT_FUNCTION BOOLEAN NTAPI CcInitializeCacheManager (VOID)
 
NTSTATUS NTAPI CcRosUnmapVacb (PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, BOOLEAN NowDirty)
 
PROS_VACB NTAPI CcRosLookupVacb (PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
 
VOID NTAPI CcInitCacheZeroPage (VOID)
 
NTSTATUS NTAPI CcRosMarkDirtyFile (PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
 
VOID NTAPI CcRosMarkDirtyVacb (PROS_VACB Vacb)
 
VOID NTAPI CcRosUnmarkDirtyVacb (PROS_VACB Vacb, BOOLEAN LockViews)
 
NTSTATUS NTAPI CcRosFlushDirtyPages (ULONG Target, PULONG Count, BOOLEAN Wait, BOOLEAN CalledFromLazy)
 
VOID NTAPI CcRosDereferenceCache (PFILE_OBJECT FileObject)
 
VOID NTAPI CcRosReferenceCache (PFILE_OBJECT FileObject)
 
VOID NTAPI CcRosRemoveIfClosed (PSECTION_OBJECT_POINTERS SectionObjectPointer)
 
NTSTATUS NTAPI CcRosReleaseVacb (PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
 
NTSTATUS NTAPI CcRosRequestVacb (PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
 
NTSTATUS NTAPI CcRosInitializeFileCache (PFILE_OBJECT FileObject, PCC_FILE_SIZES FileSizes, BOOLEAN PinAccess, PCACHE_MANAGER_CALLBACKS CallBacks, PVOID LazyWriterContext)
 
NTSTATUS NTAPI CcRosReleaseFileCache (PFILE_OBJECT FileObject)
 
VOID NTAPI CcShutdownSystem (VOID)
 
VOID NTAPI CcWorkerThread (PVOID Parameter)
 
VOID NTAPI CcScanDpc (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID CcScheduleLazyWriteScan (BOOLEAN NoDelay)
 
VOID CcPostDeferredWrites (VOID)
 
VOID CcPostWorkQueue (IN PWORK_QUEUE_ENTRY WorkItem, IN PLIST_ENTRY WorkQueue)
 
VOID CcPerformReadAhead (IN PFILE_OBJECT FileObject)
 
NTSTATUS CcRosInternalFreeVacb (IN PROS_VACB Vacb)
 
FORCEINLINE BOOLEAN DoRangesIntersect (_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Offset2, _In_ LONGLONG Length2)
 
FORCEINLINE BOOLEAN IsPointInRange (_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Point)
 
FORCEINLINE ULONG CcRosVacbDecRefCount (PROS_VACB vacb)
 

Variables

ULONG CcRosTraceLevel
 
LIST_ENTRY DirtyVacbListHead
 
ULONG CcDirtyPageThreshold
 
ULONG CcTotalDirtyPages
 
LIST_ENTRY CcDeferredWrites
 
KSPIN_LOCK CcDeferredWriteSpinLock
 
ULONG CcNumberWorkerThreads
 
LIST_ENTRY CcIdleWorkerThreadList
 
LIST_ENTRY CcExpressWorkQueue
 
LIST_ENTRY CcRegularWorkQueue
 
LIST_ENTRY CcPostTickWorkQueue
 
NPAGED_LOOKASIDE_LIST CcTwilightLookasideList
 
LARGE_INTEGER CcIdleDelay
 
ULONG CcLazyWritePages
 
ULONG CcLazyWriteIos
 
ULONG CcMapDataWait
 
ULONG CcMapDataNoWait
 
ULONG CcPinReadWait
 
ULONG CcPinReadNoWait
 
ULONG CcPinMappedDataCount
 
ULONG CcDataPages
 
ULONG CcDataFlushes
 
LAZY_WRITER LazyWriter
 

Macro Definition Documentation

◆ _CC_DEBUG_

#define _CC_DEBUG_   0x00

Definition at line 6 of file cc.h.

◆ CC_API_DEBUG

#define CC_API_DEBUG   0x01

Definition at line 11 of file cc.h.

◆ CcBugCheck

#define CcBugCheck (   A,
  B,
  C 
)    KeBugCheckEx(CACHE_MANAGER, BugCheckFileId | ((ULONG)(__LINE__)), A, B, C)

Definition at line 502 of file cc.h.

◆ CcRosVacbGetRefCount

#define CcRosVacbGetRefCount (   vacb)    InterlockedCompareExchange((PLONG)&(vacb)->ReferenceCount, 0, 0)

Definition at line 543 of file cc.h.

◆ CcRosVacbIncRefCount

#define CcRosVacbIncRefCount (   vacb)    InterlockedIncrement((PLONG)&(vacb)->ReferenceCount)

Definition at line 528 of file cc.h.

◆ CCTRACE

#define CCTRACE (   x,
  fmt,
  ... 
)    DPRINT(fmt, ##__VA_ARGS__)

Definition at line 36 of file cc.h.

◆ NODE_TYPE_DEFERRED_WRITE

#define NODE_TYPE_DEFERRED_WRITE   0x02FC

Definition at line 285 of file cc.h.

◆ NODE_TYPE_PRIVATE_MAP

#define NODE_TYPE_PRIVATE_MAP   0x02FE

Definition at line 286 of file cc.h.

◆ NODE_TYPE_SHARED_MAP

#define NODE_TYPE_SHARED_MAP   0x02FF

Definition at line 287 of file cc.h.

◆ READAHEAD_DISABLED

#define READAHEAD_DISABLED   0x1

Definition at line 198 of file cc.h.

◆ WRITEBEHIND_DISABLED

#define WRITEBEHIND_DISABLED   0x2

Definition at line 199 of file cc.h.

Typedef Documentation

◆ INTERNAL_BCB

◆ LAZY_WRITER

◆ PF_LOG_ENTRY

◆ PF_SCENARIO_ID

◆ PF_SECTION_INFO

◆ PF_TRACE_HEADER

◆ PFSN_LOG_ENTRIES

◆ PFSN_PREFETCHER_GLOBALS

◆ PFSN_TRACE_DUMP

◆ PFSN_TRACE_HEADER

◆ PINTERNAL_BCB

◆ PLAZY_WRITER

◆ PPF_LOG_ENTRY

◆ PPF_SCENARIO_ID

◆ PPF_SECTION_INFO

◆ PPF_TRACE_HEADER

◆ PPFSN_LOG_ENTRIES

◆ PPFSN_PREFETCHER_GLOBALS

◆ PPFSN_TRACE_DUMP

◆ PPFSN_TRACE_HEADER

◆ PROS_SHARED_CACHE_MAP

◆ PROS_VACB

◆ PWORK_QUEUE_ENTRY

◆ PWORK_QUEUE_FUNCTIONS

◆ ROS_SHARED_CACHE_MAP

◆ ROS_VACB

◆ WORK_QUEUE_ENTRY

◆ WORK_QUEUE_FUNCTIONS

Enumeration Type Documentation

◆ _WORK_QUEUE_FUNCTIONS

Enumerator
ReadAhead 
WriteBehind 
LazyScan 
SetDone 

Definition at line 275 of file cc.h.

276 {
277  ReadAhead = 1,
278  WriteBehind = 2,
279  LazyScan = 3,
280  SetDone = 4,
Definition: cc.h:279
Definition: cc.h:280
Definition: cc.h:277
enum _WORK_QUEUE_FUNCTIONS WORK_QUEUE_FUNCTIONS
enum _WORK_QUEUE_FUNCTIONS * PWORK_QUEUE_FUNCTIONS

Function Documentation

◆ 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

◆ CcInitializeCacheManager()

INIT_FUNCTION BOOLEAN NTAPI CcInitializeCacheManager ( VOID  )

Definition at line 82 of file fssup.c.

83 {
84  int i;
85 
86  DPRINT("Initialize\n");
87  for (i = 0; i < CACHE_NUM_SECTIONS; i++)
88  {
89  KeInitializeEvent(&CcCacheSections[i].ExclusiveWait,
91  FALSE);
92 
93  InitializeListHead(&CcCacheSections[i].ThisFileList);
94  }
95 
97 
101 
104  DPRINT1("Cache has %d entries\n", CcCacheBitmap->SizeOfBitMap);
106 
107  return TRUE;
108 }
KEVENT CcpLazyWriteEvent
Definition: lazyrite.c:18
PULONG Buffer
Definition: typedefs.h:89
#define TRUE
Definition: types.h:120
FAST_MUTEX CcMutex
Definition: pinsup.c:101
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
#define CACHE_NUM_SECTIONS
Definition: newcc.h:130
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
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
KEVENT CcDeleteEvent
Definition: pinsup.c:102
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
KEVENT CcFinalizeEvent
Definition: pinsup.c:103
PRTL_BITMAP CcCacheBitmap
Definition: pinsup.c:100
ULONG SizeOfBitMap
Definition: typedefs.h:88
LIST_ENTRY CcpAllSharedCacheMaps
Definition: fssup.c:76
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8

Referenced by Phase1InitializationDiscard().

◆ CcInitView()

INIT_FUNCTION VOID NTAPI CcInitView ( VOID  )

Definition at line 1535 of file view.c.

1537 {
1538  DPRINT("CcInitView()\n");
1539 
1546  NULL,
1547  NULL,
1548  0,
1549  sizeof(INTERNAL_BCB),
1550  TAG_BCB,
1551  20);
1553  NULL,
1554  NULL,
1555  0,
1556  sizeof(ROS_SHARED_CACHE_MAP),
1558  20);
1560  NULL,
1561  NULL,
1562  0,
1563  sizeof(ROS_VACB),
1564  TAG_VACB,
1565  20);
1566 
1568 
1570 }
Definition: cc.h:201
#define TAG_VACB
Definition: tag.h:5
static NPAGED_LOOKASIDE_LIST VacbLookasideList
Definition: view.c:50
#define TAG_BCB
Definition: nodetype.h:157
static LIST_ENTRY VacbLruListHead
Definition: view.c:46
#define TAG_SHARED_CACHE_MAP
Definition: tag.h:6
NTSTATUS CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
Definition: view.c:290
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LIST_ENTRY CcCleanSharedCacheMapList
Definition: view.c:63
VOID NTAPI CcInitCacheZeroPage(VOID)
Definition: copy.c:63
INIT_FUNCTION VOID NTAPI MmInitializeMemoryConsumer(ULONG Consumer, NTSTATUS(*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed))
Definition: balance.c:82
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:222
static NPAGED_LOOKASIDE_LIST SharedCacheMapLookasideList
Definition: view.c:49
LIST_ENTRY CcDeferredWrites
Definition: view.c:61
KSPIN_LOCK CcDeferredWriteSpinLock
Definition: view.c:62
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NPAGED_LOOKASIDE_LIST iBcbLookasideList
Definition: view.c:48
#define MC_CACHE
Definition: mm.h:93
LIST_ENTRY DirtyVacbListHead
Definition: view.c:45

◆ CcMdlReadComplete2()

VOID NTAPI CcMdlReadComplete2 ( IN PFILE_OBJECT  FileObject,
IN PMDL  MemoryDescriptorList 
)

Definition at line 83 of file mdlsup.c.

85 {
87 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CcMdlReadComplete(), and FsRtlMdlReadCompleteDev().

◆ CcMdlWriteComplete2()

VOID NTAPI CcMdlWriteComplete2 ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN PMDL  MdlChain 
)

Definition at line 111 of file mdlsup.c.

114 {
116 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CcMdlWriteComplete(), and FsRtlMdlWriteCompleteDev().

◆ 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().

◆ CcPfInitializePrefetcher()

INIT_FUNCTION VOID NTAPI CcPfInitializePrefetcher ( VOID  )

Definition at line 112 of file fssup.c.

113 {
114  /* Notify debugger */
117  "CCPF: InitializePrefetecher()\n");
118 
119  /* Setup the Prefetcher Data */
123 
124  /* FIXME: Setup the rest of the prefetecher */
125 }
FAST_MUTEX CompletedTracesLock
Definition: cc.h:164
NTSYSAPI ULONG __cdecl DbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ _Printf_format_string_ PCSTR Format,...)
LIST_ENTRY CompletedTraces
Definition: cc.h:163
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
PFSN_PREFETCHER_GLOBALS CcPfGlobals
Definition: fssup.c:20
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ActiveTraces
Definition: cc.h:160
#define DPFLTR_TRACE_LEVEL
Definition: kdtypes.h:32

Referenced by Phase1InitializationDiscard().

◆ 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().

◆ CcPostWorkQueue()

VOID CcPostWorkQueue ( IN PWORK_QUEUE_ENTRY  WorkItem,
IN PLIST_ENTRY  WorkQueue 
)

Definition at line 53 of file lazywrite.c.

56 {
57  KIRQL OldIrql;
58  PWORK_QUEUE_ITEM ThreadToSpawn;
59 
60  /* First of all, insert the item in the queue */
62  InsertTailList(WorkQueue, &WorkItem->WorkQueueLinks);
63 
64  /* Now, define whether we have to spawn a new work thread
65  * We will spawn a new one if:
66  * - There's no throttle in action
67  * - There's still at least one idle thread
68  */
69  ThreadToSpawn = NULL;
71  {
72  PLIST_ENTRY ListEntry;
73 
74  /* Get the idle thread */
76  ThreadToSpawn = CONTAINING_RECORD(ListEntry, WORK_QUEUE_ITEM, List);
77 
78  /* We're going to have one more! */
80  }
81 
83 
84  /* If we have a thread to spawn, do it! */
85  if (ThreadToSpawn != NULL)
86  {
87  /* We NULLify it to be consistent with initialization */
88  ThreadToSpawn->List.Flink = NULL;
89  ExQueueWorkItem(ThreadToSpawn, CriticalWorkQueue);
90  }
91 }
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
LIST_ENTRY List
Definition: extypes.h:203
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY CcIdleWorkerThreadList
Definition: lazywrite.c:41
LIST_ENTRY WorkQueue
Definition: workqueue.c:20
ULONG CcNumberActiveWorkerThreads
Definition: lazywrite.c:44
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
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 List
Definition: psmgr.c:57
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
BOOLEAN CcQueueThrottle
Definition: lazywrite.c:43

Referenced by CcLazyWriteScan(), CcScanDpc(), and CcScheduleReadAhead().

◆ 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:67
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:2938
LONGLONG QuadPart
Definition: typedefs.h:112

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

◆ CcRosDereferenceCache()

VOID NTAPI CcRosDereferenceCache ( PFILE_OBJECT  FileObject)

Definition at line 1305 of file view.c.

1307 {
1308  PROS_SHARED_CACHE_MAP SharedCacheMap;
1309  KIRQL OldIrql;
1310 
1312  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
1313  ASSERT(SharedCacheMap);
1314  if (SharedCacheMap->OpenCount > 0)
1315  {
1316  SharedCacheMap->OpenCount--;
1317  if (SharedCacheMap->OpenCount == 0)
1318  {
1320  MmFreeSectionSegments(SharedCacheMap->FileObject);
1321 
1323  CcRosDeleteFileCache(FileObject, SharedCacheMap, &OldIrql);
1325 
1326  return;
1327  }
1328  }
1330 }
ULONG OpenCount
Definition: cc.h:174
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject)
Definition: section.c:807
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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
NTSTATUS NTAPI CcRosDeleteFileCache(PFILE_OBJECT FileObject, PROS_SHARED_CACHE_MAP SharedCacheMap, PKIRQL OldIrql)
Definition: view.c:1159
PFILE_OBJECT FileObject
Definition: cc.h:178

Referenced by MmpDeleteSection().

◆ CcRosFlushDirtyPages()

NTSTATUS NTAPI CcRosFlushDirtyPages ( ULONG  Target,
PULONG  Count,
BOOLEAN  Wait,
BOOLEAN  CalledFromLazy 
)

Definition at line 183 of file view.c.

188 {
189  PLIST_ENTRY current_entry;
191  BOOLEAN Locked;
193  KIRQL OldIrql;
194 
195  DPRINT("CcRosFlushDirtyPages(Target %lu)\n", Target);
196 
197  (*Count) = 0;
198 
201 
202  current_entry = DirtyVacbListHead.Flink;
203  if (current_entry == &DirtyVacbListHead)
204  {
205  DPRINT("No Dirty pages\n");
206  }
207 
208  while ((current_entry != &DirtyVacbListHead) && (Target > 0))
209  {
210  current = CONTAINING_RECORD(current_entry,
211  ROS_VACB,
212  DirtyVacbListEntry);
213  current_entry = current_entry->Flink;
214 
216 
217  /* When performing lazy write, don't handle temporary files */
218  if (CalledFromLazy &&
219  BooleanFlagOn(current->SharedCacheMap->FileObject->Flags, FO_TEMPORARY_FILE))
220  {
222  continue;
223  }
224 
225  /* Don't attempt to lazy write the files that asked not to */
226  if (CalledFromLazy &&
227  BooleanFlagOn(current->SharedCacheMap->Flags, WRITEBEHIND_DISABLED))
228  {
230  continue;
231  }
232 
233  ASSERT(current->Dirty);
234 
236 
237  Locked = current->SharedCacheMap->Callbacks->AcquireForLazyWrite(
238  current->SharedCacheMap->LazyWriteContext, Wait);
239  if (!Locked)
240  {
243  continue;
244  }
245 
247 
248  current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
249  current->SharedCacheMap->LazyWriteContext);
250 
253 
254  if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE) &&
256  {
257  DPRINT1("CC: Failed to flush VACB.\n");
258  }
259  else
260  {
261  ULONG PagesFreed;
262 
263  /* How many pages did we free? */
264  PagesFreed = VACB_MAPPING_GRANULARITY / PAGE_SIZE;
265  (*Count) += PagesFreed;
266 
267  /* Make sure we don't overflow target! */
268  if (Target < PagesFreed)
269  {
270  /* If we would have, jump to zero directly */
271  Target = 0;
272  }
273  else
274  {
275  Target -= PagesFreed;
276  }
277  }
278 
279  current_entry = DirtyVacbListHead.Flink;
280  }
281 
284 
285  DPRINT("CcRosFlushDirtyPages() finished\n");
286  return STATUS_SUCCESS;
287 }
Definition: cc.h:201
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_END_OF_FILE
Definition: shellext.h:67
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:260
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#define WRITEBEHIND_DISABLED
Definition: cc.h:199
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:531
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define CcRosVacbIncRefCount(vacb)
Definition: cc.h:528
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
Status
Definition: gdiplustypes.h:24
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
#define FO_TEMPORARY_FILE
Definition: iotypes.h:1748
#define DPRINT1
Definition: precomp.h:8
#define VACB_MAPPING_GRANULARITY
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI CcRosFlushVacb(PROS_VACB Vacb)
Definition: view.c:165
return STATUS_SUCCESS
Definition: btrfs.c:2938
LIST_ENTRY DirtyVacbListHead
Definition: view.c:45
struct task_struct * current
Definition: linux.c:32
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by CcRosTrimCache(), CcWriteBehind(), and NtSetSystemPowerState().

◆ CcRosFlushVacb()

NTSTATUS NTAPI CcRosFlushVacb ( PROS_VACB  Vacb)

Definition at line 165 of file view.c.

167 {
169 
170  CcRosUnmarkDirtyVacb(Vacb, TRUE);
171 
173  if (!NT_SUCCESS(Status))
174  {
175  CcRosMarkDirtyVacb(Vacb);
176  }
177 
178  return Status;
179 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI CcWriteVirtualAddress(PROS_VACB Vacb)
Definition: copy.c:153
Status
Definition: gdiplustypes.h:24
VOID NTAPI CcRosMarkDirtyVacb(PROS_VACB Vacb)
Definition: view.c:502
VOID NTAPI CcRosUnmarkDirtyVacb(PROS_VACB Vacb, BOOLEAN LockViews)
Definition: view.c:538

Referenced by CcFlushCache(), CcRosFlushDirtyPages(), and CcUnpinRepinnedBcb().

◆ CcRosGetVacb()

NTSTATUS NTAPI CcRosGetVacb ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
LONGLONG  FileOffset,
PLONGLONG  BaseOffset,
PVOID BaseAddress,
PBOOLEAN  UptoDate,
PROS_VACB Vacb 
)

Definition at line 937 of file view.c.

944 {
947  ULONG Refs;
948  KIRQL OldIrql;
949 
950  ASSERT(SharedCacheMap);
951 
952  DPRINT("CcRosGetVacb()\n");
953 
954  /*
955  * Look for a VACB already mapping the same data.
956  */
957  current = CcRosLookupVacb(SharedCacheMap, FileOffset);
958  if (current == NULL)
959  {
960  /*
961  * Otherwise create a new VACB.
962  */
963  Status = CcRosCreateVacb(SharedCacheMap, FileOffset, &current);
964  if (!NT_SUCCESS(Status))
965  {
966  return Status;
967  }
968  }
969 
971 
973 
974  /* Move to the tail of the LRU list */
975  RemoveEntryList(&current->VacbLruListEntry);
976  InsertTailList(&VacbLruListHead, &current->VacbLruListEntry);
977 
979 
980  /*
981  * Return information about the VACB to the caller.
982  */
983  *UptoDate = current->Valid;
984  *BaseAddress = current->BaseAddress;
985  DPRINT("*BaseAddress %p\n", *BaseAddress);
986  *Vacb = current;
987  *BaseOffset = current->FileOffset.QuadPart;
988 
989  ASSERT(Refs > 1);
990 
991  return STATUS_SUCCESS;
992 }
Definition: cc.h:201
LONG NTSTATUS
Definition: precomp.h:26
static LIST_ENTRY VacbLruListHead
Definition: view.c:46
#define InsertTailList(ListHead, Entry)
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
void DPRINT(...)
Definition: polytest.cpp:61
#define CcRosVacbGetRefCount(vacb)
Definition: cc.h:543
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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
Status
Definition: gdiplustypes.h:24
static NTSTATUS CcRosCreateVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PROS_VACB *Vacb)
Definition: view.c:780
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
PROS_VACB NTAPI CcRosLookupVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
Definition: view.c:458
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
struct task_struct * current
Definition: linux.c:32

Referenced by CcpMapData(), CcRosRequestVacb(), and MiReadPage().

◆ CcRosInitializeFileCache()

NTSTATUS NTAPI CcRosInitializeFileCache ( PFILE_OBJECT  FileObject,
PCC_FILE_SIZES  FileSizes,
BOOLEAN  PinAccess,
PCACHE_MANAGER_CALLBACKS  CallBacks,
PVOID  LazyWriterContext 
)

Definition at line 1399 of file view.c.

1408 {
1409  KIRQL OldIrql;
1411  PROS_SHARED_CACHE_MAP SharedCacheMap;
1412 
1413  DPRINT("CcRosInitializeFileCache(FileObject 0x%p)\n", FileObject);
1414 
1415  Allocated = FALSE;
1416  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
1417  if (SharedCacheMap == NULL)
1418  {
1419  Allocated = TRUE;
1420  SharedCacheMap = ExAllocateFromNPagedLookasideList(&SharedCacheMapLookasideList);
1421  if (SharedCacheMap == NULL)
1422  {
1424  }
1425  RtlZeroMemory(SharedCacheMap, sizeof(*SharedCacheMap));
1426  SharedCacheMap->NodeTypeCode = NODE_TYPE_SHARED_MAP;
1427  SharedCacheMap->NodeByteSize = sizeof(*SharedCacheMap);
1428  SharedCacheMap->FileObject = FileObject;
1429  SharedCacheMap->Callbacks = CallBacks;
1430  SharedCacheMap->LazyWriteContext = LazyWriterContext;
1431  SharedCacheMap->SectionSize = FileSizes->AllocationSize;
1432  SharedCacheMap->FileSize = FileSizes->FileSize;
1433  SharedCacheMap->PinAccess = PinAccess;
1434  SharedCacheMap->DirtyPageThreshold = 0;
1435  SharedCacheMap->DirtyPages = 0;
1436  InitializeListHead(&SharedCacheMap->PrivateList);
1437  KeInitializeSpinLock(&SharedCacheMap->CacheMapLock);
1438  InitializeListHead(&SharedCacheMap->CacheMapVacbListHead);
1439  InitializeListHead(&SharedCacheMap->BcbList);
1440  }
1441 
1443  if (Allocated)
1444  {
1445  if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
1446  {
1449  NULL,
1450  KernelMode);
1451  FileObject->SectionObjectPointer->SharedCacheMap = SharedCacheMap;
1452 
1454  }
1455  else
1456  {
1457  ExFreeToNPagedLookasideList(&SharedCacheMapLookasideList, SharedCacheMap);
1458  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
1459  }
1460  }
1461  if (FileObject->PrivateCacheMap == NULL)
1462  {
1463  PPRIVATE_CACHE_MAP PrivateMap;
1464 
1465  /* Allocate the private cache map for this handle */
1466  if (SharedCacheMap->PrivateCacheMap.NodeTypeCode != 0)
1467  {
1469  }
1470  else
1471  {
1472  PrivateMap = &SharedCacheMap->PrivateCacheMap;
1473  }
1474 
1475  if (PrivateMap == NULL)
1476  {
1477  /* If we also allocated the shared cache map for this file, kill it */
1478  if (Allocated)
1479  {
1480  RemoveEntryList(&SharedCacheMap->SharedCacheMapLinks);
1481 
1482  FileObject->SectionObjectPointer->SharedCacheMap = NULL;
1484  ExFreeToNPagedLookasideList(&SharedCacheMapLookasideList, SharedCacheMap);
1485  }
1486 
1489  }
1490 
1491  /* Initialize it */
1492  RtlZeroMemory(PrivateMap, sizeof(PRIVATE_CACHE_MAP));
1493  PrivateMap->NodeTypeCode = NODE_TYPE_PRIVATE_MAP;
1494  PrivateMap->ReadAheadMask = PAGE_SIZE - 1;
1495  PrivateMap->FileObject = FileObject;
1497 
1498  /* Link it to the file */
1499  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
1500  InsertTailList(&SharedCacheMap->PrivateList, &PrivateMap->PrivateLinks);
1501  KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock);
1502 
1503  FileObject->PrivateCacheMap = PrivateMap;
1504  SharedCacheMap->OpenCount++;
1505  }
1507 
1508  return STATUS_SUCCESS;
1509 }
BOOLEAN PinAccess
Definition: cc.h:191
LIST_ENTRY PrivateList
Definition: cc.h:184
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
ULONG OpenCount
Definition: cc.h:174
LARGE_INTEGER SectionSize
Definition: cc.h:177
LIST_ENTRY SharedCacheMapLinks
Definition: cc.h:180
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
LIST_ENTRY BcbList
Definition: cc.h:176
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
static CC_FILE_SIZES FileSizes
#define InsertTailList(ListHead, Entry)
ULONG ReadAheadMask
Definition: cctypes.h:75
LARGE_INTEGER FileSize
Definition: cctypes.h:16
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
unsigned char BOOLEAN
IN PFCB IN VBO OUT PLBO OUT PULONG OUT PBOOLEAN Allocated
Definition: fatprocs.h:297
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:383
PCACHE_MANAGER_CALLBACKS Callbacks
Definition: cc.h:182
LIST_ENTRY CcCleanSharedCacheMapList
Definition: view.c:63
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
LIST_ENTRY CacheMapVacbListHead
Definition: cc.h:190
KSPIN_LOCK ReadAheadSpinLock
Definition: cctypes.h:83
static NPAGED_LOOKASIDE_LIST SharedCacheMapLookasideList
Definition: view.c:49
LIST_ENTRY PrivateLinks
Definition: cctypes.h:84
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
CSHORT NodeTypeCode
Definition: cc.h:172
#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
#define PAGE_SIZE
Definition: env_spec_w32.h:49
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
PFILE_OBJECT FileObject
Definition: cctypes.h:76
CSHORT NodeByteSize
Definition: cc.h:173
#define NODE_TYPE_PRIVATE_MAP
Definition: cc.h:286
PRIVATE_CACHE_MAP PrivateCacheMap
Definition: cc.h:187
LARGE_INTEGER AllocationSize
Definition: cctypes.h:15
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PVOID LazyWriteContext
Definition: cc.h:183
LARGE_INTEGER FileSize
Definition: cc.h:175
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define TAG_PRIVATE_CACHE_MAP
Definition: tag.h:7
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
CSHORT NodeTypeCode
Definition: cctypes.h:71
PFILE_OBJECT FileObject
Definition: cc.h:178
return STATUS_SUCCESS
Definition: btrfs.c:2938
ULONG DirtyPageThreshold
Definition: cc.h:185
#define NODE_TYPE_SHARED_MAP
Definition: cc.h:287
ULONG DirtyPages
Definition: cc.h:179

Referenced by CcInitializeCacheMap().

◆ CcRosInternalFreeVacb()

NTSTATUS CcRosInternalFreeVacb ( IN PROS_VACB  Vacb)

Referenced by CcRosVacbDecRefCount().

◆ CcRosLookupVacb()

PROS_VACB NTAPI CcRosLookupVacb ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
LONGLONG  FileOffset 
)

Definition at line 458 of file view.c.

461 {
462  PLIST_ENTRY current_entry;
464  KIRQL oldIrql;
465 
466  ASSERT(SharedCacheMap);
467 
468  DPRINT("CcRosLookupVacb(SharedCacheMap 0x%p, FileOffset %I64u)\n",
469  SharedCacheMap, FileOffset);
470 
472  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
473 
474  current_entry = SharedCacheMap->CacheMapVacbListHead.Flink;
475  while (current_entry != &SharedCacheMap->CacheMapVacbListHead)
476  {
477  current = CONTAINING_RECORD(current_entry,
478  ROS_VACB,
479  CacheMapVacbListEntry);
480  if (IsPointInRange(current->FileOffset.QuadPart,
482  FileOffset))
483  {
487  return current;
488  }
489  if (current->FileOffset.QuadPart > FileOffset)
490  break;
491  current_entry = current_entry->Flink;
492  }
493 
496 
497  return NULL;
498 }
Definition: cc.h:201
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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
FORCEINLINE BOOLEAN IsPointInRange(_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Point)
Definition: cc.h:494
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CcRosVacbIncRefCount(vacb)
Definition: cc.h:528
Definition: typedefs.h:117
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define VACB_MAPPING_GRANULARITY
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
struct task_struct * current
Definition: linux.c:32

Referenced by CcFlushCache(), CcRosGetVacb(), CcRosMarkDirtyFile(), CcRosUnmapVacb(), CcSetFileSizes(), and MiIsPageFromCache().

◆ CcRosMarkDirtyFile()

NTSTATUS NTAPI CcRosMarkDirtyFile ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
LONGLONG  FileOffset 
)

Definition at line 572 of file view.c.

575 {
576  PROS_VACB Vacb;
577 
578  ASSERT(SharedCacheMap);
579 
580  DPRINT("CcRosMarkDirtyVacb(SharedCacheMap 0x%p, FileOffset %I64u)\n",
581  SharedCacheMap, FileOffset);
582 
583  Vacb = CcRosLookupVacb(SharedCacheMap, FileOffset);
584  if (Vacb == NULL)
585  {
586  KeBugCheck(CACHE_MANAGER);
587  }
588 
589  CcRosReleaseVacb(SharedCacheMap, Vacb, Vacb->Valid, TRUE, FALSE);
590 
591  return STATUS_SUCCESS;
592 }
#define TRUE
Definition: types.h:120
Definition: cc.h:201
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
NTSTATUS NTAPI CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:421
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN Valid
Definition: cc.h:208
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
PROS_VACB NTAPI CcRosLookupVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
Definition: view.c:458
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by MmFreeSectionPage(), and MmWritePageSectionView().

◆ CcRosMarkDirtyVacb()

VOID NTAPI CcRosMarkDirtyVacb ( PROS_VACB  Vacb)

Definition at line 502 of file view.c.

504 {
505  KIRQL oldIrql;
506  PROS_SHARED_CACHE_MAP SharedCacheMap;
507 
508  SharedCacheMap = Vacb->SharedCacheMap;
509 
511  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
512 
513  ASSERT(!Vacb->Dirty);
514 
518  CcRosVacbIncRefCount(Vacb);
519 
520  /* Move to the tail of the LRU list */
523 
524  Vacb->Dirty = TRUE;
525 
527 
528  /* Schedule a lazy writer run to now that we have dirty VACB */
529  if (!LazyWriter.ScanActive)
530  {
532  }
534 }
#define TRUE
Definition: types.h:120
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
static LIST_ENTRY VacbLruListHead
Definition: view.c:46
#define InsertTailList(ListHead, Entry)
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
LAZY_WRITER LazyWriter
Definition: lazywrite.c:37
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
BOOLEAN ScanActive
Definition: cc.h:245
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
BOOLEAN Dirty
Definition: cc.h:210
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG CcTotalDirtyPages
Definition: view.c:60
#define CcRosVacbIncRefCount(vacb)
Definition: cc.h:528
#define PAGE_SIZE
Definition: env_spec_w32.h:49
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
VOID CcScheduleLazyWriteScan(IN BOOLEAN NoDelay)
Definition: lazywrite.c:200
#define VACB_MAPPING_GRANULARITY
LIST_ENTRY DirtyVacbListEntry
Definition: cc.h:217
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
LIST_ENTRY DirtyVacbListHead
Definition: view.c:45
ULONG DirtyPages
Definition: cc.h:179
LIST_ENTRY VacbLruListEntry
Definition: cc.h:219

Referenced by CcRosFlushVacb(), CcRosReleaseVacb(), and CcSetDirtyPinnedData().

◆ CcRosReferenceCache()

VOID NTAPI CcRosReferenceCache ( PFILE_OBJECT  FileObject)

Definition at line 1270 of file view.c.

1272 {
1273  PROS_SHARED_CACHE_MAP SharedCacheMap;
1274  KIRQL OldIrql;
1275 
1277  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
1278  ASSERT(SharedCacheMap);
1279  ASSERT(SharedCacheMap->OpenCount != 0);
1280  SharedCacheMap->OpenCount++;
1282 }
ULONG OpenCount
Definition: cc.h:174
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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

Referenced by MmCreateDataFileSection(), and MmCreateImageSection().

◆ CcRosReleaseFileCache()

NTSTATUS NTAPI CcRosReleaseFileCache ( PFILE_OBJECT  FileObject)

Definition at line 1334 of file view.c.

1340 {
1341  KIRQL OldIrql;
1342  PPRIVATE_CACHE_MAP PrivateMap;
1343  PROS_SHARED_CACHE_MAP SharedCacheMap;
1344 
1346 
1347  if (FileObject->SectionObjectPointer->SharedCacheMap != NULL)
1348  {
1349  SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
1350 
1351  /* Closing the handle, so kill the private cache map
1352  * Before you event try to remove it from FO, always
1353  * lock the master lock, to be sure not to race
1354  * with a potential read ahead ongoing!
1355  */
1356  PrivateMap = FileObject->PrivateCacheMap;
1357  FileObject->PrivateCacheMap = NULL;
1358 
1359  if (PrivateMap != NULL)
1360  {
1361  /* Remove it from the file */
1362  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
1363  RemoveEntryList(&PrivateMap->PrivateLinks);
1364  KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock);
1365 
1366  /* And free it. */
1367  if (PrivateMap != &SharedCacheMap->PrivateCacheMap)
1368  {
1370  }
1371  else
1372  {
1373  PrivateMap->NodeTypeCode = 0;
1374  }
1375 
1376  if (SharedCacheMap->OpenCount > 0)
1377  {
1378  SharedCacheMap->OpenCount--;
1379  if (SharedCacheMap->OpenCount == 0)
1380  {
1382  MmFreeSectionSegments(SharedCacheMap->FileObject);
1383 
1385  CcRosDeleteFileCache(FileObject, SharedCacheMap, &OldIrql);
1387 
1388  return STATUS_SUCCESS;
1389  }
1390  }
1391  }
1392  }
1394  return STATUS_SUCCESS;
1395 }
ULONG OpenCount
Definition: cc.h:174
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
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
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject)
Definition: section.c:807
LIST_ENTRY PrivateLinks
Definition: cctypes.h:84
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
_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
PRIVATE_CACHE_MAP PrivateCacheMap
Definition: cc.h:187
NTSTATUS NTAPI CcRosDeleteFileCache(PFILE_OBJECT FileObject, PROS_SHARED_CACHE_MAP SharedCacheMap, PKIRQL OldIrql)
Definition: view.c:1159
#define TAG_PRIVATE_CACHE_MAP
Definition: tag.h:7
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
CSHORT NodeTypeCode
Definition: cctypes.h:71
PFILE_OBJECT FileObject
Definition: cc.h:178
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CcUninitializeCacheMap().

◆ CcRosReleaseVacb()

NTSTATUS NTAPI CcRosReleaseVacb ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
PROS_VACB  Vacb,
BOOLEAN  Valid,
BOOLEAN  Dirty,
BOOLEAN  Mapped 
)

Definition at line 421 of file view.c.

427 {
428  ULONG Refs;
429  ASSERT(SharedCacheMap);
430 
431  DPRINT("CcRosReleaseVacb(SharedCacheMap 0x%p, Vacb 0x%p, Valid %u)\n",
432  SharedCacheMap, Vacb, Valid);
433 
434  Vacb->Valid = Valid;
435 
436  if (Dirty && !Vacb->Dirty)
437  {
438  CcRosMarkDirtyVacb(Vacb);
439  }
440 
441  if (Mapped)
442  {
443  if (InterlockedIncrement((PLONG)&Vacb->MappedCount) == 1)
444  {
445  CcRosVacbIncRefCount(Vacb);
446  }
447  }
448 
449  Refs = CcRosVacbDecRefCount(Vacb);
450  ASSERT(Refs > 0);
451 
452  return STATUS_SUCCESS;
453 }
ULONG MappedCount
Definition: cc.h:213
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:531
BOOLEAN Dirty
Definition: cc.h:210
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CcRosVacbIncRefCount(vacb)
Definition: cc.h:528
#define InterlockedIncrement
Definition: armddk.h:53
BOOLEAN Valid
Definition: cc.h:208
VOID NTAPI CcRosMarkDirtyVacb(PROS_VACB Vacb)
Definition: view.c:502
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5

Referenced by CcCopyData(), CcFlushCache(), CcMapData(), CcpDereferenceBcb(), CcPerformReadAhead(), CcpGetAppropriateBcb(), CcpMapData(), CcpPinData(), CcRosMarkDirtyFile(), CcRosUnmapVacb(), CcSetFileSizes(), CcUnpinRepinnedBcb(), MiIsPageFromCache(), and MiReadPage().

◆ CcRosRemoveIfClosed()

VOID NTAPI CcRosRemoveIfClosed ( PSECTION_OBJECT_POINTERS  SectionObjectPointer)

Definition at line 1286 of file view.c.

1288 {
1289  PROS_SHARED_CACHE_MAP SharedCacheMap;
1290  KIRQL OldIrql;
1291 
1292  DPRINT("CcRosRemoveIfClosed()\n");
1294  SharedCacheMap = SectionObjectPointer->SharedCacheMap;
1295  if (SharedCacheMap && SharedCacheMap->OpenCount == 0)
1296  {
1297  CcRosDeleteFileCache(SharedCacheMap->FileObject, SharedCacheMap, &OldIrql);
1298  }
1300 }
ULONG OpenCount
Definition: cc.h:174
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer
Definition: fsrtlfuncs.h:1368
UCHAR KIRQL
Definition: env_spec_w32.h:591
void DPRINT(...)
Definition: polytest.cpp:61
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
_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
NTSTATUS NTAPI CcRosDeleteFileCache(PFILE_OBJECT FileObject, PROS_SHARED_CACHE_MAP SharedCacheMap, PKIRQL OldIrql)
Definition: view.c:1159
PFILE_OBJECT FileObject
Definition: cc.h:178

Referenced by MmFlushImageSection().

◆ CcRosRequestVacb()

NTSTATUS NTAPI CcRosRequestVacb ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
LONGLONG  FileOffset,
PVOID BaseAddress,
PBOOLEAN  UptoDate,
PROS_VACB Vacb 
)

Definition at line 996 of file view.c.

1005 {
1006  LONGLONG BaseOffset;
1007 
1008  ASSERT(SharedCacheMap);
1009 
1011  {
1012  DPRINT1("Bad fileoffset %I64x should be multiple of %x",
1014  KeBugCheck(CACHE_MANAGER);
1015  }
1016 
1017  return CcRosGetVacb(SharedCacheMap,
1018  FileOffset,
1019  &BaseOffset,
1020  BaseAddress,
1021  UptoDate,
1022  Vacb);
1023 }
NTSTATUS NTAPI CcRosGetVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset, PLONGLONG BaseOffset, PVOID *BaseAddress, PBOOLEAN UptoDate, PROS_VACB *Vacb)
Definition: view.c:937
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
int64_t LONGLONG
Definition: typedefs.h:66
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define DPRINT1
Definition: precomp.h:8
#define VACB_MAPPING_GRANULARITY

Referenced by CcCopyData(), and CcPerformReadAhead().

◆ CcRosUnmapVacb()

NTSTATUS NTAPI CcRosUnmapVacb ( PROS_SHARED_CACHE_MAP  SharedCacheMap,
LONGLONG  FileOffset,
BOOLEAN  NowDirty 
)

Definition at line 600 of file view.c.

604 {
605  PROS_VACB Vacb;
606 
607  ASSERT(SharedCacheMap);
608 
609  DPRINT("CcRosUnmapVacb(SharedCacheMap 0x%p, FileOffset %I64u, NowDirty %u)\n",
610  SharedCacheMap, FileOffset, NowDirty);
611 
612  Vacb = CcRosLookupVacb(SharedCacheMap, FileOffset);
613  if (Vacb == NULL)
614  {
615  return STATUS_UNSUCCESSFUL;
616  }
617 
618  ASSERT(Vacb->MappedCount != 0);
619  if (InterlockedDecrement((PLONG)&Vacb->MappedCount) == 0)
620  {
621  CcRosVacbDecRefCount(Vacb);
622  }
623 
624  CcRosReleaseVacb(SharedCacheMap, Vacb, Vacb->Valid, NowDirty, FALSE);
625 
626  return STATUS_SUCCESS;
627 }
Definition: cc.h:201
ULONG MappedCount
Definition: cc.h:213
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI CcRosReleaseVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped)
Definition: view.c:421
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:531
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define InterlockedDecrement
Definition: armddk.h:52
BOOLEAN Valid
Definition: cc.h:208
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
PROS_VACB NTAPI CcRosLookupVacb(PROS_SHARED_CACHE_MAP SharedCacheMap, LONGLONG FileOffset)
Definition: view.c:458
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5

Referenced by MmPageOutSectionView(), and MmUnsharePageEntrySectionSegment().

◆ CcRosUnmarkDirtyVacb()

VOID NTAPI CcRosUnmarkDirtyVacb ( PROS_VACB  Vacb,
BOOLEAN  LockViews 
)

Definition at line 538 of file view.c.

541 {
542  KIRQL oldIrql;
543  PROS_SHARED_CACHE_MAP SharedCacheMap;
544 
545  SharedCacheMap = Vacb->SharedCacheMap;
546 
547  if (LockViews)
548  {
550  KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock);
551  }
552 
553  ASSERT(Vacb->Dirty);
554 
555  Vacb->Dirty = FALSE;
556 
561  CcRosVacbDecRefCount(Vacb);
562 
563  if (LockViews)
564  {
567  }
568 }
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
PROS_SHARED_CACHE_MAP SharedCacheMap
Definition: cc.h:225
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
FORCEINLINE ULONG CcRosVacbDecRefCount(PROS_VACB vacb)
Definition: cc.h:531
BOOLEAN Dirty
Definition: cc.h:210
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG CcTotalDirtyPages
Definition: view.c:60
#define PAGE_SIZE
Definition: env_spec_w32.h:49
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define VACB_MAPPING_GRANULARITY
LIST_ENTRY DirtyVacbListEntry
Definition: cc.h:217
KSPIN_LOCK CacheMapLock
Definition: cc.h:192
ULONG DirtyPages
Definition: cc.h:179

Referenced by CcPurgeCacheSection(), CcRosDeleteFileCache(), and CcRosFlushVacb().

◆ CcRosVacbDecRefCount()

FORCEINLINE ULONG CcRosVacbDecRefCount ( PROS_VACB  vacb)

Definition at line 531 of file cc.h.

533 {
534  ULONG Refs;
535 
536  Refs = InterlockedDecrement((PLONG)&vacb->ReferenceCount);
537  if (Refs == 0)
538  {
539  CcRosInternalFreeVacb(vacb);
540  }
541  return Refs;
542 }
volatile ULONG ReferenceCount
Definition: cc.h:223
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS CcRosInternalFreeVacb(IN PROS_VACB Vacb)
signed int * PLONG
Definition: retypes.h:5

Referenced by CcPurgeCacheSection(), CcRosCreateVacb(), CcRosDeleteFileCache(), CcRosFlushDirtyPages(), CcRosFreeUnusedVacb(), CcRosReleaseVacb(), CcRosTrimCache(), CcRosUnmapVacb(), and CcRosUnmarkDirtyVacb().

◆ CcScanDpc()

VOID NTAPI CcScanDpc ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

◆ CcScheduleLazyWriteScan()

VOID CcScheduleLazyWriteScan ( BOOLEAN  NoDelay)

◆ CcShutdownLazyWriter()

VOID NTAPI CcShutdownLazyWriter ( VOID  )

◆ CcShutdownSystem()

VOID NTAPI CcShutdownSystem ( VOID  )

Definition at line 299 of file cachesub.c.

300 {
301  ULONG i, Result;
303 
304  DPRINT1("CC: Shutdown\n");
305 
306  for (i = 0; i < CACHE_NUM_SECTIONS; i++)
307  {
309  if (Bcb->SectionObject)
310  {
311  DPRINT1("Evicting #%02x %08x%08x %wZ\n",
312  i,
313  Bcb->FileOffset.u.HighPart,
314  Bcb->FileOffset.u.LowPart,
315  &MmGetFileObjectForSection((PROS_SECTION_OBJECT)Bcb->SectionObject)->FileName);
316 
317  CcpFlushCache(Bcb->Map, NULL, 0, NULL, TRUE);
318  Bcb->Dirty = FALSE;
319  }
320  }
321 
322  /* Evict all section pages */
323  Status = MiRosTrimCache(~0, 0, &Result);
324 
325  DPRINT1("Done (Evicted %d, Status %x)\n", Result, Status);
326 }
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1681
#define TRUE
Definition: types.h:120
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
#define CACHE_NUM_SECTIONS
Definition: newcc.h:130
LONG NTSTATUS
Definition: precomp.h:26
#define CcpFlushCache(M, F, L, I, D)
Definition: newcc.h:96
NTSTATUS MiRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
Definition: swapout.c:633
Definition: newcc.h:3
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
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
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

Referenced by PopGracefulShutdown().

◆ CcWorkerThread()

VOID NTAPI CcWorkerThread ( PVOID  Parameter)

◆ 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:67
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:2938
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CcRosFlushVacb().

◆ DoRangesIntersect()

FORCEINLINE BOOLEAN DoRangesIntersect ( _In_ LONGLONG  Offset1,
_In_ LONGLONG  Length1,
_In_ LONGLONG  Offset2,
_In_ LONGLONG  Length2 
)

Definition at line 479 of file cc.h.

484 {
485  if (Offset1 + Length1 <= Offset2)
486  return FALSE;
487  if (Offset2 + Length2 <= Offset1)
488  return FALSE;
489  return TRUE;
490 }
#define TRUE
Definition: types.h:120
INT Length2
Definition: FsRtlDissect.c:16
INT Length1
Definition: FsRtlDissect.c:15
INT Offset1
Definition: FsRtlDissect.c:13
INT Offset2
Definition: FsRtlDissect.c:14

Referenced by CcCopyData(), and IsPointInRange().

◆ IsPointInRange()

FORCEINLINE BOOLEAN IsPointInRange ( _In_ LONGLONG  Offset1,
_In_ LONGLONG  Length1,
_In_ LONGLONG  Point 
)

Definition at line 494 of file cc.h.

498 {
499  return DoRangesIntersect(Offset1, Length1, Point, 1);
500 }
INT Length1
Definition: FsRtlDissect.c:15
FORCEINLINE BOOLEAN DoRangesIntersect(_In_ LONGLONG Offset1, _In_ LONGLONG Length1, _In_ LONGLONG Offset2, _In_ LONGLONG Length2)
Definition: cc.h:479
INT Offset1
Definition: FsRtlDissect.c:13

Referenced by CcRosCreateVacb(), and CcRosLookupVacb().

Variable Documentation

◆ CcDataFlushes

ULONG CcDataFlushes

Definition at line 51 of file copy.c.

Referenced by IoSynchronousPageWrite(), and QSI_DEF().

◆ CcDataPages

ULONG CcDataPages

Definition at line 50 of file copy.c.

Referenced by IoSynchronousPageWrite(), and QSI_DEF().

◆ CcDeferredWrites

LIST_ENTRY CcDeferredWrites

◆ CcDeferredWriteSpinLock

KSPIN_LOCK CcDeferredWriteSpinLock

Definition at line 62 of file view.c.

Referenced by CcCanIWrite(), CcDeferWrite(), CcInitView(), and CcPostDeferredWrites().

◆ CcDirtyPageThreshold

ULONG CcDirtyPageThreshold

Definition at line 59 of file view.c.

Referenced by CcCanIWrite(), and CcInitializeCacheManager().

◆ CcExpressWorkQueue

LIST_ENTRY CcExpressWorkQueue

Definition at line 39 of file lazywrite.c.

Referenced by CcInitializeCacheManager(), CcScheduleReadAhead(), and CcWorkerThread().

◆ CcIdleDelay

LARGE_INTEGER CcIdleDelay

Definition at line 46 of file lazywrite.c.

Referenced by CcCanIWrite(), and CcScheduleLazyWriteScan().

◆ CcIdleWorkerThreadList

LIST_ENTRY CcIdleWorkerThreadList

Definition at line 41 of file lazywrite.c.

Referenced by CcInitializeCacheManager(), CcPostWorkQueue(), and CcWorkerThread().

◆ CcLazyWriteIos

ULONG CcLazyWriteIos

Definition at line 21 of file lazywrite.c.

Referenced by CcWriteBehind(), and QSI_DEF().

◆ CcLazyWritePages

ULONG CcLazyWritePages

Definition at line 20 of file lazywrite.c.

Referenced by CcWriteBehind(), and QSI_DEF().

◆ CcMapDataNoWait

ULONG CcMapDataNoWait

Definition at line 29 of file pin.c.

Referenced by CcMapData(), and QSI_DEF().

◆ CcMapDataWait

ULONG CcMapDataWait

Definition at line 28 of file pin.c.

Referenced by CcMapData(), and QSI_DEF().

◆ CcNumberWorkerThreads

ULONG CcNumberWorkerThreads

Definition at line 48 of file lazywrite.c.

Referenced by CcInitializeCacheManager().

◆ CcPinMappedDataCount

ULONG CcPinMappedDataCount

Definition at line 32 of file pin.c.

Referenced by CcPinMappedData(), and QSI_DEF().

◆ CcPinReadNoWait

ULONG CcPinReadNoWait

Definition at line 31 of file pin.c.

Referenced by CcPinRead(), and QSI_DEF().

◆ CcPinReadWait

ULONG CcPinReadWait

Definition at line 30 of file pin.c.

Referenced by CcPinRead(), and QSI_DEF().

◆ CcPostTickWorkQueue

LIST_ENTRY CcPostTickWorkQueue

◆ CcRegularWorkQueue

LIST_ENTRY CcRegularWorkQueue

Definition at line 40 of file lazywrite.c.

Referenced by CcInitializeCacheManager(), CcLazyWriteScan(), CcScanDpc(), and CcWorkerThread().

◆ CcRosTraceLevel

ULONG CcRosTraceLevel

Definition at line 38 of file copy.c.

◆ CcTotalDirtyPages

ULONG CcTotalDirtyPages

◆ CcTwilightLookasideList

◆ DirtyVacbListHead

LIST_ENTRY DirtyVacbListHead

Definition at line 45 of file view.c.

Referenced by CcInitView(), CcIsThereDirtyData(), CcRosFlushDirtyPages(), and CcRosMarkDirtyVacb().

◆ LazyWriter