Quote:
Originally posted by lisafern
but my boss insists in saying that it uses buffers and gives back control to the OS before the actual writing finishes.
That is probably true. But it depends on the exact command, the exact filesystem(s), and the exact os version, and possibly on the exact hardware. It also depends on his definition of "buffer".
In the case of a tar to tape, the data will be on tape before the command exits. In case of copy disk to disk, it's complicated. Unix tries to do read-ahead and write-behind with most disk i/o to a file in a filesystem. Usually disk reads and writes go to and from a buffer cache. Some file systems now have special options to control this, (vxfio on HP-UX) but that is kinda new. A syncer program runs every so often (30 seconds on HP-UX) to flush out old data. There is a sync program that can flush the data as well. But sync and syncer only schedule the i/o... some time may be needed for the driver to process the request.
Today's disk drives are really little computers and they too have a cache. They can have a feature called immediate-report which makes them pretend that a write is finished when it has just been cached locally in the drive. A well designed drive can even withstand (in theory) a powerfail in this state. When power is restored, the drive will write the data. The OS may be able to control this behavior (scsictl in HP-UX).
One universal way to be sure that all data has been flushed from the system to the drives: unmount the filesystem. The unmount will not succeed until after the data is flushed. Well, this bummed people out when applied to nfs filesystems and some OS's now discard(!) the data on a nfs dismount if the nfs server is not responding. (Nothing is sacred anymore...)
My company is also very paranoid about losing data. We replicate our data to three massive servers... 2 in North America and one in Europe.