1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14 15# 16# Copyright (c) 2015 by Delphix. All rights reserved. 17# 18 19. $STF_SUITE/tests/functional/rsend/rsend.kshlib 20 21# 22# Description: 23# Verify that compressed send correctly handles volumes 24# 25# Strategy: 26# 1. Write compressible data into a volume, take a snap 27# 2. Verify the compressed stream is the correct size, and has the correct data 28# 3. Repeat step 2 for an incremental compressed stream 29# 30 31function cleanup 32{ 33 rm $BACKDIR/copy 34 log_must_busy zfs destroy -r $vol 35 cleanup_pool $POOL2 36} 37 38verify_runnable "both" 39 40log_assert "Verify compressed send works with volumes" 41log_onexit cleanup 42 43typeset vol="$POOL/newvol" 44typeset vol2="$POOL2/newvol" 45typeset voldev="$ZVOL_DEVDIR/$POOL/newvol" 46typeset voldev2="$ZVOL_DEVDIR/$POOL2/newvol" 47typeset data1=$BACKDIR/file.0 48typeset data2=$BACKDIR/file.1 49typeset megs=8 50 51log_must zfs create -V 256m -o compress=lz4 $vol 52 53write_compressible $BACKDIR ${megs}m 2 54hash1=$(xxh128digest $data1) 55hash2=$(xxh128digest $data2) 56 57log_must dd if=$data1 of=$voldev bs=1024k 58log_must zfs snapshot $vol@snap 59 60log_must eval "zfs send -c $vol@snap >$BACKDIR/full" 61log_must eval "zfs recv -d $POOL2 <$BACKDIR/full" 62 63verify_stream_size $BACKDIR/full $vol 64verify_stream_size $BACKDIR/full $vol2 65block_device_wait $voldev2 66log_must dd if=$voldev2 of=$BACKDIR/copy bs=1024k count=$megs 67hash=$(xxh128digest $BACKDIR/copy) 68[[ $hash = $hash1 ]] || log_fail "hash mismatch: $hash != $hash1" 69 70# Repeat, for an incremental send 71log_must dd seek=$megs if=$data2 of=$voldev bs=1024k 72log_must zfs snapshot $vol@snap2 73 74log_must eval "zfs send -c -i snap $vol@snap2 >$BACKDIR/inc" 75log_must eval "zfs recv -d $POOL2 <$BACKDIR/inc" 76 77verify_stream_size $BACKDIR/inc $vol 90 $vol@snap 78verify_stream_size $BACKDIR/inc $vol2 90 $vol2@snap 79block_device_wait $voldev2 80log_must dd skip=$megs if=$voldev2 of=$BACKDIR/copy bs=1024k count=$megs 81hash=$(xxh128digest $BACKDIR/copy) 82[[ $hash = $hash2 ]] || log_fail "hash mismatch: $hash != $hash2" 83 84log_pass "Verify compressed send works with volumes" 85