LWN.net Logo

When is "save" really "maybe save"?

When is "save" really "maybe save"?

Posted Sep 26, 2008 15:05 UTC (Fri) by dmarti (subscriber, #11625)
In reply to: Now what about shutdown? by njs
Parent article: LPC: Booting Linux in five seconds

Applications could be smart about this. The answer might be something like: fsync on save if 100 user actions or 10s of CPU time have been spent on the file since the last save. Or fsync on save if the file has gone from a broken state (invalid HTML, spelling errors, audio that clips, program that won't compile) to a fixed state.

(And you could always do the fsync in a separate thread or process, so the app is responsive again.)


(Log in to post comments)

When is "save" really "maybe save"?

Posted Sep 26, 2008 21:43 UTC (Fri) by njs (guest, #40338) [Link]

fsync doesn't mean "hey kernel actually write this to disk", it means "write this to disk *now*" (and in practice, "write everything to disk *now*", because our filesystems are not that great). If you're running it async, then you get exactly the same semantics as a plain write. The kernel already guarantees that stuff will be written to disk within n seconds, with n a tweakable parameter that's important for power saving. I guess I just don't see the advantages of moving that to a million per-app settings, all using an inappropriate interface.

If the goal is to reach a point where we can throw away a lot of data instead of flushing it to disk at shutdown, then this approach is making a classic mistake: it's trying to mark everything that *does* need to go to disk, and hoping that eventually everything will be marked and we'll be able to flip the switch and throw everything else away. The better approach is to mark stuff that isn't important, like some fcntl to request "power-loss semantics" for writes to some file; then you could get some win immediately, and expand it incrementally over time.

I doubt this is easy or important enough to actually get the coordinated effort needed to implement it, but that's how I'd do it...

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