5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
17 # Copyright (c) 2019 Datto, Inc. All rights reserved.
20 . $STF_SUITE/include/libtest.shlib
24 # Verify that 'zfs receive' produces an error when mixing
25 # raw and non-raw sends in a way that would break IV set
29 # 1. Create an initial dataset with 3 snapshots.
30 # 2. Perform a raw send of the first snapshot to 2 other datasets.
31 # 3. Perform a non-raw send of the second snapshot to one of
32 # the other datasets. Perform a raw send from this dataset to
34 # 4. Attempt to raw send the final snapshot of the first dataset
35 # to the other 2 datasets, which should fail.
36 # 5. Repeat steps 1-4, but using bookmarks for incremental sends.
40 # ------------------------------------------------------------------------------
41 # snap1 ---raw---> snap1 --raw--> snap1 # all snaps initialized via raw send
42 # snap2 -non-raw-> snap2 --raw--> snap2 # A sends non-raw to B, B sends raw to C
43 # snap3 ------------raw---------> snap3 # attempt send to C (should fail)
47 verify_runnable "both"
51 datasetexists $TESTPOOL/$TESTFS3 && \
52 log_must zfs destroy -r $TESTPOOL/$TESTFS3
53 datasetexists $TESTPOOL/$TESTFS2 && \
54 log_must zfs destroy -r $TESTPOOL/$TESTFS2
55 datasetexists $TESTPOOL/$TESTFS1 && \
56 log_must zfs destroy -r $TESTPOOL/$TESTFS1
60 log_assert "Mixing raw and non-raw receives should fail"
62 typeset passphrase="password"
64 log_must eval "echo $passphrase | zfs create -o encryption=on" \
65 "-o keyformat=passphrase $TESTPOOL/$TESTFS1"
67 log_must zfs snapshot $TESTPOOL/$TESTFS1@1
68 log_must touch /$TESTPOOL/$TESTFS1/a
69 log_must zfs snapshot $TESTPOOL/$TESTFS1@2
70 log_must touch /$TESTPOOL/$TESTFS1/b
71 log_must zfs snapshot $TESTPOOL/$TESTFS1@3
73 # Testing with snapshots
74 log_must eval "zfs send -w $TESTPOOL/$TESTFS1@1 |" \
75 "zfs receive $TESTPOOL/$TESTFS2"
76 log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS2"
77 log_must eval "zfs send -w $TESTPOOL/$TESTFS2@1 |" \
78 "zfs receive $TESTPOOL/$TESTFS3"
79 log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS3"
81 log_must eval "zfs send -i $TESTPOOL/$TESTFS1@1 $TESTPOOL/$TESTFS1@2 |" \
82 "zfs receive $TESTPOOL/$TESTFS2"
83 log_must eval "zfs send -w -i $TESTPOOL/$TESTFS2@1 $TESTPOOL/$TESTFS2@2 |" \
84 "zfs receive $TESTPOOL/$TESTFS3"
86 log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS1@2 $TESTPOOL/$TESTFS1@3 |" \
87 "zfs receive $TESTPOOL/$TESTFS2"
88 log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS2@2 $TESTPOOL/$TESTFS2@3 |" \
89 "zfs receive $TESTPOOL/$TESTFS3"
91 log_must zfs destroy -r $TESTPOOL/$TESTFS3
92 log_must zfs destroy -r $TESTPOOL/$TESTFS2
94 # Testing with bookmarks
95 log_must zfs bookmark $TESTPOOL/$TESTFS1@1 $TESTPOOL/$TESTFS1#b1
96 log_must zfs bookmark $TESTPOOL/$TESTFS1@2 $TESTPOOL/$TESTFS1#b2
98 log_must eval "zfs send -w $TESTPOOL/$TESTFS1@1 |" \
99 "zfs receive $TESTPOOL/$TESTFS2"
100 log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS2"
102 log_must zfs bookmark $TESTPOOL/$TESTFS2@1 $TESTPOOL/$TESTFS2#b1
104 log_must eval "zfs send -w $TESTPOOL/$TESTFS2@1 |" \
105 "zfs receive $TESTPOOL/$TESTFS3"
106 log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS3"
108 log_must eval "zfs send -i $TESTPOOL/$TESTFS1#b1 $TESTPOOL/$TESTFS1@2 |" \
109 "zfs receive $TESTPOOL/$TESTFS2"
110 log_must eval "zfs send -w -i $TESTPOOL/$TESTFS2#b1 $TESTPOOL/$TESTFS2@2 |" \
111 "zfs receive $TESTPOOL/$TESTFS3"
113 log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS1#b2" \
114 "$TESTPOOL/$TESTFS1@3 | zfs receive $TESTPOOL/$TESTFS2"
115 log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS2#b2" \
116 "$TESTPOOL/$TESTFS2@3 | zfs receive $TESTPOOL/$TESTFS3"
118 log_pass "Mixing raw and non-raw receives fail as expected"