On 12/18/2016 11:30 AM, Lasse Collin wrote:
There's a bug report about data loss due computer losing power. fsync()
or fdatasync() in xz would quite likely have avoided the data loss.


I considered adding fsync() to xz a long ago (it probably was before
5.0.0). I didn't add it because it had a huge performance impact when
compressing many small files, and that downside still exists. gzip and
bzip2 don't use fsync(). On the other hand, performance doesn't matter
so much if there's a too high chance of data loss.

The chance of data loss is somewhat small.  Also, in practice the actual
damages can be bounded by regular backups [in the case of bug 814089 above,
a USB flash memory drive would have served], and/or by using the option
"data=journal" when mounting an ext4 file system.  For the truly
paranoid, LD_PRELOAD a shared library which intercepts the rename()
system call, and apply fsync()/fdatasync().

Keep the existing non-fsync() behavior of the xz app.


Reply via email to