Paging IO and stream handle context

From MSDN:
* Post Write can be called at IRQL DISPATCH_LEVEL.
* FltGetStreamHandleContext() should only be called at IRQL <= APC_LEVEL.

If I must process the callback within the context of the operation, (can’t queue a work item) then what are some ways to get to the stream handle context so it is available during the processing of this call?

Thanks!

Can you grab it during the pre-op and pass it in the postop’s context?

~Eric

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Friday, February 27, 2009 3:43 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Paging IO and stream handle context

From MSDN:
* Post Write can be called at IRQL DISPATCH_LEVEL.
* FltGetStreamHandleContext() should only be called at IRQL
<= APC_LEVEL.

If I must process the callback within the context of the
operation, (can’t queue a work item) then what are some ways
to get to the stream handle context so it is available during
the processing of this call?

Thanks!


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

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

xxxxx@hotmail.com wrote:

From MSDN:
* Post Write can be called at IRQL DISPATCH_LEVEL.
* FltGetStreamHandleContext() should only be called at IRQL <= APC_LEVEL.

If I must process the callback within the context of the operation, (can’t queue a work item) then what are some ways to get to the stream handle context so it is available during the processing of this call?

Remember that your completion callback is may not be called in the same
context as the dispatch handler. Of course there are exceptions to this
but I would not depend on the context being the same in all cases.

Pete

Thanks!


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

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


Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295

> xxxxx@hotmail.com wrote:

> From MSDN:
> * Post Write can be called at IRQL DISPATCH_LEVEL.
> * FltGetStreamHandleContext() should only be called at IRQL
<= APC_LEVEL.
>
> If I must process the callback within the context of the
operation, (can’t queue a work item) then what are some ways
to get to the stream handle context so it is available during
the processing of this call?
>

Remember that your completion callback is may not be called
in the same context as the dispatch handler. Of course there
are exceptions to this but I would not depend on the context
being the same in all cases.

Wait, what? You just lost me here. He wants a stream handle context
(or so I gather), so long as he has a reference to it, does it really
matter what thread context he’s in?

Did we just get derailled by the three different meanings of context in
this discussion (an fltmgr managed context like a stream handle context
where you stash your info, the context you pass to your postop callback,
and thread context). This is getting to be like trying to talk
intelligibly about “this” and “const” in C++.

~Eric

> Can you grab it during the pre-op and pass it in the postop’s context?

Is the pre-callback called at “IRQL <= APC_LEVEL”?
I looked at MSDN for the Pre-op-Callback but it wasn’t very clear as for the IRQL level at which it can get called (unlike the post op which states clearly the levels at which it can get called).

So if I get the Stream Handle Context at PRE then pass it to the POST using the postop’s context, then this should work for paging IO?

> > Can you grab it during the pre-op and pass it in the

postop’s context?

Is the pre-callback called at “IRQL <= APC_LEVEL”?
I looked at MSDN for the Pre-op-Callback but it wasn’t very
clear as for the IRQL level at which it can get called
(unlike the post op which states clearly the levels at which
it can get called).

Yes, see here (and bookmark it, because it’s a pain to google up if you
can’t remember the title):

http://msdn.microsoft.com/en-us/library/ms790762.aspx

It is incredible that how many years after the advent of fltmgr that
there isn’t any documentation that calls out this stuff specifically for
the minifilter callbacks. Or at least points to this and explicitly
spells out that it applies.

So if I get the Stream Handle Context at PRE then pass it to
the POST using the postop’s context, then this should work
for paging IO?

Yup, you can dereference the SHC at DISPATCH_LEVEL.

~Eric

Excellent, Thanks Eric!
-Vance

xxxxx@hotmail.com wrote:

> Can you grab it during the pre-op and pass it in the postop’s context?

Is the pre-callback called at “IRQL <= APC_LEVEL”?
I looked at MSDN for the Pre-op-Callback but it wasn’t very clear as for the IRQL level at which it can get called (unlike the post op which states clearly the levels at which it can get called).

So if I get the Stream Handle Context at PRE then pass it to the POST using the postop’s context, then this should work for paging IO?

Sorry, misunderstanding of context. I was understanding context to be
the process context, not the context pointer. I assumed that the OP was
quite aware of how to pass context pointers around, even to a worker thread.

Pete


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

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


Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295

> If I must process the callback within the context of the operation, (can’t queue a work item) then what

are some ways to get to the stream handle context so it is available during the processing of this call?

Query in PreWrite and pass to PostWrite via the per-request context.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com