Re: fsync vs fdatasync - Mailing list pgsql-hackers

From Matthew Kirkwood
Subject Re: fsync vs fdatasync
Date
Msg-id Pine.LNX.4.30.0106101950060.30695-100000@sphinx.mythic-beasts.com
Whole thread Raw
In response to fsync vs fdatasync  (mlw <markw@mohawksoft.com>)
List pgsql-hackers
On Sun, 10 Jun 2001, mlw wrote:

> Is there any reason to EVER call pg_fsync?
>
> What would happen if we always called pg_fdatasync?

In theory, nothing.  I believe SUS guarantees that fdatasync
will flush all data and metadata to disk, _except_ perhaps
inode access/change/modify times.  This means file size,
permissions, ownership and indirect blocks (or whatever is
relevant to your filesystem).

Thus, unless you need the timestamps to be accurate, it is
always safe.

Unfortunately, there are (said to be -- I couldn't name one)
implementations which predate this (fairly sane) semantic,
and flush only file contents.

I think that use of fsync is wise on occasion.  If we know
that (for example) we've extended the file, then fdatasync
will behave as fsync on SUS-conformant platforms, and will
risk data loss on non-conformant platforms.

Matthew.



pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: fsync vs fdatasync
Next
From: Tom Lane
Date:
Subject: Re: fsync vs fdatasync