@@ -39,24 +39,27 @@ log_assert $claim
3939
4040DS1=" $TESTPOOL /encrypted1"
4141DS2=" $TESTPOOL /encrypted2"
42+ DS1_NC=" $TESTPOOL /notcrypted1"
4243PASSPHRASE=" top_secret"
4344
4445function prepare_enc
4546{
4647 log_must zpool create -o feature@block_cloning=enabled $TESTPOOL $DISKS
4748 log_must eval " echo $PASSPHRASE | zfs create -o encryption=on" \
48- " -o keyformat=passphrase $DS1 "
49+ " -o keyformat=passphrase -o keylocation=prompt $DS1 "
4950 log_must eval " echo $PASSPHRASE | zfs create -o encryption=on" \
5051 " -o keyformat=passphrase -o keylocation=prompt $DS2 "
5152 log_must zfs create $DS1 /child1
5253 log_must zfs create $DS1 /child2
54+ log_must zfs create $DS1_NC
5355
5456 log_note " Create test file"
5557 # we must wait until the src file txg is written to the disk otherwise we
5658 # will fallback to normal copy. See "dmu_read_l0_bps" in "zfs/module/zfs/dmu.c"
5759 # and "zfs_clone_range" in "zfs/module/zfs/zfs_vnops.c"
5860 log_must dd if=/dev/urandom of=/$DS1 /file bs=128K count=4
5961 log_must dd if=/dev/urandom of=/$DS1 /child1/file bs=128K count=4
62+ log_must dd if=/dev/urandom of=/$DS1_NC /file bs=128K count=4
6063 log_must sync_pool $TESTPOOL
6164}
6265
@@ -141,6 +144,18 @@ log_must zfs destroy -r $DS2@s1
141144typeset hash2=$( cat " /$DS1 /file" | md5sum)
142145log_must [ " $hash1 " = " $hash2 " ]
143146
147+ cleanup_enc
148+ prepare_enc
149+
150+ log_note " Copying with copy_file_range from non encrypted to encrypted"
151+ clone_and_check " file" " copy" $DS1_NC $DS1 " " true
152+
153+ cleanup_enc
154+ prepare_enc
155+
156+ log_note " Copying with copy_file_range from encrypted to non encrypted"
157+ clone_and_check " file" " copy" $DS1 $DS1_NC " " true
158+
144159log_must sync_pool $TESTPOOL
145160
146161log_pass $claim
0 commit comments