]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/redacted_send/redacted_many_clones.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / redacted_send / redacted_many_clones.ksh
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
33 typeset ds_name="many_clones"
34 typeset sendfs="$POOL/$ds_name"
35 typeset recvfs="$POOL2/$ds_name"
36 typeset clone="$POOL/${ds_name}_clone"
37 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
38 typeset stream=$(mktemp $tmpdir/stream.XXXX)
39 setup_dataset $ds_name ''
40 typeset clone_mnt="$(get_prop mountpoint $clone)"
41 typeset send_mnt="$(get_prop mountpoint $sendfs)"
42 typeset recv_mnt="/$POOL2/$ds_name"
43 typeset redaction_list=''
44 typeset mntpnt
45
46 log_onexit redacted_cleanup $sendfs $recvfs
47
48 # Fill in both the last block, and a different block in every clone.
49 for 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
57 done
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().
61 log_must zfs redact $sendfs@snap book1 $clone{1..32}@snap
62 log_must eval "zfs send --redact book1 $sendfs@snap >$stream"
63 log_must eval "zfs recv $recvfs <$stream"
64 compare_files $sendfs $recvfs "f2" "$RANGE8"
65
66 log_mustnot zfs redact $sendfs@snap book2 $clone{1..64}@snap
67
68 log_pass "Redacted send can deal with a large redaction list."