4 ms·
> No. You need to use fsync to ensure the file is flushed to disk. Are you sure? At least in case of ZFS AFAIK the file wouldn't get corrupted, since it uses c
by kouteiheika 6y ago
> No. You need to use fsync to ensure the file is flushed to disk.
Are you sure? At least in case of ZFS AFAIK the file wouldn't get corrupted, since it uses copy-on-write internally. Sure, you might get the old data back, but you wouldn't get corruption. And it automatically checksums your files anyway so it will detect any data that did get corrupted, and if you're using RAID-1 (as you should for any important data) it will automatically repair it.
> Also careful not to rename the file across mount points (/tmp is often a different mount and the most common location for people trying this.)
You can't rename across mount points. (Linux's `rename` syscall and the corresponding C API will return an EXDEV error if you try.)
> If you introduce a bug that writes the wrong / partial data, you can't recover anything that isn't in the previous day's backup.
Sure. If I was working in a bank not being able to do that would be totally unacceptable. But in my case that's the tradeoff I'm willing to live with.