compress: consolidate all compression into compress.c with dlopen
Move the push-based streaming compression API from import-compress.c into compress.c and delete import-compress.c/h. This consolidates all compression code in one place and makes all compression libraries (liblzma, liblz4, libzstd, libz, libbz2) runtime-loaded via dlopen instead of directly linked. Introduce opaque Compressor/Decompressor types backed by a heap- allocated struct defined only in compress.c, keeping all third-party library headers out of compress.h. Rewrite the per-codec fd-to-fd stream functions as thin wrappers around the push API via generic compress_stream()/decompress_stream() taking a Compression type parameter. Integrate LZ4 into this framework using the LZ4 Frame API, eliminating all LZ4 special-casing. Extend the Compression enum with COMPRESSION_GZIP and COMPRESSION_BZIP2 and add the corresponding blob, startswith, and stream functions for both. Rename the ImportCompress types and functions: ImportCompressType becomes the existing Compression enum, ImportCompress becomes Compressor (with Decompressor typedef), and all import_compress_*/import_uncompress_* become compressor_*/decompressor_*. Rename dlopen_lzma() to dlopen_xz() for consistency. Make compression_to_string() return lowercase by default. Add INT_MAX/UINT_MAX overflow checks for LZ4, zlib, and bzip2 blob functions where the codec API uses narrower integer types than our uint64_t parameters. Migrate test-compress.c and test-compress-benchmark.c to the TEST() macro framework, new assertion macros, and codec-generic loops instead of per-codec duplication. Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Daan De Meyer
parent
44d0f273fa
commit
f08796065d
@@ -17,6 +17,13 @@ EOF
|
||||
systemctl reset-failed systemd-journald.service
|
||||
|
||||
for c in NONE XZ LZ4 ZSTD; do
|
||||
# compression_to_string() returns "uncompressed" for COMPRESSION_NONE
|
||||
if [[ "${c}" == NONE ]]; then
|
||||
log_name="uncompressed"
|
||||
else
|
||||
log_name="${c,,}"
|
||||
fi
|
||||
|
||||
cat >/run/systemd/system/systemd-journald.service.d/compress.conf <<EOF
|
||||
[Service]
|
||||
Environment=SYSTEMD_JOURNAL_COMPRESS=${c}
|
||||
@@ -28,14 +35,20 @@ EOF
|
||||
ID="$(systemd-id128 new)"
|
||||
systemd-cat -t "$ID" bash -c "for ((i=0;i<100;i++)); do echo -n hoge with ${c}; done; echo"
|
||||
journalctl --sync
|
||||
timeout 10 bash -c "until SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /var/log/journal/$MACHINE_ID/system.journal 2>&1 | grep -F 'compress=${c}' >/dev/null; do sleep .5; done"
|
||||
timeout 10 bash -c "until SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /var/log/journal/$MACHINE_ID/system.journal 2>&1 | grep -F 'compress=${log_name}' >/dev/null; do sleep .5; done"
|
||||
|
||||
# $SYSTEMD_JOURNAL_COMPRESS= also works for journal-remote
|
||||
if [[ -x /usr/lib/systemd/systemd-journal-remote ]]; then
|
||||
for cc in NONE XZ LZ4 ZSTD; do
|
||||
if [[ "${cc}" == NONE ]]; then
|
||||
cc_log_name="uncompressed"
|
||||
else
|
||||
cc_log_name="${cc,,}"
|
||||
fi
|
||||
|
||||
rm -f /tmp/foo.journal
|
||||
SYSTEMD_JOURNAL_COMPRESS="${cc}" /usr/lib/systemd/systemd-journal-remote --split-mode=none -o /tmp/foo.journal --getter="journalctl -b -o export -t $ID"
|
||||
SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /tmp/foo.journal 2>&1 | grep -F "compress=${cc}" >/dev/null
|
||||
SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /tmp/foo.journal 2>&1 | grep -F "compress=${cc_log_name}" >/dev/null
|
||||
journalctl -t "$ID" -o cat --file /tmp/foo.journal | grep -F "hoge with ${c}" >/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user