I am developing low level (SCSI) storage filter driver. The driver intercepts read IO’s and writes the data in smaller chunks to other locations.
In some rare cases the data that is read by the driver is corrupted.
The flow of the driver is like that:
- receive IRP and MDL
- build driver IRPs and MDLs using IoBuildPartialMdl() function.
- send original IRP and wait for response.
- Send driver IRPs with “custom” build MDLs
- wait for responses and reply to upper layers.
From time to time in step 4 the data is corrupted. Need to say that not all the data is corrupted and that usually there was a separate IO request coming for this data a short time before.
What is going on here? Am I using MDLs incorrect?
Apparently MDL can contain gaps where the data will be corrupted. The correct workaround is to copy the data.
http://msdn.microsoft.com/en-us/library/windows/hardware/gg463193.aspx