Doing direct DMA transfer through a disk filter driver?

Hi,

I am trying to speed up a cross-platform Software Raid (RAID5) driver in WDM.

Currently, my method is to split the incoming IO into stripe sized chunks, allocate a parity buffer, compute the parity, and write stripe sized data to the individual disks. This unfortunately results in a large number of IO if the incoming buffer is large.

I was looking into scatter/gather lists and want to see if this approach is possible?

  1. Call IoGetDmaAdapter for the member disks. Currently, I am calling this from the completion routine of an IOCTL_GET_DRIVE_LAYOUT_EX call.
  2. Construct the MDL for scatter/gather lists using the incoming IO MDL and my parity MDL spliced together.
  3. Execute the transaction.

I tried calling IoGetDmaAdapter using the PDO I get in my disk filter driver, but I don’t get a _DMA_ADAPTER pointer even after trying several options for DEVICE_DESCRIPTION as mentioned in earlier OSR posts or in Windows samples. I always end up with a nullptr.

My PDO has !devobj output:

: kd> !devobj 0xffffa70a`c5c73050
Device object (ffffa70ac5c73050) is for:
 00000048 \Driver\storvsc DriverObject ffffa70ac1c6fa10
Current Irp 00000000 RefCount 0 Type 00000007 Flags 00001050
SecurityDescriptor ffffdf80e7e1d8e0 DevExt ffffa70ac5c731a0 DevObjExt ffffa70ac5c74120 DevNode ffffa70ac8608650 
ExtensionFlags (0000000000)  
Characteristics (0x00000180)  FILE_AUTOGENERATED_DEVICE_NAME, FILE_DEVICE_SECURE_OPEN
AttachedDevice (Upper) ffffa70ac610e060 \Driver\disk
Device queue is not busy.

Is my approach feasible? If not, is there another way to execute DMA scatter/gather from my disk filter driver?

Filter drivers don’t directly access hardware. As the name implies, they filter IRPs that other drivers then work with.

you don’t really know if the disk you are speaking with is connected via USB, SAS, NVMe, FC or something else not yet invented

Why does the split need to be in stripe sized chunks?
I mean it can be in buffer_size / num_disks + 1_for_parity sized chunks?

Typically in windows a custom raid implementation is implemented as a component of a third-party storage adapter. Software raid is more or less already implemented by the built in storage spaces.