Hi
I have a Virtual Storport driver over USB on Windows 7 32-bit. When I copy a file from the disk that my driver exposes, the file is written properly to the target location (on another local drive not controlled by my driver). However, after that, the driver starts receiving an endless stream of calls to write the file (to the SOURCE drive exposed by my Virtual Storport driver).
When I perform the equivalent operations using USBSTOR.sys the file is written and the mysterious writes do not happen. I need this same behavior in my driver.
If I read a 1-byte file the problem does not happen. But, if I read 2-Megabyte file, then the problem happens.
In my driver, after I read a file from the my device’s USB disk and write it to my local c: drive, is see the following:
SysInternals Process Monitor shows and unending series of:
FASTIO_ACQUIRE_FOR_MOD_WRITE
WriteFile Offset: 0 Length 8,192, I?O FLAGS: Non-cached
FASTIO_RELEASE_FOR_MOD_WRITE EndingOffset: 9,851,829,641,261,907,056
… an endless stream of the the above with different lengths and offsets. Obviously that Ending Offset is troubling as I only have a 30 GB disk (incidentally that EndingOffset is 88B8BADC 8B147C70 in hex, suspiciously like two virtual memory addresses)
I see this usually for the file I just read, but sometimes also for other files that exist on that disk.
One one of those calls, I placed a breakpoint in my driver to see who is issuing the write request. This is the stack:
0: kd> k 100
ChildEBP RetAddr
[… my usbdrv.sys code to handle the write]
a2d3f8a8 9ca17634 usbdrv!HwStartIo+0xc8
a2d3f8b8 9ca191d0 storport!RaCallMiniportStartIo+0x1e
a2d3f8e0 9ca1944e storport!RaidAdapterPostScatterGatherExecute+0x156
a2d3f8f0 9ca26ed5 storport!RaidAdapterExecuteXrb+0x2d
a2d3f910 9ca1e3c9 storport!RaUnitStartIo+0xbf
a2d3f950 9ca249bc storport!RaidStartIoPacket+0x10c
a2d3f970 9ca27610 storport!RaidUnitSubmitRequest+0x4e
a2d3f990 9ca1d4f0 storport!RaUnitScsiIrp+0x114
a2d3f9ac 88e1ea51 storport!RaDriverScsiIrp+0x60
WARNING: Stack unwind information not available. Following frames may be wrong.
a2d3f9dc 88e1e40d bustrce9+0x4a51
a2d3f9f8 832514bc bustrce9+0x440d
a2d3fa10 893885a4 nt!IofCallDriver+0x63
a2d3fa20 89387fe8 CLASSPNP!SubmitTransferPacket+0x103
a2d3fa60 89388303 CLASSPNP!ServiceTransferRequest+0x225
a2d3fa88 893883bf CLASSPNP!ClassReadWrite+0x172
a2d3fa9c 832514bc CLASSPNP!ClassGlobalDispatch+0x20
a2d3fab4 88f39230 nt!IofCallDriver+0x63
a2d3fac8 88f392e5 partmgr!PmReadWrite+0x112
a2d3fadc 832514bc partmgr!PmGlobalDispatch+0x1d
a2d3faf4 88f4a9ae nt!IofCallDriver+0x63
a2d3fb10 832514bc volmgr!VmReadWrite+0x1a8
a2d3fb28 89342475 nt!IofCallDriver+0x63
a2d3fb34 89342548 fvevol!FveRequestPassThrough+0x31
a2d3fb50 89342759 fvevol!FveReadWrite+0x4e
a2d3fb80 893427a9 fvevol!FveFilterRundownReadWrite+0x197
a2d3fb90 832514bc fvevol!FveFilterRundownWrite+0x33
a2d3fba8 8940c76e nt!IofCallDriver+0x63
a2d3fc88 8940c8a5 rdyboost!SmdProcessReadWrite+0xa14
a2d3fca8 832514bc rdyboost!SmdDispatchReadWrite+0xcb
a2d3fcc0 895bbfd9 nt!IofCallDriver+0x63
a2d3fce8 895bc2fd volsnap!VolsnapWriteFilter+0x265
a2d3fcf8 832514bc volsnap!VolSnapWrite+0x21
a2d3fd10 8901d94c nt!IofCallDriver+0x63
a2d3fd1c 8328527e Ntfs!NtfsStorageDriverCallout+0x14
a2d3fd1c 83285375 nt!KiSwapKernelStackAndExit+0x15a
8b147828 832a523d nt!KiSwitchKernelStackAndCallout+0x31
8b14789c 8901c952 nt!KeExpandKernelStackAndCalloutEx+0x29d
8b1478c8 8901d5d6 Ntfs!NtfsCallStorageDriver+0x2d
8b14790c 8901c0b9 Ntfs!NtfsMultipleAsync+0x4d
8b147a0c 8901b0c6 Ntfs!NtfsNonCachedIo+0x413
8b147b24 8901c878 Ntfs!NtfsCommonWrite+0x1eed
8b147b9c 832514bc Ntfs!NtfsFsdWrite+0x2e1
8b147bb4 88dbd20c nt!IofCallDriver+0x63
8b147bd8 88dbd3cb fltmgr!FltpLegacyProcessingAfterPreCallbacksCompleted+0x2aa
8b147c10 832514bc fltmgr!FltpDispatch+0xc5
8b147c28 8324e811 nt!IofCallDriver+0x63
8b147c3c 832991a1 nt!IoAsynchronousPageWrite+0x1c1
8b147cec 83299364 nt!MiGatherMappedPages+0xa62
8b147d50 83423a55 nt!MiMappedPageWriter+0x13d
8b147d90 832d5239 nt!PspSystemThreadStartup+0x9e
00000000 00000000 nt!KiThreadStartup+0x19
And this is the SRB that is sent to the driver:
0: kd> dt /b _SCSI_REQUEST_BLOCK 87052d1c
CLASSPNP!_SCSI_REQUEST_BLOCK
+0x000 Length : 0x40
+0x002 Function : 0 ‘’
+0x003 SrbStatus : 0 ‘’
+0x004 ScsiStatus : 0 ‘’
+0x005 PathId : 0 ‘’
+0x006 TargetId : 0 ‘’
+0x007 Lun : 0 ‘’
+0x008 QueueTag : 0xfc ‘’
+0x009 QueueAction : 0x20 ’ ’
+0x00a CdbLength : 0xa ‘’
+0x00b SenseInfoBufferLength : 0x14 ‘’
+0x00c SrbFlags : 0x40200382
+0x010 DataTransferLength : 0x200000
+0x014 TimeOutValue : 0x3c
+0x018 DataBuffer : 0xa3600000
+0x01c SenseInfoBuffer : 0x866f0230
+0x020 NextSrb : (null)
+0x024 OriginalRequest : 0x866f00b0
+0x028 SrbExtension : 0x866f0330
+0x02c InternalStatus : 0x5ebb90
+0x02c QueueSortKey : 0x5ebb90
+0x02c LinkTimeoutValue : 0x5ebb90
+0x030 Cdb : “*”
[00] 0x2a ‘*’
[01] 0 ‘’
[02] 0 ‘’
[03] 0x5e ‘^’
[04] 0xbb ‘’
[05] 0x90 ‘’
[06] 0 ‘’
[07] 0x10 ‘’
[08] 0 ‘’
[09] 0 ‘’
[10] 0 ‘’
[11] 0 ‘’
[12] 0 ‘’
[13] 0 ‘’
[14] 0 ‘’
[15] 0 ‘’
Might someone be able help me understand how to fix this?