From 1338ad16b15d53c7b9b08242d34f3683b5e46d73 Mon Sep 17 00:00:00 2001 From: Lukas Straub Date: Thu, 24 Dec 2020 00:10:33 +0100 Subject: [PATCH] Add suport for zstd long distance matching --- btrbk | 14 +++++++++++++- doc/btrbk.conf.5.asciidoc | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/btrbk b/btrbk index 0efabf6..a03aa4c 100755 --- a/btrbk +++ b/btrbk @@ -54,7 +54,7 @@ my %compression = ( xz => { name => 'xz', format => 'xz', compress_cmd => [ 'xz', '-c' ], decompress_cmd => [ 'xz', '-d', '-c' ], level_min => 0, level_max => 9, threads => '-T' }, lzo => { name => 'lzo', format => 'lzo', compress_cmd => [ 'lzop', '-c' ], decompress_cmd => [ 'lzop', '-d', '-c' ], level_min => 1, level_max => 9 }, lz4 => { name => 'lz4', format => 'lz4', compress_cmd => [ 'lz4', '-c' ], decompress_cmd => [ 'lz4', '-d', '-c' ], level_min => 1, level_max => 9 }, - zstd => { name => 'zstd', format => 'zst', compress_cmd => [ 'zstd', '-c' ], decompress_cmd => [ 'zstd', '-d', '-c' ], level_min => 1, level_max => 19, threads => '-T' }, + zstd => { name => 'zstd', format => 'zst', compress_cmd => [ 'zstd', '-c' ], decompress_cmd => [ 'zstd', '-d', '-c' ], level_min => 1, level_max => 19, threads => '-T', long => '--long=' }, ); my $compress_format_alt = join '|', map { $_->{format} } values %compression; # note: this contains duplicate alternations @@ -108,10 +108,12 @@ my %config_options = ( stream_buffer_remote => { default => undef, accept => [ "no" ], accept_regexp => qr/^[0-9]+[kmgKMG%]?$/ }, # NOTE: requires 'mbuffer' command on remote hosts stream_compress => { default => undef, accept => [ "no", (keys %compression) ] }, stream_compress_level => { default => "default", accept => [ "default" ], accept_numeric => 1 }, + stream_compress_long => { default => "default", accept => [ "default" ], accept_numeric => 1 }, stream_compress_threads => { default => "default", accept => [ "default" ], accept_numeric => 1 }, raw_target_compress => { default => undef, accept => [ "no", (keys %compression) ] }, raw_target_compress_level => { default => "default", accept => [ "default" ], accept_numeric => 1 }, + raw_target_compress_long => { default => "default", accept => [ "default" ], accept_numeric => 1 }, raw_target_compress_threads => { default => "default", accept => [ "default" ], accept_numeric => 1 }, raw_target_encrypt => { default => undef, accept => [ "no", "gpg", "openssl_enc" ] }, raw_target_block_size => { default => "128K", accept_regexp => qr/^[0-9]+[kmgKMG]?$/ }, @@ -681,6 +683,15 @@ sub compress_cmd_text($;$) WARN_ONCE "Threading is not supported for '$cc->{name}', ignoring"; } } + if(defined($def->{long}) && ($def->{long} ne "default")) { + my $long_opt = $cc->{long}; + if($long_opt) { + push @cmd, $long_opt . $def->{long}; + } + else { + WARN_ONCE "Long distance matching is not supported for '$cc->{name}', ignoring"; + } + } return { cmd_text => join(' ', @cmd) }; } @@ -3943,6 +3954,7 @@ sub config_compress_hash($$) return { key => $compress_key, level => config_key($config, $config_key . "_level"), + long => config_key($config, $config_key . "_long"), threads => config_key($config, $config_key . "_threads"), }; } diff --git a/doc/btrbk.conf.5.asciidoc b/doc/btrbk.conf.5.asciidoc index 553cb32..aed8d24 100644 --- a/doc/btrbk.conf.5.asciidoc +++ b/doc/btrbk.conf.5.asciidoc @@ -298,6 +298,11 @@ option in ssh_config(5). fastest compression). Defaults to ``default'' (the default compression level of ''). +*stream_compress_long* default|:: + Enable long distance matching for the specified + ''. Refer to the related man-page for details. + Only supported for "zstd". + *stream_compress_threads* default|:: Number of threads to use for . Only supported for "pigz", "pbzip2", "zstd" and recent versions of "xz". @@ -569,6 +574,9 @@ Additional options for raw targets: zstd. *raw_target_compress_level* default|:: Compression level for the specified . +*raw_target_compress_long* default|:: + Enable long distance matching for the specified + ''. *raw_target_compress_threads* default|:: Number of threads to use for . *raw_target_split* |no::