Re:Things Unix can do atomically (2010)
by zAy0LfpBZLC8mAC on Monday May 30, 2016 @08:38PM
(#11803967)
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).
[ Parent
| on HN ]
That's what people would expect. But there was some drama around ext4, renames and fsync a few years ago.
Re:Things Unix can do atomically (2010)
by zAy0LfpBZLC8mAC on Tuesday May 31, 2016 @08:51AM
(#11806225)
You mean around truncation and rewrite?
It 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.