diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-24 13:17:54 +0200 |
---|---|---|
committer | Kunhoon Baik <knhoon.baik@samsung.com> | 2016-12-29 16:15:38 +0900 |
commit | 204cbf4400d6cab1f41e01a7d6b359cf5cf7ddce (patch) | |
tree | 9a4f9dad4059c3cfc1139102b44865922b2ad8a4 | |
parent | 6359bb919dac81725265d2eef8446230ff89d07f (diff) | |
download | systemd-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 |
journal: fix error handling when compressing journal objectssubmit/tizen_3.0/20170102.034134submit/tizen_3.0.m2/20170104.093755accepted/tizen/3.0/wearable/20170102.095117accepted/tizen/3.0/tv/20170102.095103accepted/tizen/3.0/mobile/20170102.095040accepted/tizen/3.0/ivi/20170102.095140accepted/tizen/3.0/common/20170102.143352accepted/tizen/3.0.m2/wearable/20170105.025732accepted/tizen/3.0.m2/tv/20170105.025646accepted/tizen/3.0.m2/mobile/20170105.025437tizen_3.0.m2accepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobile
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.c | 13 | ||||
-rw-r--r-- | src/journal/journal-file.h | 5 |
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; +} |