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) 2017, 2018 by Delphix. All rights reserved.
18 .
$STF_SUITE/tests
/functional
/redacted_send
/redacted.kshlib
22 # Verify redaction works as expected with respect to deleted files
25 # 1. A file on the delete queue counts as deleted when using it to calculate
27 # 2. A file that is removed in the tosnap of an incremental, where the fromsnap
28 # is a redaction bookmark that contains references to that file, does not
29 # result in records for that file.
32 typeset ds_name
="deleted"
33 typeset sendfs
="$POOL/$ds_name"
34 typeset recvfs
="$POOL2/$ds_name"
35 typeset clone
="$POOL/${ds_name}_clone"
36 typeset clone2
="$POOL/${ds_name}_clone2"
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"
44 log_onexit redacted_cleanup
$sendfs $recvfs
47 # A file on the delete queue counts as deleted when using it to calculate
52 # Open file descriptor 5 for appending to $clone_mnt/f1 so that it will go on
53 # the delete queue when we rm it.
56 log_must
dd if=/dev
/urandom of
=$clone_mnt/f1 bs
=512 count
=1 conv
=notrunc
57 log_must
rm $clone_mnt/f1
58 log_must zfs snapshot
$clone@snap1
59 # Close file descriptor 5
61 log_must zfs redact
$sendfs@snap book1
$clone@snap1
62 log_must
eval "zfs send --redact book1 $sendfs@snap >$stream"
63 log_must
eval "zfs recv $recvfs <$stream"
64 log_must mount_redacted
-f $recvfs
66 # We have temporarily disabled redaction blkptrs, so this will not
67 # fail as was originally intended. We should uncomment this line
68 # when we reenable redaction blkptrs.
70 #log_mustnot dd if=$recv_mnt/f1 of=/dev/null bs=512 count=1
71 log_must
diff $send_mnt/f2
$recv_mnt/f2
72 log_must zfs rollback
-R $clone@snap
73 log_must zfs destroy
-R $recvfs
76 # A file that is removed in the tosnap of an incremental, where the fromsnap
77 # is a redaction bookmark that contains references to that file, does not
78 # result in records for that file.
80 log_must zfs clone
$sendfs@snap
$clone2
81 typeset clone2_mnt
="$(get_prop mountpoint $clone2)"
82 log_must
rm -rf $clone2_mnt/*
83 log_must zfs snapshot
$clone2@snap
84 log_must zfs redact
$sendfs@snap book2
$clone2@snap
85 log_must zfs destroy
-R $clone2
86 log_must
eval "zfs send --redact book2 $sendfs@snap >$stream"
87 log_must
eval "zfs recv $recvfs <$stream"
88 log_must
rm $send_mnt/f1
89 log_must zfs snapshot
$sendfs@snap2
90 log_must zfs clone
$sendfs@snap2
$clone2
91 typeset clone2_mnt
="$(get_prop mountpoint $clone2)"
92 log_must
rm $clone2_mnt/*
93 log_must zfs snapshot
$clone2@snap
94 log_must zfs redact
$sendfs@snap2 book3
$clone2@snap
95 log_must zfs destroy
-R $clone2
96 log_must
eval "zfs send -i $sendfs#book2 --redact book3 $sendfs@snap2 >$stream"
97 log_must
eval "zfs recv $recvfs <$stream"
98 log_must mount_redacted
-f $recvfs
99 log_must
diff <(ls $send_mnt) <(ls $recv_mnt)
100 log_must zfs destroy
-R $recvfs
101 log_must zfs rollback
-R $sendfs@snap
103 log_pass
"Verify Redaction works as expected with respect to deleted files."