Hi Wayne,
Many thanks for your response!
>Srb->DataTransferLength isn’t the only key to impact performance. Did you track the command depth?
I am not familiar with SRB, could you indicate which parameter or field I have to track?
By the way, I have some other questions as follows:
I had written a disk lower filter for my USB storage device.
I would like to compare the relationship between MaximumTransferLength in STORAGE_ADAPTER_DESCRIPTOR and disk transfering performance, so I need to overwrite MaximumTransferLength in my filter driver.
I add a ‘DeviceIOControl’ routine in filter to handle ‘IOCTL_STORAGE_QUERY_PROPERTY’ request. When QueryType in PSTORAGE_PROPERTY_QUERY equals PropertyStandardQuery(0x00), I set a completion routine and pass through the irp.
However, when it goes into my completion routine, the QueryType is changed form PropertyStandardQuery(0x00) to 0x20. Therefore, I can’t modify MaximumTransferLength in the completion routine.
My questions are as followings:
- How to overwrite MaximumTransferLength in filter driver?
- Why does the QueryType in Irp be changed when it enters completion routine?
Any suggestion is highly appreciated.
The routines are as below:
NTSTATUS DDKDeviceIOControl(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp)
{
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) pDevObj->DeviceExtension;
NTSTATUS status;
ULONG ioControlCode;
ULONG inlen;
ULONG outBufflen;
PVOID buffer;
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(pIrp);
buffer = pIrp->AssociatedIrp.SystemBuffer;
inlen = irpStack->Parameters.DeviceIoControl.InputBufferLength;
outBufflen = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
status = STATUS_NOT_SUPPORTED;//STATUS_INVALID_DEVICE_REQUEST;//
ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
switch(ioControlCode)
{
case IOCTL_STORAGE_QUERY_PROPERTY: // 0x002d1400
{
PSTORAGE_PROPERTY_QUERY pQuery = (PSTORAGE_PROPERTY_QUERY)buffer;
PSTORAGE_DESCRIPTOR_HEADER pOutput = (PSTORAGE_DESCRIPTOR_HEADER)buffer;
status = STATUS_INVALID_PARAMETER;
if (pQuery->QueryType == PropertyStandardQuery)
{
switch (pQuery->PropertyId)
{
case StorageAdapterProperty:
{
if (outBufflen >= sizeof(STORAGE_ADAPTER_DESCRIPTOR))
{
PSTORAGE_ADAPTER_DESCRIPTOR pAdapDesc = (PSTORAGE_ADAPTER_DESCRIPTOR)buffer;
IoCopyCurrentIrpStackLocationToNext(pIrp);
IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE) IOCTLCompletionRoutine,
(PVOID) pdx, TRUE, TRUE, TRUE);
return IoCallDriver(pdx->LowerDeviceObject, pIrp);
}
}
break;
} // ~ switch (pQuery->PropertyId)
} // ~ if (pQuery->QueryType == PropertyStandardQuery)
}
break;
}
IoSkipCurrentIrpStackLocation(pIrp);
status = IoCallDriver(pdx->LowerDeviceObject, pIrp);
return status;
}
#pragma LOCKEDCODE
NTSTATUS IOCTLCompletionRoutine(PDEVICE_OBJECT fido, PIRP Irp, PDEVICE_EXTENSION pdx)
{ // StartDeviceCompletionRoutine
IoAcquireRemoveLock(&pdx->RemoveLock,Irp);
NTSTATUS status;
ULONG ioControlCode;
ULONG inlen;
ULONG outBufflen;
PVOID buffer;
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp);
buffer = Irp->AssociatedIrp.SystemBuffer;
inlen = irpStack->Parameters.DeviceIoControl.InputBufferLength;
outBufflen = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
status = STATUS_NOT_SUPPORTED;//STATUS_INVALID_DEVICE_REQUEST;//
ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
switch(ioControlCode)
{
case IOCTL_STORAGE_QUERY_PROPERTY: // 0x002d1400
{
PSTORAGE_PROPERTY_QUERY pQuery = (PSTORAGE_PROPERTY_QUERY)buffer;
PSTORAGE_DESCRIPTOR_HEADER pOutput = (PSTORAGE_DESCRIPTOR_HEADER)buffer;
status = STATUS_INVALID_PARAMETER;
if (pQuery->QueryType == PropertyStandardQuery)
{
switch (pQuery->PropertyId)
{
case StorageAdapterProperty:
{
if (outBufflen >= sizeof(STORAGE_ADAPTER_DESCRIPTOR))
{
PSTORAGE_ADAPTER_DESCRIPTOR pAdapDesc = (PSTORAGE_ADAPTER_DESCRIPTOR)buffer;
pAdapDesc->MaximumTransferLength = 0x00100000;
pAdapDesc->MaximumPhysicalPages = 0x101;
pAdapDesc->AcceleratedTransfer = TRUE;
}
} //case
} //switch id
} // if
} //case
break;
} //switch ioctl
IoReleaseRemoveLock(&pdx->RemoveLock, Irp);
return STATUS_SUCCESS;
}
Thanks!
Best Regards,
Gordon