btrbk: add suport for zstd long distance matching

pull/370/head
Lukas Straub 2020-12-24 00:10:33 +01:00 committed by Axel Burri
parent 3562e75a70
commit dd5991099a
2 changed files with 21 additions and 1 deletions

14
btrbk
View File

@ -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"),
};
}

View File

@ -298,6 +298,11 @@ option in ssh_config(5).
fastest compression). Defaults to ``default'' (the default
compression level of '<compress_command>').
*stream_compress_long* default|<number>::
Enable long distance matching for the specified
'<compress_command>'. Refer to the related man-page for details.
Only supported for "zstd".
*stream_compress_threads* default|<number>::
Number of threads to use for <compress_command>. 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|<number>::
Compression level for the specified <compress_command>.
*raw_target_compress_long* default|<number>::
Enable long distance matching for the specified
'<compress_command>'.
*raw_target_compress_threads* default|<number>::
Number of threads to use for <compress_command>.
*raw_target_split* <size>|no::