CcMapData maps the data into system cache memory, where the file that backs the segmen object is my file.
Correct, the VACB is allocated.
This is why after calling the CcMapData, it is not safe to modify the data using the returned buffer pointer, since the data can get paged out without saving the contents.
No. This is only a requirement of the Cache Manager developers - you are not allowed to write in the mapped region if it has not been pinned. The CcMapData may be optimized because it maps data for read access only. For example, the Cache Manager developers might design the CcMapData function in such a way that even if the PTE is marked as dirty( i.e. the page has been modified ) but the region is not pinned then this page will not be written to disk because the page frame data base descriptor( PFN descriptor ) is not marked as dirty due to optimization. But if the mapped region is pinned the Cache Manager developers guarantee that all dirty pages will be written to disk before being paged out. In other words, if you modify data that has been only mapped but not pinned then you are breaching the contract.
CcPinMappedData ensures that the segment object will be backed by the system paging file.
No. Forget about pagefile.
Therefore after calling the CcPinMappedData it is safe to modify the data using the buffer returnmed from previous CcMapData call.
See 2)
wrote in message news:xxxxx@ntfsd…
Correct me if I am wrong …
CcMapData maps the data into system cache memory, where the file that backs the segmen object is my file. This is why after calling the CcMapData, it is not safe to modify the data using the returned buffer pointer, since the data can get paged out without saving the contents. CcPinMappedData ensures that the segment object will be backed by the system paging file. Therefore after calling the CcPinMappedData it is safe to modify the data using the buffer returnmed from previous CcMapData call.
-Ilya.
-------------- Original message --------------
From: “Slava Imameyev”
>it will result in a page fault, and the data will be read from the system page file
data will be read from the file that backs the memory mapping the file( i.e. the file that backs the segment object ), this is not the page file, this is common file, i.e. this is your file. And if the page is dirty it will be written in your file!
>Again, can you or somebody else verify that the data stays mapped in this example untill the CcUnpinData is called
yes, there must be a reference counter incremented on each CcPinMappedData, CcRepinBcb etc. and decremented in CcUnpinData.
wrote in message news:xxxxx@ntfsd…
>>>>Yes, you can CcSetDirtyPinnedData - CcRepinBcb/CcUnpinRepinnedBcb again.
The problem here is that I do not see any paging writes after the above calls - the data does not get re-written.
>>>>You use phrase “lock the pages”, but in Windows world this means- “resedent pages”. CcPinMappedData doesn’t lock the page frames. CcPinMappedData only guarantees that the portion of the mapped file will be mapped untill CcUnpinData.
Sorry for my poor use of words. What I meant is that after calling CcPinMappedData and untill calling the CcUnpinData the data will be mapped into the system cache virtual address space. I understand that the data can get paged out, and when referenced again, it will result in a page fault, and the data will be read from the system page file. Again, can you or somebody else verify that the data stays mapped in this example untill the CcUnpinData is called. Or something else can cause the data to unmap. e.g calls to CcRepinBcb/CcUnpinRepinnedBcb APIs.
Thanks,
Ilya.
-------------- Original message --------------
From: “Slava Imameyev”
> If I find out that the server side write behind failed, can I mark the relevant BCBs as dirty again, and than flush the data again using CcRepinBcb/CcUnpinRepinnedBcb APIs??? I assume that BCB is valid and locked till CcUnpinData is called.
Yes, you can CcSetDirtyPinnedData - CcRepinBcb/CcUnpinRepinnedBcb again.
>I think another way to do it, which I described in my previous e-mail, is to keep track of the dirty pages and lazy write them to the disk myself. I should lock the pages via CcMapData and CcPinMappedData APIs, and keep them locked
You use phrase “lock the pages”, but in Windows world this means- “resedent pages”. CcPinMappedData doesn’t lock the page frames. CcPinMappedData only guarantees that the portion of the mapped file will be mapped untill CcUnpinData. The Cache Manager or the Memory Manager may decide to flush the pages mapping the file if there is a page frames shortage in the system, so you will have to cope with this write requests for which you are not originator.
wrote in message news:xxxxx@ntfsd…
Slava,
thanks for you reply. While returning the STATUS_FILE_LOCK_CONFLICT processing the lazy-writer threads is an interesting option, it is not really applicable in my case. My goal here is to keep data in shared memory even after a successful lazy-writer request is complete, and if neccessary, mark this shared data as dirty again and force the CM to requeue the lazy-writer thread.
A call to CcRepinBcb/CcUnpinRepinnedBcb APIs will trigger a lazy-writer thread to flush the data described by BCB to disk. Obviously the data had to be marked as dirty previously via CcSetDirtyPinnedData API. Note that even if lazy-writer threads complete the operation successfully, let’s assume they always do, it is still possible that the data will not get committed on the server side - this is similar to client side “write behind failed” error/message. If I find out that the server side write behind failed, can I mark the relevant BCBs as dirty again, and than flush the data again using CcRepinBcb/CcUnpinRepinnedBcb APIs??? I assume that BCB is valid and locked till CcUnpinData is called.
I think another way to do it, which I described in my previous e-mail, is to keep track of the dirty pages and lazy write them to the disk myself. I should lock the pages via CcMapData and CcPinMappedData APIs, and keep them locked till I receive a confirmation from the server that the data was committed. I will use the returned buffer from CcMapData to modify the data in-memory; and asynchronously write it to the server using my worker (lazy-writer) thread. The downside with this method is that I may loose all optimizations that CM already has built in. e.g. small file writes.
Any thoughts?
Thanks,
Ilya.
-------------- Original message --------------
From: “Slava Imameyev”
> Q. Is it possible to assynchroneously process the lazy-writer threads, and notify the CM that the specified page is not dirty any more only after it is committed to disk?
I think you want to avoid the popup message “write behind failed”.
The page frames are marked as not dirty before write and if the write failed the page frames are marked again as dirty. If the lazy writer fails to write pages the system creates the popup msg “write behind failed”, but there is one exception - if STATUS_FILE_LOCK_CONFLICT is returned the lazy writer thread requeues the request and will repeat an attempt to write pages from the shared cache map. So simply return STATUS_FILE_LOCK_CONFLICT.
>Some time later I force the flush of these BCBs using the CcRepinBcb/CcUnpinRepinnedBcb
If you set WriteThrough to TRUE, then you mark the page frames as dirty and calls MmFlushSection.
And again, if STATUS_FILE_LOCK_CONFLICT is returned the system will repeat an attempt to write data from the lazy writer thread.
Also, CcSetDirtyPinnedData doesn’t mark the page frames as dirty - it marks the BCB as dirty.
>I should lock the pages via CcMapData and CcPinMappedData
This APIs don’t lock page frames associated with a file mapped in the cache!
wrote in message news:xxxxx@ntfsd…
Hi All,
I’ll start with a question and than follow with a more specific description of what I am trying to achieve.
Q. Is it possible to assynchroneously process the lazy-writer threads, and notify the CM that the specified page is not dirty any more only after it is committed to disk?
I am writting a netwrok file system that has both client and server side caching. Even after the client side cache is written to the server I want to keep it around till I receive a confirmation from the server that data was committed to disk. In case of a server side error I want to re-send the client data.
Here is what I do:
On a client side I utilize the Cc pinning interface to cache the user writes. I map and pin the write buffers processing the user write requests using the CcMapData and CcPinMappedData Apis. I mark the data as dirty using CcSetDirtyPinnedData, and I add the resulting BCB to the FCB link list.
Some time later I force the flush of these BCBs using the CcRepinBcb/CcUnpinRepinnedBcb, which writes out all data that was previously was marked as dirty to the server. Next, if I receive notification that the server encountered an error committing the data to disk, I want to mark the data as dirty again via CcSetDirtyPinnedData, but it does not seem to work.
Here is amore simplified description of above using a sequence of API calls:
In FsdWrite thread:
1. CcMapData
2. CcPinMappedData
3. CcSetDirtyPinnedData
4. Add BCB to the link list of FCB and Return
In a worker thread per each BCB in the link list of FCB:
1. CcRepinBcb
2. CcUnpinRepinnedBcb - this triggers the write of dirty data
…
3. Send message to the server to commit the data to the disk - in case of an error do the following.
4. CcSetDirtyPinnedData, and than repeat steps 1-3. However, the problem is that I do not see any writes going through when I call CcRepinBcb/CcUnpinRepinnedBcb Apis next time, which is at the core of my problem.
Thanks in advance for all your responses.
-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
—
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
—
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