Buffered IO to Direct IO

Hi All,

I am using DeviceIoControl with IOCTL_SCSI_MINIPORT to call NVMe driver. I could see IOCTL_SCSI_MINIPORT is a Buffered_IO. Is it possible to change it to Direct_IO, If so what needs to be modified in application and NVMe driver?

Kindly help me out.

Thanks In advance,
Muthu

xxxxx@gmail.com xxxxx@lists.osr.com wrote:

I am using DeviceIoControl with IOCTL_SCSI_MINIPORT to call NVMe driver. I could see IOCTL_SCSI_MINIPORT is a Buffered_IO. Is it possible to change it to Direct_IO, If so what needs to be modified in application and NVMe driver?

Nope, that’s impossible. The buffering is built in to the ioctl code.
If you change the ioctl code, then it’s no longer IOCTL_SCSI_MINIPORT.

Any reason why you can’t define your own code?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

You can use scsi pass through direct operations to get custom direct io
data you your miniport. You may have to go through some gyrations, such as
creating a custom scsi device, to avoid have the class driver above you
refuse to pass the request down.

Mark Roddy

On Tue, Aug 1, 2017 at 1:16 PM, Tim Roberts <
xxxxx@lists.osr.com> wrote:

> xxxxx@gmail.com xxxxx@lists.osr.com wrote:
> > I am using DeviceIoControl with IOCTL_SCSI_MINIPORT to call NVMe driver.
> I could see IOCTL_SCSI_MINIPORT is a Buffered_IO. Is it possible to change
> it to Direct_IO, If so what needs to be modified in application and NVMe
> driver?
>
> Nope, that’s impossible. The buffering is built in to the ioctl code.
> If you change the ioctl code, then it’s no longer IOCTL_SCSI_MINIPORT.
>
> Any reason why you can’t define your own code?
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> 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:></http:>

Sorry for the late reply, and Thanks for your reply.

Actually I am doing performance profiling with IOCTL_SCSI_MINIPORT path, and found that Result was very low. Hence we doubted on buffered IO, So I modified the IOCTL_SCSI_MINIPORT

If DirectIO is not possible by IOCTL_SCSI_MINIPORT then I will try with Custom Control Code.

Regards,
Muthu

I modified the IOCTL_SCSI_MINIPORT in Application like below.

#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)

#define IOCTL_SCSI_MINIPORT_IN CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_SCSI_MINIPORT_OUT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_OUT_DIRECT,FILE_READ_ACCESS | FILE_WRITE_ACCESS)

You need to re-read the earlier replies that noted that you cannot do this.
The control code is now not understood by the port driver.

Mark Roddy

On Thu, Aug 10, 2017 at 3:10 AM, xxxxx@gmail.com > wrote:

> I modified the IOCTL_SCSI_MINIPORT in Application like below.
>
> #define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402,
> METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
>
> #define IOCTL_SCSI_MINIPORT_IN CTL_CODE(IOCTL_SCSI_BASE, 0x0402,
> METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
> #define IOCTL_SCSI_MINIPORT_OUT CTL_CODE(IOCTL_SCSI_BASE, 0x0402,
> METHOD_OUT_DIRECT,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> 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:></http:>

xxxxx@gmail.com xxxxx@lists.osr.com wrote:

I modified the IOCTL_SCSI_MINIPORT in Application like below.

#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)

#define IOCTL_SCSI_MINIPORT_IN CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_SCSI_MINIPORT_OUT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_OUT_DIRECT,FILE_READ_ACCESS | FILE_WRITE_ACCESS)

Those ARE custom ioctl codes. Even though the fields have meaning, the
code is the entire 32-bit value. If you’re sending this to a custom
driver, that’s fine, but no standard driver will respond to this. And
in the port/miniport case, I doubt the port driver will pass through
codes it doesn’t know.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> I modified the IOCTL_SCSI_MINIPORT in Application …

Great!!! The only thing left now is to modify the target driver accordingly ( I make a, probably, too bold assumption that you actually DO realise that in order for a modified protocol to work identical modifications have to be applied to both sides of the communication channel). Therefore, modify the system-provided port driver accordingly, replace the old version of this driver with the new one on every computer where your app may possibly run, and the whole thing will work just fine…

Anton Bassov