Debian Patches

Status for xz-utils/5.6.4-1

Patch Description Author Forwarded Bugs Origin Last update
xz-Use-goto-for-error-handling-in-io_open_dest_real.patch xz: Use "goto" for error handling in io_open_dest_real()
(cherry picked from commit 2e28c7145747b3287283f13c9d2becd73a7c4a1f)
Lasse Collin <lasse.collin@tukaani.org> no 2024-12-27
xz-Use-fsync-before-deleting-the-input-file-and-add-no-sy.patch xz: Use fsync() before deleting the input file, and add --no-sync
xz's default behavior is to delete the input file after successful
compression or decompression (unless writing to standard output).
If the system crashes soon after the deletion, it is possible that
the newly written file has not yet hit the disk while the previous
delete operation might have. In that case neither the original file
nor the written file is available.

Call fsync() on the file. On POSIX systems, sync also the directory
where the file was created.

Add a new option --no-sync which disables fsync() usage. It can avoid
a (possibly significant) performance penalty when processing many
small files. It's fine to use --no-sync when one knows that the files
are easy to recreate or restore after a system crash.

Using fsync() after every flush initiated by --flush-timeout was
considered. It wasn't implemented at least for now.

- --flush-timeout is typically used when writing to stdout. If stdout
is a file, xz cannot (portably) sync the directory of the file.
One would need to create the output file first, sync the directory,
and then run xz with fsync() enabled.

- If xz --flush-timeout output goes to a file, it's possible to use
a separate script to sync the file, for example, once per minute
while telling xz to flush more frequently.

- Not supporting syncing with --flush-timeout was simpler.

Portability notes:

- On systems that lack O_SEARCH (like Linux), "xz dir/file" will now
fail if "dir" cannot be opened for reading. If "dir" still has
write and search permissions (like d-wx------ in "ls -l"),
previously xz would have been able to compress "dir/file" still.
Now it only works if using --no-sync (or --keep or --stdout).

- <libgen.h> and dirname() should be available on all POSIX systems,
and aren't needed on non-POSIX systems.

- fsync() is available on all POSIX systems. The directory syncing
could be changed to fdatasync() although at least on ext4 it
doesn't seem to make a performance difference in xz's usage.
fdatasync() would need a build system check to support (old)
special cases, for example, MINIX 3.3.0 doesn't have fdatasync()
and Solaris 10 needs -lrt.

- On native Windows, _commit() is used to replace fsync(). Directory
syncing isn't done and shouldn't be needed. (In Cygwin, fsync() on
directories is a no-op.)

- DJGPP has fsync() for files. ;-)

Using fsync() was considered somewhere around 2009 and again in 2016 but
those times the idea was rejected. For comparison, GNU gzip 1.7 (2016)
added the option --synchronous which enables fsync().

(cherry picked from commit 2a9e91d796d091740489d951fa7780525e4275f1)
Lasse Collin <lasse.collin@tukaani.org> no 2025-01-05
xz-Workaround-broken-O_SEARCH-in-musl.patch xz: Workaround broken O_SEARCH in musl
Testing with musl 1.2.5 and Linux 6.12, O_SEARCH doesn't result
in a file descriptor that works with fsync() although it should work.
See the added comment.

The same issue affected gzip --synchronous:

https://bugs.gnu.org/75405

Thanks to Paul Eggert.

(cherry picked from commit 75d91d6b39ea3e2fae8f027dcec01be2dca9594d)
Lasse Collin <lasse.collin@tukaani.org> no 2025-01-08

All known versions for source package 'xz-utils'

Links