Refactor atomic writing to atomic_write_start() + atomic_write_finish().