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/zfs-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/zfs-tests')
-rwxr-xr-x | tests/zfs-tests/tests/functional/rsend/send-c_zstream_recompress.ksh | 58 |
1 files changed, 58 insertions, 0 deletions
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." |