Bug 2183546
Summary: | Reenable LZ4 compression support in 9.2 journald | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 9 | Reporter: | Scott Dodson <sdodson> | |
Component: | systemd | Assignee: | Jan Macku <jamacku> | |
Status: | CLOSED ERRATA | QA Contact: | Frantisek Sumsal <fsumsal> | |
Severity: | unspecified | Docs Contact: | ||
Priority: | unspecified | |||
Version: | 9.2 | CC: | dtardon, eparis, jamacku, jwboyer, msekleta, systemd-maint-list, systemd-maint, walters, yuwatana | |
Target Milestone: | rc | Keywords: | Patch, Triaged, ZStream | |
Target Release: | --- | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | systemd-252-15.el9 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 2184929 (view as bug list) | Environment: | ||
Last Closed: | 2023-11-07 08:54:03 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 2184929 |
Description
Scott Dodson
2023-03-31 15:07:15 UTC
I typed this up, it compiles, haven't tested it: diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 8da4ca9cad..2fcc9157ae 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -336,6 +336,22 @@ static bool compact_mode_requested(void) { return true; } +static Compression compression_requested(void) { + const char *alg; + Compression ret; + + alg = getenv("SYSTEMD_JOURNAL_COMPRESS"); + if (alg == NULL) + return DEFAULT_COMPRESSION; + + ret = compression_from_string(alg); + if (ret == _COMPRESSION_INVALID) { + log_debug("Failed to parse SYSTEMD_JOURNAL_COMPRESS value, ignoring: %s", alg); + return DEFAULT_COMPRESSION; + } + return ret; +} + static int journal_file_init_header( JournalFile *f, JournalFileFlags file_flags, @@ -1626,7 +1642,7 @@ static Compression maybe_compress_payload(JournalFile *f, uint8_t *dst, const ui #if HAVE_COMPRESSION if (JOURNAL_FILE_COMPRESS(f) && size >= f->compress_threshold_bytes) { - compression = compress_blob(src, size, dst, size - 1, rsize); + compression = compress_blob_explicit(f->compression, src, size, dst, size - 1, rsize); if (compression > 0) log_debug("Compressed data object %"PRIu64" -> %zu using %s", size, *rsize, compression_to_string(compression)); @@ -3785,6 +3801,7 @@ int journal_file_open( .fd = fd, .mode = mode, .open_flags = open_flags, + .compression = compression_requested(), .compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ? DEFAULT_COMPRESS_THRESHOLD : MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes), diff --git a/src/libsystemd/sd-journal/journal-file.h b/src/libsystemd/sd-journal/journal-file.h index 70d2276ced..a14f4ea51f 100644 --- a/src/libsystemd/sd-journal/journal-file.h +++ b/src/libsystemd/sd-journal/journal-file.h @@ -100,6 +100,7 @@ typedef struct JournalFile { unsigned last_seen_generation; + Compression compression; uint64_t compress_threshold_bytes; #if HAVE_COMPRESSION void *compress_buffer; (In reply to Colin Walters from comment #3) > I typed this up, it compiles, haven't tested it: This looks like the right way. And it should probably be done upstream, as it looks like an omission. I.e., we have env. vars to turn off other incompatible features, but none to force a particular compression algorithm. (That said, I'm pretty sure the patch in its current form doesn't work. In particular, setting of .incompatible_flags in journal_file_init_header() needs to be updated too.) > This looks like the right way. And it should probably be done upstream, as it looks like an omission. I.e., we have env. vars to turn off other incompatible features, but none to force a particular compression algorithm. Right, agree. Would someone mind taking this ball and doing a PR upstream? I have to chase a different bug. > (That said, I'm pretty sure the patch in its current form doesn't work. In particular, setting of .incompatible_flags in journal_file_init_header() needs to be updated too.) Ah yes, indeed. Upstream patch: https://github.com/systemd/systemd/pull/27126 fix merged to github main branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/159 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (systemd bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:6640 |