Re: CreateFile() and FILE_FLAG_WRITE_THROUGH



Well just to be clear, by 'write' we must of course mean 'FlushFileBuffers'.

However, the CreateFile documentation states this:

"If FILE_FLAG_WRITE_THROUGH and FILE_FLAG_NO_BUFFERING are both specified,
so that system caching is not in effect, then the data is immediately flushed
to disk without going through the system cache. The operating system also
requests a write-through of the hard disk cache to persistent media."

That last sentence doesnt give any room for caching by any driver. I
therefore don't think you are correct, because if you are correct, then this
documentation is wrong.

My understanding is that if all these flags etc are in effect, then upon
return from FlushFileBufers, it is beyone doubt, that the data is persisted
onto the disk platters, if you claim a driver can complicate this, then
surely that would be a driver bug?

Hugh

"Pavel A." wrote:

Hugo gleaves@xxxxxxxxxxx> <hugh wrote:
Just to clarify, if you have the file opened with these flags and you do a
write, when that write returns you can be 100% confident that the data is on
the physical media.

Upon return from write, it _may_ only guarantee that the data has been
handed to the storage device driver. Whether or not it is on the media,
depends on the driver...

--pa



"Nick Tucker" wrote:

Hi everyone

If I create a file using CreateFile(), specifying the
FILE_FLAG_WRITE_THROUGH flag, then write to that file, the file still shows
as zero bytes long in the directory and in Windows Explorer, and if I then
turn the power off, that file is still zero bytes long on restart, so the
data I wrote is unavailable. I have tried this test on a variety of
operating systems including Vista, XP and Windows Server 2003/2008 using a
variety of hardware platforms with both SATA and SCSI disk systems, and they
all behave the same way.

Surely the whole point of specifying that flag is that I want the data to be
written to disk, together with it's corresponding metadata, so if a
catastrophic failure occurs, the data is available to me on restart.

My researches of newsgroup articles on this subject suggest that if I want
this, then I also have to use FileFlushBuffers(), but if that is so then
surely I don't need to specify the write through flag since all file and
folder data will be committed to disk when I call that function.

So, what is the point of specifying the write-through flag in this scenario?

I think the documentation of CreateFile() could do with a little
clarification!

Thanks in advance for responses.

Nick


.



Relevant Pages

  • Re: File Syncrhonization Necessary?
    ... > see it in the DDK documentation, and also in the documentation for ... Can this flag be passed through the Win32 CreateFile ... make it through to NtCreateFile if passed in the dwDesiredAccess parameter ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateFile() and FILE_FLAG_WRITE_THROUGH
    ... What does your CreateFile call look like? ... variety of hardware platforms with both SATA and SCSI disk systems, ... Surely the whole point of specifying that flag is that I want the data to ...
    (microsoft.public.win32.programmer.kernel)
  • Re: File Syncrhonization Necessary?
    ... >> see it in the DDK documentation, and also in the documentation for ... Can this flag be passed through the Win32 CreateFile ... > fact make it through to NtCreateFile if passed in the dwDesiredAccess ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Forgot to put old_rootvg to sleep before reboot - How to Wake
    ... Performs operations on existing alternate rootvg volume groups. ... To rename Alternate Disk Volume Group: ... The alt_rootvg_op command can be used to determine which disk is the ... flag) can be executed at this time. ...
    (comp.unix.aix)
  • 1571 SPEED ADJUSTMENT FOR SUPERCARD-RAMBOARD NEEDED
    ... speed control adjustment to a 1571 disk drive, ... I have a Supercard Plus 1571 installed, ... none of this shows anything about the speed control. ... If anyone has the original Documentation from Utilities Unlimited ...
    (comp.sys.cbm)