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 large blocks and redacted send work correctly together.
23#
24# Strategy:
25# 1. Create a dataset and clone with a 1m recordsize, modifying a few k
26#    within the first 1m of a 16m file.
27# 2. Verify that the whole first 1m of the file is redacted.
28# 3. Receive an incremental stream from the original snap to the snap it
29#    was redacted with respect to.
30# 4. Verify that the received dataset matches the clone
31#
32
33typeset ds_name="largeblocks"
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 '-o recsize=1m'
40typeset clone_mnt="$(get_prop mountpoint $clone)"
41typeset send_mnt="$(get_prop mountpoint $sendfs)"
42typeset recv_mnt="/$POOL2/$ds_name"
43
44log_onexit redacted_cleanup $sendfs $recvfs
45
46log_must dd if=/dev/urandom of=$clone_mnt/f1 bs=32k count=3 seek=8 conv=notrunc
47log_must zfs snapshot $clone@snap1
48
49log_must zfs redact $sendfs@snap book1 $clone@snap1
50log_must eval "zfs send -L --redact book1 $sendfs@snap >$stream"
51log_must stream_has_features $stream redacted large_blocks
52log_must eval "zfs recv $recvfs <$stream"
53compare_files $sendfs $recvfs "f1" "$RANGE11"
54log_must mount_redacted -f $recvfs
55log_must diff $send_mnt/f2 $recv_mnt/f2
56unmount_redacted $recvfs
57
58log_must eval "zfs send -L -i $sendfs@snap $clone@snap1 >$stream"
59log_must stream_has_features $stream large_blocks
60log_must eval "zfs recv $recvfs/new <$stream"
61log_must diff -r $clone_mnt $recv_mnt/new
62
63log_pass "Large blocks and redacted send work correctly together."
64