IRP_MJ_DEVICE_CONTROL with IoAllocateIrp can it be aync for SCSI passthrough

Hello All,

MS documentation mentions that SCSI Passthrough can only be called synchronously, is this true even when we do this from the driver?

Is it possible to call this async from the upper disk filter?

Here is what I do;

  1. use IoAllocateIrp to create a new IRP
  2. setup Passthrough with buffers and setup the CDB, transfer length, etc
  3. set the transfer type as METHOD BUFFERED and Passthrough structure to SystemBuffer
  4. Set irpSp->MajorFunction = IRP_MJ_DEVICE_CONTROL;
    Input and OutputBufferLenghts;
    irpSp->Parameters.DeviceIoControl.IoControlCode = IOCTL_SCSI_PASS_THROUGH;
  5. Setup Completion Routine
  6. IoCallDriver()
  7. Some additional code

On IO completion completion routine gets called with success and the amount of data transfered etc.

However, I noticed that the execution is always stuck at IoCallDriver, and after a little while while execution transfers to CompletionRoutine.

So is IRP_MJ_DEVICE_CONTROL synchronous even when called as described above? Can someone please clarify how it works?

> MS documentation mentions that SCSI Passthrough can only be called synchronously, is this true

even when we do this from the driver?

Yes. SCSIPORT synchronizes this internally.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks Maxim.

Does it means that StorPort will only handle only one SCSI Passthrough at a time, and serialize them if there are several Passthrough commands outstanding?

Therefore, if I send several passthrough concurrently from different threads within a driver, they would get serializes by StorPort. Is there a workaround?

TIA!

This has all the marks of a pig + wings problem. Search OSR Online for that reference if you don’t already know what that means.

What problem are you trying to solve, for which you think sending SPT requests asynchronously represents a solution?

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER 2012 SIEM Magic Quadrant
WINNER of SC Magazine’s 2012 SIEM Best Buy

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, April 26, 2013 10:51 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IRP_MJ_DEVICE_CONTROL with IoAllocateIrp can it be aync for SCSI passthrough

Thanks Maxim.

Does it means that StorPort will only handle only one SCSI Passthrough at a time, and serialize them if there are several Passthrough commands outstanding?

Therefore, if I send several passthrough concurrently from different threads within a driver, they would get serializes by StorPort. Is there a workaround?

TIA!


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hello Phil,

I understand that reference, and I have been a long time visitor to this site.

I am not necessarily averse to StorPort handling SCSI Passthrough in q serial order, but I was trying to figure out when I call the IoCallDriver in the sequence given in the OP above, should the call to IoCallDriver return immediately or not?

What I have been observing is that the call does not return. I am trying to fire several of these Passthrough without having to wait and be done with them.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, April 26, 2013 11:10 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IRP_MJ_DEVICE_CONTROL with IoAllocateIrp can it be aync for SCSI passthrough

What I have been observing is that the call does not return. I am trying to fire several of these Passthrough without having to wait and be done with them.

Again, to what purpose? “trying to fire several of these Passthrough without having to wait and be done with them.” is not a problem statement, it’s a solution statement. What problem do you want to solve? There is probably a decent way to solve the problem, if you tell us what that is.

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER 2012 SIEM Magic Quadrant
WINNER of SC Magazine’s 2012 SIEM Best Buy

Thanks for taking interest in my posts, I very much appreciate your assistance.

Ok, let me provide some more details. I have several storage boxes connected to a host and I want to send an internal SCSI command to each of these boxes, and perform some post processing on these data. I have a thread which does all this. It has a while loop that runs times the storage boxes, and then send passthrough to each of these boxes, and there is substantial post processing of the data (I can offload that to workitem etc). Hence the proposed solution above in OP.

Since I am upper filter this is an issue, had I been below disk class, I could have done this using SRB and had no issue with parallelism.

TIA!

If the storage boxes are connected through different instances of your HBA’s driver, you *may* be able to launch independent work-items to do that. I’ve never tried that. If they are connected through the same HBA, there is no way to force SPT to be async.

You could install yourself as lower filter as well as upper and only use the lower instance for issuing SRBs.

I think there’s probably another way or two to approach your problem. Probably be good to start a new thread with a statement of your actual problem as the subject, you might get contributors who are currently ignoring this thread.

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER 2012 SIEM Magic Quadrant
WINNER of SC Magazine’s 2012 SIEM Best Buy

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, April 26, 2013 11:31 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IRP_MJ_DEVICE_CONTROL with IoAllocateIrp can it be aync for SCSI passthrough

Thanks for taking interest in my posts, I very much appreciate your assistance.

Ok, let me provide some more details. I have several storage boxes connected to a host and I want to send an internal SCSI command to each of these boxes, and perform some post processing on these data. I have a thread which does all this. It has a while loop that runs times the storage boxes, and then send passthrough to each of these boxes, and there is substantial post processing of the data (I can offload that to workitem etc). Hence the proposed solution above in OP.

Since I am upper filter this is an issue, had I been below disk class, I could have done this using SRB and had no issue with parallelism.