qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/4] block: use fdatasync instead of fsync


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH 2/4] block: use fdatasync instead of fsync
Date: Wed, 2 Sep 2009 02:18:01 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Christoph Hellwig wrote:
> On Wed, Sep 02, 2009 at 01:34:54AM +0100, Jamie Lokier wrote:
> > fdatasync is common among the big commercial unixes which were still
> > being actively developed a few years ago, but fsync is universal -
> > it's very old.
> > 
> > Neither OpenBSD nor FreeBSD have fdatasync.
> > 
> > mingw32 is a thin wrapper around Windows.  Windows as far as I can
> > tell doesn't have an equivalent of fdatasync, although it does have an
> > equivalent of O_DIRECT|O_SYNC (but documentation contradicts itself
> > regarding whether the combination flushes metadata on each write).
> 
> Yeah,  I'll just add a
> 
> #ifndef _POSIX_SYNCHRONIZED_IO
> # define fdatasync(fd)        fsync(fd)
> #endif
> 
> Now I'm pretty sure we'll find various fuckups where headers define
> fdatasync but not _POSIX_SYNCHRONIZED_IO or vice versa, but I can
> outsource adding workarounds for that to people with those broken
> setups.

I've now learned that Windows has equivalents of O_DSYNC and fsync,
but not O_SYNC and fdatasync, and that the O_DSYNC equivalent doesn't
flush metadata needed to access newly allocated data; it only commits
overwrites, and that the fsync equivalent does try to flush the
drive's volatile write cache after writing metadata, but only on some
versions with some settings and some drivers and possibly some types
of drive.  Not that you could tell any of that from the documentation.

Why do I have the feeling some unixes are the same.

No wonder the SQLite folks say, paraphrasing, "we call fsync or
something else; we can't help you beyond that point and many OSes have
rumoured bugs in this area or don't fulfil what these functions promise".

-- Jamie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]