Writes after Close

It’s a newbie question, and the answer might be obvious, but I need some
clarification here…

What does my File System Driver have to do to make all writes occur before
the file is closed?

My driver doesn’t yet support cache. I do nothing in my FSD except
CcUninitializeCacheMap (per Nagar’s book!) in cleanup processing, after
all user file handles are closed.

I ran filemon and I see “system” is doing writes to my FSD with an
asterisk next to IRP_MJ_WRITE, meaning “paging IO”. I assumed that the
application writing to my FSD is doing it as memory mapped io, and the
system wants to write out dirty pages. Is this sort of how it works?

Is this the LazyWriterThread doing this? I didn’t fully understand
Nagar’s explanation…

Thanks for your time,

Greg

Greg,

I/O cannot occur to a file after the file is closed. It CAN occur after the
file is cleaned up (IRP_MJ_CLEANUP) and before the close (IRP_MJ_CLOSE) but
only paging I/O operations are allowed at that point.

If you want to disallow I/O after cleanup and before close, you can do so
but you will cause hard-error pop-up messages (Lost-delayed-write-data).

ANY application that does the following:

  • Open the file
  • Memory Map the file
  • Close the file
  • Write on the memory mapping

Will cause I/O operations after the IRP_MJ_CLEANUP, no matter what
flush/purge operations performed by the FSD. That’s just the way the OS
works.

Regards,

Tony

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

-----Original Message-----
From: Greg Pearce [mailto:xxxxx@filetek.com]
Sent: Friday, March 29, 2002 12:35 AM
To: File Systems Developers
Subject: [ntfsd] Writes after Close

It’s a newbie question, and the answer might be obvious, but I need some
clarification here…

What does my File System Driver have to do to make all writes occur before
the file is closed?

My driver doesn’t yet support cache. I do nothing in my FSD except
CcUninitializeCacheMap (per Nagar’s book!) in cleanup processing, after
all user file handles are closed.

I ran filemon and I see “system” is doing writes to my FSD with an
asterisk next to IRP_MJ_WRITE, meaning “paging IO”. I assumed that the
application writing to my FSD is doing it as memory mapped io, and the
system wants to write out dirty pages. Is this sort of how it works?

Is this the LazyWriterThread doing this? I didn’t fully understand
Nagar’s explanation…

Thanks for your time,

Greg


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

> What does my File System Driver have to do to make all writes occur before

the file is closed?

My driver doesn’t yet support cache.

Implement the cache support.

Then - when all handles to the file object will be closed, you will receive CLEANUP IRP. At this moment, the cache maps can be
alive, and the file can be memory-mapped by the app.
Cache map maintains a reference on the file object, so does MM’s structures used to memory-map the file.
CLEANUP path must call CcUninitializeCacheMap, which will queue the cache map for the destruction by the worker thread.
Cache map destruction will result in derefing the file object. After this and after all user mapped views will be unmapped, you will
get a CLOSE IRP which is the file object’s “destructor”.
CLOSE path must dereference the FCB, and, if FCB’s reference count is zero, you can drop it.

Max