disk-like object

Hi all

I’m doing a bit of research into the “best” way of exposing a disk-like object to windows. I’m aware that the recommended way is to create a virtual storport miniport, but I do find myself wondering what is the overhead of all that SCSI stuff, so I’ve done a little prototyping of a simple kmdf driver that exposes a FILE_DEVICE_DISK to see if I could get some objective measures of this architecture vs the storport route. [Oh, and WHCK certification is low on the priority list].

I can make an object appear and send disk-like I/Os to it from a test application, however I can’t make it appear in disk manager, and hence can’t create MBR/GPT/volumes/format it etc. I have looked at the ramdisk sample, it’s the same.

I’ve hooked a disk filter above the simple driver and above a storport one, and the device stacks look the same (filter->partmgr->fdo), but the traffic is significantly different - namely the storport one receives various ioctls that the kmdf doesn’t. So presumably disk/classpnp do some other magic.

Is this approach really so undocumented that it’s impossible, or is there a recipe I’ve failed to google?

As I said, I know the recommended route is storport, and I know that classpnp/disk do various ETW/WMI magic that I may have to duplicate, I don’t for a second doubt the ability of the storage stack developers, and I know it won’t get through WHCK. In this case I just want an objective measure of any latency/concurrency improvement I can get with a smaller driver, so I can weigh it up against the above downsides.

Thankyou
Andy

Correction: my disk-like object does appear in disk manager, and I can create MBR/GPT. It’s the volume that is not fully populated. If I create a simple volume, disk manager doesn’t show it, although a drive letter is assigned and the volume seems to be useable

Storport miniport is the way to go. It makes life easy, and uses AN ISO
standard command set.

On Tue, Apr 5, 2016, 11:27 AM wrote:

> Correction: my disk-like object does appear in disk manager, and I can
> create MBR/GPT. It’s the volume that is not fully populated. If I create a
> simple volume, disk manager doesn’t show it, although a drive letter is
> assigned and the volume seems to be useable
>
> —
> 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:>

>is the overhead of all that SCSI stuff, so I’ve done a little prototyping of a simple kmdf driver that

exposes a FILE_DEVICE_DISK

Then you will have overhead of all that IOCTL stuff, instead of all that SCSI stuff.

Nevertheless, the disk-in-file drivers to expose mountable disk images to the OS are often developed this way.

I can make an object appear and send disk-like I/Os to it from a test application, however I can’t
make it appear in disk manager,

Wow, this is yet another song, which requires the proper PnP devinterfaces registered to the disk device. And, if your driver is not PnP, you just plain cannot do this.

For this, it is absolutely recommended to use STORPORT miniport.

Is this approach really so undocumented that it’s impossible,

Just support ALL of the IOCTL_DISK_xxx and IOCTL_STORAGE_xxx, be a PnP driver, register the proper PnP devinterfaces on a stack.

You can only support the subset. Sometimes it is enough. For some disk drivers, it is OK if the disk cannot be displayed in Windows Explorer (only in command line and file API). For some, like backup image mounters, there is no need to ever format or partition the disk.

ETW/WMI magic that I may have to duplicate,

Major doubts, unless you want your disk to be visible as Win32_PhysicalDisk to WMI/PowerShell.


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

Why do you want a “disk-like object”? Can this be done with a usual virtual disk (.vhd or iso) ?

Neither. It’s just pointless. AND overly difficult.

If you want a disk that is integrated as a disk in Windows, that gets a file system instant intend on it, and does all the things a Windos disk drive does, there’s an architecture for that. You write a StorPort mini port. StorPort sucks, but it’s pretty tightly coupled with the Disk class driver, and everything else in Windows,

You could do all the work that’s done in Disk.sys (the source code is available)… And figure out everything else you need to do. People used to do this “back in the day” … It was a PITA even then… When things were simpler, and we all wanted to fight for every last CPU cycle. Then we all gave in and took the route of least resistance and wrote StorPort mini ports.

OTOH, if you want to surface a big tank that services reads and writes, but doesn’t those a file system… Then go for writing a simple KMDF drivers. It won’t be a DISK in the conventional sense to Windows. But it’ll be fast and simple.

Peter
OSR
@OSRDrivers