how can manually dirty pages in cache after post write

I want to manually dirty some pages in cache after write operation (in post write).
The pages that i want to be dirty is same pages that cached in IRP_MJ_WRITE.

File system is NTFS.
Win7+

Tanks,
Jahan

> I want to manually dirty some pages in cache after write operation (in

post write).

What sort of write? (cached, uncached, paging)? Is there any reason (apart
from consistency and time races) why you cannot just write them again?

For a smaller timing window you could do something with sections (at the
cost of more end user visibility).

If you need this level of control over the cache you are going to have to
bite off owning it, putting up with incomplete solutions (or deadlocking
your customers from time to time).

What problem are you trying to solve? This might be a “superglue the wings
onto a pig” situation…

my problem is reading cipher data (manipulated data by my minifilter cached in write operation)
for more info Pls reading “http://www.osronline.com/cf.cfm?PageURL=showThread.CFM?link=279248

I guess that if i dirty cache on post write, we can solve problem reading cipher data.

[/quote]
my problem is reading cipher data (manipulated data by my minifilter cached in write operation) for more info Pls reading “http://www.osronline.com/cf.cfm?PageURL=showThread.CFM?link=279248

I guess that if i dirty cache on post write, we can solve problem reading cipher data.
[/quote]

The best solution is to *use your own buffer* for encryption. You can’t encrypt inside the buffer you are given in the write path because you can never make that work right. Memory mapped files (for example) can continue to access the buffer, so if you encrypt in place you won’t ever be able to do it in such a way that user mode applications can’t see it.

Tony
OSR

I use swapbuffer sample, then i use from my own buffer.
but MMF read cached data.

Then you have some sort of bug in your implementation, because if you aren’t encrypting data in the cache, it won’t be visible to memory mapped files. Are you sure you are only acting on non-cached I/O operations?

Tony
OSR

From the previous discussions I know that your are talking about cache purging. As I told you you can play with CcFlushCahce followed by CcPurgeCacheSection but this will never work well from a filter which is not an isolation filter. Some of your customer’s PCs will hang, others will BSOD, in some cases the cache will not be purged and data is being corrupted.

There is always a bit of uncertainty in a swap buffer implementation for data encryption. If your filter observes a non-cached non-paged write what should it do? FSD is allowed to use cache for non-cached IO. So if it swaps and encrypts the buffer and FSD decides to use cached IO or synchronize cache with this data the encrypted data goes to cache and all applications will observe encrypted data. When the cache is flushed with paging IO you will encrypt already encrypted data.

This is particularly problematic for network file systems, where they can (internally) change their behavior depending upon the protocol between the redirector and the server based upon cache coherency protocol. This is not visible to the layers above.

The usual local file system example of this behavior is NTFS and compressed files, but there’s certainly no restriction as to this: promoting a “no intermediate buffering” to “write through caching” implementation *does not* compromise data integrity or correctness.

Isolation filters don’t suffer from this problem because they control the cache that is presented to applications. This is far beyond swap buffers. The OP wasn’t clear at all on when she or he was experiencing this behavior, so it is also possible that this is some other issue. Regardless, it is a bug in the implementation, whether because the OP does not understand the caching model or because the OP has an implementation mistake.

I *do* talk about this in my file systems class at length, because much of this is definitely not obvious.

Tony
OSR