关于Fast I/O和IRP

来源:互联网 发布:java web项目开发书籍 编辑:程序博客网 时间:2024/05/01 21:33

这篇文章只是对Fast I/O和IRP做个简单的区分,不同点做简单的说明而已。


NT 下 Fast I/O 是一套 IO MANAGER 与 DEVICE DRIVER 沟通的另外一套 API。在进行基于 IRP 为基础的接口调用前, IO MANAGER 会尝试使用Fast I/O接口来加速各种 IO操作.

首先,Fast I/O是独立于普通的处理 IRP的分发函数之外的另一组接口。但是他们的作用是一样的,就是由驱动处理外部给予的请求。而且所处理的请求也基本相同。

其次,文件系统的普通分发例程和 fastio 例程都随时有可能被调用。做好的过滤驱动显然应该同时过滤这两套接口。然而,一般都只介绍 IRP过滤的方法。Fast I/O接口非常复杂。但是与 IRP过滤是基本一一对应的。


下面附上一段DDK的原文,希望对那些想深入了解他们之间区别的同志们有帮助。

IRPs Are Different From Fast I/O

    IRPs are the default mechanism for requesting I/O operations. IRPs can be used for synchronous or asynchronous I/O, and for cached or noncached I/O. IRPs are also used for paging I/O. The Memory Manager processes page faults by sending appropriate IRPs to the file system.

   Fast I/O is specifically designed for rapid synchronous I/O on cached files. In fast I/O operations, data is transferred directly between user buffers and the system cache, bypassing the file system and the storage driver stack. (Storage drivers do not use fast I/O.) If all of the data to be read from a file is resident in the system cache when a fast I/O read or write request is received, the request is satisfied immediately. Otherwise, a page fault can occur, causing one or more IRPs to be generated. When this happens, the fast I/O routine either returns FALSE, or puts the caller into a wait state until the page fault is processed. If the fast I/O routine returns FALSE, the requested operation failed and the caller must create an IRP.

    File systems are required to support IRPs, but they are not required to support fast I/O. When the I/O Manager receives a request for synchronous file I/O (other than paging I/O), it first determines whether the target device object's driver contains an appropriate fast I/O callback routine. If it does, the I/O Manager invokes the fast I/O routine. If no such fast I/O routine is found, the I/O Manager creates and sends an IRP instead.

    File system filter drivers are not required to support I/O on control device objects. However, filter device objects that are attached to file systems or volumes are required to pass all unrecognized or unwanted IRPs to the next-lower driver on the driver stack. In addition, filter device objects that are attached to volumes must implementFastIoDetachDevice.



原创粉丝点击