9 ms·
It should be noted that those filesystem operations are only atomic with respect to an observer running on the same operating system incarnation. Whether they a
by zAy0LfpBZLC8mAC 10y ago
It should be noted that those filesystem operations are only atomic with respect to an observer running on the same operating system incarnation. Whether they are also atomic across power loss depends on the filesystem (though with a modern journaling filesystem, that generally should be the case).
- gpderetta 10y agoThat's what people would expect. But there was some drama around ext4, renames and fsync a few years ago.
- zAy0LfpBZLC8mAC 10y agoYou mean around truncation and rewrite?
- gpderetta 10y agoIt is not necessarily about truncation. IIRC the problem was that rename doesn't (didn't?) act as a full barrier on ext4 and the metadata write that updates the name from the old file to the new file can be committed to disk before the updates to the new file. This means that after a crash the new name might point to a corrupted file. The barrier behavior wasn't explicitly mandated by POSIX, but it is an intuitive release consistency-like model which was implicitly expected by most programmers. edit: spurious words and parens.