March 21st, 2009

Don't break the fsync

I agree that applications need to use fsync() if they want data on platters. But I don't like plan where we first add "too many" fsyncs() and then add a control to disable them for laptop mode...

I guess the main problem is that there are really two different renames... One just changes the name (just_rename()). The other is used to atomically replace old version of the file with new version. (update_file(); can be poorly emulated as fsync(source), rename(source,dest), on ext3, can be done as simply rename()).

I guess the long term solution is to split those operations, and have applications explicitely specify which one they want. First step would be to introduce update_file() libc call (fsync+rename); then the syscall should be added -- we know that fsync is not neccessary at least on ext3... and we can slowly teach kernel to do right thing in both cases.