Garrett: ext4, application expectations and power management
Garrett: ext4, application expectations and power management
Posted Mar 15, 2009 16:27 UTC (Sun) by drag (guest, #31333)In reply to: Garrett: ext4, application expectations and power management by smoogen
Parent article: Garrett: ext4, application expectations and power management
When you go:
1. Create file 1
2. Write file 1
3. (do proccessing for some amount of time)
4. Create file 2
5. Write file 2
6. Rename file 2 over file 1
This is the application telling the OS that it wants either good old data or good new data. That in the crash the application developer is trying to ensure that all data is not lost.
Also this sort of technique is used for lots of other reasons.. You can run into situations were multiple applications want to write the same file and this sort of technique helps make sure that they don't corrupt each other's data. Also this is useful for applications that may crash themselves. If they segfault or otherwise go apeshit while writing out a new file this allows them to fail ungracefully without corrupting the old file.
So it's not really much to do with how the file system works on the block-to-filesystem layer of things; it's ment to deal with how the OS works on the filesystem-to-application layer of things. The applications should be unaware and not really care a whole lot about the lower levels as long as they don't do any pathalogically bad behavior.
So remember the goal is "either good new data or good old data".
When my desktop is writing out all those .gconf files I don't really care about that data. If I crash my system I expect to loose those preferences. That's normal, but I don't want to end up with a desktop that won't work at all due to a bunch of corrupt "registry" files.
If you use fsync() on all of that then this means that every time I make a change to the UI or some settings then my disk is going to spin up. When using fsync() that is telling the OS that "I only want good new data" and this is a much more strigent requirement and thus has much heavier impact on system as a whole.
The only time, I as a user, expect and want that behavior is when writing out important files or doing important system tasks. Like writing out a file with OO.org or editing /etc files with vim or whatnot.
When that happens I don't care so much about the disk spinning up, or that I am using a entire block of my flash drive to store a 1k file, because that small file is important...
-------------------
It took me a while to understand this. Fsync is just to big of a hammer for what many applications need to do, or desire.
