LWN.net Logo

Better than POSIX?

Better than POSIX?

Posted Mar 18, 2009 5:26 UTC (Wed) by bojan (subscriber, #14302)
In reply to: Better than POSIX? by quotemstr
Parent article: Better than POSIX?

> And that means you too, bojan.

Sorry. I'll bring up whatever I see fit, whether you like that or not. But, by all means, don't listen to me and don't reply to my comments. Ignore me - that's OK. But at least do try to understand what Ted's saying.

> If a program is truly POSIX-compliant, it can't make any assumptions about what happens after a crash.

Not, it cannot make assumptions. It can make preparations as best it can (which are defined in the standard) to have data on disk. These preparations are called fsync(). Or, it can be smart and create little tiny backup files with fsync() beforehand and then be fast and keep renaming in the hope that the system doesn't crash all the time.

Either intentionally or otherwise, you keep misinterpreting what POSIX does or does not define. POSIX defines that fsync() is your best bet on having the data on disk. It doesn't define anything about rename() having ordered characteristics. It also doesn't define anything about the situation after the crash.

Out of this, you are giving people advice that the best thing to do is to go with undefined behaviour of rename() if you want your data on disk after the crash. The mind boggles...


(Log in to post comments)

Better than POSIX?

Posted Mar 18, 2009 14:22 UTC (Wed) by nlucas (subscriber, #33793) [Link]

Even if you go the POSIX way, many cheap disk drives lie to the system saying the data is on the disk plater when it's still on it's internal buffers. So even that can not guarantee you the operation is atomic.

An anecdotal case some years ago was Windows 98 corrupting the disk on "modern" PCs, because the hardware was so much faster than the disk flushing. When windows was shutdown it would kill the power before the disk finished buffering it's writes, corrupting the file system.

The only solution was to add some wait time before killing the power.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds