Re: CreateFile() and FILE_FLAG_WRITE_THROUGH



Yes that's quite true, BUT this will not work UNLESS you specify the
FILE_FLAG_NO_BUFFERING flag, this is my understanding anyway. If I am wrong
please do let me know, this is pretty vital stuff!

Thx


"Nick Tucker" wrote:

Hi Hugh

Thanks a lot for your interest.

However, I have now proved to myself that file metadata is not written
through, whatever flags you specify. The only way to update the metadata is
to call FlushFileBuffers().

You can overwrite existing data where the metadata is already present, no
problem. But if you add new data to the end of the file and don't call
FlushFileBuffers(), and then pull the plug, the file size as shown by the
directory on restart does not include the extra data.

Thanks again

Nick

"Hugo gleaves@xxxxxxxxxxx>" <hugh<underbar> wrote in message
news:EC52B3EC-2522-4751-9E43-A49E50231AE7@xxxxxxxxxxxxxxxx
To my knowledge, yes.

My understanding is that to "write the file" requires the entire NTFS on
disk structure to be consistent, this incurs a cost and that's why the
flags
are optional.

If you return from that call, then power off the system (like literally
pull
the plug) then assuming it boots (never a good idea of course) you should
see
the file intact and accessible.

I tested this to a degree some years back, powering off and on showed the
file to be written as expected.

Hugh


"Uwe Sieber" wrote:


Yes, but the problem the OP asked about is the
metadata, as file size and cluster allocation.
Does FILE_FLAG_NO_BUFFERING ensure that they
are not buffered too?


Uwe



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.

"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: CreateFile() and FILE_FLAG_WRITE_THROUGH
    ... write-through to do this as long as I call FlushFileBuffersto update the metadata each time a new block is added. ... is written with write through, and if the power then fails, the data is available to be read on restart. ... 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 be ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateFile() and FILE_FLAG_WRITE_THROUGH
    ... 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 be ... "...together with it's corresponding metadata" is wishful thinking on your ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateFile() and FILE_FLAG_WRITE_THROUGH
    ... 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. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateFile() and FILE_FLAG_WRITE_THROUGH
    ... However, I have now proved to myself that file metadata is not written through, whatever flags you specify. ... >> variety of hardware platforms with both SATA and SCSI disk systems,>> and they ... >> Surely the whole point of specifying that flag is that I want the data>> to be ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Letting a user select a color for a control
    ... CC_FULLOPEN flag instead of the CC_SOLIDCOLOR flag in order to do this. ... is there any way to specify where on the screen the Color Dialog ... > specify an initial color selection. ... >> something before calling aDialogColor. ...
    (microsoft.public.access.modulesdaovba)