1#! /bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or https://opensource.org/licenses/CDDL-1.0. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24# 25# Copyright (c) 2023 by Pawel Jakub Dawidek 26# 27 28. $STF_SUITE/include/libtest.shlib 29. $STF_SUITE/include/math.shlib 30. $STF_SUITE/tests/functional/bclone/bclone_common.kshlib 31 32verify_runnable "both" 33 34verify_crossfs_block_cloning 35 36save_tunable BCLONE_STRICT_PROPERTIES 37 38function cleanup 39{ 40 restore_tunable BCLONE_STRICT_PROPERTIES 41 log_must zfs inherit checksum $TESTSRCFS 42 log_must zfs inherit compress $TESTSRCFS 43 log_must zfs inherit copies $TESTSRCFS 44 log_must zfs inherit recordsize $TESTSRCFS 45 log_must zfs inherit checksum $TESTDSTFS 46 log_must zfs inherit compress $TESTDSTFS 47 log_must zfs inherit copies $TESTDSTFS 48 log_must zfs inherit recordsize $TESTDSTFS 49} 50log_onexit cleanup 51 52log_assert "Verify block cloning across datasets with different properties" 53 54# Disable strict property checking to allow cross-dataset cloning with different properties 55log_must set_tunable32 BCLONE_STRICT_PROPERTIES 0 56 57log_must zfs set checksum=off $TESTSRCFS 58log_must zfs set compress=off $TESTSRCFS 59log_must zfs set copies=1 $TESTSRCFS 60log_must zfs set recordsize=131072 $TESTSRCFS 61log_must zfs set checksum=fletcher2 $TESTDSTFS 62log_must zfs set compress=lz4 $TESTDSTFS 63log_must zfs set copies=3 $TESTDSTFS 64log_must zfs set recordsize=8192 $TESTDSTFS 65 66FILESIZE=$(random_int_between 2 32767) 67FILESIZE=$((FILESIZE * 64)) 68bclone_test text $FILESIZE false $TESTSRCDIR $TESTDSTDIR 69 70log_must zfs set checksum=sha256 $TESTSRCFS 71log_must zfs set compress=zstd $TESTSRCFS 72log_must zfs set copies=2 $TESTSRCFS 73log_must zfs set recordsize=262144 $TESTSRCFS 74log_must zfs set checksum=off $TESTDSTFS 75log_must zfs set compress=off $TESTDSTFS 76log_must zfs set copies=1 $TESTDSTFS 77log_must zfs set recordsize=131072 $TESTDSTFS 78 79FILESIZE=$(random_int_between 2 32767) 80FILESIZE=$((FILESIZE * 64)) 81bclone_test text $FILESIZE false $TESTSRCDIR $TESTDSTDIR 82 83log_must zfs set checksum=sha512 $TESTSRCFS 84log_must zfs set compress=gzip $TESTSRCFS 85log_must zfs set copies=2 $TESTSRCFS 86log_must zfs set recordsize=512 $TESTSRCFS 87log_must zfs set checksum=fletcher4 $TESTDSTFS 88log_must zfs set compress=lzjb $TESTDSTFS 89log_must zfs set copies=3 $TESTDSTFS 90log_must zfs set recordsize=16384 $TESTDSTFS 91 92FILESIZE=$(random_int_between 2 32767) 93FILESIZE=$((FILESIZE * 64)) 94bclone_test text $FILESIZE false $TESTSRCDIR $TESTDSTDIR 95 96log_pass 97