1#!/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) 2018 by Delphix. All rights reserved. 16# 17 18. $STF_SUITE/tests/functional/redacted_send/redacted.kshlib 19 20# 21# Description: 22# Verify redacted send works with datasets of different sizes. 23# 24# Strategy: 25# 1. Create two dataset one with recsize 512, and one 1m and create a 2m file. 26# 2. For each dataset, create clones of both 512 and 1m recsize and modify 27# the first 16k of the file. 28# 3. Send each original dataset, redacted with respect to each of the clones 29# into both a dataset inheriting a 512 recsize and a 1m one. 30# 4. Verify that the smallest unit of redaction is that of the origin fs. 31# 32 33typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 34typeset stream=$(mktemp $tmpdir/stream.XXXX) 35typeset mntpnt 36 37log_onexit redacted_cleanup $POOL/512 $POOL/1m $POOL2/512 $POOL2/1m 38 39# Set up the datasets we'll send and redact from. 40log_must zfs create -o recsize=512 $POOL/512 41mntpnt=$(get_prop mountpoint $POOL/512) 42log_must dd if=/dev/urandom of=$mntpnt/f1 bs=1024k count=2 43log_must zfs snapshot $POOL/512@snap 44log_must zfs clone -o recsize=1m $POOL/512@snap $POOL/1mclone 45mntpnt=$(get_prop mountpoint $POOL/1mclone) 46log_must dd if=/dev/urandom of=$mntpnt/f1 bs=512 count=32 conv=notrunc 47log_must zfs snapshot $POOL/1mclone@snap 48 49log_must zfs create -o recsize=1m $POOL/1m 50mntpnt=$(get_prop mountpoint $POOL/1m) 51log_must dd if=/dev/urandom of=$mntpnt/f1 bs=1024k count=2 52log_must zfs snapshot $POOL/1m@snap 53log_must zfs clone -o recsize=512 $POOL/1m@snap $POOL/512clone 54mntpnt=$(get_prop mountpoint $POOL/512clone) 55log_must dd if=/dev/urandom of=$mntpnt/f1 bs=512 count=32 conv=notrunc 56log_must zfs snapshot $POOL/512clone@snap 57 58# Create datasets that allow received datasets to inherit recordsize. 59log_must zfs create -o recsize=512 $POOL2/512 60log_must zfs create -o recsize=1m $POOL2/1m 61 62# Do the sends and verify the contents. 63log_must zfs redact $POOL/512@snap book1 $POOL/1mclone@snap 64log_must eval "zfs send --redact book1 $POOL/512@snap>$stream" 65log_must eval "zfs recv $POOL2/512/recva <$stream" 66compare_files $POOL/512 $POOL2/512/recva "f1" "$RANGE13" 67log_must eval "zfs recv $POOL2/1m/recvb <$stream" 68compare_files $POOL/512 $POOL2/1m/recvb "f1" "$RANGE13" 69 70log_must zfs redact $POOL/1m@snap book2 $POOL/512clone@snap 71log_must eval "zfs send --redact book2 $POOL/1m@snap >$stream" 72log_must eval "zfs recv $POOL2/512/recvc <$stream" 73compare_files $POOL/1m $POOL2/512/recvc "f1" "$RANGE11" 74log_must eval "zfs recv $POOL2/1m/recvd <$stream" 75compare_files $POOL/1m $POOL2/1m/recvd "f1" "$RANGE11" 76 77log_pass "Redaction works correctly with different recordsizes." 78