Hi all !
I would like to implement IRPs queue in my driver.
I call IoMarkIrpPending() in the dispatch routine, insert IRP to the queue and return STATUS_PENDING.
Then I take IRP from queue, set its completion routine and forward it to the underlying driver.
What have I do in the completion routine? Do I have to check Irp->PendingReturned and call IoMarkIrpPending()
again or just to return Irp->IoStatus.Status.
Regards,
Dany
** Reply to message from “Dany Polovets” on Tue, 21
May 2002 12:05:22 +0200
> I call IoMarkIrpPending() in the dispatch routine, insert IRP to the queue and return STATUS_PENDING.
> Then I take IRP from queue, set its completion routine and forward it to the underlying driver.
> What have I do in the completion routine? Do I have to check Irp->PendingReturned and call IoMarkIrpPending()
> again or just to return Irp->IoStatus.Status.
You don’t need to call IoMarkIrpPending twice, but it won’t hurt if you do.
IRP completion is a confusing topic for many driver developers, so I think that
an argument can be made for habitually putting the boilerplate code in I/O
completion routines, at least until one is well grounded in how it all works.
Sincerely,
Chris Myers
Senior Project Engineer
Quatech, Inc.
there’s nothing to do in your completion routine (with respect to
pending that is) if you’ve already marked the IRP pending in your
dispatch routine.
-p
-----Original Message-----
From: Dany Polovets [mailto:xxxxx@store-age.com]
Sent: Tuesday, May 21, 2002 3:05 AM
To: NT Developers Interest List
Subject: [ntdev] IoMarkIrpPending() and completion routine
Hi all !
I would like to implement IRPs queue in my driver.
I call IoMarkIrpPending() in the dispatch routine, insert IRP to the
queue and return STATUS_PENDING. Then I take IRP from queue, set its
completion routine and forward it to the underlying driver. What have I
do in the completion routine? Do I have to check Irp->PendingReturned
and call IoMarkIrpPending()
again or just to return Irp->IoStatus.Status.
Regards,
Dany
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%
>Then I take IRP from queue, set its completion routine and forward it to the underlying driver.
What have I do in the completion routine? Do I have to check Irp->PendingReturned and call
IoMarkIrpPending()
again or just to return Irp->IoStatus.Status.
You must never return Irp->IoStatus.Status, you must return either STATUS_SUCCESS or STATUS_MORE_PROCESSING_REQUIRED.
In the first case and only in the first case, do the Irp->PendingReturned thing.
Max
It doesn’t matter if you return Irp->IoStatus.Status from a completion
routine. Any status other than STATUS_MORE_PROCESSING_REQUIRED will have
the same affect, which is allowing the I/O manager to continue completion
processing. Returnig STATUS_MORE_PROCESSING_REQUIRED from the completion
routine will halt such processing until IoCompleteRequest is called on the
IRP.
They should have, and Adrian Oney has indicated they might, just created two
statuses STATUS_COMPLETE or STATUS_MORE_PROCESSING_REQUIRED to be returned.
Where STATUS_COMPLETE, or whatever it would be called, would just be
==STATUS_SUCCESS.
–
Bill McKenzie
“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> >Then I take IRP from queue, set its completion routine and forward it to
the underlying driver.
> >What have I do in the completion routine? Do I have to check
Irp->PendingReturned and call
> >IoMarkIrpPending()
> >again or just to return Irp->IoStatus.Status.
>
> You must never return Irp->IoStatus.Status, you must return either
STATUS_SUCCESS or STATUS_MORE_PROCESSING_REQUIRED.
> In the first case and only in the first case, do the Irp->PendingReturned
thing.
>
> Max
>
>
>
>
> They should have, and Adrian Oney has indicated they might, just created two
statuses STATUS_COMPLETE or STATUS_MORE_PROCESSING_REQUIRED to be
Or maybe BOOLEAN return value from the completion routine would be good.
Max
Right, they should have done that. Too late now, all existing completion
routines return an NTSTATUS, so the two status values would be a good
compromise, at least hopefully it would make more clear what is going on,
even if it didn’t truly affect any operation.
–
Bill McKenzie
“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> > They should have, and Adrian Oney has indicated they might, just created
two
> > statuses STATUS_COMPLETE or STATUS_MORE_PROCESSING_REQUIRED to be
>
> Or maybe BOOLEAN return value from the completion routine would be good.
>
> Max
>
>
>
>
There are only two possible valid return values from a completion
routine; 1) STATUS_SUCCESS or 2) STATUS_MORE_PROCESSING_REQUIRED. There
are no other valid return values from a completion routine. So, we are
almost there with the current implementation.
BOOLEAN return would have been good or some other limited enumeration
like:
- COMPLETE_HALT
- COMPLETE_CONTINUE
This would allow for future values if the NT model changes enough to
warrant it.
Ah, what heck, I am use to STATUS_SUCCESS and
STATUS_MORE_PROCESSING_REQUIRED.
Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bill McKenzie
Sent: Thursday, May 23, 2002 4:16 PM
To: NT Developers Interest List
Subject: [ntdev] Re: IoMarkIrpPending() and completion routine
Right, they should have done that. Too late now, all existing
completion
routines return an NTSTATUS, so the two status values would be a good
compromise, at least hopefully it would make more clear what is going
on,
even if it didn’t truly affect any operation.
–
Bill McKenzie
“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> > They should have, and Adrian Oney has indicated they might, just
created
two
> > statuses STATUS_COMPLETE or STATUS_MORE_PROCESSING_REQUIRED to be
>
> Or maybe BOOLEAN return value from the completion routine would be
good.
>
> Max
>
>
>
>
—
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%
> There are only two possible valid return values from a completion
routine; 1) STATUS_SUCCESS or 2) STATUS_MORE_PROCESSING_REQUIRED. There
are no other valid return values from a completion routine. So, we are
almost there with the current implementation.
Not strictly true. You can, if you want, return STATUS_PENDING from a
completion routine and you will get exactly the same behavior as you would
returning STATUS_SUCCESS. Its either STATUS_MORE_PROCESSING_REQUIRED or it
isn’t, any other value is treated the same. That said, I would always
return STATUS_SUCCESS for, if for no other reason, clarity.
–
Bill McKenzie
“Jamey Kirby” wrote in message news:xxxxx@ntdev…
>
> There are only two possible valid return values from a completion
> routine; 1) STATUS_SUCCESS or 2) STATUS_MORE_PROCESSING_REQUIRED. There
> are no other valid return values from a completion routine. So, we are
> almost there with the current implementation.
>
> BOOLEAN return would have been good or some other limited enumeration
> like:
>
> - COMPLETE_HALT
> - COMPLETE_CONTINUE
>
> This would allow for future values if the NT model changes enough to
> warrant it.
>
> Ah, what heck, I am use to STATUS_SUCCESS and
> STATUS_MORE_PROCESSING_REQUIRED.
>
> Jamey Kirby
> StorageCraft, inc.
> xxxxx@storagecraft.com
> www.storagecraft.com
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Bill McKenzie
> Sent: Thursday, May 23, 2002 4:16 PM
> To: NT Developers Interest List
> Subject: [ntdev] Re: IoMarkIrpPending() and completion routine
>
> Right, they should have done that. Too late now, all existing
> completion
> routines return an NTSTATUS, so the two status values would be a good
> compromise, at least hopefully it would make more clear what is going
> on,
> even if it didn’t truly affect any operation.
>
> –
> Bill McKenzie
>
>
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
> >
> > > They should have, and Adrian Oney has indicated they might, just
> created
> two
> > > statuses STATUS_COMPLETE or STATUS_MORE_PROCESSING_REQUIRED to be
> >
> > Or maybe BOOLEAN return value from the completion routine would be
> good.
> >
> > Max
> >
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
>
> Right, they should have done that. Too late now, all existing completion
routines return an NTSTATUS, so the two status values would be a good
compromise
Will Verifier assert wrong return from the completion routine?
Max