Calling CcInitializeCacheMap processing Mapped Pager Writer ...

Hi Experts,

do not ask me why ( I am trying to do some weird stuff) but is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine? Assuming that caching is not initialized for the FileObject, I would like to initialize it at this time, and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData? Than I will complete the write as usual, and return.

I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

-Ilya.

>is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine?

Yes, it is possible. The file has already been mapped so the segment object exists, only the section object for the cache will be created.

and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData

This API does not lock pages in memory( “locked pages” stands for “resident pages” ), this API maps a file into a cache and “locks” this virtual address range.

I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

There is yet another solution:

  1. Create a new MDL for this pages( map them, then IoAllocateMdl ).
  2. Then call MmProbeAndLockPages with IoWriteAccess.
  3. When you want to mark them as dirty you will call MmUnlockPages, and all pages’ PFNs will be marked as dirty!


Slava Imameyev, xxxxx@hotmail.com

wrote in message news:xxxxx@ntfsd…
Hi Experts,

do not ask me why ( I am trying to do some weird stuff) but is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine? Assuming that caching is not initialized for the FileObject, I would like to initialize it at this time, and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData? Than I will complete the write as usual, and return.

I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

-Ilya.

Thanks Slava.

What are the benefits of using your method with MDL over the one that I described using CcMapData->CcPinMappedData->CcSetDirtyPinnedData?

-Ilya.

-------------- Original message --------------
From: “Slava Imameyev”

>is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine?

Yes, it is possible. The file has already been mapped so the segment object exists, only the section object for the cache will be created.

>and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData

This API does not lock pages in memory( “locked pages” stands for “resident pages” ), this API maps a file into a cache and “locks” this virtual address range.

>I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

There is yet another solution:
1) Create a new MDL for this pages( map them, then IoAllocateMdl ).
2) Then call MmProbeAndLockPages with IoWriteAccess.
3) When you want to mark them as dirty you will call MmUnlockPages, and all pages’ PFNs will be marked as dirty!


Slava Imameyev, xxxxx@hotmail.com

wrote in message news:xxxxx@ntfsd…
Hi Experts,

do not ask me why ( I am trying to do some weird stuff) but is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine? Assuming that caching is not initialized for the FileObject, I would like to initialize it at this time, and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData? Than I will complete the write as usual, and return.

I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

-Ilya.


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

>What are the benefits of using your method with MDL over the one that I described using CcMapData->CcPinMappedData->CcSetDirtyPinnedData?

The benefit is that the physical page frames will contain data until you unlock them( the MPW or lazy writer might flush them, but the pages will be resident in any case ). However, there is also a drawback - you can lock only a moderate( or small ) amount of pages.
When you map pages in the cache using CcMapData->CcPinMappedData the system might page them out, i.e. the system’s working set manager pages them out silently because neither PTE no PFN have been marked as dirty( by CcSetDirtyPinnedData ), you won’t receive any write request. The working set manager invalidates PTE, decrements the PFN usage counter and if it drops to zero moves physical page in the transition list from which it will be either moved to the free list or returned back by the page fault handler( so called “soft page fault”). If page is moved to the free list you will lose data.


Slava Imameyev, xxxxx@hotmail.com

wrote in message news:xxxxx@ntfsd…
Thanks Slava.

What are the benefits of using your method with MDL over the one that I described using CcMapData->CcPinMappedData->CcSetDirtyPinnedData?

-Ilya.

-------------- Original message --------------
From: “Slava Imameyev”

>is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine?

Yes, it is possible. The file has already been mapped so the segment object exists, only the section object for the cache will be created.

>and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData

This API does not lock pages in memory( “locked pages” stands for “resident pages” ), this API maps a file into a cache and “locks” this virtual address range.

>I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

There is yet another solution:
1) Create a new MDL for this pages( map them, then IoAllocateMdl ).
2) Then call MmProbeAndLockPages with IoWriteAccess.
3) When you want to mark them as dirty you will call MmUnlockPages, and all pages’ PFNs will be marked as dirty!


Slava Imameyev, xxxxx@hotmail.com

wrote in message news:xxxxx@ntfsd…
Hi Experts,

do not ask me why ( I am trying to do some weird stuff) but is it possible to call CcInitializeCacheMap processing Mapped Pager Writer in my write dispatch routine? Assuming that caching is not initialized for the FileObject, I would like to initialize it at this time, and lock the very page(s) that Mapped Page Writer is trying to send to disk in memory via CcMapData and CcPinMappedData? Than I will complete the write as usual, and return.

I want to lock these pages in memory so I would have an option to mark them as dirty later on via CcSetDirtyPinnedData API.

-Ilya.


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com