Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!don
From: don@allegra.UUCP (D. Mitchell)
Newsgroups: net.unix-wizards
Subject: sync and fsync
Message-ID: <2787@allegra.UUCP>
Date: Tue, 18-Sep-84 10:42:39 EDT
Article-I.D.: allegra.2787
Posted: Tue Sep 18 10:42:39 1984
Date-Received: Tue, 25-Sep-84 03:10:40 EDT
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 13

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.