Re: XFS: how to NOT null files on fsck?

Helge Hafting
2004-07-11T21:52:04Z

On Sat, Jul 10, 2004 at 11:24:53PM +0200, Bernd Eckenfels wrote:
> In article <20040710184357.GA5014@taniwha.stupidest.org> you wrote:
> > No, that's not the case. Normally when files are written the data
> > isn't not flushed immediately, it sits in memory (the page-cache) for
> > some (usually) small amount of time.
>
> Does that mean, that closing a tempfile and then renaming the file is not
> a reliable way to tell, that the data is persited? I usually use a atomic
> rename to have a point from which on I can tell if the data is complete
> and persisted.
>
> I thought close() has fsync() semantics?
>
No, it doesn't.

close() will flush the C library buffer. That means the data
moves from theose buffers to the pagacache. The program crashing
after that will have no effect on the file. It can still
be lost if the _kernel_ crashes though.
If you want the pagecache flushed to disk, use fsync (or sync)

Helge Hafting