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
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.
15 # Copyright (c) 2018 by Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
22 # Verify redacted send works with datasets of different sizes.
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.
33 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
34 typeset stream=$(mktemp $tmpdir/stream.XXXX)
37 log_onexit redacted_cleanup $POOL/512 $POOL/1m $POOL2/512 $POOL2/1m
39 # Set up the datasets we'll send and redact from.
40 log_must zfs create -o recsize=512 $POOL/512
41 mntpnt=$(get_prop mountpoint $POOL/512)
42 log_must dd if=/dev/urandom of=$mntpnt/f1 bs=1024k count=2
43 log_must zfs snapshot $POOL/512@snap
44 log_must zfs clone -o recsize=1m $POOL/512@snap $POOL/1mclone
45 mntpnt=$(get_prop mountpoint $POOL/1mclone)
46 log_must dd if=/dev/urandom of=$mntpnt/f1 bs=512 count=32 conv=notrunc
47 log_must zfs snapshot $POOL/1mclone@snap
49 log_must zfs create -o recsize=1m $POOL/1m
50 mntpnt=$(get_prop mountpoint $POOL/1m)
51 log_must dd if=/dev/urandom of=$mntpnt/f1 bs=1024k count=2
52 log_must zfs snapshot $POOL/1m@snap
53 log_must zfs clone -o recsize=512 $POOL/1m@snap $POOL/512clone
54 mntpnt=$(get_prop mountpoint $POOL/512clone)
55 log_must dd if=/dev/urandom of=$mntpnt/f1 bs=512 count=32 conv=notrunc
56 log_must zfs snapshot $POOL/512clone@snap
58 # Create datasets that allow received datasets to inherit recordsize.
59 log_must zfs create -o recsize=512 $POOL2/512
60 log_must zfs create -o recsize=1m $POOL2/1m
62 # Do the sends and verify the contents.
63 log_must zfs redact $POOL/512@snap book1 $POOL/1mclone@snap
64 log_must eval "zfs send --redact book1 $POOL/512@snap>$stream"
65 log_must eval "zfs recv $POOL2/512/recva <$stream"
66 compare_files $POOL/512 $POOL2/512/recva "f1" "$RANGE13"
67 log_must eval "zfs recv $POOL2/1m/recvb <$stream"
68 compare_files $POOL/512 $POOL2/1m/recvb "f1" "$RANGE13"
70 log_must zfs redact $POOL/1m@snap book2 $POOL/512clone@snap
71 log_must eval "zfs send --redact book2 $POOL/1m@snap >$stream"
72 log_must eval "zfs recv $POOL2/512/recvc <$stream"
73 compare_files $POOL/1m $POOL2/512/recvc "f1" "$RANGE11"
74 log_must eval "zfs recv $POOL2/1m/recvd <$stream"
75 compare_files $POOL/1m $POOL2/1m/recvd "f1" "$RANGE11"
77 log_pass "Redaction works correctly with different recordsizes."