It was a lot simpler before filesystems decided that reordering writes and renames should be allowed.