File System filter driver hangs ..

Hello Everyone,

I have a file system filter driver that intercepts file open/close
operations. Well i need to perform some work on the file data once a file
is accessed. This work is performed in a user mode application. The
general model i follow is depicted below

File Operation----Filter Driver: Signals Event to App, (Blocked)----User
Mode Service:Opens file, performs work, closes file, Signals Event to
Filter Driver----Filter Driver: (Unblocks) Performs original file
operation–>returns IRP with status.

I handle re-entrancy in the Driver by checking for the Process ID of the
user mode application.

Now the problem i face is that under intense file system activity (Network
access, Lots of files being opened , same file being opened by mutiple
threads etc … i start getting STATUS_IO_PENDING in increasing amounts and
finally the system freezes.

In fact even if i perform NO WORK in the user mode side … just a single
open / close operation the system freezes even then under activity.

Any hints about how to tackle the core of this issue ? Is the model
ofperforming work on the user mode side robust enough in high access
scenarios ?

  • Vikrant

I think you are seeing a common deadlock when doing bad things during
paging IO operations.
It usually freezes very soon, after numerous operations are started.

xxxxx@yahoo.com wrote:

Hello Everyone,

I have a file system filter driver that intercepts file open/close
operations. Well i need to perform some work on the file data once a file
is accessed. This work is performed in a user mode application. The
general model i follow is depicted below

File Operation----Filter Driver: Signals Event to App, (Blocked)----User
Mode Service:Opens file, performs work, closes file, Signals Event to
Filter Driver----Filter Driver: (Unblocks) Performs original file
operation–>returns IRP with status.

I handle re-entrancy in the Driver by checking for the Process ID of the
user mode application.

Now the problem i face is that under intense file system activity (Network
access, Lots of files being opened , same file being opened by mutiple
threads etc … i start getting STATUS_IO_PENDING in increasing amounts and
finally the system freezes.

In fact even if i perform NO WORK in the user mode side … just a single
open / close operation the system freezes even then under activity.

Any hints about how to tackle the core of this issue ? Is the model
ofperforming work on the user mode side robust enough in high access
scenarios ?

  • Vikrant

You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to %%email.unsub%%


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32 developers.

Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.

If you’re calling the app only in the IRP_MJ_CREATE path your approach
should work just fine.
Now the Q: do you hold any sync objects (resources, mutexes, etc.) when
blocking the thread and
calling the app?

-----Original Message-----
From: xxxxx@yahoo.com [mailto:xxxxx@yahoo.com]
Sent: Tuesday, July 23, 2002 12:19 AM
To: File Systems Developers
Subject: [ntfsd] File System filter driver hangs …

Hello Everyone,

I have a file system filter driver that intercepts file open/close
operations. Well i need to perform some work on the file data once a file
is accessed. This work is performed in a user mode application. The
general model i follow is depicted below

File Operation----Filter Driver: Signals Event to App, (Blocked)----User
Mode Service:Opens file, performs work, closes file, Signals Event to
Filter Driver----Filter Driver: (Unblocks) Performs original file
operation–>returns IRP with status.

I handle re-entrancy in the Driver by checking for the Process ID of the
user mode application.

Now the problem i face is that under intense file system activity (Network
access, Lots of files being opened , same file being opened by mutiple
threads etc … i start getting STATUS_IO_PENDING in increasing amounts and
finally the system freezes.

In fact even if i perform NO WORK in the user mode side … just a single
open / close operation the system freezes even then under activity.

Any hints about how to tackle the core of this issue ? Is the model
ofperforming work on the user mode side robust enough in high access
scenarios ?

  • Vikrant

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

Hi all,

Thanks for your reply. Well Dejan, is it wrong to block the calling thread
during a paging i/o operation? Because it freezes even if I dont do any
work in the user mode app.
Vladimir, I do ignore the CREATEs for pipes and mailslots. But I have not
done anything for sync objects.

Regards.

It doesn’t matter if you do any work, or not, what matters is that you
WAIT for the application to signal you in your driver.
I have heard people saying they did it - but I never saw it done,
really…
One tip: doing a simple name / size query during paging I/O will block the
system, too, when it is stressed, so imagine what would happen if you do work
via application.

Regards, Dejan.

xxxxx@yahoo.com wrote:

Hi all,

Thanks for your reply. Well Dejan, is it wrong to block the calling thread
during a paging i/o operation? Because it freezes even if I dont do any
work in the user mode app.
Vladimir, I do ignore the CREATEs for pipes and mailslots. But I have not
done anything for sync objects.

Regards.


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to %%email.unsub%%


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32 developers.

Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.

Hello all,

Vladimir, I think I completely misunderstood your question. Yes i do
acquire resources and semaphores. Any hints regarding this?

Regards.
Vikrant.

Hints are pretty obvious :slight_smile: If you hold locks in create IRP path while
waiting on your app to do something with files, you’ve got to carefully
check that those locks are not going to cause a deadlock. In general, I
would suggest you to review your locking in such a way that when you block
the thread there are no locks hold by you. I’ve been many times to the
situations when my locking logics looked perfect but still there was
something that caused a deadlock. Less “strict” requirement - don’t mix
exclusive and shared acquisition of the same resource in the create path.
Chances are you will deadlock on them.
But again, most likely you’re deadlocking on blockin paging I/O.

Regards,

Vladimir

-----Original Message-----
From: xxxxx@yahoo.com [mailto:xxxxx@yahoo.com]
Sent: Thursday, July 25, 2002 5:48 AM
To: File Systems Developers
Subject: [ntfsd] RE: File System filter driver hangs …

Hello all,

Vladimir, I think I completely misunderstood your question. Yes i do
acquire resources and semaphores. Any hints regarding this?

Regards.
Vikrant.


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

Hi all,

I have modified the code in such a way that while I block the thread, I do
not hold any locks or resources or sync. objects. Actually I need to hold
a semaphore before I block the thread and release it only before I let the
thread proceed. But temporarily I have stopped using it. But still the
problem persists.

I tried to look into the problem through softice but could not make out
anything substantial from it. Only thing I noticed was that the driver
thread was waiting for some unnamed kernel event to be signalled. But that
is pretty obvious isnt it?

Regards.
Vikrant.

Did you modify or replace Irp->MdlAddress? If so, did you ensure that
Irp->UserBuffer contains the VA in the new MDL?

I’ve seen a mismatch between Irp->UserBuffer and the value from
MmGetMdlVirtualAddress(Irp->MdlAddress) cause this type of problem.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@yahoo.com [mailto:xxxxx@yahoo.com]
Sent: Tuesday, July 30, 2002 8:38 AM
To: File Systems Developers
Subject: [ntfsd] RE: File System filter driver hangs …

Hi all,

I have modified the code in such a way that while I block the thread, I do
not hold any locks or resources or sync. objects. Actually I need to hold
a semaphore before I block the thread and release it only before I let the
thread proceed. But temporarily I have stopped using it. But still the
problem persists.

I tried to look into the problem through softice but could not make out
anything substantial from it. Only thing I noticed was that the driver
thread was waiting for some unnamed kernel event to be signalled. But that
is pretty obvious isnt it?

Regards.
Vikrant.


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to %%email.unsub%%

Hi all,

No I have not done any such thing.

Regards.
Vikrant.

Hi all,

Another thing, if I use the semaphore and give an infinite timeout to it,
then the system hangs. But if I give a finite timeout of say some 20 ms,
it crashes with a KMODE_EXCEPTION_NOT_HANDLED. Teh parameters are as
follows:-
Exeception code 0xc0000047
Parameter 2: 80110b51
Parameter 3: 0
Parameter 4: 0

I have not seen this exception before and am not able to get any clues
from it. I tried to search the docs, but could not find anything. Now my
question is, is this exeception somehow connected with the deadlock
problem?

Regards.
Vikrant.