ReactOS  0.4.14-dev-614-gbfd8a84
copysup.c File Reference
#include <ntoskrnl.h>
#include "newcc.h"
#include "section/newmm.h"
#include <debug.h>
Include dependency graph for copysup.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define TAG_COPY_READ   TAG('C', 'o', 'p', 'y')
 
#define TAG_COPY_WRITE   TAG('R', 'i', 't', 'e')
 

Functions

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)
 
VOID NTAPI CcFastCopyRead (IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN ULONG PageCount, 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 CcFastCopyWrite (IN PFILE_OBJECT FileObject, IN ULONG FileOffset, IN ULONG Length, IN PVOID Buffer)
 
BOOLEAN NTAPI CcCanIWrite (IN PFILE_OBJECT FileObject, IN ULONG BytesToWrite, IN BOOLEAN Wait, IN UCHAR Retrying)
 
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)
 

Variables

ULONG CcFastMdlReadWait
 
ULONG CcFastMdlReadNotPossible
 
ULONG CcFastReadNotPossible
 
ULONG CcFastReadWait
 
ULONG CcFastReadNoWait
 
ULONG CcFastReadResourceMiss
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file copysup.c.

◆ TAG_COPY_READ

#define TAG_COPY_READ   TAG('C', 'o', 'p', 'y')

Definition at line 26 of file copysup.c.

◆ TAG_COPY_WRITE

#define TAG_COPY_WRITE   TAG('R', 'i', 't', 'e')

Definition at line 27 of file copysup.c.

Function Documentation

◆ CcCanIWrite()

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

◆ 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 43 of file copysup.c.

49 {
51  ULONG ReadLen;
52  PVOID Bcb;
53  PCHAR BufferTarget = (PCHAR)Buffer;
54  LARGE_INTEGER CacheOffset, EndOfExtent, NextOffset;
55 
56  DPRINT("CcCopyRead(%x,%x,%d,%d,%x)\n",
57  FileObject,
58  FileOffset->LowPart,
59  Length,
60  Wait,
61  Buffer);
62 
63  CacheOffset.QuadPart = FileOffset->QuadPart;
64  EndOfExtent.QuadPart = FileOffset->QuadPart + Length;
65 
66  while (CacheOffset.QuadPart < EndOfExtent.QuadPart)
67  {
68  NextOffset.QuadPart = CacheOffset.QuadPart;
69  NextOffset.LowPart = (NextOffset.LowPart + CACHE_STRIPE) & ~(CACHE_STRIPE-1);
70  ReadLen = EndOfExtent.QuadPart - CacheOffset.QuadPart;
71  if (CacheOffset.QuadPart + ReadLen > NextOffset.QuadPart)
72  {
73  ReadLen = NextOffset.QuadPart - CacheOffset.QuadPart;
74  }
75 
76  DPRINT("Reading %d bytes in this go (at %08x%08x)\n",
77  ReadLen,
78  CacheOffset.HighPart,
79  CacheOffset.LowPart);
80 
81  if (!CcPinRead(FileObject,
82  &CacheOffset,
83  ReadLen,
85  &Bcb,
86  (PVOID*)&ReadBuffer))
87  {
88  IoStatus->Status = STATUS_UNSUCCESSFUL;
89  IoStatus->Information = 0;
90  DPRINT("Failed CcCopyRead\n");
91  return FALSE;
92  }
93 
94  DPRINT("Copying %d bytes at %08x%08x\n",
95  ReadLen,
96  CacheOffset.HighPart,
97  CacheOffset.LowPart);
98 
99  RtlCopyMemory(BufferTarget, ReadBuffer, ReadLen);
100 
101  BufferTarget += ReadLen;
102 
103  CacheOffset = NextOffset;
104  CcUnpinData(Bcb);
105  }
106 
107  IoStatus->Status = STATUS_SUCCESS;
108  IoStatus->Information = Length;
109 
110  DPRINT("Done with CcCopyRead\n");
111 
112  return TRUE;
113 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define ReadBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:339
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define PCHAR
Definition: match.c:90
#define CACHE_STRIPE
Definition: newcc.h:128
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG LowPart
Definition: typedefs.h:104
#define PIN_IF_BCB
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
LONGLONG QuadPart
Definition: typedefs.h:112
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by _Requires_lock_held_(), do_read(), Ext2LoadInodeXattr(), Ext2ReadFile(), Ext2ReadInode(), Ext2ReadVolume(), Ext2RefreshSuper(), FFSCopyRead(), FFSReadFile(), FFSReadVolume(), FsRtlCopyRead(), FsRtlCopyRead2(), PerformTest(), RfsdCopyRead(), RfsdReadFile(), RfsdReadVolume(), RxCommonRead(), TestIrpHandler(), UDFCommonRead(), and VfatCommonRead().

◆ CcCopyWrite()

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

Definition at line 129 of file copysup.c.

134 {
135  INT Count = 0;
136  BOOLEAN Result;
137  PNOCC_BCB Bcb;
138  PVOID WriteBuf;
139  ULONG WriteLen;
140  LARGE_INTEGER CurrentOffset = *FileOffset;
141  LARGE_INTEGER EndOffset;
142  LARGE_INTEGER NextOffset;
143 
144  EndOffset.QuadPart = CurrentOffset.QuadPart + Length;
145 
146  DPRINT("CcCopyWrite(%x,%x,%d,%d,%x)\n",
147  FileObject,
148  FileOffset->LowPart,
149  Length,
150  Wait,
151  Buffer);
152 
153  while (CurrentOffset.QuadPart < EndOffset.QuadPart)
154  {
155  NextOffset.HighPart = CurrentOffset.HighPart;
156  NextOffset.LowPart = (CurrentOffset.LowPart + CACHE_STRIPE) & ~(CACHE_STRIPE - 1);
157  DPRINT("NextOffset %08x%08x\n", NextOffset.u.HighPart, NextOffset.u.LowPart);
158  WriteLen = MIN(NextOffset.QuadPart - CurrentOffset.QuadPart, Length);
159 
160  DPRINT("Copying %x bytes from %08x%08x\n",
161  WriteLen,
162  CurrentOffset.u.HighPart,
163  CurrentOffset.u.LowPart);
164 
165  DPRINT("CcPreparePinWrite\n");
166 
168  &CurrentOffset,
169  WriteLen,
170  FALSE,
172  (PVOID *)&Bcb, &WriteBuf);
173 
174  DPRINT("Result %s %x %x\n", Result ? "TRUE" : "FALSE", Bcb, WriteBuf);
175  if (!Result)
176  {
177  DPRINT1("CcPreparePinWrite Failed?\n");
178  if (Wait)
180  else
181  return FALSE;
182  }
183 
184  DPRINT("Copying actual memory to BCB#%x (@%x) (from buffer at %x)\n",
186  WriteBuf,
187  Bcb->BaseAddress);
188 
189  RtlCopyMemory(WriteBuf, ((PCHAR)Buffer) + Count, WriteLen);
190  Count += WriteLen;
191  Length -= WriteLen;
192  CurrentOffset = NextOffset;
193  Bcb->Dirty = TRUE;
194  CcUnpinData(Bcb);
195  }
196 
197  DPRINT("Done with CcCopyWrite\n");
198 
199  return TRUE;
200 }
struct _LARGE_INTEGER::@2220 u
signed char * PCHAR
Definition: retypes.h:7
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_NOT_MAPPED_DATA
Definition: udferr_usr.h:157
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define PIN_WAIT
Definition: newcc.h:3
int32_t INT
Definition: typedefs.h:56
NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS]
Definition: pinsup.c:98
T MIN(T a, T b)
Definition: polytest.cpp:79
unsigned char BOOLEAN
_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
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define CACHE_STRIPE
Definition: newcc.h:128
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG LowPart
Definition: typedefs.h:104
#define PIN_IF_BCB
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI CcPreparePinWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Zero, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:827
LONGLONG QuadPart
Definition: typedefs.h:112
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by _Requires_lock_held_(), Ext2WriteFile(), Ext2WriteVolume(), FatMarkEaRangeDirty(), FFSWriteFile(), FFSWriteVolume(), FsRtlCopyWrite(), FsRtlCopyWrite2(), RfsdWriteFile(), RfsdWriteVolume(), RxCommonWrite(), TestIrpHandler(), UDFCommonWrite(), UDFPurgeCacheEx_(), VfatWrite(), and write_file2().

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

◆ 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 117 of file copysup.c.

123 {
125 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

Referenced by FsRtlCopyRead(), and FsRtlCopyRead2().

◆ CcFastCopyWrite()

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

Definition at line 204 of file copysup.c.

208 {
210 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

Referenced by FsRtlCopyWrite(), and FsRtlCopyWrite2().

Variable Documentation

◆ CcFastMdlReadNotPossible

ULONG CcFastMdlReadNotPossible

Definition at line 20 of file copysup.c.

Referenced by FsRtlMdlReadDev().

◆ CcFastMdlReadWait

ULONG CcFastMdlReadWait

Definition at line 19 of file copysup.c.

Referenced by FsRtlMdlReadDev().

◆ CcFastReadNotPossible

ULONG CcFastReadNotPossible

Definition at line 21 of file copysup.c.

Referenced by FsRtlCopyRead(), and FsRtlIncrementCcFastReadNotPossible().

◆ CcFastReadNoWait

ULONG CcFastReadNoWait

Definition at line 23 of file copysup.c.

Referenced by FsRtlIncrementCcFastReadNoWait().

◆ CcFastReadResourceMiss

ULONG CcFastReadResourceMiss

Definition at line 24 of file copysup.c.

Referenced by FsRtlIncrementCcFastReadResourceMiss().

◆ CcFastReadWait

ULONG CcFastReadWait

Definition at line 22 of file copysup.c.

Referenced by FsRtlCopyRead(), and FsRtlIncrementCcFastReadWait().