Good day.
Thank you all for your replies to my previous request. Sorry for my dumb
questions but just for my curiosity I’d like to make the information on
this subject more accurate and clear.
As I said in my previous post I took a glance at FileSpy source code and
as I understood it turns out that FileSpy uses sync objects other than
spin locks in arbitrary contexts, for example in some completion
routines (calling FsRtl routines for Per Stream Contexts which use
FastMutex), in paging I/O paths routines. Nevertheless FileSpy uses the
global spin lock to synchronize access to cache table with all file
objects passed thru its create dispatch routine (to store incoming file
names). I’m really stuck. Maybe there are some exceptions to the
synchronization rules in arbitrary context solely for file system
drivers??? To be exact, can I use FsRtlLookupPerStreamContext() and
other per stream context routines which uses FastMutex for own internal
synchronization anywhere in my dispatch routines or I should do it only
taking into account the “right” thread context?
Also I saw that FastFAT driver calls ExReleaseResourceForThreadLite()
routine in its asynchronous read completion routine for releasing main
resource or paging I/O resource which was previously acquired in the
read dispatch routine. Is it really possible? But what about being in
critical region or being at APC_LEVEL? I think that it’s ok if the read
completion routine was called at DISPATCH_LEVEL, but if not?
At this point I’m totally confused. It turned out that sometimes it’s
allowed to break the synchronization rules and use different sync
objects other than spin locks in arbitrary contexts. Am I wrong or
partially right (I mean only file system stuff)?
And once again back to the paged/non-paged pool question. FastFAT driver
allocates temporary buffer from non-paged pool in its non-aligned read
routine, and then this buffer is locked via MmProbeAndLockPages() call
(but why not to call MmBuildMdlForNonPagedPool() routine for filling in
an Mdl). Why not to use buffers from paged pool? After all, this buffer
will be locked in MmProbeAndLockPages(). Maybe it relates to possible
page faults (while locking paged pages) which are very undesirable in
read dispatch handlers due to kernel stack limit?
Many thanks beforehand, excuse me for my excessive curiosity and
possibly very dumb questions.
Konstantin Manurin