I have a mini-filter that watches writes and creates a journal. I am
writing my journal data to a file in a system thread that gets data from a
queue. The pre-write callbacks put data into the queue. The data I am
writing is getting delayed in the actual FltWriteFile call, even though it
is an non-cached async call. When this happens (during stress test) my
output queue backs up and fills up non-paged memory.
I was thinking that maybe if I used paged writes by turning on
FLTFL_IO_OPERATION_PAGING it might give my writes higher priority so they
don’t get behind. When I tried this the writes returned a
Data->IoStatus.Status of zero, but Data->IoStatus.Information was also zero,
correctly indicating it had written nothing. My output file was empty.
Are there any special rules about using FLTFL_IO_OPERATION_PAGING? I will
try doing sync writes instead of async and different output page sizes
instead of the 16K page size I am trying now.
Here are the pertinent parts of my code:
InitializeObjectAttributes( &attr, &fileName, OBJ_CASE_INSENSITIVE |
OBJ_KERNEL_HANDLE, NULL, NULL );
status = FltCreateFile( gFilter, gOutVolInstance, &gOutputFileHandle,
FILE_APPEND_DATA | SYNCHRONIZE, &attr, &ioStatus, 0, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ, FILE_CREATE, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0, 0 );
FltWriteFile( gOutVolInstance, gOutputFileObject, NULL, OUT_PAGE_SIZE,
PagePtr, FLTFL_IO_OPERATION_NON_CACHED | FLTFL_IO_OPERATION_PAGING,
&bytesWritten, CpsPageWriteCallback, PagePtr );