Q's over IRP cancellation

Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make sure that IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:

  1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
  2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid


How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

  1. If your driver holds an IRP for a “short” time, and then forwards it to a
    lower driver using IoCallDriver, then it is the responsibility of that lower
    driver to check the Cancel flag of the IRP, and/or to set a cancel routine
    for the IRP. In brief, what you are describing is “safe”. However, if your
    driver does queue the IRP, why not provide a cancel routine? If it’s a
    simple FIFO queue, why not use the WDM cancel-safe queue? See
    IoCsqInitialize/Ex.

  2. If a driver above your driver sets a cancel routine, and passes the IRP
    to your driver BEFORE removing that cancel routine, then the driver above
    you is buggy. I believe Driver Verifier will catch this, and will flag the
    driver above you as faulty. This is a clear violation of the WDM rules for
    passing IRPs between drivers. A driver may only set a cancel routine for an
    IRP while that driver owns the IRP. Before passing the IRP to another
    driver, or completing the IRP, the driver must safely disarm the cancel
    routine. By “safely” I mean that the code that disarms the cancel routine
    must synchronize its execution with the cancel routine itself. This can be
    quite complicated, which is why the general advice these days is “use CSQ”,
    because it gets it right.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Friday, March 31, 2006 1:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Q’s over IRP cancellation

Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make
sure that IRPs are not held beyond certain time. Currently, i don’t support
cancellation. I am trying to weigh in on the needs to do that. I had two
questions on this:

  1. First scenario, While the IRP is in my queue, it gets canceled. My driver
    does not come to know of it. Later, my driver dequeue the IRP and forward to
    the below driver. Does IoCallDriver perform any check on IRP or it just call
    the next driver dispatch routine. If ,indeed, lower driver ( lets say
    ultimately function driver)gets the canceled IRP, does it simply completely
    complete the request.
  2. A driver above me sets the cancel routine, so when IRP is canceled by I/O
    manager. This routine gets invoked and it completes the IRP. So, it will
    result in multiple completion for the same IRP ( IRP will be again completed
    when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid


How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List
Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
http:t=39663/*http://voice.yahoo.com></http:>

Thanks Arlie for explaining it.

Arlie Davis wrote:
1. If your driver holds an IRP for a “short” time, and then forwards it to a
lower driver using IoCallDriver, then it is the responsibility of that lower
driver to check the Cancel flag of the IRP, and/or to set a cancel routine
for the IRP. In brief, what you are describing is “safe”. However, if your
driver does queue the IRP, why not provide a cancel routine? If it’s a
simple FIFO queue, why not use the WDM cancel-safe queue? See
IoCsqInitialize/Ex.

2. If a driver above your driver sets a cancel routine, and passes the IRP
to your driver BEFORE removing that cancel routine, then the driver above
you is buggy. I believe Driver Verifier will catch this, and will flag the
driver above you as faulty. This is a clear violation of the WDM rules for
passing IRPs between drivers. A driver may only set a cancel routine for an
IRP while that driver owns the IRP. Before passing the IRP to another
driver, or completing the IRP, the driver must safely disarm the cancel
routine. By “safely” I mean that the code that disarms the cancel routine
must synchronize its execution with the cancel routine itself. This can be
quite complicated, which is why the general advice these days is “use CSQ”,
because it gets it right.

– arlie



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Friday, March 31, 2006 1:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Q’s over IRP cancellation

Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make
sure that IRPs are not held beyond certain time. Currently, i don’t support
cancellation. I am trying to weigh in on the needs to do that. I had two
questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver
does not come to know of it. Later, my driver dequeue the IRP and forward to
the below driver. Does IoCallDriver perform any check on IRP or it just call
the next driver dispatch routine. If ,indeed, lower driver ( lets say
ultimately function driver)gets the canceled IRP, does it simply completely
complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O
manager. This routine gets invoked and it completes the IRP. So, it will
result in multiple completion for the same IRP ( IRP will be again completed
when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid



How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List
Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
t=39663/*http://voice.yahoo.com>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Define ‘certain duration’. If you have an IRP in a queue and don’t set a cancellation routine then how can it be ‘cancelled’? Use CSQ and most of this will disappear. Use KMDF and it might be even easier.
“krnl_drv” wrote in message news:xxxxx@ntdev…
Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make sure that IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid

------------------------------------------------------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

Duration is a configurable stuff. It varies anything from 1 min to 5 min. So, I am hoping if the IRP gets canceled while in my queue and I forward it to lower driver. Will the lower driver ( e.g. function driver) check the status of IRP and complete with error.
One problem which I see is that if lower drivers complete the IRP synchronously, then it may not check IRP->Cancel value. For asynchrous, i believe before driver put an IRP in the queue it should check the above value.

“David J. Craig” wrote:
Define ‘certain duration’. If you have an IRP in a queue and don’t set a cancellation routine then how can it be ‘cancelled’? Use CSQ and most of this will disappear. Use KMDF and it might be even easier.
“krnl_drv” wrote in message news:xxxxx@ntdev…
Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make sure that IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid

---------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

If the lower driver completes the request synchronously, then the cancellation state of the PIRP doesn’t matter because the PIRP will be completed back to the sender.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Saturday, April 01, 2006 9:51 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Q’s over IRP cancellation

Duration is a configurable stuff. It varies anything from 1 min to 5 min. So, I am hoping if the IRP gets canceled while in my queue and I forward it to lower driver. Will the lower driver (?e.g. function driver) check the status of IRP?and complete with error.
One problem which I see is that if lower drivers complete the IRP synchronously, then it may not check IRP->Cancel value. For asynchrous, i believe before driver put an IRP in the queue it should check the above value.
?

“David J. Craig” wrote:
Define ‘certain duration’.? If you have an IRP in a queue and don’t set a cancellation routine then how can it be ‘cancelled’?? Use CSQ and most of this will disappear.? Use KMDF and it might be even easier.
“krnl_drv” wrote in message news:xxxxx@ntdev…
Hi,
In my upper volume filter driver, i hold?IRPs for certain duration. I make sure that?IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it?will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).
?
I am thinking we should go for CSQ. Let me know your suggestions.
?
TIA
Sid
?

How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

My driver is introducing asynchronous behavior of the blocked PIRPs. But I understand what you are trying to say. I am trying to understand the impact on application and system b/c of my driver work flow.

  1. Thread , which owns the IRPs, may not be terminated immediately but will get eventually.
  2. Also, overlapped I/O cancellation routine ( CancelIo() ) may not cancel.

Doron Holan wrote:
If the lower driver completes the request synchronously, then the cancellation state of the PIRP doesn’t matter because the PIRP will be completed back to the sender.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Saturday, April 01, 2006 9:51 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Q’s over IRP cancellation

Duration is a configurable stuff. It varies anything from 1 min to 5 min. So, I am hoping if the IRP gets canceled while in my queue and I forward it to lower driver. Will the lower driver ( e.g. function driver) check the status of IRP and complete with error.
One problem which I see is that if lower drivers complete the IRP synchronously, then it may not check IRP->Cancel value. For asynchrous, i believe before driver put an IRP in the queue it should check the above value.

“David J. Craig” wrote:
Define ‘certain duration’. If you have an IRP in a queue and don’t set a cancellation routine then how can it be ‘cancelled’? Use CSQ and most of this will disappear. Use KMDF and it might be even easier.
“krnl_drv” wrote in message news:xxxxx@ntdev…
Hi,
In my upper volume filter driver, i hold IRPs for certain duration. I make sure that IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).

I am thinking we should go for CSQ. Let me know your suggestions.

TIA
Sid


How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

________________________________________
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Correct. I am not saying that I agree with your design that you are pending irps without a cancel routine. (in my opinion, you need to set a cancel routine.) What I am saying is that when you send a canceled irp with IoCallDriver and the driver to which you send the PIRP, checking for the Cancel flag and completing synchronously is functionally the same

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Saturday, April 01, 2006 10:43 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Q’s over IRP cancellation

My driver is introducing asynchronous behavior of?the blocked?PIRPs. But I understand what you are trying to say. I am trying to understand the impact on application?and system b/c?of?my driver work flow.
1.?Thread , which owns the IRPs, may not be terminated immediately but will get eventually.
2. Also, overlapped I/O cancellation routine ( CancelIo() ) may not cancel.

Doron Holan wrote:
If the lower driver completes the request synchronously, then the cancellation state of the PIRP doesn’t matter because the PIRP will be completed back to the sender.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of krnl_drv
Sent: Saturday, April 01, 2006 9:51 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Q’s over IRP cancellation

Duration is a configurable stuff. It varies anything from 1 min to 5 min. So, I am hoping if the IRP gets canceled while in my queue and I forward it to lower driver. Will the lower driver (?e.g. function driver) check the status of IRP?and complete with error.
One problem which I see is that if lower drivers complete the IRP synchronously, then it may not check IRP->Cancel value. For asynchrous, i believe before driver put an IRP in the queue it should check the above value.
?

“David J. Craig” wrote:
Define ‘certain duration’.? If you have an IRP in a queue and don’t set a cancellation routine then how can it be ‘cancelled’?? Use CSQ and most of this will disappear.? Use KMDF and it might be even easier.
“krnl_drv” wrote in message news:xxxxx@ntdev…
Hi,
In my upper volume filter driver, i hold?IRPs for certain duration. I make sure that?IRPs are not held beyond certain time. Currently, i don’t support cancellation. I am trying to weigh in on the needs to do that. I had two questions on this:
1. First scenario, While the IRP is in my queue, it gets canceled. My driver does not come to know of it. Later, my driver dequeue the IRP and forward to the below driver. Does IoCallDriver perform any check on IRP or it just call the next driver dispatch routine. If ,indeed, lower driver ( lets say ultimately function driver)gets the canceled IRP, does it simply completely complete the request.
2. A driver above me sets the cancel routine, so when IRP is canceled by I/O manager. This routine gets invoked and it completes the IRP. So, it?will result in multiple completion for the same IRP ( IRP will be again completed when my driver dequeues and forward it down).
?
I am thinking we should go for CSQ. Let me know your suggestions.
?
TIA
Sid
?

How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer