In article <khcbmd$532$
1...@speranza.aioe.org>,
dee.e...@icode.co.uk
(Deanna Earley) writes:
> On 08/03/2013 07:41, Xavier Roche wrote:
>
>> Hi folks,
>>
>> FlushFileBuffers() allows to flush pending write buffers to disk
>> [assuming that no write-through cache is enabled], similarly as
>> fdatasync() would do on POSIX platforms.
>>
>> Is it sufficient to ensure that a file entry has been committed too ?
>>
>> Ie. on a more general case, if the file is renamed (MoveFile()
>> and MoveFileEx()) afterwards, what guarantee that the actual move
>> operation has been commited ?
>
> There is no guarantee.
> There are multiple levels of buffering, but Windows/NTFS will try its
> best to make sure everything is committed or at least written to the
> journal.
>
> It's best not to second guess Windows and just tell it to do the file
> operation and leave it.
I don't know whether it's related, but I've occasionally run into
problems when deleting and renaming files. When updating a file
I'll often copy it to a work file, making changes as I go. At end
of file I close the files, unlink the original file, and rename
the work file to the original file. Once in a while, the process
fails. I suspect that the original file doesn't get deleted in
time, causing the rename to fail. It doesn't happen often, but
when you have software running daily in a couple of thousand sites,
even a 0.01% failure rate results in one anguished customer a week
complaining that he's lost a critical configuration file.
I did a bit of reading on what Microsoft calls "file system tunneling"
and almost lost my lunch. I've concluded that under Windows, any
delete/rename process is inherently unreliable; I've replaced all
such code in all of my software with a straight copying of the
work file back over the original file. It's less efficient,
but at least it's reliable.
--
/~\ cgi...@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!