Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenfastio.c
Go to the documentation of this file.
00001 /************************************************************************* 00002 * 00003 * File: fastio.c 00004 * 00005 * Module: Ext2 File System Driver (Kernel mode execution only) 00006 * 00007 * Description: 00008 * Contains code to handle the various "fast-io" calls. 00009 * 00010 * Author: Manoj Paul Joseph 00011 * 00012 * 00013 *************************************************************************/ 00014 00015 #include "ext2fsd.h" 00016 00017 // define the file specific bug-check id 00018 #define EXT2_BUG_CHECK_ID EXT2_FILE_FAST_IO 00019 00020 00021 00022 /************************************************************************* 00023 * 00024 * Function: Ext2FastIoCheckIfPossible() 00025 * 00026 * Description: 00027 * To fast-io or not to fast-io, that is the question ... 00028 * This routine helps the I/O Manager determine whether the FSD wishes 00029 * to permit fast-io on a specific file stream. 00030 * 00031 * Expected Interrupt Level (for execution) : 00032 * 00033 * IRQL_PASSIVE_LEVEL 00034 * 00035 * Return Value: TRUE/FALSE 00036 * 00037 *************************************************************************/ 00038 BOOLEAN NTAPI Ext2FastIoCheckIfPossible( 00039 IN PFILE_OBJECT FileObject, 00040 IN PLARGE_INTEGER FileOffset, 00041 IN ULONG Length, 00042 IN BOOLEAN Wait, 00043 IN ULONG LockKey, 00044 IN BOOLEAN CheckForReadOperation, 00045 OUT PIO_STATUS_BLOCK IoStatus, 00046 IN PDEVICE_OBJECT DeviceObject) 00047 { 00048 BOOLEAN ReturnedStatus = FALSE; 00049 PtrExt2FCB PtrFCB = NULL; 00050 PtrExt2CCB PtrCCB = NULL; 00051 LARGE_INTEGER IoLength; 00052 00053 // Obtain a pointer to the FCB and CCB for the file stream. 00054 PtrCCB = (PtrExt2CCB)(FileObject->FsContext2); 00055 ASSERT(PtrCCB); 00056 PtrFCB = PtrCCB->PtrFCB; 00057 ASSERT(PtrFCB); 00058 00059 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoCheckIfPossible - Denying", 0); 00060 if( FileObject ) 00061 { 00062 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00063 } 00064 00065 AssertFCBorVCB( PtrFCB ); 00066 00067 /* if( !( PtrFCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_FCB 00068 || PtrFCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_VCB ) ) 00069 { 00070 // Ext2BreakPoint(); 00071 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Invalid FCB...", 0); 00072 00073 return FALSE; 00074 } 00075 */ 00076 00077 return FALSE; 00078 00079 // Validate that this is a fast-IO request to a regular file. 00080 // The sample FSD for example, will not allow fast-IO requests 00081 // to volume objects, or to directories. 00082 if ((PtrFCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_VCB) || 00083 (PtrFCB->FCBFlags & EXT2_FCB_DIRECTORY)) 00084 { 00085 // This is not allowed. 00086 return(ReturnedStatus); 00087 } 00088 00089 IoLength = RtlConvertUlongToLargeInteger(Length); 00090 00091 // Your FSD can determine the checks that it needs to perform. 00092 // Typically, a FSD will check whether there exist any byte-range 00093 // locks that would prevent a fast-IO operation from proceeding. 00094 00095 // ... (FSD specific checks go here). 00096 00097 if (CheckForReadOperation) 00098 { 00099 // Chapter 11 describes how to use the FSRTL package for byte-range 00100 // lock requests. The following routine is exported by the FSRTL 00101 // package and it returns TRUE if the read operation should be 00102 // allowed to proceed based on the status of the current byte-range 00103 // locks on the file stream. If you do not use the FSRTL package 00104 // for byte-range locking support, then you must substitute your 00105 // own checks over here. 00106 // ReturnedStatus = FsRtlFastCheckLockForRead(&(PtrFCB->FCBByteRangeLock), 00107 // FileOffset, &IoLength, LockKey, FileObject, 00108 // PsGetCurrentProcess()); 00109 } 00110 else 00111 { 00112 // This is a write request. Invoke the FSRTL byte-range lock package 00113 // to see whether the write should be allowed to proceed. 00114 // ReturnedStatus = FsRtlFastCheckLockForWrite(&(PtrFCB->FCBByteRangeLock), 00115 // FileOffset, &IoLength, LockKey, FileObject, 00116 // PsGetCurrentProcess()); 00117 } 00118 00119 return(ReturnedStatus); 00120 } 00121 00122 00123 /************************************************************************* 00124 * 00125 * Function: Ext2FastIoRead() 00126 * 00127 * Description: 00128 * Bypass the traditional IRP method to perform a read operation. 00129 * 00130 * Expected Interrupt Level (for execution) : 00131 * 00132 * IRQL_PASSIVE_LEVEL 00133 * 00134 * Return Value: TRUE/FALSE 00135 * 00136 *************************************************************************/ 00137 BOOLEAN NTAPI Ext2FastIoRead( 00138 IN PFILE_OBJECT FileObject, 00139 IN PLARGE_INTEGER FileOffset, 00140 IN ULONG Length, 00141 IN BOOLEAN Wait, 00142 IN ULONG LockKey, 00143 OUT PVOID Buffer, 00144 OUT PIO_STATUS_BLOCK IoStatus, 00145 IN PDEVICE_OBJECT DeviceObject) 00146 { 00147 00148 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00149 NTSTATUS RC = STATUS_SUCCESS; 00150 PtrExt2IrpContext PtrIrpContext = NULL; 00151 00152 FsRtlEnterFileSystem(); 00153 00154 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoRead", 0); 00155 if( FileObject ) 00156 { 00157 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00158 } 00159 00160 00161 try 00162 { 00163 00164 try 00165 { 00166 00167 // Chapter 11 describes how to roll your own fast-IO entry points. 00168 // Typically, you will acquire appropriate resources here and 00169 // then (maybe) forward the request to FsRtlCopyRead(). 00170 // If you are a suitably complex file system, you may even choose 00171 // to do some pre-processing (e.g. prefetching data from someplace) 00172 // before passing on the request to the FSRTL package. 00173 00174 // Of course, you also have the option of bypassing the FSRTL 00175 // package completely and simply forwarding the request directly 00176 // to the NT Cache Manager. 00177 00178 // Bottom line is that you have complete flexibility on determining 00179 // what you decide to do here. Read Chapter 11 well (and obviously 00180 // other related issues) before filling in this and other fast-IO 00181 // dispatch entry points. 00182 00183 NOTHING; 00184 00185 } 00186 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00187 { 00188 00189 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00190 00191 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00192 00193 } 00194 } finally { 00195 00196 } 00197 00198 FsRtlExitFileSystem(); 00199 00200 return(ReturnedStatus); 00201 } 00202 00203 00204 /************************************************************************* 00205 * 00206 * Function: Ext2FastIoWrite() 00207 * 00208 * Description: 00209 * Bypass the traditional IRP method to perform a write operation. 00210 * 00211 * Expected Interrupt Level (for execution) : 00212 * 00213 * IRQL_PASSIVE_LEVEL 00214 * 00215 * Return Value: TRUE/FALSE 00216 * 00217 *************************************************************************/ 00218 BOOLEAN NTAPI Ext2FastIoWrite( 00219 IN PFILE_OBJECT FileObject, 00220 IN PLARGE_INTEGER FileOffset, 00221 IN ULONG Length, 00222 IN BOOLEAN Wait, 00223 IN ULONG LockKey, 00224 OUT PVOID Buffer, 00225 OUT PIO_STATUS_BLOCK IoStatus, 00226 IN PDEVICE_OBJECT DeviceObject) 00227 { 00228 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00229 NTSTATUS RC = STATUS_SUCCESS; 00230 PtrExt2IrpContext PtrIrpContext = NULL; 00231 00232 FsRtlEnterFileSystem(); 00233 00234 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoWrite", 0); 00235 if( FileObject ) 00236 { 00237 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00238 } 00239 try 00240 { 00241 try 00242 { 00243 00244 // See description in Ext2FastIoRead() before filling-in the 00245 // stub here. 00246 NOTHING; 00247 00248 } 00249 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00250 { 00251 00252 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00253 00254 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00255 00256 } 00257 } 00258 finally 00259 { 00260 00261 } 00262 00263 FsRtlExitFileSystem(); 00264 00265 return(ReturnedStatus); 00266 } 00267 00268 00269 /************************************************************************* 00270 * 00271 * Function: Ext2FastIoQueryBasicInfo() 00272 * 00273 * Description: 00274 * Bypass the traditional IRP method to perform a query basic 00275 * information operation. 00276 * 00277 * Expected Interrupt Level (for execution) : 00278 * 00279 * IRQL_PASSIVE_LEVEL 00280 * 00281 * Return Value: TRUE/FALSE 00282 * 00283 *************************************************************************/ 00284 BOOLEAN NTAPI Ext2FastIoQueryBasicInfo( 00285 IN PFILE_OBJECT FileObject, 00286 IN BOOLEAN Wait, 00287 OUT PFILE_BASIC_INFORMATION Buffer, 00288 OUT PIO_STATUS_BLOCK IoStatus, 00289 IN PDEVICE_OBJECT DeviceObject) 00290 { 00291 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00292 NTSTATUS RC = STATUS_SUCCESS; 00293 PtrExt2IrpContext PtrIrpContext = NULL; 00294 00295 FsRtlEnterFileSystem(); 00296 00297 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoQueryBasicInfo", 0); 00298 if( FileObject ) 00299 { 00300 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00301 } 00302 try 00303 { 00304 00305 try 00306 { 00307 00308 // See description in Ext2FastIoRead() before filling-in the 00309 // stub here. 00310 NOTHING; 00311 00312 } 00313 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00314 { 00315 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00316 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00317 } 00318 } 00319 finally 00320 { 00321 00322 } 00323 00324 FsRtlExitFileSystem(); 00325 00326 return(ReturnedStatus); 00327 } 00328 00329 /************************************************************************* 00330 * 00331 * Function: Ext2FastIoQueryStdInfo() 00332 * 00333 * Description: 00334 * Bypass the traditional IRP method to perform a query standard 00335 * information operation. 00336 * 00337 * Expected Interrupt Level (for execution) : 00338 * 00339 * IRQL_PASSIVE_LEVEL 00340 * 00341 * Return Value: TRUE/FALSE 00342 * 00343 *************************************************************************/ 00344 BOOLEAN NTAPI Ext2FastIoQueryStdInfo( 00345 IN PFILE_OBJECT FileObject, 00346 IN BOOLEAN Wait, 00347 OUT PFILE_STANDARD_INFORMATION Buffer, 00348 OUT PIO_STATUS_BLOCK IoStatus, 00349 IN PDEVICE_OBJECT DeviceObject) 00350 { 00351 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00352 NTSTATUS RC = STATUS_SUCCESS; 00353 PtrExt2IrpContext PtrIrpContext = NULL; 00354 00355 FsRtlEnterFileSystem(); 00356 00357 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoQueryStdInfo", 0); 00358 if( FileObject ) 00359 { 00360 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00361 } 00362 try 00363 { 00364 00365 try 00366 { 00367 00368 // See description in Ext2FastIoRead() before filling-in the 00369 // stub here. 00370 NOTHING; 00371 00372 } 00373 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00374 { 00375 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00376 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00377 } 00378 } 00379 finally 00380 { 00381 00382 } 00383 00384 FsRtlExitFileSystem(); 00385 00386 return(ReturnedStatus); 00387 } 00388 00389 /************************************************************************* 00390 * 00391 * Function: Ext2FastIoLock() 00392 * 00393 * Description: 00394 * Bypass the traditional IRP method to perform a byte range lock 00395 * operation. 00396 * 00397 * Expected Interrupt Level (for execution) : 00398 * 00399 * IRQL_PASSIVE_LEVEL 00400 * 00401 * Return Value: TRUE/FALSE 00402 * 00403 *************************************************************************/ 00404 BOOLEAN NTAPI Ext2FastIoLock( 00405 IN PFILE_OBJECT FileObject, 00406 IN PLARGE_INTEGER FileOffset, 00407 IN PLARGE_INTEGER Length, 00408 PEPROCESS ProcessId, 00409 ULONG Key, 00410 BOOLEAN FailImmediately, 00411 BOOLEAN ExclusiveLock, 00412 OUT PIO_STATUS_BLOCK IoStatus, 00413 IN PDEVICE_OBJECT DeviceObject) 00414 { 00415 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00416 NTSTATUS RC = STATUS_SUCCESS; 00417 PtrExt2IrpContext PtrIrpContext = NULL; 00418 00419 FsRtlEnterFileSystem(); 00420 00421 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoLock", 0); 00422 if( FileObject ) 00423 { 00424 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00425 } 00426 00427 try 00428 { 00429 00430 try 00431 { 00432 00433 // See description in Ext2FastIoRead() before filling-in the 00434 // stub here. 00435 NOTHING; 00436 00437 } 00438 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00439 { 00440 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00441 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00442 } 00443 } 00444 finally 00445 { 00446 00447 } 00448 00449 FsRtlExitFileSystem(); 00450 00451 return(ReturnedStatus); 00452 } 00453 00454 00455 /************************************************************************* 00456 * 00457 * Function: Ext2FastIoUnlockSingle() 00458 * 00459 * Description: 00460 * Bypass the traditional IRP method to perform a byte range unlock 00461 * operation. 00462 * 00463 * Expected Interrupt Level (for execution) : 00464 * 00465 * IRQL_PASSIVE_LEVEL 00466 * 00467 * Return Value: TRUE/FALSE 00468 * 00469 *************************************************************************/ 00470 BOOLEAN NTAPI Ext2FastIoUnlockSingle( 00471 IN PFILE_OBJECT FileObject, 00472 IN PLARGE_INTEGER FileOffset, 00473 IN PLARGE_INTEGER Length, 00474 PEPROCESS ProcessId, 00475 ULONG Key, 00476 OUT PIO_STATUS_BLOCK IoStatus, 00477 IN PDEVICE_OBJECT DeviceObject) 00478 { 00479 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00480 NTSTATUS RC = STATUS_SUCCESS; 00481 PtrExt2IrpContext PtrIrpContext = NULL; 00482 00483 FsRtlEnterFileSystem(); 00484 00485 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoUnlockSingle", 0); 00486 if( FileObject ) 00487 { 00488 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00489 } 00490 00491 try 00492 { 00493 00494 try 00495 { 00496 00497 // See description in Ext2FastIoRead() before filling-in the 00498 // stub here. 00499 NOTHING; 00500 00501 } 00502 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00503 { 00504 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00505 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00506 } 00507 } 00508 finally 00509 { 00510 00511 } 00512 00513 FsRtlExitFileSystem(); 00514 00515 return(ReturnedStatus); 00516 } 00517 00518 00519 /************************************************************************* 00520 * 00521 * Function: Ext2FastIoUnlockAll() 00522 * 00523 * Description: 00524 * Bypass the traditional IRP method to perform multiple byte range unlock 00525 * operations. 00526 * 00527 * Expected Interrupt Level (for execution) : 00528 * 00529 * IRQL_PASSIVE_LEVEL 00530 * 00531 * Return Value: TRUE/FALSE 00532 * 00533 *************************************************************************/ 00534 BOOLEAN NTAPI Ext2FastIoUnlockAll( 00535 IN PFILE_OBJECT FileObject, 00536 PEPROCESS ProcessId, 00537 OUT PIO_STATUS_BLOCK IoStatus, 00538 IN PDEVICE_OBJECT DeviceObject) 00539 { 00540 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00541 NTSTATUS RC = STATUS_SUCCESS; 00542 PtrExt2IrpContext PtrIrpContext = NULL; 00543 00544 FsRtlEnterFileSystem(); 00545 00546 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoUnlockAll", 0); 00547 if( FileObject ) 00548 { 00549 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00550 } 00551 00552 try 00553 { 00554 try 00555 { 00556 00557 // See description in Ext2FastIoRead() before filling-in the 00558 // stub here. 00559 NOTHING; 00560 00561 } 00562 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00563 { 00564 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00565 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00566 } 00567 } 00568 finally 00569 { 00570 00571 } 00572 00573 FsRtlExitFileSystem(); 00574 00575 return(ReturnedStatus); 00576 } 00577 00578 00579 /************************************************************************* 00580 * 00581 * Function: Ext2FastIoUnlockAllByKey() 00582 * 00583 * Description: 00584 * Bypass the traditional IRP method to perform multiple byte range unlock 00585 * operations. 00586 * 00587 * Expected Interrupt Level (for execution) : 00588 * 00589 * IRQL_PASSIVE_LEVEL 00590 * 00591 * Return Value: TRUE/FALSE 00592 * 00593 *************************************************************************/ 00594 BOOLEAN NTAPI Ext2FastIoUnlockAllByKey( 00595 IN PFILE_OBJECT FileObject, 00596 PVOID ProcessId, 00597 ULONG Key, 00598 OUT PIO_STATUS_BLOCK IoStatus, 00599 IN PDEVICE_OBJECT DeviceObject) 00600 { 00601 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 00602 NTSTATUS RC = STATUS_SUCCESS; 00603 PtrExt2IrpContext PtrIrpContext = NULL; 00604 00605 FsRtlEnterFileSystem(); 00606 00607 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoUnlockAllByKey", 0); 00608 if( FileObject ) 00609 { 00610 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00611 } 00612 try 00613 { 00614 00615 try 00616 { 00617 00618 // See description in Ext2FastIoRead() before filling-in the 00619 // stub here. 00620 NOTHING; 00621 00622 } 00623 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 00624 { 00625 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 00626 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 00627 } 00628 } 00629 finally 00630 { 00631 00632 } 00633 00634 FsRtlExitFileSystem(); 00635 00636 return(ReturnedStatus); 00637 } 00638 00639 00640 /************************************************************************* 00641 * 00642 * Function: Ext2FastIoAcqCreateSec() 00643 * 00644 * Description: 00645 * Not really a fast-io operation. Used by the VMM to acquire FSD resources 00646 * before processing a file map (create section object) request. 00647 * 00648 * Expected Interrupt Level (for execution) : 00649 * 00650 * IRQL_PASSIVE_LEVEL 00651 * 00652 * Return Value: None (we must be prepared to handle VMM initiated calls) 00653 * 00654 *************************************************************************/ 00655 void NTAPI Ext2FastIoAcqCreateSec( 00656 IN PFILE_OBJECT FileObject) 00657 { 00658 PtrExt2FCB PtrFCB = NULL; 00659 PtrExt2CCB PtrCCB = NULL; 00660 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 00661 00662 // Obtain a pointer to the FCB and CCB for the file stream. 00663 PtrCCB = (PtrExt2CCB)(FileObject->FsContext2); 00664 ASSERT(PtrCCB); 00665 PtrFCB = PtrCCB->PtrFCB; 00666 ASSERT(PtrFCB); 00667 00668 AssertFCB( PtrFCB ); 00669 00670 /* if( PtrFCB->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) 00671 { 00672 // Ext2BreakPoint(); 00673 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Invalid FCB...", 0); 00674 return; 00675 } */ 00676 00677 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 00678 00679 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoAcqCreateSec", 0); 00680 if( FileObject ) 00681 { 00682 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00683 } 00684 00685 // Acquire the MainResource exclusively for the file stream 00686 00687 DebugTrace(DEBUG_TRACE_MISC, "*** Attempting to acquire FCB Exclusively [FastIo]", 0); 00688 00689 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", PtrReqdFCB->MainResource.ActiveCount, PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 00690 ExAcquireResourceExclusiveLite(&(PtrReqdFCB->MainResource), TRUE); 00691 00692 DebugTrace(DEBUG_TRACE_MISC,"*** FCB acquired [FastIo]", 0); 00693 00694 // Although this is typically not required, the sample FSD will 00695 // also acquire the PagingIoResource exclusively at this time 00696 // to conform with the resource acquisition described in the set 00697 // file information routine. Once again though, you will probably 00698 // not need to do this. 00699 DebugTrace(DEBUG_TRACE_MISC,"*** Attempting to acquire FCBPaging Exclusively [FastIo]", 0); 00700 DebugTraceState( "FCBPaging AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", PtrReqdFCB->PagingIoResource.ActiveCount, PtrReqdFCB->PagingIoResource.NumberOfExclusiveWaiters, PtrReqdFCB->PagingIoResource.NumberOfSharedWaiters ); 00701 ExAcquireResourceExclusiveLite(&(PtrReqdFCB->PagingIoResource), TRUE); 00702 00703 DebugTrace(DEBUG_TRACE_MISC,"*** FCBPaging acquired [FastIo]", 0); 00704 00705 return; 00706 } 00707 00708 00709 /************************************************************************* 00710 * 00711 * Function: Ext2FastIoRelCreateSec() 00712 * 00713 * Description: 00714 * Not really a fast-io operation. Used by the VMM to release FSD resources 00715 * after processing a file map (create section object) request. 00716 * 00717 * Expected Interrupt Level (for execution) : 00718 * 00719 * IRQL_PASSIVE_LEVEL 00720 * 00721 * Return Value: None 00722 * 00723 *************************************************************************/ 00724 void NTAPI Ext2FastIoRelCreateSec( 00725 IN PFILE_OBJECT FileObject) 00726 { 00727 00728 PtrExt2FCB PtrFCB = NULL; 00729 PtrExt2CCB PtrCCB = NULL; 00730 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 00731 00732 // Obtain a pointer to the FCB and CCB for the file stream. 00733 PtrCCB = (PtrExt2CCB)(FileObject->FsContext2); 00734 ASSERT(PtrCCB); 00735 PtrFCB = PtrCCB->PtrFCB; 00736 ASSERT(PtrFCB); 00737 AssertFCB( PtrFCB ); 00738 00739 /* if( PtrFCB->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) 00740 { 00741 // Ext2BreakPoint(); 00742 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Invalid FCB...", 0); 00743 return; 00744 }*/ 00745 00746 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 00747 00748 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoRelCreateSec", 0); 00749 if( FileObject ) 00750 { 00751 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 00752 } 00753 00754 // Release the PagingIoResource for the file stream 00755 Ext2ReleaseResource(&(PtrReqdFCB->PagingIoResource)); 00756 DebugTrace(DEBUG_TRACE_MISC, "*** FCBPaging Released in [FastIo]", 0); 00757 DebugTraceState( "FCBPaging AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", 00758 PtrReqdFCB->PagingIoResource.ActiveCount, 00759 PtrReqdFCB->PagingIoResource.NumberOfExclusiveWaiters, 00760 PtrReqdFCB->PagingIoResource.NumberOfSharedWaiters ); 00761 00762 // Release the MainResource for the file stream 00763 Ext2ReleaseResource(&(PtrReqdFCB->MainResource)); 00764 DebugTrace(DEBUG_TRACE_MISC, "*** FCB Released [FastIo]", 0); 00765 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", 00766 PtrReqdFCB->MainResource.ActiveCount, 00767 PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, 00768 PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 00769 00770 return; 00771 } 00772 00773 00774 /************************************************************************* 00775 * 00776 * Function: Ext2AcqLazyWrite() 00777 * 00778 * Description: 00779 * Not really a fast-io operation. Used by the NT Cache Mgr to acquire FSD 00780 * resources before performing a delayed write (write behind/lazy write) 00781 * operation. 00782 * NOTE: this function really must succeed since the Cache Manager will 00783 * typically ignore failure and continue on ... 00784 * 00785 * Expected Interrupt Level (for execution) : 00786 * 00787 * IRQL_PASSIVE_LEVEL 00788 * 00789 * Return Value: TRUE/FALSE (Cache Manager does not tolerate FALSE well) 00790 * 00791 *************************************************************************/ 00792 BOOLEAN NTAPI Ext2AcqLazyWrite( 00793 IN PVOID Context, 00794 IN BOOLEAN Wait) 00795 { 00796 BOOLEAN ReturnedStatus = TRUE; 00797 00798 PtrExt2VCB PtrVCB = NULL; 00799 PtrExt2FCB PtrFCB = NULL; 00800 PtrExt2CCB PtrCCB = NULL; 00801 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 00802 00803 // The context is whatever we passed to the Cache Manager when invoking 00804 // the CcInitializeCacheMaps() function. In the case of the sample FSD 00805 // implementation, this context is a pointer to the CCB structure. 00806 00807 ASSERT(Context); 00808 PtrCCB = (PtrExt2CCB)(Context); 00809 00810 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2AcqLazyWrite", 0); 00811 00812 if(PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_CCB) 00813 { 00814 // 00815 // Acquiring Resource for a file write... 00816 // 00817 PtrFCB = PtrCCB->PtrFCB; 00818 AssertFCB( PtrFCB ); 00819 } 00820 else if( PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_VCB ) 00821 { 00822 // 00823 // Acquiring Resource for a volume write... 00824 // 00825 PtrVCB = ( PtrExt2VCB )PtrCCB; 00826 PtrCCB = NULL; 00827 DebugTrace(DEBUG_TRACE_MISC,"~~~[FastIO call]~~~ Ext2AcqLazyWrite - for Volume", 0); 00828 00829 // Acquire nothing... 00830 // Just proceed... 00831 return TRUE; 00832 00833 } 00834 else if( PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_FCB ) 00835 { 00836 // 00837 // This must have been a FCB created / maintained on the FSD's initiative... 00838 // This would have been done to cache access to a directory... 00839 // 00840 PtrFCB = ( PtrExt2FCB )PtrCCB; 00841 PtrCCB = NULL; 00842 } 00843 else 00844 { 00845 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Ext2AcqLazyWrite - Invalid context", 0); 00846 Ext2BreakPoint(); 00847 return FALSE; 00848 } 00849 00850 if( PtrCCB && PtrCCB->PtrFileObject ) 00851 { 00852 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", PtrCCB->PtrFileObject ); 00853 } 00854 00855 AssertFCB( PtrFCB ); 00856 00857 00858 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 00859 00860 00861 // Acquire the MainResource in the FCB exclusively. Then, set the 00862 // lazy-writer thread id in the FCB structure for identification when 00863 // an actual write request is received by the FSD. 00864 // Note: The lazy-writer typically always supplies WAIT set to TRUE. 00865 00866 DebugTrace(DEBUG_TRACE_MISC,"*** Attempting to acquire FCB Exclusively [FastIo]", 0); 00867 00868 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", PtrReqdFCB->MainResource.ActiveCount, PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 00869 if (!ExAcquireResourceExclusiveLite(&(PtrReqdFCB->MainResource), 00870 Wait)) 00871 { 00872 DebugTrace(DEBUG_TRACE_MISC,"*** Attempt to acquire FCB FAILED [FastIo]", 0); 00873 ReturnedStatus = FALSE; 00874 } 00875 else 00876 { 00877 DebugTrace(DEBUG_TRACE_MISC,"*** FCB acquired [FastIo]", 0); 00878 // Now, set the lazy-writer thread id. 00879 ASSERT(!(PtrFCB->LazyWriterThreadID)); 00880 PtrFCB->LazyWriterThreadID = (unsigned int)(PsGetCurrentThread()); 00881 } 00882 00883 // If your FSD needs to perform some special preparations in anticipation 00884 // of receving a lazy-writer request, do so now. 00885 00886 return(ReturnedStatus); 00887 } 00888 00889 00890 /************************************************************************* 00891 * 00892 * Function: Ext2RelLazyWrite() 00893 * 00894 * Description: 00895 * Not really a fast-io operation. Used by the NT Cache Mgr to release FSD 00896 * resources after performing a delayed write (write behind/lazy write) 00897 * operation. 00898 * 00899 * Expected Interrupt Level (for execution) : 00900 * 00901 * IRQL_PASSIVE_LEVEL 00902 * 00903 * Return Value: None 00904 * 00905 *************************************************************************/ 00906 void NTAPI Ext2RelLazyWrite( 00907 IN PVOID Context) 00908 { 00909 00910 PtrExt2VCB PtrVCB = NULL; 00911 PtrExt2FCB PtrFCB = NULL; 00912 PtrExt2CCB PtrCCB = NULL; 00913 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 00914 00915 // The context is whatever we passed to the Cache Manager when invoking 00916 // the CcInitializeCacheMaps() function. In the case of the sample FSD 00917 // implementation, this context is a pointer to the CCB structure. 00918 00919 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2RelLazyWrite", 0); 00920 00921 ASSERT(Context); 00922 PtrCCB = (PtrExt2CCB)(Context); 00923 00924 if(PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_CCB) 00925 { 00926 PtrFCB = PtrCCB->PtrFCB; 00927 AssertFCB( PtrFCB ); 00928 } 00929 else if( PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_VCB ) 00930 { 00931 PtrVCB = ( PtrExt2VCB )PtrCCB; 00932 PtrCCB = NULL; 00933 DebugTrace(DEBUG_TRACE_MISC,"~~~[FastIO call]~~~ Ext2RelLazyWrite - for Volume", 0); 00934 00935 // Acquire was acquired nothing... 00936 // Just return... 00937 return; 00938 00939 } 00940 else if( PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_FCB ) 00941 { 00942 // 00943 // This must have been a FCB created / maintained on the FSD's initiative... 00944 // This would have been done to cache access to a directory... 00945 // 00946 PtrFCB = ( PtrExt2FCB )PtrCCB; 00947 PtrCCB = NULL; 00948 } 00949 else 00950 { 00951 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Ext2RelLazyWrite - Invalid context", 0); 00952 Ext2BreakPoint(); 00953 return ; 00954 } 00955 00956 if( PtrCCB && PtrCCB->PtrFileObject ) 00957 { 00958 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", PtrCCB->PtrFileObject ); 00959 } 00960 00961 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 00962 00963 // Remove the current thread-id from the FCB and release the MainResource. 00964 ASSERT( (PtrFCB->LazyWriterThreadID) == (unsigned int)PsGetCurrentThread() ); 00965 PtrFCB->LazyWriterThreadID = 0; 00966 00967 00968 // Release the acquired resource. 00969 Ext2ReleaseResource(&(PtrReqdFCB->MainResource)); 00970 DebugTrace(DEBUG_TRACE_MISC, "*** FCB Released [FastIo]", 0); 00971 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", 00972 PtrReqdFCB->MainResource.ActiveCount, 00973 PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, 00974 PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 00975 00976 // 00977 // Undo whatever else seems appropriate at this time... 00978 // 00979 00980 return; 00981 } 00982 00983 00984 /************************************************************************* 00985 * 00986 * Function: Ext2AcqReadAhead() 00987 * 00988 * Description: 00989 * Not really a fast-io operation. Used by the NT Cache Mgr to acquire FSD 00990 * resources before performing a read-ahead operation. 00991 * NOTE: this function really must succeed since the Cache Manager will 00992 * typically ignore failure and continue on ... 00993 * 00994 * Expected Interrupt Level (for execution) : 00995 * 00996 * IRQL_PASSIVE_LEVEL 00997 * 00998 * Return Value: TRUE/FALSE (Cache Manager does not tolerate FALSE well) 00999 * 01000 *************************************************************************/ 01001 BOOLEAN NTAPI Ext2AcqReadAhead( 01002 IN PVOID Context, 01003 IN BOOLEAN Wait) 01004 { 01005 01006 BOOLEAN ReturnedStatus = TRUE; 01007 01008 PtrExt2FCB PtrFCB = NULL; 01009 PtrExt2CCB PtrCCB = NULL; 01010 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 01011 01012 // The context is whatever we passed to the Cache Manager when invoking 01013 // the CcInitializeCacheMaps() function. In the case of the sample FSD 01014 // implementation, this context is a pointer to the CCB structure. 01015 01016 ASSERT(Context); 01017 PtrCCB = (PtrExt2CCB)(Context); 01018 ASSERT(PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_CCB); 01019 01020 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2AcqReadAhead", 0); 01021 if( PtrCCB && PtrCCB->PtrFileObject ) 01022 { 01023 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", PtrCCB->PtrFileObject ); 01024 } 01025 01026 PtrFCB = PtrCCB->PtrFCB; 01027 ASSERT(PtrFCB); 01028 01029 AssertFCB( PtrFCB ); 01030 /* 01031 if( PtrFCB->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) 01032 { 01033 // Ext2BreakPoint(); 01034 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Invalid FCB...", 0); 01035 return TRUE; 01036 } */ 01037 01038 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 01039 01040 // Acquire the MainResource in the FCB shared. 01041 // Note: The read-ahead thread typically always supplies WAIT set to TRUE. 01042 DebugTrace(DEBUG_TRACE_MISC,"*** Attempting to acquire FCB Shared [FastIo]", 0); 01043 01044 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", PtrReqdFCB->MainResource.ActiveCount, PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 01045 if (!ExAcquireResourceSharedLite(&(PtrReqdFCB->MainResource), Wait)) 01046 { 01047 DebugTrace(DEBUG_TRACE_MISC,"*** Attempt to acquire FCB FAILED [FastIo]", 0); 01048 ReturnedStatus = FALSE; 01049 } 01050 else 01051 { 01052 DebugTrace(DEBUG_TRACE_MISC,"*** FCB acquired [FastIo]", 0); 01053 } 01054 01055 // If your FSD needs to perform some special preparations in anticipation 01056 // of receving a read-ahead request, do so now. 01057 01058 return ReturnedStatus; 01059 01060 } 01061 01062 01063 01064 /************************************************************************* 01065 * 01066 * Function: Ext2RelReadAhead() 01067 * 01068 * Description: 01069 * Not really a fast-io operation. Used by the NT Cache Mgr to release FSD 01070 * resources after performing a read-ahead operation. 01071 * 01072 * Expected Interrupt Level (for execution) : 01073 * 01074 * IRQL_PASSIVE_LEVEL 01075 * 01076 * Return Value: None 01077 * 01078 *************************************************************************/ 01079 void NTAPI Ext2RelReadAhead( 01080 IN PVOID Context) 01081 { 01082 PtrExt2FCB PtrFCB = NULL; 01083 PtrExt2CCB PtrCCB = NULL; 01084 PtrExt2NTRequiredFCB PtrReqdFCB = NULL; 01085 01086 01087 // The context is whatever we passed to the Cache Manager when invoking 01088 // the CcInitializeCacheMaps() function. In the case of the sample FSD 01089 // implementation, this context is a pointer to the CCB structure. 01090 01091 ASSERT(Context); 01092 PtrCCB = (PtrExt2CCB)(Context); 01093 ASSERT(PtrCCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_CCB); 01094 01095 PtrFCB = PtrCCB->PtrFCB; 01096 01097 AssertFCB( PtrFCB ); 01098 01099 // ASSERT(PtrFCB->NodeIdentifier.NodeType == EXT2_NODE_TYPE_FCB ); 01100 01101 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2RelReadAhead", 0); 01102 if( PtrCCB && PtrCCB->PtrFileObject ) 01103 { 01104 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", PtrCCB->PtrFileObject ); 01105 } 01106 01107 /* if( PtrFCB->NodeIdentifier.NodeType != EXT2_NODE_TYPE_FCB ) 01108 { 01109 // Ext2BreakPoint(); 01110 DebugTrace(DEBUG_TRACE_ERROR, "~~~[FastIO call]~~~ Invalid FCB...", 0); 01111 return; 01112 } */ 01113 01114 PtrReqdFCB = &(PtrFCB->NTRequiredFCB); 01115 01116 01117 // Release the acquired resource. 01118 Ext2ReleaseResource(&(PtrReqdFCB->MainResource)); 01119 DebugTrace(DEBUG_TRACE_MISC, "*** FCB Released [FastIo]", 0); 01120 DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [FastIo]", 01121 PtrReqdFCB->MainResource.ActiveCount, 01122 PtrReqdFCB->MainResource.NumberOfExclusiveWaiters, 01123 PtrReqdFCB->MainResource.NumberOfSharedWaiters ); 01124 01125 // Of course, your FSD should undo whatever else seems appropriate at this 01126 // time. 01127 01128 return; 01129 } 01130 01131 01132 /* the remaining are only valid under NT Version 4.0 and later */ 01133 #if(_WIN32_WINNT >= 0x0400) 01134 01135 01136 /************************************************************************* 01137 * 01138 * Function: Ext2FastIoQueryNetInfo() 01139 * 01140 * Description: 01141 * Get information requested by a redirector across the network. This call 01142 * will originate from the LAN Manager server. 01143 * 01144 * Expected Interrupt Level (for execution) : 01145 * 01146 * IRQL_PASSIVE_LEVEL 01147 * 01148 * Return Value: TRUE/FALSE 01149 * 01150 *************************************************************************/ 01151 BOOLEAN NTAPI Ext2FastIoQueryNetInfo( 01152 IN PFILE_OBJECT FileObject, 01153 IN BOOLEAN Wait, 01154 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer, 01155 OUT PIO_STATUS_BLOCK IoStatus, 01156 IN PDEVICE_OBJECT DeviceObject) 01157 { 01158 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 01159 NTSTATUS RC = STATUS_SUCCESS; 01160 PtrExt2IrpContext PtrIrpContext = NULL; 01161 01162 FsRtlEnterFileSystem(); 01163 01164 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoQueryNetInfo", 0); 01165 if( FileObject ) 01166 { 01167 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01168 } 01169 01170 try 01171 { 01172 01173 try 01174 { 01175 01176 // See description in Ext2FastIoRead() before filling-in the 01177 // stub here. 01178 NOTHING; 01179 01180 01181 } 01182 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01183 { 01184 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01185 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01186 } 01187 } 01188 finally 01189 { 01190 01191 } 01192 01193 FsRtlExitFileSystem(); 01194 01195 return(ReturnedStatus); 01196 } 01197 01198 01199 /************************************************************************* 01200 * 01201 * Function: Ext2FastIoMdlRead() 01202 * 01203 * Description: 01204 * Bypass the traditional IRP method to perform a MDL read operation. 01205 * 01206 * Expected Interrupt Level (for execution) : 01207 * 01208 * IRQL_PASSIVE_LEVEL 01209 * 01210 * Return Value: TRUE/FALSE 01211 * 01212 *************************************************************************/ 01213 BOOLEAN NTAPI Ext2FastIoMdlRead( 01214 IN PFILE_OBJECT FileObject, 01215 IN PLARGE_INTEGER FileOffset, 01216 IN ULONG Length, 01217 IN ULONG LockKey, 01218 OUT PMDL *MdlChain, 01219 OUT PIO_STATUS_BLOCK IoStatus, 01220 IN PDEVICE_OBJECT DeviceObject) 01221 { 01222 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 01223 NTSTATUS RC = STATUS_SUCCESS; 01224 PtrExt2IrpContext PtrIrpContext = NULL; 01225 01226 FsRtlEnterFileSystem(); 01227 01228 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoMdlRead", 0); 01229 if( FileObject ) 01230 { 01231 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01232 } 01233 01234 try 01235 { 01236 01237 try 01238 { 01239 01240 // See description in Ext2FastIoRead() before filling-in the 01241 // stub here. 01242 NOTHING; 01243 01244 01245 } 01246 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01247 { 01248 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01249 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01250 } 01251 } 01252 finally 01253 { 01254 01255 } 01256 01257 FsRtlExitFileSystem(); 01258 01259 return(ReturnedStatus); 01260 } 01261 01262 01263 /************************************************************************* 01264 * 01265 * Function: Ext2FastIoMdlReadComplete() 01266 * 01267 * Description: 01268 * Bypass the traditional IRP method to inform the NT Cache Manager and the 01269 * FSD that the caller no longer requires the data locked in the system cache 01270 * or the MDL to stay around anymore .. 01271 * 01272 * Expected Interrupt Level (for execution) : 01273 * 01274 * IRQL_PASSIVE_LEVEL 01275 * 01276 * Return Value: TRUE/FALSE 01277 * 01278 *************************************************************************/ 01279 BOOLEAN NTAPI Ext2FastIoMdlReadComplete( 01280 IN PFILE_OBJECT FileObject, 01281 OUT PMDL MdlChain, 01282 IN PDEVICE_OBJECT DeviceObject) 01283 { 01284 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 01285 NTSTATUS RC = STATUS_SUCCESS; 01286 PtrExt2IrpContext PtrIrpContext = NULL; 01287 01288 FsRtlEnterFileSystem(); 01289 01290 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoMdlReadComplete", 0); 01291 if( FileObject ) 01292 { 01293 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01294 } 01295 01296 try 01297 { 01298 01299 try 01300 { 01301 01302 // See description in Ext2FastIoRead() before filling-in the 01303 // stub here. 01304 NOTHING; 01305 01306 } 01307 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01308 { 01309 01310 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01311 01312 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01313 01314 } 01315 } 01316 finally 01317 { 01318 01319 } 01320 01321 FsRtlExitFileSystem(); 01322 01323 return(ReturnedStatus); 01324 } 01325 01326 01327 /************************************************************************* 01328 * 01329 * Function: Ext2FastIoPrepareMdlWrite() 01330 * 01331 * Description: 01332 * Bypass the traditional IRP method to prepare for a MDL write operation. 01333 * 01334 * Expected Interrupt Level (for execution) : 01335 * 01336 * IRQL_PASSIVE_LEVEL 01337 * 01338 * Return Value: TRUE/FALSE 01339 * 01340 *************************************************************************/ 01341 BOOLEAN NTAPI Ext2FastIoPrepareMdlWrite( 01342 IN PFILE_OBJECT FileObject, 01343 IN PLARGE_INTEGER FileOffset, 01344 IN ULONG Length, 01345 IN ULONG LockKey, 01346 OUT PMDL *MdlChain, 01347 OUT PIO_STATUS_BLOCK IoStatus, 01348 IN PDEVICE_OBJECT DeviceObject) 01349 { 01350 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 01351 NTSTATUS RC = STATUS_SUCCESS; 01352 PtrExt2IrpContext PtrIrpContext = NULL; 01353 01354 FsRtlEnterFileSystem(); 01355 01356 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoPrepareMdlWrite", 0); 01357 if( FileObject ) 01358 { 01359 DebugTrace( DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01360 } 01361 01362 try 01363 { 01364 try 01365 { 01366 01367 // See description in Ext2FastIoRead() before filling-in the 01368 // stub here. 01369 NOTHING; 01370 01371 } except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) { 01372 01373 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01374 01375 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01376 01377 } 01378 } 01379 finally 01380 { 01381 01382 } 01383 01384 FsRtlExitFileSystem(); 01385 01386 return(ReturnedStatus); 01387 } 01388 01389 01390 /************************************************************************* 01391 * 01392 * Function: Ext2FastIoMdlWriteComplete() 01393 * 01394 * Description: 01395 * Bypass the traditional IRP method to inform the NT Cache Manager and the 01396 * FSD that the caller has updated the contents of the MDL. This data can 01397 * now be asynchronously written out to secondary storage by the Cache Mgr. 01398 * 01399 * Expected Interrupt Level (for execution) : 01400 * 01401 * IRQL_PASSIVE_LEVEL 01402 * 01403 * Return Value: TRUE/FALSE 01404 * 01405 *************************************************************************/ 01406 BOOLEAN NTAPI Ext2FastIoMdlWriteComplete( 01407 IN PFILE_OBJECT FileObject, 01408 IN PLARGE_INTEGER FileOffset, 01409 OUT PMDL MdlChain, 01410 IN PDEVICE_OBJECT DeviceObject) 01411 { 01412 BOOLEAN ReturnedStatus = FALSE; // fast i/o failed/not allowed 01413 NTSTATUS RC = STATUS_SUCCESS; 01414 PtrExt2IrpContext PtrIrpContext = NULL; 01415 01416 FsRtlEnterFileSystem(); 01417 01418 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoMdlWriteComplete", 0); 01419 if( FileObject ) 01420 { 01421 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01422 } 01423 01424 try 01425 { 01426 01427 try 01428 { 01429 01430 // See description in Ext2FastIoRead() before filling-in the 01431 // stub here. 01432 NOTHING; 01433 01434 } 01435 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01436 { 01437 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01438 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01439 } 01440 } 01441 finally 01442 { 01443 01444 } 01445 01446 FsRtlExitFileSystem(); 01447 01448 return(ReturnedStatus); 01449 } 01450 01451 01452 /************************************************************************* 01453 * 01454 * Function: Ext2FastIoAcqModWrite() 01455 * 01456 * Description: 01457 * Not really a fast-io operation. Used by the VMM to acquire FSD resources 01458 * before initiating a write operation via the Modified Page/Block Writer. 01459 * 01460 * Expected Interrupt Level (for execution) : 01461 * 01462 * IRQL_PASSIVE_LEVEL 01463 * 01464 * Return Value: STATUS_SUCCESS/Error (try not to return an error, will 'ya ? :-) 01465 * 01466 *************************************************************************/ 01467 NTSTATUS NTAPI Ext2FastIoAcqModWrite( 01468 IN PFILE_OBJECT FileObject, 01469 IN PLARGE_INTEGER EndingOffset, 01470 OUT PERESOURCE *ResourceToRelease, 01471 IN PDEVICE_OBJECT DeviceObject) 01472 { 01473 NTSTATUS RC = STATUS_SUCCESS; 01474 PtrExt2IrpContext PtrIrpContext = NULL; 01475 01476 FsRtlEnterFileSystem(); 01477 01478 DebugTrace(DEBUG_TRACE_IRP_ENTRY,"~~~[FastIO call]~~~ Ext2FastIoAcqModWrite", 0); 01479 if( FileObject ) 01480 { 01481 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01482 } 01483 01484 try 01485 { 01486 try 01487 { 01488 01489 // You must determine which resource(s) you would like to 01490 // acquire at this time. You know that a write is imminent; 01491 // you will probably therefore acquire appropriate resources 01492 // exclusively. 01493 01494 // You must first get the FCB and CCB pointers from the file object 01495 // that is passed in to this function (as an argument). Note that 01496 // the ending offset (when examined in conjunction with current valid data 01497 // length) may help you in determining the appropriate resource(s) to acquire. 01498 01499 // For example, if the ending offset is beyond current valid data length, 01500 // you may decide to acquire *both* the MainResource and the PagingIoResource 01501 // exclusively; otherwise, you may decide simply to acquire the PagingIoResource. 01502 01503 // Consult the text for more information on synchronization in FSDs. 01504 01505 // One final note; the VMM expects that you will return a pointer to 01506 // the resource that you acquired (single return value). This pointer 01507 // will be returned back to you in the release call (below). 01508 01509 NOTHING; 01510 01511 } 01512 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01513 { 01514 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01515 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01516 } 01517 } 01518 finally 01519 { 01520 01521 } 01522 01523 FsRtlExitFileSystem(); 01524 01525 return(RC); 01526 } 01527 01528 01529 /************************************************************************* 01530 * 01531 * Function: Ext2FastIoRelModWrite() 01532 * 01533 * Description: 01534 * Not really a fast-io operation. Used by the VMM to release FSD resources 01535 * after processing a modified page/block write operation. 01536 * 01537 * Expected Interrupt Level (for execution) : 01538 * 01539 * IRQL_PASSIVE_LEVEL 01540 * 01541 * Return Value: STATUS_SUCCESS/Error (an error returned here is really not expected!) 01542 * 01543 *************************************************************************/ 01544 NTSTATUS NTAPI Ext2FastIoRelModWrite( 01545 IN PFILE_OBJECT FileObject, 01546 IN PERESOURCE ResourceToRelease, 01547 IN PDEVICE_OBJECT DeviceObject) 01548 { 01549 NTSTATUS RC = STATUS_SUCCESS; 01550 PtrExt2IrpContext PtrIrpContext = NULL; 01551 01552 FsRtlEnterFileSystem(); 01553 01554 DebugTrace( DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoRelModWrite", 0); 01555 if( FileObject ) 01556 { 01557 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01558 } 01559 01560 try 01561 { 01562 try 01563 { 01564 01565 // The MPW has complete the write for modified pages and therefore 01566 // wants you to release pre-acquired resource(s). 01567 01568 // You must undo here whatever it is that you did in the 01569 // Ext2FastIoAcqModWrite() call above. 01570 01571 NOTHING; 01572 01573 } 01574 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01575 { 01576 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01577 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01578 } 01579 } 01580 finally 01581 { 01582 01583 } 01584 01585 FsRtlExitFileSystem(); 01586 01587 return(RC); 01588 } 01589 01590 01591 /************************************************************************* 01592 * 01593 * Function: Ext2FastIoAcqCcFlush() 01594 * 01595 * Description: 01596 * Not really a fast-io operation. Used by the NT Cache Mgr to acquire FSD 01597 * resources before performing a CcFlush() operation on a specific file 01598 * stream. 01599 * 01600 * Expected Interrupt Level (for execution) : 01601 * 01602 * IRQL_PASSIVE_LEVEL 01603 * 01604 * Return Value: STATUS_SUCCESS/Error 01605 * 01606 *************************************************************************/ 01607 NTSTATUS NTAPI Ext2FastIoAcqCcFlush( 01608 IN PFILE_OBJECT FileObject, 01609 IN PDEVICE_OBJECT DeviceObject) 01610 { 01611 NTSTATUS RC = STATUS_SUCCESS; 01612 PtrExt2IrpContext PtrIrpContext = NULL; 01613 01614 FsRtlEnterFileSystem(); 01615 01616 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoAcqCcFlush", 0); 01617 if( FileObject ) 01618 { 01619 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01620 } 01621 01622 try 01623 { 01624 try 01625 { 01626 // Acquire appropriate resources that will allow correct synchronization 01627 // with a flush call (and avoid deadlock). 01628 NOTHING; 01629 01630 } 01631 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01632 { 01633 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01634 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01635 } 01636 } 01637 finally 01638 { 01639 01640 } 01641 01642 FsRtlExitFileSystem(); 01643 01644 return(RC); 01645 } 01646 01647 01648 /************************************************************************* 01649 * 01650 * Function: Ext2FastIoRelCcFlush() 01651 * 01652 * Description: 01653 * Not really a fast-io operation. Used by the NT Cache Mgr to acquire FSD 01654 * resources before performing a CcFlush() operation on a specific file 01655 * stream. 01656 * 01657 * Expected Interrupt Level (for execution) : 01658 * 01659 * IRQL_PASSIVE_LEVEL 01660 * 01661 * Return Value: STATUS_SUCCESS/Error 01662 * 01663 *************************************************************************/ 01664 NTSTATUS NTAPI Ext2FastIoRelCcFlush( 01665 IN PFILE_OBJECT FileObject, 01666 IN PDEVICE_OBJECT DeviceObject) 01667 { 01668 NTSTATUS RC = STATUS_SUCCESS; 01669 PtrExt2IrpContext PtrIrpContext = NULL; 01670 01671 FsRtlEnterFileSystem(); 01672 01673 DebugTrace(DEBUG_TRACE_IRP_ENTRY, "~~~[FastIO call]~~~ Ext2FastIoRelCcFlush", 0); 01674 if( FileObject ) 01675 { 01676 DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [FastIO]", FileObject); 01677 } 01678 01679 try 01680 { 01681 try 01682 { 01683 // Release resources acquired in Ext2FastIoAcqCcFlush() above. 01684 NOTHING; 01685 01686 } 01687 except (Ext2ExceptionFilter(PtrIrpContext, GetExceptionInformation())) 01688 { 01689 RC = Ext2ExceptionHandler(PtrIrpContext, NULL); 01690 Ext2LogEvent(EXT2_ERROR_INTERNAL_ERROR, RC); 01691 } 01692 } 01693 finally 01694 { 01695 01696 } 01697 01698 FsRtlExitFileSystem(); 01699 01700 return(RC); 01701 } 01702 01703 #endif //_WIN32_WINNT >= 0x0400 Generated on Sat May 26 2012 04:26:18 for ReactOS by
1.7.6.1
|