ReactOS 0.4.15-dev-7924-g5949c20
cachesup.c File Reference
#include "fatprocs.h"
Include dependency graph for cachesup.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (FAT_BUG_CHECK_CACHESUP)
 
#define Dbg   (DEBUG_TRACE_CACHESUP)
 

Functions

VOID FatInitializeCacheMap (_In_ PFILE_OBJECT FileObject, _In_ PCC_FILE_SIZES FileSizes, _In_ BOOLEAN PinAccess, _In_ PCACHE_MANAGER_CALLBACKS Callbacks, _In_ PVOID LazyWriteContext)
 
VOID FatReadVolumeFile (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN VBO StartingVbo, IN ULONG ByteCount, OUT PBCB *Bcb, OUT PVOID *Buffer)
 
 _Requires_lock_held_ (_Global_critical_region_)
 
PFILE_OBJECT FatOpenEaFile (IN PIRP_CONTEXT IrpContext, IN PFCB EaFcb)
 
VOID FatCloseEaFile (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN BOOLEAN FlushFirst)
 
VOID FatRepinBcb (IN PIRP_CONTEXT IrpContext, IN PBCB Bcb)
 
VOID FatUnpinRepinnedBcbs (IN PIRP_CONTEXT IrpContext)
 
FINISHED FatZeroData (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN ULONG StartingZero, IN ULONG ByteCount)
 
NTSTATUS FatCompleteMdl (IN PIRP_CONTEXT IrpContext, IN PIRP Irp)
 
VOID FatSyncUninitializeCacheMap (IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject)
 
VOID FatPinMappedData (IN PIRP_CONTEXT IrpContext, IN PDCB Dcb, IN VBO StartingVbo, IN ULONG ByteCount, OUT PBCB *Bcb)
 
NTSTATUS FatPrefetchPages (IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject, IN ULONG StartingPage, IN ULONG PageCount)
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (FAT_BUG_CHECK_CACHESUP)

Definition at line 23 of file cachesup.c.

◆ Dbg

#define Dbg   (DEBUG_TRACE_CACHESUP)

Definition at line 29 of file cachesup.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 187 of file cachesup.c.

236{
238
239 PAGED_CODE();
240
241 //
242 // Check to see that all references are within the Bios Parameter Block
243 // or the fat(s).
244 //
245
247 (FatRootDirectoryLbo( &Vcb->Bpb ))));
248
249 DebugTrace(+1, Dbg, "FatPrepareWriteVolumeFile\n", 0);
250 DebugTrace( 0, Dbg, "Vcb = %p\n", Vcb);
251 DebugTrace( 0, Dbg, "StartingVbo = %08lx\n", (ULONG)StartingVbo);
252 DebugTrace( 0, Dbg, "ByteCount = %08lx\n", ByteCount);
253 DebugTrace( 0, Dbg, "Zero = %08lx\n", Zero);
254
255 //
256 // Call the Cache manager to attempt the transfer.
257 //
258
259 Vbo.QuadPart = StartingVbo;
260
261 if (!CcPinRead( Vcb->VirtualVolumeFile,
262 &Vbo,
263 ByteCount,
264 BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT),
265 Bcb,
266 Buffer )) {
267
268 NT_ASSERT( !FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
269
270 //
271 // Could not read the data without waiting (cache miss).
272 //
273
274 FatRaiseStatus( IrpContext, STATUS_CANT_WAIT );
275 }
276
277 //
278 // This keeps the data pinned until we complete the request
279 // and writes the dirty bit through to the disk.
280 //
281
282 DbgDoit( IrpContext->PinCount += 1 )
283
284 _SEH2_TRY {
285
286 if (Zero) {
287
289 }
290
291 FatSetDirtyBcb( IrpContext, *Bcb, Vcb, Reversible );
292
293 } _SEH2_FINALLY {
294
296
297 FatUnpinBcb(IrpContext, *Bcb);
298 }
299 } _SEH2_END;
300
301 DebugTrace(-1, Dbg, "FatPrepareWriteVolumeFile -> VOID, *Bcb = %p\n", *Bcb);
302
303 return;
304}
#define PAGED_CODE()
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
Definition: bufpool.h:45
#define FatRootDirectoryLbo(B)
Definition: fat.h:445
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
#define Dbg
Definition: cachesup.c:29
#define DbgDoit(X)
Definition: fatdata.h:336
#define DebugTrace(INDENT, LEVEL, X, Y)
Definition: fatdata.h:313
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:414
#define FatUnpinBcb(IRPCONTEXT, BCB)
Definition: fatprocs.h:546
IN PVCB IN VBO StartingVbo
Definition: fatprocs.h:412
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:418
IN PFCB IN VBO Vbo
Definition: fatprocs.h:307
#define FatRaiseStatus(IRPCONTEXT, STATUS)
Definition: fatprocs.h:2977
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN Reversible
Definition: fatprocs.h:416
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define Vcb
Definition: cdprocs.h:1415
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 _SEH2_AbnormalTermination()
Definition: pseh2_64.h:160
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1099
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ FatCloseEaFile()

VOID FatCloseEaFile ( IN PIRP_CONTEXT  IrpContext,
IN PVCB  Vcb,
IN BOOLEAN  FlushFirst 
)

Definition at line 1079 of file cachesup.c.

1106{
1107 PFILE_OBJECT EaFileObject = Vcb->VirtualEaFile;
1108
1109 PAGED_CODE();
1110
1111 DebugTrace(+1, Dbg, "FatCloseEaFile\n", 0);
1112 DebugTrace( 0, Dbg, "Vcb = %p\n", Vcb);
1113
1114 NT_ASSERT( FatVcbAcquiredExclusive(IrpContext, Vcb) );
1115
1116 if (EaFileObject != NULL) {
1117
1118 EaFileObject = Vcb->VirtualEaFile;
1119
1120 if (FlushFirst) {
1121
1122 CcFlushCache( Vcb->VirtualEaFile->SectionObjectPointer, NULL, 0, NULL );
1123 }
1124
1125 Vcb->VirtualEaFile = NULL;
1126
1127 //
1128 // Empty the Mcb for the Ea file.
1129 //
1130
1131 FatRemoveMcbEntry( Vcb, &Vcb->EaFcb->Mcb, 0, 0xFFFFFFFF );
1132
1133 //
1134 // Uninitialize the cache for this file object and dereference it.
1135 //
1136
1137 FatSyncUninitializeCacheMap( IrpContext, EaFileObject );
1138
1139 ObDereferenceObject( EaFileObject );
1140 }
1141
1142 DebugTrace(-1, Dbg, "FatCloseEaFile -> %p\n", EaFileObject);
1143}
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
#define NULL
Definition: types.h:112
VOID FatSyncUninitializeCacheMap(IN PIRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject)
Definition: cachesup.c:1812
#define FatVcbAcquiredExclusive(IRPCONTEXT, VCB)
Definition: fatprocs.h:1495
VOID FatRemoveMcbEntry(IN PVCB Vcb, IN PLARGE_MCB Mcb, IN VBO Vbo, IN ULONG SectorCount)
Definition: fsctrl.c:599
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by FatTearDownVcb().

◆ FatCompleteMdl()

NTSTATUS FatCompleteMdl ( IN PIRP_CONTEXT  IrpContext,
IN PIRP  Irp 
)

Definition at line 1728 of file cachesup.c.

1750{
1753
1754 PAGED_CODE();
1755
1756 DebugTrace(+1, Dbg, "FatCompleteMdl\n", 0 );
1757 DebugTrace( 0, Dbg, "IrpContext = %p\n", IrpContext );
1758 DebugTrace( 0, Dbg, "Irp = %p\n", Irp );
1759
1760 //
1761 // Do completion processing.
1762 //
1763
1765
1766 switch( IrpContext->MajorFunction ) {
1767
1768 case IRP_MJ_READ:
1769
1770 CcMdlReadComplete( FileObject, Irp->MdlAddress );
1771 break;
1772
1773 case IRP_MJ_WRITE:
1774
1776
1777 NT_ASSERT( FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT ));
1778
1779 CcMdlWriteComplete( FileObject, &IrpSp->Parameters.Write.ByteOffset, Irp->MdlAddress );
1780
1781 Irp->IoStatus.Status = STATUS_SUCCESS;
1782
1783 break;
1784
1785 default:
1786
1787 DebugTrace( DEBUG_TRACE_ERROR, 0, "Illegal Mdl Complete.\n", 0);
1788#ifdef _MSC_VER
1789#pragma prefast( suppress: 28159, "we're very broken if we get here" )
1790#endif
1791 FatBugCheck( IrpContext->MajorFunction, 0, 0 );
1792 }
1793
1794 //
1795 // Mdl is now deallocated.
1796 //
1797
1798 Irp->MdlAddress = NULL;
1799
1800 //
1801 // Complete the request and exit right away.
1802 //
1803
1804 FatCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
1805
1806 DebugTrace(-1, Dbg, "FatCompleteMdl -> STATUS_SUCCESS\n", 0 );
1807
1808 return STATUS_SUCCESS;
1809}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID NTAPI CcMdlReadComplete(IN PFILE_OBJECT FileObject, IN PMDL MdlChain)
Definition: mdlsup.c:75
VOID NTAPI CcMdlWriteComplete(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain)
Definition: mdlsup.c:102
_In_ PIRP Irp
Definition: csq.h:116
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define FatBugCheck(A, B, C)
Definition: nodetype.h:104
#define FatCompleteRequest(IRPCONTEXT, IRP, STATUS)
Definition: fatprocs.h:2633
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define STATUS_SUCCESS
Definition: shellext.h:65
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
union _IO_STACK_LOCATION::@1564 Parameters
struct _IO_STACK_LOCATION::@3978::@3983 Write
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

Referenced by _Function_class_().

◆ FatInitializeCacheMap()

VOID FatInitializeCacheMap ( _In_ PFILE_OBJECT  FileObject,
_In_ PCC_FILE_SIZES  FileSizes,
_In_ BOOLEAN  PinAccess,
_In_ PCACHE_MANAGER_CALLBACKS  Callbacks,
_In_ PVOID  LazyWriteContext 
)

Definition at line 62 of file cachesup.c.

78{
79 //
80 // Initialize caching
81 //
82
85 PinAccess,
87 LazyWriteContext );
88
89#if (NTDDI_VERSION >= NTDDI_WIN8)
90 //
91 // Enable Disk IO Accounting for this file
92 //
93
95
96 CcSetAdditionalCacheAttributesEx( FileObject, CC_ENABLE_DISK_IO_ACCOUNTING );
97 }
98#endif
99}
static CC_FILE_SIZES FileSizes
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
#define CC_ENABLE_DISK_IO_ACCOUNTING
Definition: btrfs_drv.h:1845
LOGICAL FatDiskAccountingEnabled
Definition: fatdata.c:129
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:195

Referenced by _Requires_lock_held_(), FatOpenEaFile(), and FatSetupAllocationSupport().

◆ FatOpenEaFile()

PFILE_OBJECT FatOpenEaFile ( IN PIRP_CONTEXT  IrpContext,
IN PFCB  EaFcb 
)

Definition at line 979 of file cachesup.c.

1000{
1001 PFILE_OBJECT EaFileObject = NULL;
1002 PDEVICE_OBJECT RealDevice;
1003
1004 PAGED_CODE();
1005
1006 DebugTrace(+1, Dbg, "FatOpenEaFile\n", 0);
1007 DebugTrace( 0, Dbg, "EaFcb = %p\n", EaFcb);
1008
1009 //
1010 // Create the special file object for the ea file, and set
1011 // up its pointers back to the Fcb and the section object pointer
1012 //
1013
1014 RealDevice = EaFcb->Vcb->CurrentDevice;
1015
1016 EaFileObject = IoCreateStreamFileObject( NULL, RealDevice );
1017
1018 _SEH2_TRY {
1019
1020 FatPreallocateCloseContext( IrpContext->Vcb);
1021
1022 FatSetFileObject( EaFileObject,
1023 EaFile,
1024 EaFcb,
1025 NULL );
1026
1027 //
1028 // Remember this internal, residual open.
1029 //
1030
1031 InterlockedIncrement( (LONG*)&(EaFcb->Vcb->InternalOpenCount) );
1032 InterlockedIncrement( (LONG*)&(EaFcb->Vcb->ResidualOpenCount) );
1033
1034 EaFileObject->SectionObjectPointer = &EaFcb->NonPaged->SectionObjectPointers;
1035
1036 EaFileObject->ReadAccess = TRUE;
1037 EaFileObject->WriteAccess = TRUE;
1038
1039 //
1040 // Finally check if we need to initialize the Cache Map for the
1041 // ea file. The size of the section we are going to map
1042 // the current allocation size for the Fcb.
1043 //
1044
1045 EaFcb->Header.ValidDataLength = FatMaxLarge;
1046
1047 FatInitializeCacheMap( EaFileObject,
1048 (PCC_FILE_SIZES)&EaFcb->Header.AllocationSize,
1049 TRUE,
1051 EaFcb );
1052
1053 CcSetAdditionalCacheAttributes( EaFileObject, TRUE, TRUE );
1054
1055 } _SEH2_FINALLY {
1056
1057 //
1058 // Drop the fileobject if we're raising. Two cases: couldn't get
1059 // the close context, and it is still an UnopenedFileObject, or
1060 // we lost trying to build the cache map - in which case we're
1061 // OK for the close context if we have to.
1062 //
1063
1065
1066 ObDereferenceObject( EaFileObject );
1067 }
1068 } _SEH2_END;
1069
1070 DebugTrace(-1, Dbg, "FatOpenEaFile -> %p\n", EaFileObject);
1071
1072 UNREFERENCED_PARAMETER( IrpContext );
1073
1074 return EaFileObject;
1075}
#define InterlockedIncrement
Definition: armddk.h:53
#define TRUE
Definition: types.h:120
FatSetFileObject(FileObject, UserDirectoryOpen,(*Dcb), UnwindCcb=FatCreateCcb(IrpContext))
VOID FatInitializeCacheMap(_In_ PFILE_OBJECT FileObject, _In_ PCC_FILE_SIZES FileSizes, _In_ BOOLEAN PinAccess, _In_ PCACHE_MANAGER_CALLBACKS Callbacks, _In_ PVOID LazyWriteContext)
Definition: cachesup.c:62
LARGE_INTEGER FatMaxLarge
Definition: fatdata.c:63
FAT_DATA FatData
Definition: fatdata.c:56
VOID FatPreallocateCloseContext(IN PVCB Vcb)
@ EaFile
Definition: fatprocs.h:1047
VOID NTAPI CcSetAdditionalCacheAttributes(IN PFILE_OBJECT FileObject, IN BOOLEAN DisableReadAhead, IN BOOLEAN DisableWriteBehind)
Definition: logsup.c:22
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
Definition: file.c:3187
long LONG
Definition: pedump.c:60
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks
Definition: fatstruc.h:159

◆ FatPinMappedData()

VOID FatPinMappedData ( IN PIRP_CONTEXT  IrpContext,
IN PDCB  Dcb,
IN VBO  StartingVbo,
IN ULONG  ByteCount,
OUT PBCB Bcb 
)

Definition at line 1866 of file cachesup.c.

1892{
1894
1895 PAGED_CODE();
1896
1897 DebugTrace(+1, Dbg, "FatPinMappedData\n", 0);
1898 DebugTrace( 0, Dbg, "Dcb = %p\n", Dcb);
1899 DebugTrace( 0, Dbg, "StartingVbo = %08lx\n", StartingVbo);
1900 DebugTrace( 0, Dbg, "ByteCount = %08lx\n", ByteCount);
1901
1902 //
1903 // Call the Cache manager to perform the operation.
1904 //
1905
1906 Vbo.QuadPart = StartingVbo;
1907
1908 if (!CcPinMappedData( Dcb->Specific.Dcb.DirectoryFile,
1909 &Vbo,
1910 ByteCount,
1911 BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT),
1912 Bcb )) {
1913
1914 //
1915 // Could not pin the data without waiting (cache miss).
1916 //
1917
1918 FatRaiseStatus( IrpContext, STATUS_CANT_WAIT );
1919 }
1920
1921 DebugTrace(-1, Dbg, "FatReadDirectoryFile -> VOID, *BCB = %p\n", *Bcb);
1922
1923 return;
1924}
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
BOOLEAN NTAPI CcPinMappedData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, IN OUT PVOID *Bcb)
Definition: pinsup.c:774

◆ FatPrefetchPages()

NTSTATUS FatPrefetchPages ( IN PIRP_CONTEXT  IrpContext,
IN PFILE_OBJECT  FileObject,
IN ULONG  StartingPage,
IN ULONG  PageCount 
)

Definition at line 1929 of file cachesup.c.

1935{
1936 IO_PRIORITY_INFO PriorityInformation = {0};
1937 MM_PREFETCH_FLAGS PrefetchFlags;
1938 ULONG PageNo;
1940
1941 PREAD_LIST ReadList = NULL;
1942
1943 UNREFERENCED_PARAMETER( IrpContext );
1944
1945 PAGED_CODE();
1946
1947 //
1948 // Succeed zero page prefetch requests.
1949 //
1950
1951 if (PageCount == 0) {
1952
1953 return STATUS_SUCCESS;
1954 }
1955
1956 //
1957 // Mm's prefetch API's "only" support fetching a ULONG worth of pages.
1958 // Make sure we don't overflow.
1959 //
1960
1961 ASSERT( PageCount < (PFN_NUMBER)MAXULONG );
1962
1963 IoInitializePriorityInfo( &PriorityInformation );
1964
1965 Status = IoRetrievePriorityInfo( IrpContext->OriginatingIrp,
1966 FileObject,
1967 IrpContext->OriginatingIrp->Tail.Overlay.Thread,
1968 &PriorityInformation );
1969
1970 if (!NT_SUCCESS( Status)) {
1971
1972 goto Cleanup;
1973 }
1974
1975 ReadList = ExAllocatePoolWithTag( PagedPool,
1976 FIELD_OFFSET( READ_LIST, List ) + PageCount * sizeof( FILE_SEGMENT_ELEMENT ),
1977 ' taF' );
1978
1979 if (ReadList == NULL) {
1980
1982 goto Cleanup;
1983 }
1984
1985 //
1986 // Call Mm to prefetch data.
1987 //
1988
1989 ReadList->FileObject = FileObject;
1990 ReadList->IsImage = FALSE;
1991 ReadList->NumberOfEntries = PageCount;
1992
1993 PrefetchFlags.AllFlags = 0;
1994 PrefetchFlags.Flags.Priority = PriorityInformation.PagePriority;
1995 PrefetchFlags.Flags.RepurposePriority = SYSTEM_PAGE_PRIORITY_LEVELS - 1;
1996 PrefetchFlags.Flags.PriorityProtection = 1;
1997 ReadList->List[0].Alignment = StartingPage * PAGE_SIZE;
1998 ReadList->List[0].Alignment |= PrefetchFlags.AllFlags;
1999
2000 for (PageNo = 1; PageNo < PageCount; PageNo++) {
2001
2002 ReadList->List[PageNo].Alignment = ReadList->List[PageNo-1].Alignment + PAGE_SIZE;
2003 }
2004
2005 Status = MmPrefetchPages( 1, &ReadList );
2006
2007Cleanup:
2008
2009 if (ReadList != NULL) {
2010
2011 ExFreePoolWithTag( ReadList, ' taF' );
2012 }
2013
2014 return Status;
2015}
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI MmPrefetchPages(IN ULONG NumberOfLists, IN PREAD_LIST *ReadLists)
Definition: mdlsup.c:1655
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define SYSTEM_PAGE_PRIORITY_LEVELS
ULONG PFN_NUMBER
Definition: ke.h:9
ULONG PagePriority
Definition: iotypes.h:7457
PFILE_OBJECT FileObject
Definition: mmtypes.h:186
FILE_SEGMENT_ELEMENT List[ANYSIZE_ARRAY]
Definition: mmtypes.h:189
ULONG NumberOfEntries
Definition: mmtypes.h:187
LOGICAL IsImage
Definition: mmtypes.h:188
#define MAXULONG
Definition: typedefs.h:251
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONGLONG Alignment
Definition: iotypes.h:5432
struct _MM_PREFETCH_FLAGS::@4136 Flags
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by FatExamineFatEntries().

◆ FatReadVolumeFile()

VOID FatReadVolumeFile ( IN PIRP_CONTEXT  IrpContext,
IN PVCB  Vcb,
IN VBO  StartingVbo,
IN ULONG  ByteCount,
OUT PBCB Bcb,
OUT PVOID Buffer 
)

Definition at line 102 of file cachesup.c.

138{
140
141 PAGED_CODE();
142
143 //
144 // Check to see that all references are within the Bios Parameter Block
145 // or the fat(s). A special case is made when StartingVbo == 0 at
146 // mounting time since we do not know how big the fat is.
147 //
148
149 NT_ASSERT( ((StartingVbo == 0) || ((StartingVbo + ByteCount) <= (ULONG)
150 (FatRootDirectoryLbo( &Vcb->Bpb ) + PAGE_SIZE))));
151
152 DebugTrace(+1, Dbg, "FatReadVolumeFile\n", 0);
153 DebugTrace( 0, Dbg, "Vcb = %p\n", Vcb);
154 DebugTrace( 0, Dbg, "StartingVbo = %08lx\n", StartingVbo);
155 DebugTrace( 0, Dbg, "ByteCount = %08lx\n", ByteCount);
156
157 //
158 // Call the Cache manager to attempt the transfer.
159 //
160
161 Vbo.QuadPart = StartingVbo;
162
163 if (!CcMapData( Vcb->VirtualVolumeFile,
164 &Vbo,
165 ByteCount,
166 BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT),
167 Bcb,
168 Buffer )) {
169
170 NT_ASSERT( !FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
171
172 //
173 // Could not read the data without waiting (cache miss).
174 //
175
176 FatRaiseStatus( IrpContext, STATUS_CANT_WAIT );
177 }
178
179 DbgDoit( IrpContext->PinCount += 1 )
180
181 DebugTrace(-1, Dbg, "FatReadVolumeFile -> VOID, *BCB = %p\n", *Bcb);
182
183 return;
184}
return
Definition: dirsup.c:529
VOID FatReadVolumeFile(IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN VBO StartingVbo, IN ULONG ByteCount, OUT PBCB *Bcb, OUT PVOID *Buffer)
Definition: cachesup.c:102
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
BOOLEAN NTAPI CcMapData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *BcbResult, OUT PVOID *Buffer)
Definition: pinsup.c:694

Referenced by FatCheckDirtyBit(), FatExamineFatEntries(), and FatLookupFatEntry().

◆ FatRepinBcb()

VOID FatRepinBcb ( IN PIRP_CONTEXT  IrpContext,
IN PBCB  Bcb 
)

Definition at line 1317 of file cachesup.c.

1340{
1341 PREPINNED_BCBS Repinned;
1342 ULONG i;
1343
1344 PAGED_CODE();
1345
1346 DebugTrace(+1, Dbg, "FatRepinBcb\n", 0 );
1347 DebugTrace( 0, Dbg, "IrpContext = %p\n", IrpContext );
1348 DebugTrace( 0, Dbg, "Bcb = %p\n", Bcb );
1349
1350 //
1351 // The algorithm is to search the list of repinned records until
1352 // we either find a match for the bcb or we find a null slot.
1353 //
1354
1355 Repinned = &IrpContext->Repinned;
1356
1357 while (TRUE) {
1358
1359 //
1360 // For every entry in the repinned record check if the bcb's
1361 // match or if the entry is null. If the bcb's match then
1362 // we've done because we've already repinned this bcb, if
1363 // the entry is null then we know, because it's densely packed,
1364 // that the bcb is not in the list so add it to the repinned
1365 // record and repin it.
1366 //
1367
1368 for (i = 0; i < REPINNED_BCBS_ARRAY_SIZE; i += 1) {
1369
1370 if (Repinned->Bcb[i] == Bcb) {
1371
1372 DebugTrace(-1, Dbg, "FatRepinBcb -> VOID\n", 0 );
1373 return;
1374 }
1375
1376 if (Repinned->Bcb[i] == NULL) {
1377
1378 Repinned->Bcb[i] = Bcb;
1379 CcRepinBcb( Bcb );
1380
1381 DebugTrace(-1, Dbg, "FatRepinBcb -> VOID\n", 0 );
1382 return;
1383 }
1384 }
1385
1386 //
1387 // We finished checking one repinned record so now locate the next
1388 // repinned record, If there isn't one then allocate and zero out
1389 // a new one.
1390 //
1391
1392 if (Repinned->Next == NULL) {
1393
1395 sizeof(REPINNED_BCBS),
1397
1398 RtlZeroMemory( Repinned->Next, sizeof(REPINNED_BCBS) );
1399 }
1400
1401 Repinned = Repinned->Next;
1402 }
1403}
VOID NTAPI CcRepinBcb(IN PVOID Bcb)
Definition: cachesub.c:331
#define TAG_REPINNED_BCB
Definition: nodetype.h:169
#define REPINNED_BCBS_ARRAY_SIZE
Definition: fatstruc.h:1464
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
PVOID NTAPI FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes, IN ULONG Tag)
Definition: filter.c:229
struct _REPINNED_BCBS * Next
Definition: fatstruc.h:1472
PBCB Bcb[REPINNED_BCBS_ARRAY_SIZE]
Definition: fatstruc.h:1481

◆ FatSyncUninitializeCacheMap()

VOID FatSyncUninitializeCacheMap ( IN PIRP_CONTEXT  IrpContext,
IN PFILE_OBJECT  FileObject 
)

Definition at line 1812 of file cachesup.c.

1831{
1832 CACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent;
1833 NTSTATUS WaitStatus;
1834
1835 UNREFERENCED_PARAMETER( IrpContext );
1836
1837 PAGED_CODE();
1838
1839 KeInitializeEvent( &UninitializeCompleteEvent.Event,
1841 FALSE);
1842
1844 &FatLargeZero,
1845 &UninitializeCompleteEvent );
1846
1847 //
1848 // Now wait for the cache manager to finish purging the file.
1849 // This will garentee that Mm gets the purge before we
1850 // delete the Vcb.
1851 //
1852
1853#ifdef _MSC_VER
1854#pragma prefast( suppress: 28931, "we use WaitStatus in the debug assert, in fre builds prefast complains it's unused" )
1855#endif
1856 WaitStatus = KeWaitForSingleObject( &UninitializeCompleteEvent.Event,
1857 Executive,
1858 KernelMode,
1859 FALSE,
1860 NULL);
1861
1862 NT_ASSERT(WaitStatus == STATUS_SUCCESS);
1863}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
LARGE_INTEGER FatLargeZero
Definition: fatdata.c:62
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
@ Executive
Definition: ketypes.h:415

Referenced by _Requires_lock_held_(), and FatCloseEaFile().

◆ FatUnpinRepinnedBcbs()

VOID FatUnpinRepinnedBcbs ( IN PIRP_CONTEXT  IrpContext)

Definition at line 1407 of file cachesup.c.

1425{
1426 IO_STATUS_BLOCK RaiseIosb;
1427 PREPINNED_BCBS Repinned;
1428 BOOLEAN WriteThroughToDisk;
1430 BOOLEAN ForceVerify = FALSE;
1431 ULONG i;
1432 PFCB FcbOrDcb = NULL;
1433
1434 PAGED_CODE();
1435
1436 DebugTrace(+1, Dbg, "FatUnpinRepinnedBcbs\n", 0 );
1437 DebugTrace( 0, Dbg, "IrpContext = %p\n", IrpContext );
1438
1439 //
1440 // The algorithm for this procedure is to scan the entire list of
1441 // repinned records unpinning any repinned bcbs. We start off
1442 // with the first record in the irp context, and while there is a
1443 // record to scan we do the following loop.
1444 //
1445
1446 Repinned = &IrpContext->Repinned;
1447 RaiseIosb.Status = STATUS_SUCCESS;
1448
1449 //
1450 // WinSE bug #307418 "Occasional data corruption when
1451 // standby/resume while copying files to removable FAT
1452 // formatted media".
1453 // Extract main FCB pointer from the irp context - we
1454 // will need it later to detect new file creation operation.
1455 //
1456
1457 if (IrpContext->MajorFunction == IRP_MJ_CREATE &&
1458 IrpContext->OriginatingIrp != NULL) {
1460
1461 IrpSp = IoGetCurrentIrpStackLocation( IrpContext->OriginatingIrp );
1462
1463 if (IrpSp != NULL &&
1464 IrpSp->FileObject != NULL &&
1465 IrpSp->FileObject->FsContext != NULL) {
1466
1467 FcbOrDcb = IrpSp->FileObject->FsContext;
1468 }
1469 }
1470
1471 //
1472 // If the request is write through or the media is deferred flush,
1473 // unpin the bcb's write through.
1474 //
1475
1476 WriteThroughToDisk = (BOOLEAN) (!FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_DISABLE_WRITE_THROUGH) &&
1477 IrpContext->Vcb != NULL &&
1478 (FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH) ||
1479 FlagOn(IrpContext->Vcb->VcbState, VCB_STATE_FLAG_DEFERRED_FLUSH)));
1480
1481 while (Repinned != NULL) {
1482
1483 //
1484 // For every non-null entry in the repinned record unpin the
1485 // repinned entry.
1486 //
1487 // If the this is removable media (therefore all requests write-
1488 // through) and the write fails, purge the cache so that we throw
1489 // away the modifications as we will be returning an error to the
1490 // user.
1491 //
1492
1493 for (i = 0; i < REPINNED_BCBS_ARRAY_SIZE; i += 1) {
1494
1495 if (Repinned->Bcb[i] != NULL) {
1496
1498
1499 if (WriteThroughToDisk &&
1500 FlagOn(IrpContext->Vcb->VcbState, VCB_STATE_FLAG_DEFERRED_FLUSH)) {
1501
1502 FileObject = CcGetFileObjectFromBcb( Repinned->Bcb[i] );
1503 }
1504
1505 CcUnpinRepinnedBcb( Repinned->Bcb[i],
1506 WriteThroughToDisk,
1507 &Iosb );
1508
1509 if (!NT_SUCCESS(Iosb.Status)) {
1510
1511 if (RaiseIosb.Status == STATUS_SUCCESS) {
1512
1513 RaiseIosb = Iosb;
1514 }
1515
1516 //
1517 // If this was a writethrough device, purge the cache,
1518 // except for Irp major codes that either don't handle
1519 // the error paths correctly or are simple victims like
1520 // cleanup.c.
1521 //
1522
1523 if (FileObject &&
1524 (IrpContext->MajorFunction != IRP_MJ_CLEANUP) &&
1525 (IrpContext->MajorFunction != IRP_MJ_FLUSH_BUFFERS) &&
1526 (IrpContext->MajorFunction != IRP_MJ_SET_INFORMATION)
1527
1528 &&
1529
1530 //
1531 // WinSE bug #307418 "Occasional data corruption when
1532 // standby/resume while copying files to removable FAT
1533 // formatted media".
1534 // Buffer unpinning for new file creation operation can
1535 // be interrupted by system syspend. As a result some BCBs
1536 // will be successfully written to the disk while others will
1537 // be kicked back with STATUS_VERIFY_REQUIRED. Since there is
1538 // is still a chance for the failed BCBs to reach the disk
1539 // after the volume verification we'll not purge them.
1540 // Instead FatCommonCreate() will unroll the file creation
1541 // changes for these pages.
1542 //
1543
1544 !(IrpContext->MajorFunction == IRP_MJ_CREATE &&
1545 Iosb.Status == STATUS_VERIFY_REQUIRED &&
1546 FcbOrDcb != NULL &&
1547 NodeType( FcbOrDcb ) == FAT_NTC_FCB)) {
1548
1549 //
1550 // The call to CcPurgeCacheSection() below will
1551 // purge the entire file from memory. It will also
1552 // block until all the file's BCB's are pinned.
1553 //
1554 // We end up in a deadlock situation of there
1555 // are any other pinned BCB's in this IRP context
1556 // so the first thing we do is search the list
1557 // for BCB's pinned in the same file and unpin
1558 // them.
1559 //
1560 // We are probably not going to lose data because
1561 // it's safe to assume that all flushes will
1562 // fail after the first one fails.
1563 //
1564
1565 ULONG j;
1566 ULONG k = i + 1;
1567 PREPINNED_BCBS RepinnedToPurge = Repinned;
1568
1569 while( RepinnedToPurge != NULL ) {
1570
1571 for (j = k; j < REPINNED_BCBS_ARRAY_SIZE; j++) {
1572
1573 if (RepinnedToPurge->Bcb[j] != NULL) {
1574
1575 if (CcGetFileObjectFromBcb( RepinnedToPurge->Bcb[j] ) == FileObject) {
1576
1577 CcUnpinRepinnedBcb( RepinnedToPurge->Bcb[j],
1578 FALSE,
1579 &Iosb );
1580
1581 RepinnedToPurge->Bcb[j] = NULL;
1582 }
1583 }
1584 }
1585
1586 RepinnedToPurge = RepinnedToPurge->Next;
1587 k = 0;
1588 }
1589
1590 CcPurgeCacheSection( FileObject->SectionObjectPointer,
1591 NULL,
1592 0,
1593 FALSE );
1594
1595 //
1596 // Force a verify operation here since who knows
1597 // what state things are in.
1598 //
1599
1600 ForceVerify = TRUE;
1601 }
1602 }
1603
1604 Repinned->Bcb[i] = NULL;
1605
1606 }
1607 }
1608
1609 //
1610 // Now find the next repinned record in the list, and possibly
1611 // delete the one we've just processed.
1612 //
1613
1614 if (Repinned != &IrpContext->Repinned) {
1615
1616 PREPINNED_BCBS Saved;
1617
1618 Saved = Repinned->Next;
1619 ExFreePool( Repinned );
1620 Repinned = Saved;
1621
1622 } else {
1623
1624 Repinned = Repinned->Next;
1625 IrpContext->Repinned.Next = NULL;
1626 }
1627 }
1628
1629 //
1630 // Now if we weren't completely successful in the our unpin
1631 // then raise the iosb we got
1632 //
1633
1634 if (!NT_SUCCESS(RaiseIosb.Status)) {
1635
1636 if (ForceVerify && FileObject) {
1637
1638 SetFlag(FileObject->DeviceObject->Flags, DO_VERIFY_VOLUME);
1639
1640 IoSetHardErrorOrVerifyDevice( IrpContext->OriginatingIrp,
1641 FileObject->DeviceObject );
1642 }
1643
1644 if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_DISABLE_RAISE )) {
1645 if (IrpContext->OriginatingIrp) {
1646 IrpContext->OriginatingIrp->IoStatus = RaiseIosb;
1647 }
1648 FatNormalizeAndRaiseStatus( IrpContext, RaiseIosb.Status );
1649 }
1650 }
1651
1652 DebugTrace(-1, Dbg, "FatUnpinRepinnedBcbs -> VOID\n", 0 );
1653
1654 return;
1655}
NodeType
Definition: Node.h:6
unsigned char BOOLEAN
VOID NTAPI CcUnpinRepinnedBcb(IN PVOID Bcb, IN BOOLEAN WriteThrough, OUT PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:343
return Iosb
Definition: create.c:4402
#define FAT_NTC_FCB
Definition: nodetype.h:29
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IRP_CONTEXT_FLAG_WRITE_THROUGH
Definition: ext2fs.h:1088
IN PFCB FcbOrDcb
Definition: fatprocs.h:306
#define FatNormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
Definition: fatprocs.h:2995
#define IRP_CONTEXT_FLAG_DISABLE_RAISE
Definition: fatstruc.h:1573
#define VCB_STATE_FLAG_DEFERRED_FLUSH
Definition: fatstruc.h:568
#define IRP_CONTEXT_FLAG_DISABLE_WRITE_THROUGH
Definition: fatstruc.h:1565
PFILE_OBJECT NTAPI CcGetFileObjectFromBcb(PVOID Bcb)
Definition: fssup.c:625
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:386
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 GLint GLint j
Definition: glfuncs.h:250
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
int k
Definition: mpi.c:3369
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
#define BOOLEAN
Definition: pedump.c:73
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
Definition: cdstruc.h:902
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_CLEANUP

Referenced by _Requires_lock_held_(), FatCommonSetEa(), FatCompleteRequest_Real(), FatDeferredCleanVolume(), FatSetFsLabelInfo(), and FatSetRenameInfo().

◆ FatZeroData()

FINISHED FatZeroData ( IN PIRP_CONTEXT  IrpContext,
IN PVCB  Vcb,
IN PFILE_OBJECT  FileObject,
IN ULONG  StartingZero,
IN ULONG  ByteCount 
)

Definition at line 1659 of file cachesup.c.

1673{
1674#ifndef __REACTOS__
1675 LARGE_INTEGER ZeroStart = {0,0};
1676 LARGE_INTEGER BeyondZeroEnd = {0,0};
1677#else
1678 LARGE_INTEGER ZeroStart = {{0,0}};
1679 LARGE_INTEGER BeyondZeroEnd = {{0,0}};
1680#endif
1681
1683
1684 BOOLEAN Finished;
1685
1686 PAGED_CODE();
1687
1688 SectorSize = (ULONG)Vcb->Bpb.BytesPerSector;
1689
1690 ZeroStart.LowPart = (StartingZero + (SectorSize - 1)) & ~(SectorSize - 1);
1691
1692 //
1693 // Detect overflow if we were asked to zero in the last sector of the file,
1694 // which must be "zeroed" already (or we're in trouble).
1695 //
1696
1697 if (StartingZero != 0 && ZeroStart.LowPart == 0) {
1698
1699 return TRUE;
1700 }
1701
1702 //
1703 // Note that BeyondZeroEnd can take the value 4gb.
1704 //
1705
1706 BeyondZeroEnd.QuadPart = ((ULONGLONG) StartingZero + ByteCount + (SectorSize - 1))
1707 & (~((LONGLONG) SectorSize - 1));
1708
1709 //
1710 // If we were called to just zero part of a sector we are in trouble.
1711 //
1712
1713 if ( ZeroStart.QuadPart == BeyondZeroEnd.QuadPart ) {
1714
1715 return TRUE;
1716 }
1717
1718 Finished = CcZeroData( FileObject,
1719 &ZeroStart,
1720 &BeyondZeroEnd,
1721 BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
1722
1723 return Finished;
1724}
BOOLEAN NTAPI CcZeroData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
Definition: fssup.c:414
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_In_ ULONG SectorSize
Definition: halfuncs.h:291

Referenced by _Requires_lock_held_().