diff options
author | Paul Dagnelie <[email protected]> | 2022-11-10 15:23:46 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-10 15:23:46 -0800 |
commit | 9f4ede63d23be4f43ba8dd0ca42c6a773a8eaa8d (patch) | |
tree | 88b62f576845104fb49b7f17af4172ff8c1dcd72 /tests | |
parent | e9ab9e512c277ce3c22208599ebe5814db41a036 (diff) |
Add ability to recompress send streams with new compression algorithm
As new compression algorithms are added to ZFS, it could be useful for
people to recompress data with new algorithms. There is currently no
mechanism to do this aside from copying the data manually into a new
filesystem with the new algorithm enabled. This tool allows the
transformation to happen through zfs send, allowing it to be done
efficiently to remote systems and in an incremental fashion.
A new zstream command is added that decompresses WRITE records and
then recompresses them with a provided algorithm, and then re-emits
the modified send stream. It may also be possible to re-compress
embedded block pointers, but that was not attempted for the initial
version.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matthew Ahrens <[email protected]>
Signed-off-by: Paul Dagnelie <[email protected]>
Closes #14106
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runfiles/common.run | 12 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/rsend/send-c_zstream_recompress.ksh | 58 |
2 files changed, 64 insertions, 6 deletions
diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 65b64f4fa..323c37a3d 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -838,12 +838,12 @@ tests = ['recv_dedup', 'recv_dedup_encrypted_zvol', 'rsend_001_pos', 'rsend_026_neg', 'rsend_027_pos', 'rsend_028_neg', 'rsend_029_neg', 'rsend_030_pos', 'send-c_verify_ratio', 'send-c_verify_contents', 'send-c_props', 'send-c_incremental', 'send-c_volume', - 'send-c_zstreamdump', 'send-c_lz4_disabled', 'send-c_recv_lz4_disabled', - 'send-c_mixed_compression', 'send-c_stream_size_estimate', - 'send-c_embedded_blocks', 'send-c_resume', 'send-cpL_varied_recsize', - 'send-c_recv_dedup', 'send-L_toggle', 'send_encrypted_hierarchy', - 'send_encrypted_props', 'send_encrypted_truncated_files', - 'send_freeobjects', 'send_realloc_files', + 'send-c_zstream_recompress', 'send-c_zstreamdump', 'send-c_lz4_disabled', + 'send-c_recv_lz4_disabled', 'send-c_mixed_compression', + 'send-c_stream_size_estimate', 'send-c_embedded_blocks', 'send-c_resume', + 'send-cpL_varied_recsize', 'send-c_recv_dedup', 'send-L_toggle', + 'send_encrypted_hierarchy', 'send_encrypted_props', + 'send_encrypted_truncated_files', 'send_freeobjects', 'send_realloc_files', 'send_realloc_encrypted_files', 'send_spill_block', 'send_holds', 'send_hole_birth', 'send_mixed_raw', 'send-wR_encrypted_zvol', 'send_partial_dataset', 'send_invalid', 'send_doall', diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_zstream_recompress.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_zstream_recompress.ksh new file mode 100755 index 000000000..dd2a7d02a --- /dev/null +++ b/tests/zfs-tests/tests/functional/rsend/send-c_zstream_recompress.ksh @@ -0,0 +1,58 @@ +#!/bin/ksh -p + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2022 by Delphix. All rights reserved. +# + +. $STF_SUITE/tests/functional/rsend/rsend.kshlib +. $STF_SUITE/include/math.shlib + +# +# Description: +# Verify compression features show up in zstream dump +# +# Strategy: +# 1. Create a compressed send stream +# 2. Recompress the stream with a different algorithm +# 3. Verify it can be received correctly +# 4. Verify the contents match the original filesystem +# 5. Create an uncompressed send stream +# 6. Compress the send stream +# 7. Verify that the stream is smaller when compressed +# + +verify_runnable "both" + +log_assert "Verify zstream recompress correctly modifies send streams." +log_onexit cleanup_pool $POOL2 + +typeset sendfs=$POOL2/fs +typeset recvfs=$POOL2/fs2 + +log_must zfs create -o compress=lz4 $sendfs +typeset dir=$(get_prop mountpoint $sendfs) +write_compressible $dir 16m +log_must zfs snapshot $sendfs@snap + +log_must eval "zfs send -c $sendfs@snap | zstream recompress gzip-1 | zfs recv $recvfs" +typeset recvdir=$(get_prop mountpoint $recvfs) +log_must diff -r $dir $recvdir + +log_must eval "zfs send $sendfs@snap >$BACKDIR/uncompressed" +log_must zstream recompress gzip-1 <$BACKDIR/uncompressed >$BACKDIR/compressed +typeset uncomp_size=$(wc -c $BACKDIR/uncompressed | awk '{print $1}') +typeset comp_size=$(wc -c $BACKDIR/compressed | awk '{print $1}') +[[ "$uncomp_size" -gt "$comp_size" ]] || log_fail "recompressed stream was not smaller" + +log_pass "zstream recompress correctly modifies send streams." |