SRB completion storport miniport driver

Hello,

I have questions about completion of SRB in Storport miniport (virtual)

  1. I have noticed that same SRB (same pointer address) comes with SCSIOP_INQUIRY op to miniport every 10 seconds. This happens if I didn’t complete (yet) previous request. To be exact I did not call StorPortNotification and didn’t change status to SRB_STATUS_BUSY.

Isn’t supposed that my miniport driver should hold ownership of that SRB until completion? Why systems submits same request with exact same SRB? I don’t mind to get another request after 10 sec, but not with exact same pointer address.

Is it possible to have influence on SRB Timeout so system never call SCSIOP_INQUIRY again?

  1. Do I need to complete pending SRB requests upon driver stop/restart/powerfailure/etc?

  2. The virtual disk storport miniport demo from WDK sometimes fails. I have traced that it is due to read/write operations that been scheduled to be completed in worker
    through IoQueueWorkItem(…). It occurs that ScsiStopAdapter eventually called and memory allocated for virtual disk got deleted (pLUExt->pDiskBuf==NULL)
    before completion of postponed WorkItem. I know how to fix it.
    Just a question: is it a bug in wdk sample or I am missing something?

  1. 10 seconds is the default timeout, you have to complete requests within
    this timeout or you get a reset. Does it really take you more than 10
    seconds to figure out what’s attached to your virtual bus?

  2. ScsiStopAdapter is sent for remove (at PASSIVE_LEVEL) and power down (at
    DIRQL). All requests are done at this point, so nothing to complete.
    ScsiRestartAdapter is called (at DIRQL) to power your adapter back up,
    nothing to complete here. I don’t know what power failure is…Note that you
    DO need to complete requests when handling a reset operation.

  3. I don’t have any experience with that sample, though I’m surprised it has
    outstanding I/O requests at ScsiStopAdapter (it’s my understanding that
    StorPort is supposed to prevent that). Are you removing the adapter or
    simply powering it down? The sample also shouldn’t be deleting its resources
    here in any case unless it’s a remove. In any case sounds like a bug to me.

-scott
OSR
@OSRDrivers

wrote in message news:xxxxx@ntdev…

Hello,

I have questions about completion of SRB in Storport miniport (virtual)

  1. I have noticed that same SRB (same pointer address) comes with
    SCSIOP_INQUIRY op to miniport every 10 seconds. This happens if I didn’t
    complete (yet) previous request. To be exact I did not call
    StorPortNotification and didn’t change status to SRB_STATUS_BUSY.

Isn’t supposed that my miniport driver should hold ownership of that SRB
until completion? Why systems submits same request with exact same SRB? I
don’t mind to get another request after 10 sec, but not with exact same
pointer address.

Is it possible to have influence on SRB Timeout so system never call
SCSIOP_INQUIRY again?

  1. Do I need to complete pending SRB requests upon driver
    stop/restart/powerfailure/etc?

  2. The virtual disk storport miniport demo from WDK sometimes fails. I have
    traced that it is due to read/write operations that been scheduled to be
    completed in worker
    through IoQueueWorkItem(…). It occurs that ScsiStopAdapter eventually
    called and memory allocated for virtual disk got deleted
    (pLUExt->pDiskBuf==NULL)
    before completion of postponed WorkItem. I know how to fix it.
    Just a question: is it a bug in wdk sample or I am missing something?

  1. I am interested to implement virtual drive on a remote machine in a user process and took this sample as a starting point. There is definitely lots of delays or disconnections on the way.

  2. Not clear… What does IRQL to do with pending SRB? (“ScsiStopAdapter is sent for remove (at PASSIVE_LEVEL)”). How this implies that storport will wait for completion of all pending SRB at miniport before calling ScsiStopAdapter?
    Does this mean that I will not see ScsiStopAdapter until I complete SCSIOP_INQUIRY srb?

  1. You’re better off returning an empty list and asynchronously populating
    your LUN data. Once you have the necessary information, call
    StorPortNotification for BusChangeDetected to get a new REPORT_LUNS request.

  2. IRQL is not related, I was just providing too much detail and noting that
    the ScsiStopAdapter notification is overloaded and executes with different
    constraints for different reasons.

In any case, as far as I understand it you should not see this notification
until you complete any outstanding SRBs (easy enough to test). This is also
described in the docs:

"The Storport driver ensures that there are no uncompleted requests "

https://msdn.microsoft.com/en-us/library/windows/hardware/ff557365(v=vs.85).aspx

-scott
OSR
@OSRDrivers

wrote in message news:xxxxx@ntdev…

  1. I am interested to implement virtual drive on a remote machine in a user
    process and took this sample as a starting point. There is definitely lots
    of delays or disconnections on the way.

  2. Not clear… What does IRQL to do with pending SRB? (“ScsiStopAdapter is
    sent for remove (at PASSIVE_LEVEL)”). How this implies that storport will
    wait for completion of all pending SRB at miniport before calling
    ScsiStopAdapter?
    Does this mean that I will not see ScsiStopAdapter until I complete
    SCSIOP_INQUIRY srb? is

Thanks!

Just note if you exceed an SRB timeout that HwStorResetBus will be called and you can’t return from it until all SRBs are completed. That might be why you see SRBs being reused.

OSR has example virtual storport driver with source that can be a good
place to start. There is also a three part OSR article associated with the
soruce here: http://www.osronline.com/article.cfm?article=538

You can also review the source code from Arsenal Recon at:
https://www.arsenalrecon.com/apps/image-mounter/

On Wed, Mar 23, 2016 at 8:12 PM wrote:

> Just note if you exceed an SRB timeout that HwStorResetBus will be called
> and you can’t return from it until all SRBs are completed. That might be
> why you see SRBs being reused.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:>