FltCreateSectionForDataScan and Cache Purge

Hello Folks,

I am using FltCreateSectionForDataScan function to read file in my minifilter driver and i am able to read file successfully.

As per the documentation, it says “Certain situations can occur where holding a section open is incompatible with current file I/O. In particular,
file I/O that triggers a cache purge can cause cache incoherency if the cache purge is prevented because of an open section.” To handle this case, i have registered
SectionNotificationCallback routine as mentioned in documentation. But here i am not sure how to generate cache purge scenario in my driver.

Can anyone please help me in generating cache purge scenario?

Thanks in advance.

> Can anyone please help me in generating cache purge scenario?

Open the file FILE_NO_INTERMDIATE_BUFFERING and issue a read.

The MJ_FLUSH ioctl has some extra bits you can set, but the documentation I
have found is scanty (as usual, it describes how, not what or why) but you
might be able provoke something.

Check the FASTFAT sample for how it handles FSCTL_SET_PURGE_FAILURE_MODE
(and how it subsequently deals with FCBs with a non-zero
PurgeFailureModeEnableCount). FltMgr sends this down as part of creating the
data section so that the file system knows purge failures are potentially
recoverable.

-scott
OSR
@OSRDrivers

wrote in message news:xxxxx@ntfsd…

Hello Folks,

I am using FltCreateSectionForDataScan function to read file in my
minifilter driver and i am able to read file successfully.

As per the documentation, it says “Certain situations can occur where
holding a section open is incompatible with current file I/O. In particular,
file I/O that triggers a cache purge can cause cache incoherency if the
cache purge is prevented because of an open section.” To handle this case, i
have registered
SectionNotificationCallback routine as mentioned in documentation. But here
i am not sure how to generate cache purge scenario in my driver.

Can anyone please help me in generating cache purge scenario?

Thanks in advance.

You do not need to purge cache. The conflict is related to an existing user map view that prevents some operations because of an existing virtual to physical mapping. Yes, usually it is cache purging when the old purge interface is used that doesn’t use reverse mapping to invalidate PTEs.

Complete the scan, unmap all views and close the section handle. This will drop the section user map views counter to zero and makes possible all I/O that requires cache purging. You do not need to worry about resident pages as long as there is no user map views.

Thank you guys for the reply.

I will let you know if i am able to generate the scenario.