sync and fsync
D. Mitchell
don at allegra.UUCP
Wed Sep 19 00:42:39 AEST 1984
Perhaps this has been discussed before, but I just noticed that the
fsync system call in 4.2 bsd is done in a stupid way. fsync is
theoretically very useful for various reliable-update protocols; but in
4.2, it takes time proportional to the file size.
I don't see a simple fix since inode information is not stored in the
buffer cache. Even if it were, someone might bypass the file system to
access the blocks of a file. As it is, fsync is at least correct.
A couple quick tests show that if the size of the file is greater than
100 blocks, one should call sync instead. For smaller files, fsync is
much faster than sync. Sync takes about 65 msec. and fsync takes about
0.6 N + 4 msec, where N is the number of blocks in the file.
More information about the Comp.unix.wizards
mailing list