Re: fsync in glib/gio



Sven Neumann wrote:

It seems wrong to work around broken file-systems on the application
level. That only takes away pressure from the file-system developers to
address the problem properly.

How is the file system broken? Read the man page for write(). If you want to guarantee that file data will hit disk (or at least the disk's HW buffer) by a certain time, you need to call fsync() (or fdatasync(), where available).

This isn't a Linux idiosyncrasy, even.  POSIX specifies this.

The only thing that's actually broken IIRC is ext3, in that a fsync() effectively acts as a full-FS sync() (see the Firefox 3.0/sqlite fiasco[1]), which is ridiculous. If anything should be fixed, *that* should be... as well as naive applications that think that open() -> write() -> close() is sufficient to get data to disk in a known amount of time.

(Of course, ext3 won't ever be fixed, so... I guess we wait for ext4 use to become more widespread, and for btrfs to go stable.)

	-brian

[1] http://shaver.off.net/diary/2008/05/25/fsyncers-and-curveballs/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]