00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef _CACHE_
00022
#define _CACHE_
00023
00024
00025
00026
00027
00028
00029
00030 #define VACB_MAPPING_GRANULARITY (0x40000)
00031 #define VACB_OFFSET_SHIFT (18)
00032
00033
00034
00035
00036
00037 typedef struct _PUBLIC_BCB {
00038
00039
00040
00041
00042
00043
00044
00045 CSHORT
NodeTypeCode;
00046 CSHORT
NodeByteSize;
00047
00048
00049
00050
00051
00052 ULONG
MappedLength;
00053 LARGE_INTEGER
MappedFileOffset;
00054 }
PUBLIC_BCB, *
PPUBLIC_BCB;
00055
00056
00057
00058
00059
00060 typedef struct _CC_FILE_SIZES {
00061
00062 LARGE_INTEGER
AllocationSize;
00063 LARGE_INTEGER
FileSize;
00064 LARGE_INTEGER
ValidDataLength;
00065
00066 }
CC_FILE_SIZES, *
PCC_FILE_SIZES;
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
typedef
00090 BOOLEAN (*
PACQUIRE_FOR_LAZY_WRITE) (
00091 IN PVOID Context,
00092 IN BOOLEAN Wait
00093 );
00094
00095
00096
00097
00098
00099
typedef
00100 VOID (*
PRELEASE_FROM_LAZY_WRITE) (
00101 IN PVOID Context
00102 );
00103
00104
00105
00106
00107
00108
typedef
00109 BOOLEAN (*
PACQUIRE_FOR_READ_AHEAD) (
00110 IN PVOID Context,
00111 IN BOOLEAN Wait
00112 );
00113
00114
00115
00116
00117
00118
typedef
00119 VOID (*
PRELEASE_FROM_READ_AHEAD) (
00120 IN PVOID Context
00121 );
00122
00123 typedef struct _CACHE_MANAGER_CALLBACKS {
00124
00125 PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite;
00126 PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite;
00127 PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead;
00128 PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead;
00129
00130 }
CACHE_MANAGER_CALLBACKS, *
PCACHE_MANAGER_CALLBACKS;
00131
00132
00133
00134
00135
00136
00137 typedef struct _CACHE_UNINITIALIZE_EVENT {
00138 struct _CACHE_UNINITIALIZE_EVENT *
Next;
00139 KEVENT Event;
00140 }
CACHE_UNINITIALIZE_EVENT, *
PCACHE_UNINITIALIZE_EVENT;
00141
00142
00143
00144
00145
00146
00147
typedef
00148 VOID (*
PDIRTY_PAGE_ROUTINE) (
00149 IN
PFILE_OBJECT FileObject,
00150 IN PLARGE_INTEGER FileOffset,
00151 IN ULONG Length,
00152 IN PLARGE_INTEGER OldestLsn,
00153 IN PLARGE_INTEGER NewestLsn,
00154 IN PVOID
Context1,
00155 IN PVOID
Context2
00156 );
00157
00158
00159
00160
00161
00162
typedef
00163 VOID (*
PFLUSH_TO_LSN) (
00164 IN PVOID LogHandle,
00165 IN LARGE_INTEGER Lsn
00166 );
00167
00168
00169
00170
00171
00172
00173 #define CcIsFileCached(FO) ( \
00174
((FO)->SectionObjectPointer != NULL) && \
00175
(((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \
00176
)
00177
00178
00179
00180
00181
00182
00183 extern ULONG
CcThrowAway;
00184
00185
00186
00187
00188
00189 extern ULONG
CcFastReadNoWait;
00190 extern ULONG
CcFastReadWait;
00191 extern ULONG
CcFastReadResourceMiss;
00192 extern ULONG
CcFastReadNotPossible;
00193
00194 extern ULONG
CcFastMdlReadNoWait;
00195 extern ULONG
CcFastMdlReadWait;
00196 extern ULONG
CcFastMdlReadResourceMiss;
00197 extern ULONG
CcFastMdlReadNotPossible;
00198
00199 extern ULONG
CcMapDataNoWait;
00200 extern ULONG
CcMapDataWait;
00201 extern ULONG
CcMapDataNoWaitMiss;
00202 extern ULONG
CcMapDataWaitMiss;
00203
00204 extern ULONG
CcPinMappedDataCount;
00205
00206 extern ULONG
CcPinReadNoWait;
00207 extern ULONG
CcPinReadWait;
00208 extern ULONG
CcPinReadNoWaitMiss;
00209 extern ULONG
CcPinReadWaitMiss;
00210
00211 extern ULONG
CcCopyReadNoWait;
00212 extern ULONG
CcCopyReadWait;
00213 extern ULONG
CcCopyReadNoWaitMiss;
00214 extern ULONG
CcCopyReadWaitMiss;
00215
00216 extern ULONG
CcMdlReadNoWait;
00217 extern ULONG
CcMdlReadWait;
00218 extern ULONG
CcMdlReadNoWaitMiss;
00219 extern ULONG
CcMdlReadWaitMiss;
00220
00221 extern ULONG
CcReadAheadIos;
00222
00223 extern ULONG
CcLazyWriteIos;
00224 extern ULONG
CcLazyWritePages;
00225 extern ULONG
CcDataFlushes;
00226 extern ULONG
CcDataPages;
00227
00228 extern PULONG
CcMissCounter;
00229
00230
00231
00232
00233
00234
NTKERNELAPI
00235 BOOLEAN
00236
CcInitializeCacheManager (
00237 );
00238
00239
00240
00241
00242
00243
00244
NTKERNELAPI
00245
VOID
00246
CcInitializeCacheMap (
00247 IN
PFILE_OBJECT FileObject,
00248 IN PCC_FILE_SIZES FileSizes,
00249 IN BOOLEAN PinAccess,
00250 IN PCACHE_MANAGER_CALLBACKS Callbacks,
00251 IN PVOID LazyWriteContext
00252 );
00253
00254
NTKERNELAPI
00255 BOOLEAN
00256
CcUninitializeCacheMap (
00257 IN
PFILE_OBJECT FileObject,
00258 IN PLARGE_INTEGER TruncateSize OPTIONAL,
00259 IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL
00260 );
00261
00262
NTKERNELAPI
00263
VOID
00264
CcSetFileSizes (
00265 IN
PFILE_OBJECT FileObject,
00266 IN PCC_FILE_SIZES FileSizes
00267 );
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 #define CcGetFileSizePointer(FO) ( \
00278
((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \
00279
)
00280
00281
NTKERNELAPI
00282 BOOLEAN
00283
CcPurgeCacheSection (
00284 IN
PSECTION_OBJECT_POINTERS SectionObjectPointer,
00285 IN PLARGE_INTEGER FileOffset OPTIONAL,
00286 IN ULONG Length,
00287 IN BOOLEAN UninitializeCacheMaps
00288 );
00289
00290
NTKERNELAPI
00291
VOID
00292
CcSetDirtyPageThreshold (
00293 IN
PFILE_OBJECT FileObject,
00294 IN ULONG DirtyPageThreshold
00295 );
00296
00297
NTKERNELAPI
00298
VOID
00299
CcFlushCache (
00300 IN
PSECTION_OBJECT_POINTERS SectionObjectPointer,
00301 IN PLARGE_INTEGER FileOffset OPTIONAL,
00302 IN ULONG Length,
00303 OUT PIO_STATUS_BLOCK IoStatus OPTIONAL
00304 );
00305
00306
NTKERNELAPI
00307 LARGE_INTEGER
00308
CcGetFlushedValidData (
00309 IN
PSECTION_OBJECT_POINTERS SectionObjectPointer,
00310 IN BOOLEAN BcbListHeld
00311 );
00312
00313
00314
NTKERNELAPI
00315
VOID
00316
CcZeroEndOfLastPage (
00317 IN
PFILE_OBJECT FileObject
00318 );
00319
00320
00321
NTKERNELAPI
00322 BOOLEAN
00323
CcZeroData (
00324 IN
PFILE_OBJECT FileObject,
00325 IN PLARGE_INTEGER StartOffset,
00326 IN PLARGE_INTEGER EndOffset,
00327 IN BOOLEAN Wait
00328 );
00329
00330
NTKERNELAPI
00331 PVOID
00332
CcRemapBcb (
00333 IN PVOID Bcb
00334 );
00335
00336
NTKERNELAPI
00337
VOID
00338
CcRepinBcb (
00339 IN PVOID Bcb
00340 );
00341
00342
NTKERNELAPI
00343
VOID
00344
CcUnpinRepinnedBcb (
00345 IN PVOID Bcb,
00346 IN BOOLEAN WriteThrough,
00347 OUT PIO_STATUS_BLOCK IoStatus
00348 );
00349
00350
NTKERNELAPI
00351
PFILE_OBJECT
00352
CcGetFileObjectFromSectionPtrs (
00353 IN
PSECTION_OBJECT_POINTERS SectionObjectPointer
00354 );
00355
00356
NTKERNELAPI
00357
PFILE_OBJECT
00358
CcGetFileObjectFromBcb (
00359 IN PVOID Bcb
00360 );
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 #define CcCopyWriteWontFlush(FO,FOFF,LEN) ((LEN) <= 0X10000)
00376
00377
NTKERNELAPI
00378 BOOLEAN
00379
CcCanIWrite (
00380 IN
PFILE_OBJECT FileObject,
00381 IN ULONG BytesToWrite,
00382 IN BOOLEAN Wait,
00383 IN BOOLEAN Retrying
00384 );
00385
00386
typedef
00387 VOID (*
PCC_POST_DEFERRED_WRITE) (
00388 IN PVOID
Context1,
00389 IN PVOID
Context2
00390 );
00391
00392
NTKERNELAPI
00393
VOID
00394
CcDeferWrite (
00395 IN
PFILE_OBJECT FileObject,
00396 IN PCC_POST_DEFERRED_WRITE PostRoutine,
00397 IN PVOID Context1,
00398 IN PVOID Context2,
00399 IN ULONG BytesToWrite,
00400 IN BOOLEAN Retrying
00401 );
00402
00403
00404
00405
00406
00407
00408
NTKERNELAPI
00409 BOOLEAN
00410
CcCopyRead (
00411 IN
PFILE_OBJECT FileObject,
00412 IN PLARGE_INTEGER FileOffset,
00413 IN ULONG Length,
00414 IN BOOLEAN Wait,
00415 OUT PVOID Buffer,
00416 OUT PIO_STATUS_BLOCK IoStatus
00417 );
00418
00419
NTKERNELAPI
00420
VOID
00421
CcFastCopyRead (
00422 IN
PFILE_OBJECT FileObject,
00423 IN ULONG FileOffset,
00424 IN ULONG Length,
00425 IN ULONG PageCount,
00426 OUT PVOID Buffer,
00427 OUT PIO_STATUS_BLOCK IoStatus
00428 );
00429
00430
NTKERNELAPI
00431 BOOLEAN
00432
CcCopyWrite (
00433 IN
PFILE_OBJECT FileObject,
00434 IN PLARGE_INTEGER FileOffset,
00435 IN ULONG Length,
00436 IN BOOLEAN Wait,
00437 IN PVOID Buffer
00438 );
00439
00440
NTKERNELAPI
00441
VOID
00442
CcFastCopyWrite (
00443 IN
PFILE_OBJECT FileObject,
00444 IN ULONG FileOffset,
00445 IN ULONG Length,
00446 IN PVOID Buffer
00447 );
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
NTKERNELAPI
00458
VOID
00459
CcMdlRead (
00460 IN
PFILE_OBJECT FileObject,
00461 IN PLARGE_INTEGER FileOffset,
00462 IN ULONG Length,
00463 OUT
PMDL *MdlChain,
00464 OUT PIO_STATUS_BLOCK IoStatus
00465 );
00466
00467
00468
00469
00470
00471
NTKERNELAPI
00472
VOID
00473
CcMdlReadComplete (
00474 IN
PFILE_OBJECT FileObject,
00475 IN
PMDL MdlChain
00476 );
00477
00478
00479
NTKERNELAPI
00480
VOID
00481
CcMdlReadComplete2 (
00482 IN
PFILE_OBJECT FileObject,
00483 IN
PMDL MdlChain
00484 );
00485
00486
00487
00488
NTKERNELAPI
00489
VOID
00490
CcPrepareMdlWrite (
00491 IN
PFILE_OBJECT FileObject,
00492 IN PLARGE_INTEGER FileOffset,
00493 IN ULONG Length,
00494 OUT
PMDL *MdlChain,
00495 OUT PIO_STATUS_BLOCK IoStatus
00496 );
00497
00498
00499
00500
00501
00502
NTKERNELAPI
00503
VOID
00504
CcMdlWriteComplete (
00505 IN
PFILE_OBJECT FileObject,
00506 IN PLARGE_INTEGER FileOffset,
00507 IN
PMDL MdlChain
00508 );
00509
00510
00511
NTKERNELAPI
00512
VOID
00513
CcMdlWriteComplete2 (
00514 IN
PFILE_OBJECT FileObject,
00515 IN PLARGE_INTEGER FileOffset,
00516 IN
PMDL MdlChain
00517 );
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531 #define CcReadAhead(FO,FOFF,LEN) { \
00532
if ((LEN) >= 256) { \
00533
CcScheduleReadAhead((FO),(FOFF),(LEN)); \
00534
} \
00535
}
00536
00537
NTKERNELAPI
00538
VOID
00539
CcScheduleReadAhead (
00540 IN
PFILE_OBJECT FileObject,
00541 IN PLARGE_INTEGER FileOffset,
00542 IN ULONG Length
00543 );
00544
00545
00546
00547
00548
00549
00550
00551
00552
NTSTATUS
00553
CcWaitForCurrentLazyWriterActivity (
00554 );
00555
00556
00557
00558
00559
00560
00561
NTKERNELAPI
00562
VOID
00563
CcSetReadAheadGranularity (
00564 IN
PFILE_OBJECT FileObject,
00565 IN ULONG Granularity
00566 );
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582 #define PIN_WAIT (1)
00583
00584
00585
00586
00587
00588
00589
00590 #define PIN_EXCLUSIVE (2)
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600 #define PIN_NO_READ (4)
00601
00602
00603
00604
00605
00606
00607
00608
00609 #define PIN_IF_BCB (8)
00610
00611
NTKERNELAPI
00612 BOOLEAN
00613
CcPinRead (
00614 IN
PFILE_OBJECT FileObject,
00615 IN PLARGE_INTEGER FileOffset,
00616 IN ULONG Length,
00617 IN ULONG Flags,
00618 OUT PVOID *Bcb,
00619 OUT PVOID *Buffer
00620 );
00621
00622
NTKERNELAPI
00623 BOOLEAN
00624
CcMapData (
00625 IN
PFILE_OBJECT FileObject,
00626 IN PLARGE_INTEGER FileOffset,
00627 IN ULONG Length,
00628 IN BOOLEAN Wait,
00629 OUT PVOID *Bcb,
00630 OUT PVOID *Buffer
00631 );
00632
00633
NTKERNELAPI
00634 BOOLEAN
00635
CcPinMappedData (
00636 IN
PFILE_OBJECT FileObject,
00637 IN PLARGE_INTEGER FileOffset,
00638 IN ULONG Length,
00639 IN ULONG Flags,
00640 IN OUT PVOID *Bcb
00641 );
00642
00643
NTKERNELAPI
00644 BOOLEAN
00645
CcPreparePinWrite (
00646 IN
PFILE_OBJECT FileObject,
00647 IN PLARGE_INTEGER FileOffset,
00648 IN ULONG Length,
00649 IN BOOLEAN Zero,
00650 IN ULONG Flags,
00651 OUT PVOID *Bcb,
00652 OUT PVOID *Buffer
00653 );
00654
00655
NTKERNELAPI
00656
VOID
00657
CcSetDirtyPinnedData (
00658 IN PVOID BcbVoid,
00659 IN PLARGE_INTEGER Lsn OPTIONAL
00660 );
00661
00662
NTKERNELAPI
00663
VOID
00664
CcUnpinData (
00665 IN PVOID Bcb
00666 );
00667
00668
NTKERNELAPI
00669
VOID
00670
CcSetBcbOwnerPointer (
00671 IN PVOID Bcb,
00672 IN PVOID OwnerPointer
00673 );
00674
00675
NTKERNELAPI
00676
VOID
00677
CcUnpinDataForThread (
00678 IN PVOID Bcb,
00679 IN ERESOURCE_THREAD ResourceThreadId
00680 );
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
NTKERNELAPI
00692
VOID
00693
CcSetAdditionalCacheAttributes (
00694 IN
PFILE_OBJECT FileObject,
00695 IN BOOLEAN DisableReadAhead,
00696 IN BOOLEAN DisableWriteBehind
00697 );
00698
00699
00700
00701
NTKERNELAPI
00702
VOID
00703
CcSetLogHandleForFile (
00704 IN
PFILE_OBJECT FileObject,
00705 IN PVOID LogHandle,
00706 IN PFLUSH_TO_LSN FlushToLsnRoutine
00707 );
00708
00709
NTKERNELAPI
00710 LARGE_INTEGER
00711
CcGetDirtyPages (
00712 IN PVOID LogHandle,
00713 IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
00714 IN PVOID Context1,
00715 IN PVOID Context2
00716 );
00717
00718
00719
00720
NTKERNELAPI
00721 BOOLEAN
00722
CcIsThereDirtyData (
00723 IN
PVPB Vpb
00724 );
00725
00726
00727
00728
NTKERNELAPI
00729 LARGE_INTEGER
00730
CcGetLsnForFileObject(
00731 IN
PFILE_OBJECT FileObject,
00732 OUT PLARGE_INTEGER OldestLsn OPTIONAL
00733 );
00734
00735
#endif // CACHE