Pending Srb in Virtual Storport driver

Hi

I am writing a Virtual Storport driver that submits read/write IO to another driver -

  1. In StartIo->ExecuteSCSI for Read/Write, setting Srb Status to SRB_STATUS_PENDING.
  2. Build Irp using?IoBuildAsynchronousFsdRequest(). Set completion routine and call?IoCallDriver().
  3. NOT completing the Srb in StartIo().
  4. In completion routine, free the Irp. Set Srb Status to SRB_STATUS_SUCCESS and call StorportNotification(RequestComplete…) to complete the Srb.

I am seeing a crash after (4) which is not in my driver’s stack. From another old OSR thread http://www.osronline.com/showThread.cfm?link=220333, it looks similar issue of Srb timeout/double-complete.

Can someone please elaborate on what is the correct way of keeping Srb pending for later completion? Is there anything wrong with my sequence of operations?

Thanks in advanced.

Regards,
Kailas

The sequence itself sounds fine.

How long is the request pending? Are you getting called at any of your “reset” callbacks?

Peter
OSR
@OSRDrivers

> 1) In StartIo->ExecuteSCSI for Read/Write, setting Srb Status to SRB_STATUS_PENDING.

Don’t do that. It is useless code.

  1. Build Irp using?IoBuildAsynchronousFsdRequest()

You can’t call it from StartIo. Wrong IRQL.

I am seeing a crash after (4) which is not in my driver’s stack

Your IRP handling is probably wrong. Turn on driver verifier ASAP.

Ooooohhhhh… Great pickup, Mr. Eriksson, on the IRQL.

OP … Try running SDV as well.

Peter
OSR
@OSRDrivers

>You can’t call it from StartIo. Wrong IRQL.

It’s a virtual miniport. StartIo is called on DISPATCH_LEVEL (PNP/POWER SRBs are called on PASSIVE_LEVEL). BuildIo is never called.

Thanks all for the help. I will try calling IoBuildAsynchronousFsdRequest() from the Work Item scheduled from StartIo. I hope this approach is fine, kindly let me know if otherwise.

Will try Driver Verified and SDV if that doesn’t solve the issue.

Thanks & Regards,
Kailas

Tip: don’t try it later, turn driver verifier on FIRST. And leave it on during your development. Let it check everything except for low resource checking which should be done at a later time. You’d have to be crazy to develop a driver without verifier’s powerful error checking enabled. It is free and squashes bugs earlier to save development time and shorten the schedule.

Wisdom! Let us be attentive!

It’s only Monday and Mr. Eriksson’s post is already vying for post of the week honors.

Peter
OSR
@OSRDrivers

Hi

I could get IOs working fine on my virtual disk after moving IoBuildAsynchronousFsdRequest() out of StartIO.

My current approach is as bellow -

  1. Running dedicated kernel thread for IO submission
  2. In StartIO, Srb is added to the list and event is signaled to awake the thread, if sleeping.
  3. On event, kernel thread picks up all Srbs (one by one) from the list and sends it to another driver using IoBuildAsynchronousFsdRequest() and IoCallDriver().

Can someone please let me know whether this approach is correct from performance perspective? I am seeing very poor performance for the driver (though I am not sure storport is the bottleneck).
Also, it will be great if someone could direct on what configuration parameters should be double-checked to avoid any performance issues in virtual storport driver.

Thanks in advanced.

Regards,
Kailas