On Thu, Feb 03, 2000 at 11:15:41PM -0500, Russell Nelson wrote:
> [EMAIL PROTECTED] writes:
> > On Thu, 3 Feb 2000 15:12:00 -0500 (EST) , Russell Nelson writes:
> > > ext2 has always honored fsync. You fsync a file, and its data goes
> > > off to disk. You fsync a directory and its data goes off to disk.
> > > The only reason this surprises anyone is because the BSD hackers
> > > decided that fsyncing a file should also fsync the directory the file
> > > resides in.
> >
> > What use is syncing the data to disk, if you can't
> > get to it after a crash? It might as well have just
> > stayed in cache otherwise....
>
> fsync the data if you want the data on disk.
> fsync the directory if you want the metadata on disk.
>
> What's complicated or difficult about that?
According to McKusick yesterday when I asked specifically about this problem
discussed here, he admitted that fsync:ing a directory could be a costly
operation if directories had to be fsynced recursively. In e.g. a
queue-directory or a Maildir, it will probably have no impact.
Therefore, a fsync() of the file would be sufficient he said.
Really two.
Maildir-example:
1. write to tmp
2. fsync()
3. rename(tmp, new)
4. fsync()
/magnus
--
http://x42.com/