I’m confused about one question - how to extend EOF in pre-write routine in Isolation Filter?
Several days before, I asked a question about how to deal with RESOURCES in Isolation Filter, from that post I learned that I should allocate RESOURCES in my own Isolation Filter and try not to use the lower file system RESOURCEs to avoid deadlock.
My Iosolation Filter use FltSetInformationFile(with FileEndOfFileInformation) in pre-write routione to do the extending EOF operation, but I found that sometimes it may lead to deadlock. Because FltSetInformationFile(with FileEndOfFileInformation) will try to acquire shadow file object’s PagingIoResource exclusively, it will wait infinitely if it can not grant the resource immediately, thus a deadlock may occur.
I know calling FltSetInformationFile(with FileEndOfFileInformation) is not a good design, so I wonder if there is any better solutions about extending EOF in pre-write routine?
PreWrite: catch Cached Io write
1.Grab exclusive resouce
2.Call FltSetInfoFile…
3.call CcSetFile…
4.Then update VDl while checking All Size’s.
Hope this will help.
./Tuten
> PreWrite: catch Cached Io write
1.Grab exclusive resouce
2.Call FltSetInfoFile…
Being very careful of all the interop side effects since you are now
performing lower IO with a resource held, indeed a resource held exclusive.
So if someone provokes paging write as a result of this you will deadlock -
you need a plan to deal with this.
3.call CcSetFile…
You also need to worry about what happens to the following write if the
stream gets truncated under your feet, but you need to worry about that
anyway.
4.Then update VDl while checking All Size’s.
For myself I wouldn’t touch VDL at that point - nothing stopping you from
doing it of course (except performance).
I’d also suggest a far bit of attention to lower VDL as well as upper VDL.
You will find that various FSDs deal with this in interesting ways and it is
not uncommon to see paging writes as a result of moving lower VDL out.
R
I try to call FltSetInfoFile in my pre-write routine, but it seems that it go into a deadlock.
MiMappedPageWriter is trying to write and is not release PagingIoResource of the FileObject yet, at this time FltSetInfoFile is called and is waiting for PagingIoResource of the FileObject infinately.
How should I solve this deadlock?
Right - you cannot extend EOF in the paging write path. You have to extend it during the extending user write or during the set eof operation.
Tony
OSR
Thanks Tony, I got it.
There is another interesting questions I do not quite understand:
FsFilterCallbacks such as AcquireForModWrite, AcquireForSectionSync and etc, they all have their running thread-context, I would like to know in which context they can be called, the following is what I think:
Acquire\ReleaseForModWrite - System Thread
Acquire\ReleaseForSectionSync - System Thread \ User Thread
Acquire\ReleaseForCcFlush - System Thread \ User Thread
Acquire\ReleaseForLazyWrite - System Thread
Acquire\ReleaseForReadAhead - System Thread
Am I correct or something is wrong?