Hi,
We have a situation where we want to identify whether a disk is bad as soon as it is enumerated and presented to our SCSI class driver.
By the disk being “bad” I mean the disk fails TEST_UNIT_READY commands.
But by the time we realize that, it is too late for us as we’ve built up our device stack for that disk and cleaning it up is going to be very expensive.
To fix this, I figured if I could fire a TEST_UNIT_READY command before attaching an FDO to the disk PDO and if it fails, we’ll return failure from AddDevice and we’ll be all set.
But apparently sending an SRB synchronously to a disk while we’re in the middle of processing AddDevice (for the same disk) crashes the system.
So I thought the next best place to do that could be from the IRP_MN_START_DEVICE notification.
We can let AddDevice succeed and when we get START_DEVICE, we fire the TEST_UNIT_READY at the underlying disk and only if that call succeeds, we’ll return success from START_DEVICE.
If the call fails we’ll return FAILURE and PNP will do the cleanup of objects for us.
However the system leads to a crash regardless.
What is going wrong here?
Is there a better approach to check whether a disk is good or bad?
Any help will be greatly appreciated.