← Back to context

Comment by lanstin

3 years ago

Rename is totally atomic in a way that is simple to reason about. Ten processes try a rename to a per process name, and just one wins, even on an NFS.That one is free to do whatever and then rename back.

Yes, rename is atomic, but that doesn't get you very far. For example, if you want to do a partial update to a file, you need to copy the file (you already need more storage), edit the file and then rename it. But then you can't do this between multiple processes because maybe you have copied the file while another process was already changing a different copy (but not yet renamed). And that's not even considering fsync, or supporting different Operating Systems.