A.2.5 SCSI Filter Driver’s IoCompletion Routines

A SCSI filter driver’s IoCompletion routine is called when lower (class and port) drivers have called IoCompleteRequest. The SFD’s IoCompletion routine should return STATUS_MORE_PROCESSING_REQUIRED to prevent completion processing of a driver-allocated IRP. If the SFD will reuse the original IRP before the SFD completes it, the SFD’s IoCompletion routine also should return STATUS_MORE_PROCESSING_REQUIRED.

Like any other higher-level driver, an SFD’s IoCompletion routine is responsible for calling IoFreeIrp to release any IRP the driver’s Dispatch routine(s) created with IoAllocateIrp or IoBuildAsynchronousFsdRequest.

Depending on its device, an SFD might supply an IoCompletion routine for IRPs it sends to the class driver from its Dispatch routines. In particular, a device that retrieves and processes data in a nonstandard format might require the SFD to have a TranslateDataIn routine called from its IoCompletion routine for transfer requests from such a device to system memory.

Note that such a TranslateDataIn routine would be called at IRQL DISPATCH_LEVEL and in an arbitrary thread context. Therefore, the buffer into which the driver returns data either must be located in nonpaged pool or must be locked down and accessible using mapped, nonpaged system-space virtual addresses. For more information about accessing user-supplied buffers at raised IRQL safely, see Chapter 16.

In general, a SCSI filter driver should supply an IoCompletion routine with the same functionality as a class driver’s IoCompletion routine for IRPs that the filter driver sets up with SRBs and CDBs. Consequently, a SCSI filter driver might have any or all of the ReleaseQueue, InterpretRequestSense, or RetryRequest routines that can be called from a SCSI class driver’s IoCompletion routine(s).

For more information about InterpretRequestSense, RetryRequest, and ReleaseQueue routines, see Sections A.1.5.1, A.1.5.2, and A.1.5.3. For more information about general requirements for IoCompletion routines, see Chapter 13.