All of lore.kernel.org
 help / color / mirror / Atom feed
* writing file to disk: not as easy as it looks
@ 2008-12-02  9:40 Pavel Machek
  2008-12-02 14:04 ` Theodore Tso
  2008-12-02 23:01 ` Mikulas Patocka
  0 siblings, 2 replies; 25+ messages in thread
From: Pavel Machek @ 2008-12-02  9:40 UTC (permalink / raw)
  To: mikulas, clock, kernel list, aviro

Actually, it looks like POSIX file interface is on the lowest step of
Rusty's scale: one that is impossible to use correctly. Yes, it seems
impossible to reliably&safely write file to disk under Linux. Double
plus uncool.

So... how to write file to disk and wait for it to reach the stable
storage, with proper error handling?

> file

	...does not work, because it fails to check for errors.

touch file || error_handling.

	Is not a lot better, unless you mount your filesystems "sync"
	... and noone does that.

dd conv=fsync if=something of=file 2> /dev/zero || error_handling

	Is a bit better; not much, unless you mount your filesystems
	"dirsync", because you have file data on disk, but they do not have
	directory entry pointing to them. Noone uses dirsync.

	So you need something like

dd conv=fsync if=something of=file 2> /dev/zero || error_handling
fsync . || error_handling
fsync .. || error_handling
fsync ../.. || error_handling
fsync ../../.. || error_handling

	... which mostly works...

	If you are alone on the filesystem... fsync only returns
	errors to the first process. So if you have other process that
	does fsync ., maybe it gets "your" error and you do not learn
	of the problem.

Question is... Is there way that I missed and that actually works?
									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] 25+ messages in thread

end of thread, other threads:[~2008-12-15 20:09 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-02  9:40 writing file to disk: not as easy as it looks Pavel Machek
2008-12-02 14:04 ` Theodore Tso
2008-12-02 15:26   ` Pavel Machek
2008-12-02 16:37     ` Theodore Tso
2008-12-02 17:22       ` Chris Friesen
2008-12-02 20:55         ` Theodore Tso
2008-12-02 22:44           ` Pavel Machek
2008-12-02 22:50             ` Pavel Machek
2008-12-03  5:07             ` Theodore Tso
2008-12-03  8:46               ` Pavel Machek
2008-12-03 15:50                 ` Mikulas Patocka
2008-12-03 15:54                   ` Alan Cox
2008-12-03 17:37                     ` Mikulas Patocka
2008-12-03 17:52                       ` Alan Cox
2008-12-03 18:16                       ` Pavel Machek
2008-12-03 18:33                         ` Mikulas Patocka
2008-12-03 16:42                 ` Theodore Tso
2008-12-03 17:43                   ` Mikulas Patocka
2008-12-03 18:26                     ` Pavel Machek
2008-12-03 15:34               ` Mikulas Patocka
2008-12-15 10:24               ` [patch] " Pavel Machek
2008-12-15 11:03           ` Pavel Machek
2008-12-15 20:08             ` Folkert van Heusden
2008-12-02 19:10       ` Folkert van Heusden
2008-12-02 23:01 ` Mikulas Patocka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.