summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-24 13:17:54 +0200
committerKunhoon Baik <knhoon.baik@samsung.com>2016-12-29 16:15:38 +0900
commit204cbf4400d6cab1f41e01a7d6b359cf5cf7ddce (patch)
tree9a4f9dad4059c3cfc1139102b44865922b2ad8a4
parent6359bb919dac81725265d2eef8446230ff89d07f (diff)
downloadsystemd-accepted/tizen_3.0.m2_mobile.tar.gz
systemd-accepted/tizen_3.0.m2_mobile.tar.bz2
systemd-accepted/tizen_3.0.m2_mobile.zip
Let's make sure we handle compression errors properly, and don't misunderstand an error for success. Also, let's actually compress things if lz4 is enabled. Fixes #1662. Conflicts: src/journal/journal-file.c src/journal/journal-file.h Change-Id: Ib447838f94b837d6026b07991cb83ad3c4ca6310
-rw-r--r--src/journal/journal-file.c13
-rw-r--r--src/journal/journal-file.h5
2 files changed, 12 insertions, 6 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 0f28718b0e..1d60b1b0ab 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -1051,23 +1051,24 @@ static int journal_file_append_data(
o->data.hash = htole64(hash);
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
- if (f->compress_xz &&
- size >= COMPRESSION_SIZE_THRESHOLD) {
- size_t rsize;
+ if (JOURNAL_FILE_COMPRESS(f) && size >= COMPRESSION_SIZE_THRESHOLD) {
+ size_t rsize = 0;
compression = compress_blob(data, size, o->data.payload, &rsize);
- if (compression) {
+ if (compression >= 0) {
o->object.size = htole64(offsetof(Object, data.payload) + rsize);
o->object.flags |= compression;
log_debug("Compressed data object %"PRIu64" -> %zu using %s",
size, rsize, object_compressed_to_string(compression));
- }
+ } else
+ /* Compression didn't work, we don't really care why, let's continue without compression */
+ compression = 0;
}
#endif
- if (!compression && size > 0)
+ if (compression == 0 && size > 0)
memcpy(o->data.payload, data, size);
r = journal_file_link_data(f, o, p, hash);
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 2526e14d65..7fc8bef49f 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -229,3 +229,8 @@ int journal_file_get_cutoff_realtime_usec(JournalFile *f, usec_t *from, usec_t *
int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot, usec_t *from, usec_t *to);
bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec);
+
+static inline bool JOURNAL_FILE_COMPRESS(JournalFile *f) {
+ assert(f);
+ return f->compress_xz || f->compress_lz4;
+}