I am facing some problem with queued IRP - queued in the dispatch routine and processed later in a worker thread. Sometimes it happens that a file storage gets disconnected and when the IRP is processed system enters in bugcheck sequence (because of invalid read address). How this situation should be managed?
you should make additional checking for the IRP, i guess when you queue the IRP you queue it you have some additional info linked like the deviceobject to where it should be targeted, the storage device object, etc . . ., and also in your fast IO dispathches you have the unmount handling, and you should make also addional checkings there and you might want to cancel the IRP if the storage device object.
with a spin lock synchronization method before the working thread tries to process the IRP. you can make the checkings in the thread.
If the storage gets unmounted you could try to mount it and then do your work, or just cancel the IRP.