1#!/usr/bin/ksh 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# Copyright 2020 Joyent, Inc. 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 log_must 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="/dev/zvol/rdsk/$POOL/newvol" 45typeset voldev2="/dev/zvol/rdsk/$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 53md5_1=$(digest -a md5 $data1) 54md5_2=$(digest -a md5 $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 64md5=$(dd if=$voldev2 bs=1024k count=$megs 2>/dev/null | digest -a md5) 65[[ $md5 = $md5_1 ]] || log_fail "md5 mismatch: $md5 != $md5_1" 66 67# Repeat, for an incremental send 68log_must dd oseek=$megs if=$data2 of=$voldev bs=1024k 69log_must zfs snapshot $vol@snap2 70 71log_must eval "zfs send -c -i snap $vol@snap2 >$BACKDIR/inc" 72log_must eval "zfs recv -d $POOL2 <$BACKDIR/inc" 73 74verify_stream_size $BACKDIR/inc $vol 90 $vol@snap 75verify_stream_size $BACKDIR/inc $vol2 90 $vol2@snap 76md5=$(dd iseek=$megs if=$voldev2 bs=1024k count=$megs 2>/dev/null \ 77 | digest -a md5) 78 79[[ $md5 = $md5_2 ]] || log_fail "md5 mismatch: $md5 != $md5_2" 80 81log_pass "Verify compressed send works with volumes" 82