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# 31 32typeset ds_name="many_clones" 33typeset sendfs="$POOL/$ds_name" 34typeset recvfs="$POOL2/$ds_name" 35typeset clone="$POOL/${ds_name}_clone" 36typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 37typeset stream=$(mktemp $tmpdir/stream.XXXX) 38setup_dataset $ds_name '' 39typeset clone_mnt="$(get_prop mountpoint $clone)" 40typeset send_mnt="$(get_prop mountpoint $sendfs)" 41typeset recv_mnt="/$POOL2/$ds_name" 42typeset redaction_list='' 43typeset mntpnt 44 45log_onexit redacted_cleanup $sendfs $recvfs 46 47# Fill in both the last block, and a different block in every clone. 48for i in {1..64}; do 49 log_must zfs clone $sendfs@snap ${clone}$i 50 mntpnt=$(get_prop mountpoint ${clone}$i) 51 log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=$i \ 52 conv=notrunc 53 log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=63 \ 54 conv=notrunc 55 log_must zfs snapshot ${clone}$i@snap 56done 57 58# The limit isn't necessarily 64 snapshots. The maximum number of snapshots in 59# the redacted list is determined in dsl_bookmark_create_redacted_check(). 60log_must zfs redact $sendfs@snap book1 $clone{1..64}@snap 61log_must eval "zfs send --redact book1 $sendfs@snap >$stream" 62log_must eval "zfs recv $recvfs <$stream" 63compare_files $sendfs $recvfs "f2" "$RANGE8" 64 65rls_value="$(zpool get -H -o value feature@redaction_list_spill $POOL)" 66if [ "$rls_value" = "active" ]; then 67 log_note "redaction_list_spill feature active" 68else 69 log_fail "redaction_list_spill feature not active" 70fi 71 72log_pass "Redacted send can deal with a large redaction list." 73