Hi,
I have a problem with a mini filter driver I am writing and I suspect that it is related to an oplock on a file, but I am not sure. The symptom is deadlock - in my post-op create callback I am trying to read the file but that read is waiting on some synchronization event. The read is done while holding my main resource for the stream context. While the read is blocked I get a pre-op cleanup request for the same file (\System Volume Information\tracking.log. The deadlock only happens with this file) and I try to acquire the stream context resource only to deadlock.
I am not sure what FltReadFile is waiting for. I thought that it might be breaking an oplock. The cleanup thread has a kernel APC queued to it and I thought that that may be an oplock break IRP completion APC. Maybe, the application is trying to close the handle to the file before acknowledging the oplock break which causes this deadlock?
Attempting to test this “theory” I looked at how to use the few oplock routines the filter manager exposes. How would you check if a file has an oplock on it? I came up with something that looks like this (assume that this is an IRP operation):
OLOCK oplock = NULL;
FltInitializeOplock(&oplock);
FltCheckOplockEx(&oplock, callbackData, OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY, NULL, NULL, NULL);
if (FltCurrentOplock(&oplock)) {
print something;
do something;
}
FltUninitializeOplock(&oplock);
Should this work? I based this on the fastfat example for win 7 in which fastfat checks in similar fashing if a batch oplock exists on a file. FltCurrentOplock returns false for tracking.log. Any ideas what FltReadFile is blocked on?
Thanks,
G.