summaryrefslogtreecommitdiff
path: root/src/journal/journal-verify.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-03 22:42:22 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-06 19:06:03 -0400
commitd89c8fdf48c7bad5816b9f2e77e8361721f22517 (patch)
tree12d384fffafa1789079b7ed51c4d33d5d10116c0 /src/journal/journal-verify.c
parent5e592c66bdf76dfc8445b332f7a5088ca504ee90 (diff)
journal: add LZ4 as optional compressor
Add liblz4 as an optional dependency when requested with --enable-lz4, and use it in preference to liblzma for journal blob and coredump compression. To retain backwards compatibility, XZ is used to decompress old blobs. Things will function correctly only with lz4-119. Based on the benchmarks found on the web, lz4 seems to be the best choice for "quick" compressors atm. For pkg-config status, see http://code.google.com/p/lz4/issues/detail?id=135.
Diffstat (limited to 'src/journal/journal-verify.c')
-rw-r--r--src/journal/journal-verify.c51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 31bae5a8f8..c063d12210 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -45,7 +45,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
* possible field values. It does not follow any references to
* other objects. */
- if ((o->object.flags & OBJECT_COMPRESSED) &&
+ if ((o->object.flags & OBJECT_COMPRESSED_XZ) &&
o->object.type != OBJECT_DATA)
return -EBADMSG;
@@ -72,22 +72,38 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
h1 = le64toh(o->data.hash);
- if (o->object.flags & OBJECT_COMPRESSED) {
+ if (o->object.flags & OBJECT_COMPRESSED_XZ) {
#ifdef HAVE_XZ
- void *b = NULL;
+ _cleanup_free_ void *b = NULL;
uint64_t alloc = 0, b_size;
- if (!uncompress_blob(o->data.payload,
- le64toh(o->object.size) - offsetof(Object, data.payload),
- &b, &alloc, &b_size, 0)) {
- log_error(OFSfmt": uncompression failed", offset);
+ if (!decompress_blob_xz(o->data.payload,
+ le64toh(o->object.size) - offsetof(Object, data.payload),
+ &b, &alloc, &b_size, 0)) {
+ log_error(OFSfmt": XZ decompression failed", offset);
return -EBADMSG;
}
h2 = hash64(b, b_size);
- free(b);
#else
- log_error("Compression is not supported");
+ log_error("XZ compression is not supported");
+ return -EPROTONOSUPPORT;
+#endif
+ } else if (o->object.flags & OBJECT_COMPRESSED_LZ4) {
+#ifdef HAVE_XZ
+ _cleanup_free_ void *b = NULL;
+ uint64_t alloc = 0, b_size;
+
+ if (!decompress_blob_xz(o->data.payload,
+ le64toh(o->object.size) - offsetof(Object, data.payload),
+ &b, &alloc, &b_size, 0)) {
+ log_error(OFSfmt": LZ4 decompression failed", offset);
+ return -EBADMSG;
+ }
+
+ h2 = hash64(b, b_size);
+#else
+ log_error("XZ compression is not supported");
return -EPROTONOSUPPORT;
#endif
} else
@@ -875,8 +891,21 @@ int journal_file_verify(
goto fail;
}
- if ((o->object.flags & OBJECT_COMPRESSED) && !JOURNAL_HEADER_COMPRESSED(f->header)) {
- log_error("Compressed object in file without compression at "OFSfmt, p);
+ if ((o->object.flags & OBJECT_COMPRESSED_XZ) &&
+ (o->object.flags & OBJECT_COMPRESSED_LZ4)) {
+ log_error("Objected with double compression at "OFSfmt, p);
+ r = -EBADMSG;
+ goto fail;
+ }
+
+ if ((o->object.flags & OBJECT_COMPRESSED_XZ) && !JOURNAL_HEADER_COMPRESSED_XZ(f->header)) {
+ log_error("XZ compressed object in file without XZ compression at "OFSfmt, p);
+ r = -EBADMSG;
+ goto fail;
+ }
+
+ if ((o->object.flags & OBJECT_COMPRESSED_LZ4) && !JOURNAL_HEADER_COMPRESSED_LZ4(f->header)) {
+ log_error("LZ4 compressed object in file without LZ4 compression at "OFSfmt, p);
r = -EBADMSG;
goto fail;
}