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 can deal with a large redaction list. 23# 24# Strategy: 25# 1. Create 64 clones of sendfs each of which modifies two blocks in a file. 26# The first modification is at an offset unique to each clone, and the 27# second (the last block in the file) is common to them all. 28# 2. Verify a redacted stream with a reasonable redaction list length can 29# be correctly processed. 30# 3. Verify that if the list is too long, the send fails gracefully. 31# 32 33typeset ds_name="many_clones" 34typeset sendfs="$POOL/$ds_name" 35typeset recvfs="$POOL2/$ds_name" 36typeset clone="$POOL/${ds_name}_clone" 37typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 38typeset stream=$(mktemp $tmpdir/stream.XXXX) 39setup_dataset $ds_name '' 40typeset clone_mnt="$(get_prop mountpoint $clone)" 41typeset send_mnt="$(get_prop mountpoint $sendfs)" 42typeset recv_mnt="/$POOL2/$ds_name" 43typeset redaction_list='' 44typeset mntpnt 45 46log_onexit redacted_cleanup $sendfs $recvfs 47 48# Fill in both the last block, and a different block in every clone. 49for i in {1..64}; do 50 log_must zfs clone $sendfs@snap ${clone}$i 51 mntpnt=$(get_prop mountpoint ${clone}$i) 52 log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=$i \ 53 conv=notrunc 54 log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=63 \ 55 conv=notrunc 56 log_must zfs snapshot ${clone}$i@snap 57done 58 59# The limit isn't necessarily 32 snapshots. The maximum number of snapshots in 60# the redacted list is determined in dsl_bookmark_create_redacted_check(). 61log_must zfs redact $sendfs@snap book1 $clone{1..32}@snap 62log_must eval "zfs send --redact book1 $sendfs@snap >$stream" 63log_must eval "zfs recv $recvfs <$stream" 64compare_files $sendfs $recvfs "f2" "$RANGE8" 65 66log_mustnot zfs redact $sendfs@snap book2 $clone{1..64}@snap 67 68log_pass "Redacted send can deal with a large redaction list." 69