3 ms·
The scenario described in the article suffers from one more problem, not mentioned in the article. Quote: "Create a file adjacent to the target path using mkte
by praptak 6y ago
The scenario described in the article suffers from one more problem, not mentioned in the article. Quote:
"Create a file adjacent to the target path using mktemp or similar.
Write your data to it
rename() it from the temporary name to the final name."
I believe this is prone to data loss when the system goes down and the cause is that POSIX guarantees on write reordering are loose. The rename can make it to disk before the data gets written.
I think it caused actual data loss with one of the fancier filesystems which actually pushed the limits of write reordering and exposed this (pretty common) scenario as buggy.
Edit: I found an article about this problem. "Ext4 and data loss": https://lwn.net/Articles/322823/ https://lwn.net/Articles/322823/
- sgerenser 6y agoOf course, between finishing the write and doing the rename you have to call fsync() on the fd (as that article pointed out).