osmium said:
All I have seen you argue is that the system should be consistent. Simple
consistency is not good enough.
I would be concerned if a single HD copy was my sole way of retrieving
crucial data. Do not take this as a plea for some fatherly advise on good
data processing practices. What does a reasonable person expect to have
happened when he recives success status from fwrite and fread?
The stdio library has taken responsibility for making sure the data
gets written.
Once a fflush completes successfully, the stdio library has passed
responsibility for it to the underlying I/O system.
If that's followed by some system-specific method of asking the OS to
flush its buffers (f'rexample, sync() on unix-like systems), once that
completes, the OS has passed responsibility for it to the next level down.
After that, perhaps the file server at the other end of the network cable
will go through some similar set of mechanisms to pass it to the RAID
controller (a halfway sensible filesystem, which most network filesystems
aren't, will wait for this to happen before the system call to make sure
everything is flushed completes on the client side), which will at some
point flush it to the physical disk drives, whose on-board controllers
might buffer it for a few more seconds before it actually physically
gets written to the disk.
Is that good enough for you, or do you want to make the program I'm
talking to from my desktop wait until the magnetic particles have been
re-aligned on a disk on the other side of the continent[1], after which
it will immediately be re-read on the same system running the program
that created it, pushed through the network, after which it might as
well no longer exist on the system it was created on[2]?
dave
[1] Actually, the system I use for posting to usenet only lives across
town from my desktop workstation. But my email *does* live across
the continent.
[2] It does live on until that file gets overwritten by my next post,
and after that the electrons will eventually get recycled, but if it
fell into the bit bucket immediately, there's a good chance nobody
would ever notice the difference.