|
|
17b0f1 |
From bae0c1d66cba62b19d39a3a79cb76fbd5d4ef7e7 Mon Sep 17 00:00:00 2001
|
|
|
17b0f1 |
From: Jan Rybar <jrybar@redhat.com>
|
|
|
17b0f1 |
Date: Thu, 17 Aug 2017 14:38:11 +0200
|
|
|
17b0f1 |
Subject: [PATCH] Add support to read lz4 compressed journals
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Functionality already in codebase, but deactivated in RHEL
|
|
|
17b0f1 |
Changed calling of LZ4 functions due to deprecation of the originals.
|
|
|
17b0f1 |
Fixed typecasting of max_bytes to size_t in debuglog()
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Resolves: rhbz#1431687
|
|
|
17b0f1 |
|
|
|
17b0f1 |
changes to .spec file:
|
|
|
17b0f1 |
|
|
|
17b0f1 |
@@ -552,6 +553,7 @@ BuildRequires: libblkid-devel
|
|
|
17b0f1 |
BuildRequires: xz-devel
|
|
|
17b0f1 |
BuildRequires: zlib-devel
|
|
|
17b0f1 |
BuildRequires: bzip2-devel
|
|
|
17b0f1 |
+BuildRequires: lz4-devel
|
|
|
17b0f1 |
BuildRequires: libidn-devel
|
|
|
17b0f1 |
BuildRequires: libcurl-devel
|
|
|
17b0f1 |
BuildRequires: kmod-devel
|
|
|
17b0f1 |
@@ -742,6 +744,7 @@ CONFIGURE_OPTS=(
|
|
|
17b0f1 |
--enable-compat-libs
|
|
|
17b0f1 |
--disable-sysusers
|
|
|
17b0f1 |
--disable-ldconfig
|
|
|
17b0f1 |
+ --enable-lz4
|
|
|
17b0f1 |
%ifarch s390 s390x ppc %{power64} aarch64
|
|
|
17b0f1 |
--disable-lto
|
|
|
17b0f1 |
%endif
|
|
|
17b0f1 |
---
|
|
|
17b0f1 |
src/journal/compress.c | 11 ++++++++---
|
|
|
17b0f1 |
src/journal/compress.h | 11 -----------
|
|
|
17b0f1 |
src/journal/journal-file.c | 5 ++---
|
|
|
17b0f1 |
3 files changed, 10 insertions(+), 17 deletions(-)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/journal/compress.c b/src/journal/compress.c
|
|
|
17b0f1 |
index 4fb09f5965..3baf9e4ad7 100644
|
|
|
17b0f1 |
--- a/src/journal/compress.c
|
|
|
17b0f1 |
+++ b/src/journal/compress.c
|
|
|
17b0f1 |
@@ -98,7 +98,12 @@ int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, size_t *dst
|
|
|
17b0f1 |
if (src_size < 9)
|
|
|
17b0f1 |
return -ENOBUFS;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- r = LZ4_compress_limitedOutput(src, dst + 8, src_size, src_size - 8 - 1);
|
|
|
17b0f1 |
+#if LZ4_VERSION_NUMBER >= 10700
|
|
|
17b0f1 |
+ r = LZ4_compress_default(src, (char*)dst + 8, src_size, src_size - 8 - 1);
|
|
|
17b0f1 |
+#else
|
|
|
17b0f1 |
+ r = LZ4_compress_limitedOutput(src, (char*)dst + 8, src_size, src_size - 8 - 1);
|
|
|
17b0f1 |
+#endif
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
if (r <= 0)
|
|
|
17b0f1 |
return -ENOBUFS;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
@@ -458,7 +463,7 @@ int compress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
|
|
|
17b0f1 |
|
|
|
17b0f1 |
total_in += n;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- r = LZ4_compress_continue(&lz4_data, buf, out, n);
|
|
|
17b0f1 |
+ r = LZ4_compress_fast_continue(&lz4_data, buf, out, n, LZ4_COMPRESSBOUND(LZ4_BUFSIZE), 0);
|
|
|
17b0f1 |
if (r == 0) {
|
|
|
17b0f1 |
log_error("LZ4 compression failed.");
|
|
|
17b0f1 |
return -EBADMSG;
|
|
|
17b0f1 |
@@ -634,7 +639,7 @@ int decompress_stream_lz4(int fdf, int fdt, off_t max_bytes) {
|
|
|
17b0f1 |
total_out += r;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
if (max_bytes != -1 && total_out > (size_t) max_bytes) {
|
|
|
17b0f1 |
- log_debug("Decompressed stream longer than %zd bytes", max_bytes);
|
|
|
17b0f1 |
+ log_debug("Decompressed stream longer than %zd bytes", (size_t) max_bytes);
|
|
|
17b0f1 |
return -EFBIG;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/journal/compress.h b/src/journal/compress.h
|
|
|
17b0f1 |
index 136dda6d39..0f62a58d6e 100644
|
|
|
17b0f1 |
--- a/src/journal/compress.h
|
|
|
17b0f1 |
+++ b/src/journal/compress.h
|
|
|
17b0f1 |
@@ -35,15 +35,9 @@ int compress_blob_lz4(const void *src, uint64_t src_size, void *dst, size_t *dst
|
|
|
17b0f1 |
|
|
|
17b0f1 |
static inline int compress_blob(const void *src, uint64_t src_size, void *dst, size_t *dst_size) {
|
|
|
17b0f1 |
int r;
|
|
|
17b0f1 |
-#ifdef HAVE_LZ4
|
|
|
17b0f1 |
- r = compress_blob_lz4(src, src_size, dst, dst_size);
|
|
|
17b0f1 |
- if (r == 0)
|
|
|
17b0f1 |
- return OBJECT_COMPRESSED_LZ4;
|
|
|
17b0f1 |
-#else
|
|
|
17b0f1 |
r = compress_blob_xz(src, src_size, dst, dst_size);
|
|
|
17b0f1 |
if (r == 0)
|
|
|
17b0f1 |
return OBJECT_COMPRESSED_XZ;
|
|
|
17b0f1 |
-#endif
|
|
|
17b0f1 |
return r;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
@@ -75,12 +69,7 @@ int compress_stream_lz4(int fdf, int fdt, off_t max_bytes);
|
|
|
17b0f1 |
int decompress_stream_xz(int fdf, int fdt, off_t max_size);
|
|
|
17b0f1 |
int decompress_stream_lz4(int fdf, int fdt, off_t max_size);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
-#ifdef HAVE_LZ4
|
|
|
17b0f1 |
-# define compress_stream compress_stream_lz4
|
|
|
17b0f1 |
-# define COMPRESSED_EXT ".lz4"
|
|
|
17b0f1 |
-#else
|
|
|
17b0f1 |
# define compress_stream compress_stream_xz
|
|
|
17b0f1 |
# define COMPRESSED_EXT ".xz"
|
|
|
17b0f1 |
-#endif
|
|
|
17b0f1 |
|
|
|
17b0f1 |
int decompress_stream(const char *filename, int fdf, int fdt, off_t max_bytes);
|
|
|
17b0f1 |
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
|
|
|
17b0f1 |
index 0fd59ec073..ebc8e62305 100644
|
|
|
17b0f1 |
--- a/src/journal/journal-file.c
|
|
|
17b0f1 |
+++ b/src/journal/journal-file.c
|
|
|
17b0f1 |
@@ -2615,9 +2615,8 @@ int journal_file_open(
|
|
|
17b0f1 |
f->flags = flags;
|
|
|
17b0f1 |
f->prot = prot_from_flags(flags);
|
|
|
17b0f1 |
f->writable = (flags & O_ACCMODE) != O_RDONLY;
|
|
|
17b0f1 |
-#if defined(HAVE_LZ4)
|
|
|
17b0f1 |
- f->compress_lz4 = compress;
|
|
|
17b0f1 |
-#elif defined(HAVE_XZ)
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+#if defined(HAVE_XZ)
|
|
|
17b0f1 |
f->compress_xz = compress;
|
|
|
17b0f1 |
#endif
|
|
|
17b0f1 |
#ifdef HAVE_GCRYPT
|