Why my fsd didn't receive the IRP_MJ_CLOSE when the WinWord delete the tmp file?

My file system work fine at most of the time. But I found it didn’t receive the IRP_MJ_CLOSE when the WinWord delete the tmp file.

The result is that the tmp file can not be closed.

I must make it clear that my file system can receive the IRP_MJ_CLOSE correctly at most of the time. Just miss it when WinWord delete the tmp file.

I compare my file system code with FastFat. There is not much difference.

In my Cleanup rountine, I call MmFlushImageSection,MmForceSectionClosed,CcFlushCache,CcPurgeCacheSection,CcUninitializeCacheMap.

Will it effect the WinWord deleting tmp file problem?


I log the FastFat and my Filesystem. You can see my file system just miss IRP_MJ_CLOSE when deleting the tmp file:

FastFat:

> Process:WINWORD.EXE Moving File NewWord.doc To :~WRL0604.tmp , Replace:1 ( oldFile-> open count:1, reference count:2 )
Process:WINWORD.EXE File cleanup: ~WRL0604.tmp, OpenCount:0, ReferenceCount:2
Process:WINWORD.EXE File CLOSE: ~WRL0604.tmp, OpenCount:0, ReferenceCount:1
Process:WINWORD.EXE Open file:~WRL0604.tmp suc, OpenCount:1, ReferenceCount:2
Process:WINWORD.EXE File cleanup: ~WRL0604.tmp, OpenCount:0, ReferenceCount:2
Process:WINWORD.EXE File CLOSE: ~WRL0604.tmp, OpenCount:0, ReferenceCount:1



Process:WINWORD.EXE Query file:~WRL0604.tmp infor:35 failed:STATUS_INVALID_PARAMETER <<<<<------- Query FileAttributeTagInformation
Process:WINWORD.EXE SetFileInfor file:~WRL0604.tmp :13 suc <<<< ---- FileDispositionInformation
Process:WINWORD.EXE File CLOSE: ~WRL0604.tmp, OpenCount:0, ReferenceCount:1 <<<<< ------------ Here is the IRP_MJ_CLOSE in fast fat.
Process:WINWORD.EXE File cleanup: ~WRL0604.tmp, OpenCount:0, ReferenceCount:1
Process:WINWORD.EXE File CLOSE: ~WRL0604.tmp, OpenCount:0, ReferenceCount:0


My FileSystem:

Process:WINWORD.EXE MoveFile \NewWord.doc To :~WRL0126.tmp ( oldFile-> open count:1, reference count:2 )
Process:WINWORD.EXE Fsd->>> Cleanup File:~WRL0126.tmp, OpenCount:0, ReferenceCount:2
Process:WINWORD.EXE File Close: ~WRL0126.tmp, OpenCount: 0, NocacheCount:0, ReferenceCount:1
Process:WINWORD.EXE Open File suc:~WRL0126.tmp, OpenCount: 1, NocacheCount:0, ReferenceCount:2
Process:WINWORD.EXE Fsd->>> Cleanup File:~WRL0126.tmp, OpenCount:0, ReferenceCount:2
Process:WINWORD.EXE File Close: ~WRL0126.tmp, OpenCount: 0, NocacheCount:0, ReferenceCount:1



Process:WINWORD.EXE Open File suc:~WRL0126.tmp, OpenCount: 1, NocacheCount:0, ReferenceCount:2
Process:WINWORD.EXE Query file:~WRL0126.tmp infor:35 failed:STATUS_INVALID_PARAMETER <<<<<------- Query FileAttributeTagInformation
Process:WINWORD.EXE SetFileInfor file:~WRL0126.tmp :13 suc <<<< ---- FileDispositionInformation
Process:WINWORD.EXE Fsd->>> Cleanup File:~WRL0126.tmp, OpenCount:0, ReferenceCount:2
Process:WINWORD.EXE File Close: ~WRL0126.tmp, OpenCount: 0, NocacheCount:0, ReferenceCount:1

I found that if I invoke CcUninitializeCacheMap in SetFileInformation( FileAllocationInformation and FileEndOfFileInformation ) , these tmp files can be closed. Otherwise the problems listed above will happen.

I don’t know what’s the problem. Why CcUninitializeCacheMap must be invoked at that position ??
I can’t find the CcUninitializeCacheMap invoking in FileEndOfFileInformation and FileAllocationInformation of Ext3 fsd ( download from http://www.acc.umu.se/~bosse/ ). Any one can explain that ??

> I can’t find the CcUninitializeCacheMap invoking in FileEndOfFileInformation and

FileAllocationInformation of Ext3 fsd ( download from http://www.acc.umu.se/~bosse/ ).

Try looking at FASTFAT, it is better.


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