Re: Will FlushFileBuffers be automatically called on CloseHandle(hFile)?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



One of the principles of doing properly handled transacted databases is that you assume
that between any two instructions the machine will stop instantly. So the basic notion is
that you track what is and is not commited to the magnetic surface. do a lot of careful
flushes to commit a transaction. But now the disk drive takes over, and essentially lies
about the commitment of bits to the magnetic surface. So we can no longer tell if the
bits we submitted to the drive have been committed to the surface or nt. And that IS the
fault of the disk vendor! (I have three 1500VA battery backups on my system...)

Between 54% and 80% of all BSODs are caused by defective third-party device drivers.
joe
On Sun, 19 Aug 2007 16:53:58 -0700, "Nobody" <Nobody@xxxxxxxxx> wrote:

If there is a power failure, the data in the DRAM of the hard drive is
lost, and you will never know if it made it out.
That is why they have such things as "Battery backup" and line conditioning in case of "brown outs"
There is also these things called Surge protectors in case of power spikes.
I could hardly blame Microsoft or the Disk Vendor for such incidents.

The one thing that may or may not be MS fault is the BSOD.
That I would take issues with.

The old Visio, before microsoft took it over, did something odd that caused all the data to be lost.
I was an unfortunate member of that group.
Since Microsoft took it over, it appears to be better, but still
If there is a system crash it enevitably corrupts the Visio file.
http://www.corrupteddatarecovery.com/Repair/Microsoft-Visio-drawing-File-Repair-VSD-Data-Conversion.asp

The one thing that has irked me is disk monitoring.
My hard drive crashed at one time, I think it overheated.
Fortunately I was able to recover valuable information and most of the other data.

I don't know if Vista comes equipped with disk monitoring as far as temp and other monitoring features?
It should be part of the OS and not a 3rd party tool.

Thanks,
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:h2jhc39krc7n35vq9ihidh2gcfk85m50qn@xxxxxxxxxx
It's actually worse than you can possibly imagine. For example, the act of "flushing"
butters to a modern hard drive means that the buffers are written to the onboard buffers
on the hard drive, but not committed to the magnetic surface until the hard drive gets
around to it. If there is a power failure, the data in the DRAM of the hard drive is
lost, and you will never know if it made it out. When I was at a recent trade show, I was
talking to a disk drive vendor, and when I asked how they cope with the inevitable data
lossage that would result, he said, as if it was a joke, "Oh, we just blame it on
Microsoft".
joe

On Tue, 14 Aug 2007 11:49:26 -0700, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:


"xmllmx" <xmllmx@xxxxxxxxx> wrote in message
news:1187115960.104492.215250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To begin with code:

HANDLE hFile = CreateFile(...);
WriteFile(hFile, ...);
ReadFile(hFile, ...);
CloseHandle(hFile);

My queston is: Can CloseHandle(hFile) make sure that all the cached
data of hFile will be flushed to the disk?

I googled it and found nothing. Hope someone can give me some tips.
Thanks in advance.


I don't think so. You should call FlushFileBuffers() yourself before
CloseHandle(). I believe we encountered some difficulty that the buffers
were not truly flushed even after calling FlushFileBuffers() when this code
is executed as the result of Windows shutting down or restarting. The file
became corrupted. The workaround was to save the file immediately and not
wait for the WM_ENDSESSION. But I'm vague on the details. You might want
to check if others have encountered problems with FlushFileBuffers().

-- David



Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: EWF - force write
    ... > We are talking here about RAM EWF not DISK overlay, ... > Live commit option is not possible to implement on running OS partition. ... I don't think this would be hard to avoid such problems since read/write disk operations are redirected to one code - EWF. ... > Live RAM EWF commit would be possible only on non OS partitions if you can unmount safely file system. ...
    (microsoft.public.windowsxp.embedded)
  • [PATCH] improve jbd fsync batching
    ... There is a flaw with the way jbd handles fsync batching. ... sleep for 1 jiffie in order to wait for new writers to join into the transaction ... before forcing the commit. ... storage the time it takes to commit a transaction to disk is way ...
    (Linux-Kernel)
  • Re: EvfMgr C: -commit followed by Power Down gives lost changes
    ... directly after commit. ... someone turning power off). ... > EWF is between disk driver and filesystem driver. ...
    (microsoft.public.windowsxp.embedded)
  • Re: EvfMgr C: -commit followed by Power Down gives lost changes
    ... After the commit then force a restart using: ... > Meaning the users can only use the commit.bat file that flushes the disk. ... > Sync ... > Slobodan Brcin wrote: ...
    (microsoft.public.windowsxp.embedded)
  • Re: Larrabee delayed: anyone know whats happening?
    ... Do you mean that there are modern systems that *can't* easily get 90% of theoretical disk bandwidth without using massive buffers simply by using multi-buffering in system RAM? ... stage is not written to enable streaming, ...
    (comp.arch)