4 ms·
> the conservative thing to do would be to create, write, fsync() the file, fsync() the directory, rename, fsync() the directory again. Afaik the conservative
by the8472 8y ago
> the conservative thing to do would be to create, write, fsync() the file, fsync() the directory, rename, fsync() the directory again.
Afaik the conservative thing is the necessary thing if you're on an ext4 mounted with noauto_da_alloc,data=writeback. I think you can skip the last fsync if you're fine with losing the new version as long as you get the old version in its place.
- scottlamb 8y agoThanks for mentioning those options. I found a little more about the in the ext4 manpage. Things about it a little more, I'd expect I could skip the first directory fsync I'd mentioned. Surely the rename can't make it to the directory without the creation getting there, too... Anyway, I feel like I've could come up with a list of questions 10x as long as the one I just gave, but you'd never really get answers, even for a particular drive, os, fs combo, without expensive testing or source code digging.
- the8472 8y agoYes, it's an area of research, https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-pillai.pdf https://www.usenix.org/system/files/conference/osdi14/osdi14... But in the end you should code against what posix guarantees, not what particular filesystems happen to do, because the next filesystem might use some other leeway the spec provides.