>Ok. Now let me put it altogether. From a FS filter point of view, should we follow following rules? Please correct me if i am wrong or put your comments if there is a better explanation.
Actually you choose the wrong basis for classification - IRQL is not an appropriate basis for this, it is impossible to define a correct set of functions by using IRQL.
In the following explanation the term “ordinary data stream” stands for any data steram except pagefile data streams, i.e. “ordinary data stream” is not a pagefile. You can find exceptions to the following rules, but these exceptions always increase the possibility of a deadlock due to the page shortage and requires special conditions( if … and if … and if … then … ).
- If I receive a Paging I/O request to a PAGE FILE, i should not call any function that cannot be called at DISPATCH_LEVEL -
Wrong, function called at DISPATCH_LEVEL can’t wait, but in the case of paging IO to a pagefile you can wait, so the set of functions is much broader.
The correct definition for available function set is - the functions which don’t generate any page fault and do not acquire any resources related with any data stream if TopLevelIrp is not NULL.
- If I receive a Paging I/O request to a MAPPED FILE, i can call any function that can be called at IRQL <= APC_LEVEL -
This is a wrong definition. In that case the set of functions is defined by the following definition - you can use ANY functions which don’t generate page faults for pages backed by ordinary data streams and don’t acquire resources related with ordinary data stream if TopLevelIrp is not NULL, while there are exceptions to the former rule the latter prohibits any page fault except to pages backed by a pagefile.
- I should avoid issuing any cached I/O or allocating huge amount of memory from Paged Pool in the Paging I/O path especially if i wait after issuing that cached i/o -
Let’s rephrase this - You must not issue any cached I/O for any paging I/O path( it is better not to do this, though might be possible in some cases when TopLevelIrp is NULL ) and you must not allocate memory from Paged Pool when processing requests to a pagefile.
. I can issue non cached file system calls directed to a different file (say a Journal file, Log file, etc ) and wait for completion, in the Paging I/O path targeted to MAPPED FILE.
You can’t if TopLevelIpr is not NULL, because you do not know the synchronization model( lock hierarchy etc. ) used by the underlying FSD. If the TopLevelIpr is NULL then you can issue some type of requests, but as I said above it is better to avoid cached requests or requests to mapped files .
–
Slava Imameyev, xxxxx@hotmail.com
“Kernel Developer” wrote in message news:xxxxx@ntfsd…
Thanks Everyone!
Ok. Now let me put it altogether. From a FS filter point of view, should we follow following rules? Please correct me if i am wrong or put your comments if there is a better explanation.
1. If I receive a Paging I/O request to a PAGE FILE, i should not call any function that cannot be called at DISPATCH_LEVEL -
This is so because any function that cannot be called at IRQL = DISPATCH_LEVEL may be using some data that is allocated from Paged Pool and hence may be present in the PAGE FILE itself. This may cause a never ending recursion and thus a deadlock.
2. If I receive a Paging I/O request to a MAPPED FILE, i can call any function that can be called at IRQL <= APC_LEVEL -
This flexibility is due to the fact that if a page fault occurs, either for bringing in the CODE or DATA, they will be brought in by issuing a read request targeted to the PAGE FILE. Since, the second call is directed to PAGE FILE rather than the MAPPED FILE for which i had originally received the request, there will be no recursion and hence no deadlock.
3. I should avoid issuing any cached I/O or allocating huge amount of memory from Paged Pool in the Paging I/O path especially if i wait after issuing that cached i/o -
This is so because if i request huge amount of memory, that can lead to flushing of dirty pages in memory to disk (To PAGE FILE or MAPPED FILE). This may slow down the system. And if i am waiting on a Paging I/O path directed to a MAPPED FILE, i have blocked the Mapped Page Writer Thread. Hence, the only way sufficient memory will be available will depend on how much page frames can Modified Page Writer can free up by flushing the dirty pages to the PAGE FILE. And, if it is unable to provide the required no. of pages, the system can go in partial deadlock because no more writes can happen on MAPPED FILES.
4. I can issue non cached file system calls directed to a different file (say a Journal file, Log file, etc ) and wait for completion, in the Paging I/O path targeted to MAPPED FILE.
Regards!
-K. Dev.