>All that i want to ensure is that, the reading/ querying is done before the
actual paging write happens.
If you want to know whether this might violate the lock hierarchy, then the
answer is Yes, though it might work for many modern FSDs. Actually, I’ve
never done such thing because its deadlock pron pattern, so I only try to
guess consequences.
Is this also not possible?
It is possible, but you’ve been warned.
I think i am confused about the whole concept of TopLevelIrp and Paging
I/O
The conception is VERY SIMPLE. I’ll try to explain it.
In case of paging IO Memory Manager(MM) is an FSD client, while in other
cases this is a user application who is FSD client.
But FSD is itself a Memory Manager client(!), let’s forget here about Cache
Manager( who is a Memory Manager client and FSD is a Cache Manager client ).
It is obvious that both FSD and Memory Manager have some synchronization
primitives, let’s use “FsdSync” for FSD’s synchronization resources and
“MmSync” for Memory Manager’s synchronization resources .
So, then a user application calls FSD the synchronization resources are
acquired in the following sequence FsdSync-MmSync , remember that Fsd is a
Memory Manager client.
When Memory Managers wants to flush dirty pages it becames the FSD
client(!), but before issuing a PAGING write request Memory Manager should
acquire MmSync resources to maintain its internal synchronization, so after
calling the FSD the following lock sequence might have place MmSync-FsdSync.
So, in the case of user application the sequence is FsdSync-MmSync but in
the case of dirty pages flushing( i.e. paging write ) the sequence is
MmSync-FsdSync, as you know this will result in a deadlock. For avoid this
problem FSD callbacks are used by Memory Manager to call FSD before
acquiring its(Memory Manager’s) synchronization resources, so FSD has an
opportunity to preserve the lock hierarchy and acquire its(FSD’s)
synchronization resources before Memory Manager acquires its(MM’s) resources
and FSD does this and thread’s TopLevelIrp is set in this case to a some
value.
- Slava, can you please explain me in detail, why this will fail.
This won’t fail, this might deadlock the system.
- What is the alternate way of doing the stuff?
Sorry, this question requires more thorough investigation. May be you should
redesign your software architecture. But I am sure that generating read
request on a paging write path when ToplevelIrp is not NULL is dangerous.
- You mentioned that the set of calls that can be made are limited. What
are those calls?
Depends on FSD. There is no answer suitable for all FSDs. Test your filter
driver with all available FSDs.
–
Slava Imameyev, xxxxx@hotmail.com
“Kernel Developer” wrote in message
news:xxxxx@ntfsd…
>I am now totally confused.
>
> Ok. Let me explain what I meant.
>
> When, I get some IRP ( Callbackdata ) in my PreCallback routine ( say
> paging write ), and I issue a request to read/ query the same file by
> building a callback data using FltAllocateCallbackData and then sending it
> using FltPerformAsynchronousIo. This is what I wanted to do using, the
> sequence of steps that i had posted before. All that i want to ensure is
> that, the reading/ querying is done before the actual paging write
> happens. How do i ensure that?
>
>
>
> Is this also not possible?
>
>
>
> I think i am confused about the whole concept of TopLevelIrp and Paging
> I/O .
>
> May be its an easy concept, but as a beginner i am not able to understand
> it and its implications very well.
>
>
>
> 1. Slava, can you please explain me in detail, why this will fail.
>
> 2. What is the alternate way of doing the stuff?
>
> 3. You mentioned that the set of calls that can be made are limited. What
> are those calls?
>
>
>
>