* fsync.2 does not mention error handling
@ 2008-12-02 12:06 Pavel Machek
2008-12-04 19:12 ` Michael Kerrisk
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2008-12-02 12:06 UTC (permalink / raw)
To: mtk.manpages, linux-doc, kernel list
fsync() transfers ("flushes") all modified in-core data of (i.e.,
modified buffer cache pages for) the file referred to by the file
descriptor fd to the disk device (or other permanent storage device)
where that file resides. The call blocks until the device reports
that the transfer has completed. It also flushes metadata information
associated with the file (see stat(2)).
Calling fsync() does not necessarily ensure that the entry in the
directory containing the file has also reached disk. For that an
explicit fsync() on a file descriptor for the directory is also
needed.
...
RETURN VALUE top
On success, these system calls return zero. On error, -1 is
returned, and errno is set appropriately.
--------------
I guess it should mention that any errors during fsync are only
mentioned to the first process calling it... which means that if you
write file
fsync file
fsync .
... and someone else does "fsync ." in the meantime, you may get
success when in fact directory entry of file is not written to the
disk.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: fsync.2 does not mention error handling
2008-12-02 12:06 fsync.2 does not mention error handling Pavel Machek
@ 2008-12-04 19:12 ` Michael Kerrisk
2008-12-08 16:14 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Michael Kerrisk @ 2008-12-04 19:12 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-doc, kernel list
Pavel,
On Tue, Dec 2, 2008 at 7:06 AM, Pavel Machek <pavel@suse.cz> wrote:
>
> fsync() transfers ("flushes") all modified in-core data of (i.e.,
> modified buffer cache pages for) the file referred to by the file
> descriptor fd to the disk device (or other permanent storage device)
> where that file resides. The call blocks until the device reports
> that the transfer has completed. It also flushes metadata information
> associated with the file (see stat(2)).
>
> Calling fsync() does not necessarily ensure that the entry in the
> directory containing the file has also reached disk. For that an
> explicit fsync() on a file descriptor for the directory is also
> needed.
>
> ...
> RETURN VALUE top
>
> On success, these system calls return zero. On error, -1 is
> returned, and errno is set appropriately.
>
>
> --------------
>
>
> I guess it should mention that any errors during fsync are only
> mentioned to the first process calling it... which means that if you
>
> write file
> fsync file
> fsync .
>
> ... and someone else does "fsync ." in the meantime, you may get
> success when in fact directory entry of file is not written to the
> disk.
Could you provide some pointers to supporting information / mail
threads, relating to this?
Also, I'm still not 100% clear what you are saying above. Do you mean
that in this scenario, an error may occur but the first caller above
won't know of it? (It would help if you could write a few sentences
that you think should be in the man page.)
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: fsync.2 does not mention error handling
2008-12-04 19:12 ` Michael Kerrisk
@ 2008-12-08 16:14 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2008-12-08 16:14 UTC (permalink / raw)
To: mtk.manpages; +Cc: linux-doc, kernel list
> Pavel,
> Could you provide some pointers to supporting information / mail
> threads, relating to this?
Mail thread on lkml, "writing to disk, not...."
> > write file
> > fsync file
> > fsync .
> >
> > ... and someone else does "fsync ." in the meantime, you may get
> > success when in fact directory entry of file is not written to the
> > disk.
> Also, I'm still not 100% clear what you are saying above. Do you mean
> that in this scenario, an error may occur but the first caller above
> won't know of it?
Yes.
> (It would help if you could write a few sentences
> that you think should be in the man page.)
Ok, see below.
> > fsync() transfers ("flushes") all modified in-core data of (i.e.,
> > modified buffer cache pages for) the file referred to by the file
> > descriptor fd to the disk device (or other permanent storage device)
> > where that file resides. The call blocks until the device reports
> > that the transfer has completed. It also flushes metadata information
> > associated with the file (see stat(2)).
> >
> > Calling fsync() does not necessarily ensure that the entry in the
> > directory containing the file has also reached disk. For that an
> > explicit fsync() on a file descriptor for the directory is also
> > needed.
Replace paragraph with:
On newly created files, explicitely calling fsync on a file descriptor
for a directory is also needed, because calling fsync() on file does
not necessarily ensure that the entry in the directory containing the
file has reached disk.
> >
> > ...
> > RETURN VALUE top
> >
> > On success, these system calls return zero. On error, -1 is
> > returned, and errno is set appropriately.
I'd add:
After I/O error, fsync() only returns error condition to the first
process that finishes fsync(). Therefore special care must be taken to
coordinate different processes trying to write data to file/directory.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-08 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-02 12:06 fsync.2 does not mention error handling Pavel Machek
2008-12-04 19:12 ` Michael Kerrisk
2008-12-08 16:14 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®