Re: fsync vs fdatasync

From: Matthew Kirkwood <matthew(at)hairy(dot)beasts(dot)org>
To: mlw <markw(at)mohawksoft(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fsync vs fdatasync
Date: 2001-06-10 18:58:30
Message-ID: Pine.LNX.4.30.0106101950060.30695-100000@sphinx.mythic-beasts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-06-10 20:04:51 Re: fsync vs fdatasync
Previous Message mlw 2001-06-10 17:38:50 fsync vs fdatasync