mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
compression: add build-time option to select default
Compression and decompression are controlled by the same build flag, so if one wants to use, say, LZ4 to compress, ZSTD has to be disabled, which means one loses the ability to read zstd-compressed journals. Add a default-compression meson option, that allows to select any of the available compression algorithms as the default.
This commit is contained in:
parent
bd4297e761
commit
cd3c6322db
24
meson.build
24
meson.build
@ -1452,6 +1452,30 @@ conf.set10('HAVE_ZSTD', have_zstd)
|
||||
|
||||
conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
|
||||
|
||||
compression = get_option('default-compression')
|
||||
if compression == 'auto'
|
||||
if have_zstd
|
||||
compression = 'zstd'
|
||||
elif have_lz4
|
||||
compression = 'lz4'
|
||||
elif have_xz
|
||||
compression = 'xz'
|
||||
else
|
||||
compression = 'none'
|
||||
endif
|
||||
elif compression == 'zstd' and not have_zstd
|
||||
error('default-compression=zstd requires zstd')
|
||||
elif compression == 'lz4' and not have_lz4
|
||||
error('default-compression=lz4 requires lz4')
|
||||
elif compression == 'xz' and not have_xz
|
||||
error('default-compression=xz requires xz')
|
||||
endif
|
||||
conf.set('OBJECT_COMPRESSED_NONE', 0)
|
||||
conf.set('OBJECT_COMPRESSED_XZ', 1)
|
||||
conf.set('OBJECT_COMPRESSED_LZ4', 2)
|
||||
conf.set('OBJECT_COMPRESSED_ZSTD', 4)
|
||||
conf.set('DEFAULT_COMPRESSION', 'OBJECT_COMPRESSED_@0@'.format(compression.to_upper()))
|
||||
|
||||
want_xkbcommon = get_option('xkbcommon')
|
||||
if want_xkbcommon != 'false' and not skip_deps
|
||||
libxkbcommon = dependency('xkbcommon',
|
||||
|
@ -411,6 +411,8 @@ option('lz4', type : 'combo', choices : ['auto', 'true', 'false'],
|
||||
description : 'lz4 compression support')
|
||||
option('zstd', type : 'combo', choices : ['auto', 'true', 'false'],
|
||||
description : 'zstd compression support')
|
||||
option('default-compression', type : 'combo', choices : ['auto', 'zstd', 'lz4', 'xz'], value: 'auto',
|
||||
description : 'default compression algorithm')
|
||||
option('xkbcommon', type : 'combo', choices : ['auto', 'true', 'false'],
|
||||
description : 'xkbcommon keymap support')
|
||||
option('pcre2', type : 'combo', choices : ['auto', 'true', 'false'],
|
||||
|
@ -18,15 +18,15 @@ int compress_blob_zstd(const void *src, uint64_t src_size,
|
||||
static inline int compress_blob(const void *src, uint64_t src_size,
|
||||
void *dst, size_t dst_alloc_size, size_t *dst_size) {
|
||||
int r;
|
||||
#if HAVE_ZSTD
|
||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
||||
r = compress_blob_zstd(src, src_size, dst, dst_alloc_size, dst_size);
|
||||
if (r == 0)
|
||||
return OBJECT_COMPRESSED_ZSTD;
|
||||
#elif HAVE_LZ4
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
||||
r = compress_blob_lz4(src, src_size, dst, dst_alloc_size, dst_size);
|
||||
if (r == 0)
|
||||
return OBJECT_COMPRESSED_LZ4;
|
||||
#elif HAVE_XZ
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
||||
r = compress_blob_xz(src, src_size, dst, dst_alloc_size, dst_size);
|
||||
if (r == 0)
|
||||
return OBJECT_COMPRESSED_XZ;
|
||||
@ -72,13 +72,13 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
|
||||
int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
|
||||
int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
|
||||
|
||||
#if HAVE_ZSTD
|
||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
||||
# define compress_stream compress_stream_zstd
|
||||
# define COMPRESSED_EXT ".zst"
|
||||
#elif HAVE_LZ4
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
||||
# define compress_stream compress_stream_lz4
|
||||
# define COMPRESSED_EXT ".lz4"
|
||||
#elif HAVE_XZ
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
||||
# define compress_stream compress_stream_xz
|
||||
# define COMPRESSED_EXT ".xz"
|
||||
#else
|
||||
|
@ -42,11 +42,9 @@ typedef enum ObjectType {
|
||||
_OBJECT_TYPE_MAX
|
||||
} ObjectType;
|
||||
|
||||
/* Object flags */
|
||||
/* Object flags
|
||||
* The per-compression enums are defined in meson.build so that config.h is self-contained */
|
||||
enum {
|
||||
OBJECT_COMPRESSED_XZ = 1 << 0,
|
||||
OBJECT_COMPRESSED_LZ4 = 1 << 1,
|
||||
OBJECT_COMPRESSED_ZSTD = 1 << 2,
|
||||
OBJECT_COMPRESSION_MASK = (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4 | OBJECT_COMPRESSED_ZSTD),
|
||||
_OBJECT_COMPRESSED_MAX = OBJECT_COMPRESSION_MASK,
|
||||
};
|
||||
|
@ -3359,11 +3359,11 @@ int journal_file_open(
|
||||
.open_flags = open_flags,
|
||||
.writable = (open_flags & O_ACCMODE) != O_RDONLY,
|
||||
|
||||
#if HAVE_ZSTD
|
||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
||||
.compress_zstd = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||
#elif HAVE_LZ4
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
||||
.compress_lz4 = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||
#elif HAVE_XZ
|
||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
||||
.compress_xz = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||
#endif
|
||||
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
|
||||
|
Loading…
Reference in New Issue
Block a user