tree-wide: add new HAVE_COMPRESSION compile time flag
let's simplify the checks for ZSTD/LZ4/XZ As suggested: https://github.com/systemd/systemd/pull/16096#discussion_r440705585
This commit is contained in:
@@ -423,7 +423,7 @@ static int save_external_coredump(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
/* If we will remove the coredump anyway, do not compress. */
|
||||
if (arg_compress && !maybe_remove_external_coredump(NULL, st.st_size)) {
|
||||
|
||||
|
||||
@@ -824,7 +824,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
_cleanup_close_ int fdf;
|
||||
|
||||
fdf = open(filename, O_RDONLY | O_CLOEXEC);
|
||||
|
||||
@@ -392,7 +392,7 @@ JournalFile* journal_file_close(JournalFile *f) {
|
||||
|
||||
ordered_hashmap_free_free(f->chain_cache);
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
free(f->compress_buffer);
|
||||
#endif
|
||||
|
||||
@@ -1455,7 +1455,7 @@ int journal_file_find_data_object_with_hash(
|
||||
goto next;
|
||||
|
||||
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
uint64_t l;
|
||||
size_t rsize = 0;
|
||||
|
||||
@@ -1624,7 +1624,7 @@ static int journal_file_append_data(
|
||||
|
||||
o->data.hash = htole64(hash);
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
if (JOURNAL_FILE_COMPRESS(f) && size >= f->compress_threshold_bytes) {
|
||||
size_t rsize = 0;
|
||||
|
||||
@@ -3852,7 +3852,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
|
||||
return -E2BIG;
|
||||
|
||||
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
size_t rsize = 0;
|
||||
|
||||
r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK,
|
||||
|
||||
@@ -107,7 +107,7 @@ typedef struct JournalFile {
|
||||
unsigned last_seen_generation;
|
||||
|
||||
uint64_t compress_threshold_bytes;
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
void *compress_buffer;
|
||||
size_t compress_buffer_size;
|
||||
#endif
|
||||
|
||||
@@ -2327,7 +2327,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
|
||||
|
||||
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
|
||||
if (compression) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
r = decompress_startswith(compression,
|
||||
o->data.payload, l,
|
||||
&f->compress_buffer, &f->compress_buffer_size,
|
||||
@@ -2394,7 +2394,7 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
|
||||
|
||||
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
|
||||
if (compression) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
size_t rsize;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef int (compress_t)(const void *src, uint64_t src_size, void *dst,
|
||||
typedef int (decompress_t)(const void *src, uint64_t src_size,
|
||||
void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
|
||||
static usec_t arg_duration;
|
||||
static size_t arg_start;
|
||||
@@ -143,7 +143,7 @@ static void test_compress_decompress(const char* label, const char* type,
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef int (decompress_sw_t)(const void *src, uint64_t src_size,
|
||||
typedef int (compress_stream_t)(int fdf, int fdt, uint64_t max_bytes);
|
||||
typedef int (decompress_stream_t)(int fdf, int fdt, uint64_t max_size);
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
_unused_ static void test_compress_decompress(const char *compression,
|
||||
compress_blob_t compress,
|
||||
decompress_blob_t decompress,
|
||||
@@ -265,7 +265,7 @@ static void test_lz4_decompress_partial(void) {
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
_unused_ const char text[] =
|
||||
"text\0foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
|
||||
"foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
|
||||
|
||||
@@ -157,7 +157,7 @@ static void test_empty(void) {
|
||||
(void) journal_file_close(f4);
|
||||
}
|
||||
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) {
|
||||
dual_timestamp ts;
|
||||
JournalFile *f;
|
||||
@@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_non_empty();
|
||||
test_empty();
|
||||
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
|
||||
#if HAVE_COMPRESSION
|
||||
test_min_compress_size();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user