summaryrefslogtreecommitdiff
path: root/src/journal/coredump.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/coredump.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/coredump.c')
-rw-r--r--src/journal/coredump.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 78e89d33cf..59c6d4b716 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -49,12 +49,6 @@
# include "acl-util.h"
#endif
-#ifdef HAVE_XZ
-# include <lzma.h>
-#else
-# define LZMA_PRESET_DEFAULT 0
-#endif
-
/* The maximum size up to which we process coredumps */
#define PROCESS_SIZE_MAX ((off_t) (2LLU*1024LLU*1024LLU*1024LLU))
@@ -357,7 +351,7 @@ static int save_external_coredump(
goto fail;
}
-#ifdef HAVE_XZ
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
/* If we will remove the coredump anyway, do not compress. */
if (maybe_remove_external_coredump(NULL, st.st_size) == 0
&& arg_compress) {
@@ -365,15 +359,15 @@ static int save_external_coredump(
_cleanup_free_ char *fn_compressed = NULL, *tmp_compressed = NULL;
_cleanup_close_ int fd_compressed = -1;
- fn_compressed = strappend(fn, ".xz");
+ fn_compressed = strappend(fn, COMPRESSED_EXT);
if (!fn_compressed) {
- r = log_oom();
+ log_oom();
goto uncompressed;
}
tmp_compressed = tempfn_random(fn_compressed);
if (!tmp_compressed) {
- r = log_oom();
+ log_oom();
goto uncompressed;
}
@@ -383,7 +377,7 @@ static int save_external_coredump(
goto uncompressed;
}
- r = compress_stream(fd, fd_compressed, LZMA_PRESET_DEFAULT, -1);
+ r = compress_stream(fd, fd_compressed, -1);
if (r < 0) {
log_error("Failed to compress %s: %s", tmp_compressed, strerror(-r));
goto fail_compressed;