none
How to queue synchronized IRP in device queue RRS feed

  • Question

  • Hi all, does any one know how to queue synchronized IRP in device queue.

    I am using the following code to queue the IRP:

    IoMarkIrpPending( Irp );                 

    bRet = KeInsertDeviceQueue( &deviceExtension->DeviceQueue,
                                        &Irp->Tail.Overlay.DeviceQueueEntry );

    return STATUS_PENDING;

    it could work for Asynchronized IRP to queue into the device queue, but when queue the synchronized IRP. the system halted because it need complete the IRP and process to next IRP.

    So does anyone know how to queue synchronized IRP in device driver?

    Tuesday, August 6, 2013 8:28 PM

Answers

  • If you writing a WDM driver, use an IoCSQ and associated APIs, not a KQUEUE. But why WDM? KMDF solves all of this with WDFQUEUE

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 6, 2013 9:55 PM

All replies

  • If you writing a WDM driver, use an IoCSQ and associated APIs, not a KQUEUE. But why WDM? KMDF solves all of this with WDFQUEUE

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 6, 2013 9:55 PM
  • You mean, IoCSQ could solve my problem? queue the synchronized irp. I have difficulty in return pending status of a dispatch routine. When a synchronized IRP come into the dispatch it need to wait until the irp is finished. however if I use IocompleteIRP, such IRP could not be stay in the device queue.

    so could you help me with this?

    Thursday, August 8, 2013 5:44 PM
  • You are confused at the driver level all IRP's are asynchronous.  The IO Manager will for requests on a handle specifying synchronous behavior take care of blocking the thread till the request completes.  As Doron points out IoCSQ is the correct queing model for WDM drivers. 

    As he also asks, why are you doing the work of dealing with a WDM driver, instead of using KMDF?  There is no value in using WDM (except extremely rare instances), and you could probably take your existing driver and convert it to KMDF in less time than it will take to deal with changing to cancel safe queues, and fixing the inevitable bugs of plug and play/power.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, August 8, 2013 5:50 PM
  • I want to queue the synchronized IRP not to cancel them. Just buffer them in a queue and process them later. It is good for Asynchronized but how about the synchronized?
    Thursday, August 8, 2013 5:55 PM
  • IRP's are IRP's there is nothing you need to worry about between a user sending a request sync versus async.  In the kernel everything is async!!!!!!


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, August 8, 2013 6:06 PM
  • Really thanks your reply. but when I returned pending in my dispatch routine. system is halt even though the irp is insert into a queue. I dont want the system waiting the irp completion, and also want the current irp is insert into queue as well.

    any ideas, please...

    Thursday, August 8, 2013 6:13 PM
  • I mean, when I complete the irp by IocompleteRequest, the IRP will not exist in the queue as well. I want to complete the IRP and also make it in the queue. You know what I mean?

    Thank you very much. and wait for your reply.

    Thursday, August 8, 2013 6:17 PM
  • No you put an IRP into the queue and return from the dispatch routine a STATUS_PENDING.  Then using some other event to trigger the code you remove the IRP from the queue and complete it.  Once you complete an IRP you cannot in anyway use it.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, August 8, 2013 6:24 PM
  • Yeal, I know what you mean. But what I really intend to do is my application write disk operation. I dont want to make that IRP_MJ_WRITE operation happened at once. I want to buffer such operation in the disk filter driver layer. Then when I want to write to disk I read such IRP from the queue.

    However in return of PENDING, the user application is halted and could not run. I need it could send the irp and forget it. then I could take such irp out when I want to.

    You know what I mean, please help me with this. Really appreciate your reply!

    Thursday, August 8, 2013 6:43 PM
  • Your example shows one of the dangers that would happen if you changed the IRP model, since many applications expect that a write to a disk is truly on the disk drive.

    If you need to do this you need to make a second IRP and buffer the data yourself, then you can complete the first IRP.  This is a big project, and as Doron and I keep saying doing it with WDM is STUPID.  Be sure you understand all the problems you are creating with this approach.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, August 8, 2013 6:58 PM