MmFlushImageSection

Hi All,

How to delete a cache map after all the memory maps and file objects are
closed?

I tried with MmFlushImageSection with MmFlushForDelete option in the Close
Dispatch of the last file object. But it did not work!

Regards,
Vishnu

You don’t mean CcUninitializeCacheMap do you?

First of all - if a file object is handled by other FSD( not your FSD ) do
not try to play with it.
If ALL file objects are closed then cache map is deleted, because
CcUninitializeCacheMap must be called for each close request.
Call CcUninitializeCacheMap for each close request if the file object is
handled by your FSD. Do not do this in the FSD filter driver.

“vishnu” wrote in message news:xxxxx@ntfsd…
> Hi All,
>
>
> How to delete a cache map after all the memory maps and file objects are
> closed?
>
> I tried with MmFlushImageSection with MmFlushForDelete option in the Close
> Dispatch of the last file object. But it did not work!
>
>
> Regards,
> Vishnu
>
>
>

Sorry, call CcUninitializeCacheMap in cleanup not close request( or you do
not receive close ), I misprinted.

“Slava Imameyev” wrote in message news:xxxxx@ntfsd…
> First of all - if a file object is handled by other FSD( not your FSD ) do
> not try to play with it.
> If ALL file objects are closed then cache map is deleted, because
> CcUninitializeCacheMap must be called for each close request.
> Call CcUninitializeCacheMap for each close request if the file object is
> handled by your FSD. Do not do this in the FSD filter driver.
>
> “vishnu” wrote in message news:xxxxx@ntfsd…
>> Hi All,
>>
>>
>> How to delete a cache map after all the memory maps and file objects are
>> closed?
>>
>> I tried with MmFlushImageSection with MmFlushForDelete option in the
>> Close
>> Dispatch of the last file object. But it did not work!
>>
>>
>> Regards,
>> Vishnu
>>
>>
>>
>
>
>

Image sections are not used by the cache manager. Thus, calling MmFlushImageSection won’t do anything vis-?-vis the cache manager.

As several others have noted, the cache map is managed via Cc* calls. The memory manager will keep the data section around even after the cache map is torn down, but that’s the *data section*.

In addition, using MmFlushForDelete is less aggressive than MmFlushForWrite (the first says “I’m deleting the file that backs this executable image” and the second says “I’m rewriting the file that backs this executable image”. The former can be safely ignored, but the latter requires a rather aggressive purge.) MmFlushImageSection is normally used when a mapped image is being rewritten. You see this happen quite a lot during application development, because the image is constantly being executed and modified.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of vishnu
Sent: Saturday, February 04, 2006 4:10 AM
To: ntfsd redirect
Subject: [ntfsd] MmFlushImageSection

Hi All,

How to delete a cache map after all the memory maps and file objects are
closed?

I tried with MmFlushImageSection with MmFlushForDelete option in the Close
Dispatch of the last file object. But it did not work!

Regards,
Vishnu


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> How to delete a cache map after all the memory maps and file objects are

closed?

Cache map close precedes the last file object close for this FCB. So, when the
FCB is dying, there is no more cache maps.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> If ALL file objects are closed then cache map is deleted, because

CcUninitializeCacheMap must be called for each close request.

For each cleanup (user handle close) request. The last such request turns the
shared cache map to a candidate-to-garbage-collection state, and, after it will
be garbage-collected, MJ_CLOSE to the file object used by it will follow.

Call CcUninitializeCacheMap for each close request if the file object is
handled by your FSD.

For each MJ_CLEANUP request :slight_smile:

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

I wrote about this in my message which followed to the message which you try
to correct. I wrote that I misprinted and “cleanup” must be read instead of
“close”. I also wrote that if CcUninitialize… is called in a close request
then close request for a FO backing cache map will not be send.
Did you read this message?

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
>> If ALL file objects are closed then cache map is deleted, because
>> CcUninitializeCacheMap must be called for each close request.
>
> For each cleanup (user handle close) request. The last such request
> turns the
> shared cache map to a candidate-to-garbage-collection state, and, after it
> will
> be garbage-collected, MJ_CLOSE to the file object used by it will follow.
>
>> Call CcUninitializeCacheMap for each close request if the file object is
>> handled by your FSD.
>
> For each MJ_CLEANUP request :slight_smile:
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>