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