Thread: fsync -> fdatasync in backend/storage/file/fd.c

fsync -> fdatasync in backend/storage/file/fd.c

From
Michal Mosiewicz
Date:
I don't remember if it has been mentioned.

Anyhow, I think that it would be nice to change fsync'es into
fdatasync'es (of course as an autoconf-igurable option). I don't think
it's necessary to update all file's metadata each time a file is
flushed.

I dunno where it's implemented. But it's for sure implemented in Linux.

Mike

--
WWW: http://www.lodz.pdi.net/~mimo  tel: Int. Acc. Code + 48 42 148340
add: Michal Mosiewicz  *  Bugaj 66 m.54 *  95-200 Pabianice  *  POLAND

Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
The Hermit Hacker
Date:
On Fri, 17 Apr 1998, Michal Mosiewicz wrote:

> I don't remember if it has been mentioned.
>
> Anyhow, I think that it would be nice to change fsync'es into
> fdatasync'es (of course as an autoconf-igurable option). I don't think
> it's necessary to update all file's metadata each time a file is
> flushed.
>
> I dunno where it's implemented. But it's for sure implemented in Linux.

    We don't have it (FreeBSD)...what does it do? *raised eyebrow*
And, how many ppl actually have fsync's enabled?

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
Bruce Momjian
Date:
>
> I don't remember if it has been mentioned.
>
> Anyhow, I think that it would be nice to change fsync'es into
> fdatasync'es (of course as an autoconf-igurable option). I don't think
> it's necessary to update all file's metadata each time a file is
> flushed.
>
> I dunno where it's implemented. But it's for sure implemented in Linux.
>

We have a way of keeping proper consistency with a system sync() every
30 seconds.  See the archive.   I think it is on the short list.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
Michal Mosiewicz
Date:
The Hermit Hacker wrote:

>         We don't have it (FreeBSD)...what does it do? *raised eyebrow*
> And, how many ppl actually have fsync's enabled?

When you fsync a file it usually costs at least two write operations,
one to write the data and one to update modification/access date, etc.
fdatasync synces only data area of the file without it's
metainformation.

It's not a Linux-only feature. In fact, I'm really not sure if it's
already implemented in Linux (the man page I've got states that in
2.0.23 it was a mere fsync alias) It is a part of POSIX1b standard.

Mike

--
WWW: http://www.lodz.pdi.net/~mimo  tel: Int. Acc. Code + 48 42 148340
add: Michal Mosiewicz  *  Bugaj 66 m.54 *  95-200 Pabianice  *  POLAND

Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
The Hermit Hacker
Date:
On Fri, 17 Apr 1998, Michal Mosiewicz wrote:

> The Hermit Hacker wrote:
>
> >         We don't have it (FreeBSD)...what does it do? *raised eyebrow*
> > And, how many ppl actually have fsync's enabled?
>
> When you fsync a file it usually costs at least two write operations,
> one to write the data and one to update modification/access date, etc.
> fdatasync synces only data area of the file without it's
> metainformation.

    Similar to us (FreeBSD) mounting our file systems 'noatime', so,
ya, we have it...

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
ocie@paracel.com
Date:
The Hermit Hacker wrote:
>
> On Fri, 17 Apr 1998, Michal Mosiewicz wrote:
>
> > I don't remember if it has been mentioned.
> >
> > Anyhow, I think that it would be nice to change fsync'es into
> > fdatasync'es (of course as an autoconf-igurable option). I don't think
> > it's necessary to update all file's metadata each time a file is
> > flushed.
> >
> > I dunno where it's implemented. But it's for sure implemented in Linux.
>
>     We don't have it (FreeBSD)...what does it do? *raised eyebrow*
> And, how many ppl actually have fsync's enabled?

It's a POSIX thing.  fsync will sync the data and the metadata, but
fdatasync only syncs the data.  So in the case of a crash, the inode
might not have the right date, etc.  This can speed things up, but I
wouldn't venture a guess as to how much.

Ocie

Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
Mattias Kregert
Date:
The Hermit Hacker wrote:

>
>         We don't have it (FreeBSD)...what does it do? *raised eyebrow*
> And, how many ppl actually have fsync's enabled?

I always have fsync enabled.

/* m */

Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
The Hermit Hacker
Date:
On Sat, 18 Apr 1998, Mattias Kregert wrote:

> The Hermit Hacker wrote:
>
> >
> >         We don't have it (FreeBSD)...what does it do? *raised eyebrow*
> > And, how many ppl actually have fsync's enabled?
>
> I always have fsync enabled.

    Why?  IMHO, the only use for this is where the system you are
running it on is suspect, and you fear it crashing alot...

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: [HACKERS] fsync -> fdatasync in backend/storage/file/fd.c

From
Mattias Kregert
Date:
The Hermit Hacker wrote:
>
> > I always have fsync enabled.
>
>         Why?  IMHO, the only use for this is where the system you are
> running it on is suspect, and you fear it crashing alot...
>

I started using the -F option to speed thing up, but then I had one
powerfailure which totally trashed postgresql. I could not recover
anything and had to restore from previous day's backup, loosing a
whole day of work. Then I started using fsync again.

Perhaps some emergency rescue utility would be useful in those cases
when some vital files are trashed. A utility which could go thru all
files and try to fix things missing in system catalogs and so on,
fix all obvious errors, recreate indices, remove duplicates, add
missing pieces...

/* m */