Help, I am completely lost! problems with the Lazy Writer.....

I am currently writing a Filesystem Driver and im having problems with the
cache manager.

Basically i am trying to modify and add addtional data to a text file opened
via Notepad, and saving it. The file contents is being written to the disk
without any problems, however the filesize which is stored in the Dirent is
not being updated 100% of the time.

When i try to update the filesize in the dirent the following steps are
taken

  1. CcPinRead to read the Dirent from the disk,
  2. update the Dirent->Filesize = NewFilesize;
  3. FsRtlNotifyFullReportChange to indicate the filesize has
    been changed
  4. CcSetDirtyPinnedData to signal the cache manager to
    schedual a lazy write?
  5. CcUnpinData

now, from what i understand calling CcSetDirtyPinnedData will tell the cache
manger
to schedual a lazy write some time in the future.

I mentioned earlier that the Dirent is not always being updated, this occurs
when i save the contents of the disk, then quickly reboot the pc, open up
the file again only to find that the filesize hasnt been updated… however
if save the contents of the disk again, but wait around 30secs to a minute,
“THEN” reboot, open up the file, i can now view the extended data i added
previously to the file before the last reboot!

why is it that the lazy writer is not writing the data to the disk soon
after i’ve saved the disk and rebooted without waiting for a few seconds
before i do? is there a way to force the cachemanager to perform all the
lazy writes before shutting down? or during a IRP_MJ_CLOSE or
IRP_MJ_CLEANUP?

incidentally, i have place breakpoints on the point where the cache manager
acquires and releases the resource for a lazy write operation, and i have
noticed they are being acquired and released successfully, regardless
whether i wait 30 secs or not before a reboot… so surely this should mean
that once the cache manager has released the resource from the lazy write,
the Dirent on the disk should have been updated?!

Regards
James

General Dynamics United Kingdom Limited
Registered in England and Wales No. 1911653
Registered Office: 100 New Bridge Street, London, EC4V 6JA