Hi,
Sorry, if this question was discussed many times here.
What is the prefered way of processing in the filter driver of synchronous
I/O requests, e.g. IRP_MN_MOUNT_VOLUME, and why?
Synchronously, by waiting in dispatch routine and signaling in completion:
Dispatch()
{
…
SetCompletion(Irp, Completion, &event, TRUE, TRUE, TRUE);
status = CallDriver(deviceObject, Irp);
if (status == STATUS_PENDING) {
WaitForSingleObject(&event);
}
//
// Perform necessary postprocessing here,
// such as attaching to the mounted LV.
//
CompleteRequest(Irp);
return(status);
}
Completion()
{
// Do not mark Irp as pending
SetEvent(event);
return(STATUS_MORE_PROCESSING_REQUIRED);
}
Or asynchronously?
Dispatch()
{
…
InitializeContext(Irp, &context);
SetCompletion(Completion, context);
MarkIrpPending(Irp)
CallDriver(deviceObject, Irp);
return(STATUS_PENDING);
}
Completion()
{
QueueWorkItem(&context->WorkItem);
if (Irp->PendingReturned) {
MarkIrpPending(Irp);
}
return(STATUS_MORE_PROCESSING_REQUIRED);
}
WorkItem()
{
//
// Perform necessary postprocesing
// such as attaching to the mounted LV.
//
CompleteRequest(Irp);
}
Any your comments will be very appreciated.
Thanks in advance.
Best regards,
Leonid.