diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib index c2ccb24384a8..1273ed59df30 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib @@ -1,158 +1,157 @@ # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # # Copyright (c) 2012, 2016 by Delphix. All rights reserved. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zfs_copies/zfs_copies.cfg # # Compare the value of copies property with specified value # $1, the dataset name # $2, the expected copies value # function cmp_prop { typeset ds=$1 typeset val_expect=$2 typeset val_actual val_actual=$(get_prop copies $ds) if [[ $val_actual != $val_expect ]]; then log_fail "Expected value ($val_expect) != actual value " \ "($val_actual)" fi } # # Check the used space is charged correctly # $1, the number of used space # $2, the expected common factor between the used space and the file space # function check_used { typeset charged_spc=$1 typeset -i used typeset -i expected_cfactor=$2 typeset -i cfactor typeset -i fsize=${FILESIZE%[m|M]} ((used = $charged_spc / 1024 / 1024)) ((cfactor = used / fsize)) if ((cfactor != expected_cfactor)); then log_fail "The space is not charged correctly while setting" \ "copies as $expected_cfactor." fi } # # test ncopies on volume # $1 test type zfs|ufs|ext2 # $2 copies # $3 mntp for ufs|ext2 test function do_vol_test { typeset type=$1 typeset copies=$2 typeset mntp=$3 vol=$TESTPOOL/$TESTVOL1 vol_b_path=$ZVOL_DEVDIR/$TESTPOOL/$TESTVOL1 - vol_r_path=$ZVOL_RDEVDIR/$TESTPOOL/$TESTVOL1 log_must zfs create -V $VOLSIZE -o copies=$copies $vol log_must zfs set refreservation=none $vol - block_device_wait $vol_r_path + block_device_wait $vol_b_path case "$type" in "ext2") if is_freebsd; then log_unsupported "ext2 test not implemented for freebsd" fi - log_must eval "new_fs $vol_r_path >/dev/null 2>&1" + log_must eval "new_fs $vol_b_path >/dev/null 2>&1" log_must mount -o rw $vol_b_path $mntp ;; "ufs") if is_linux; then log_unsupported "ufs test not implemented for linux" fi - log_must eval "new_fs $vol_r_path >/dev/null 2>&1" + log_must eval "new_fs $vol_b_path >/dev/null 2>&1" log_must mount $vol_b_path $mntp ;; "zfs") if is_freebsd; then # Pool creation on zvols is forbidden by default. # Save and restore the current setting. typeset _saved=$(get_tunable VOL_RECURSIVE) log_must set_tunable64 VOL_RECURSIVE 1 # Allow zpool create $TESTPOOL1 $vol_b_path typeset _zpool_create_result=$? log_must set_tunable64 VOL_RECURSIVE $_saved # Restore log_must test $_zpool_create_result = 0 else log_must zpool create $TESTPOOL1 $vol_b_path fi log_must zfs create $TESTPOOL1/$TESTFS1 ;; *) log_unsupported "$type test not implemented" ;; esac ((nfilesize = copies * ${FILESIZE%m})) pre_used=$(get_prop used $vol) ((target_size = pre_used + nfilesize)) if [[ $type == "zfs" ]]; then log_must mkfile $FILESIZE /$TESTPOOL1/$TESTFS1/$FILE else log_must mkfile $FILESIZE $mntp/$FILE fi post_used=$(get_prop used $vol) ((retries = 0)) while ((post_used < target_size && retries++ < 42)); do sleep 1 post_used=$(get_prop used $vol) done ((used = post_used - pre_used)) if ((used < nfilesize)); then log_fail "The space is not charged correctly while setting" \ "copies as $copies ($used < $nfilesize)" \ "pre=${pre_used} post=${post_used}" fi if [[ $type == "zfs" ]]; then log_must zpool destroy $TESTPOOL1 else log_must umount $mntp fi log_must zfs destroy $vol } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_006_pos.ksh index 3ad7d4e80562..4d1605152201 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_006_pos.ksh @@ -1,85 +1,85 @@ #!/bin/ksh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # # Copyright (c) 2015, 2016 by Delphix. All rights reserved. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib # # DESCRIPTION: # 'zfs rename' can successfully rename a volume snapshot. # # STRATEGY: # 1. Create a snapshot of volume. # 2. Rename volume snapshot to a new one. # 3. Rename volume to a new one. # 4. Create a clone of the snapshot. # 5. Verify that the rename operations are successful and zfs list can # list them. # ############################################################################### verify_runnable "global" # # cleanup defined in zfs_rename.kshlib # log_onexit cleanup log_assert "'zfs rename' can successfully rename a volume snapshot." vol=$TESTPOOL/$TESTVOL snap=$TESTSNAP log_must eval "dd if=$DATA of=$VOL_R_PATH bs=$BS count=$CNT >/dev/null 2>&1" if ! snapexists $vol@$snap; then log_must zfs snapshot $vol@$snap fi rename_dataset $vol@$snap $vol@${snap}-new rename_dataset $vol ${vol}-new rename_dataset ${vol}-new@${snap}-new ${vol}-new@$snap rename_dataset ${vol}-new $vol clone=$TESTPOOL/${snap}_clone create_clone $vol@$snap $clone -block_device_wait +block_device_wait $VOLDATA #verify data integrity for input in $VOL_R_PATH $ZVOL_RDEVDIR/$clone; do log_must eval "dd if=$input of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1" if ! cmp_data $VOLDATA $DATA ; then log_fail "$input gets corrupted after rename operation." fi done destroy_clone $clone log_must zfs destroy $vol@$snap log_pass "'zfs rename' can rename volume snapshot as expected." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh index 86baf1f6e35d..40b6ca1c1897 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh @@ -1,103 +1,103 @@ #!/bin/ksh -p # # CDDL HEADER START # # This file and its contents are supplied under the terms of the # Common Development and Distribution License ("CDDL"), version 1.0. # You may only use this file in accordance with the terms of version # 1.0 of the CDDL. # # A full copy of the text of the CDDL should have accompanied this # source. A copy of the CDDL is also available via the Internet at # http://www.illumos.org/license/CDDL. # # CDDL HEADER END # # # Copyright (c) 2017 Datto, Inc. All rights reserved. # . $STF_SUITE/include/libtest.shlib # # DESCRIPTION: # 'zpool import' should import a pool with Errata #3 while preventing # the user from performing read write operations # # STRATEGY: # 1. Import a pre-packaged pool with Errata #3 # 2. Attempt to write to the effected datasets # 3. Attempt to read from the effected datasets # 4. Attempt to perform a raw send of the effected datasets # 5. Perform a regular send of the datasets under a new encryption root # 6. Verify the new datasets can be read from and written to # 7. Destroy the old effected datasets # 8. Reimport the pool and verify that the errata is no longer present # verify_runnable "global" POOL_NAME=cryptv0 POOL_FILE=cryptv0.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" log_must bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ > /$TESTPOOL/$POOL_FILE return 0 } function cleanup { poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE return 0 } log_onexit cleanup log_assert "Verify that Errata 3 is properly handled" uncompress_pool log_must zpool import -d /$TESTPOOL/ $POOL_NAME log_must eval "zpool status $POOL_NAME | grep -q Errata" # also detects 'Errata #4' log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER" log_must eval "echo 'password' | zfs load-key $POOL_NAME/testfs" log_must eval "echo 'password' | zfs load-key $POOL_NAME/testvol" log_mustnot zfs mount $POOL_NAME/testfs log_must zfs mount -o ro $POOL_NAME/testfs old_mntpnt=$(get_prop mountpoint $POOL_NAME/testfs) log_must eval "ls $old_mntpnt | grep -q testfile" -block_device_wait +block_device_wait /dev/zvol/$POOL_NAME/testvol log_mustnot dd if=/dev/zero of=/dev/zvol/$POOL_NAME/testvol bs=512 count=1 log_must dd if=/dev/zvol/$POOL_NAME/testvol of=/dev/null bs=512 count=1 log_must zpool set feature@bookmark_v2=enabled $POOL_NAME # necessary for Errata #4 log_must eval "echo 'password' | zfs create \ -o encryption=on -o keyformat=passphrase -o keylocation=prompt \ $POOL_NAME/encroot" log_mustnot eval "zfs send -w $POOL_NAME/testfs@snap1 | \ zfs recv $POOL_NAME/encroot/testfs" log_mustnot eval "zfs send -w $POOL_NAME/testvol@snap1 | \ zfs recv $POOL_NAME/encroot/testvol" log_must eval "zfs send $POOL_NAME/testfs@snap1 | \ zfs recv $POOL_NAME/encroot/testfs" log_must eval "zfs send $POOL_NAME/testvol@snap1 | \ zfs recv $POOL_NAME/encroot/testvol" -block_device_wait +block_device_wait /dev/zvol/$POOL_NAME/encroot/testvol log_must dd if=/dev/zero of=/dev/zvol/$POOL_NAME/encroot/testvol bs=512 count=1 new_mntpnt=$(get_prop mountpoint $POOL_NAME/encroot/testfs) log_must eval "ls $new_mntpnt | grep -q testfile" log_must zfs destroy -r $POOL_NAME/testfs log_must zfs destroy -r $POOL_NAME/testvol log_must zpool export $POOL_NAME log_must zpool import -d /$TESTPOOL/ $POOL_NAME log_mustnot eval "zpool status $POOL_NAME | grep -q 'Errata #3'" log_pass "Errata 3 is properly handled" diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_volmode.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_volmode.ksh index 7451bf8b7a73..322a31e07d89 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_volmode.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_volmode.ksh @@ -1,242 +1,244 @@ #!/bin/ksh -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2017, loli10K . All rights reserved. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib . $STF_SUITE/tests/functional/zvol/zvol_common.shlib . $STF_SUITE/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib # # DESCRIPTION: # Verify that ZFS volume property "volmode" works as intended. # # STRATEGY: # 1. Verify "volmode" property does not accept invalid values # 2. Verify "volmode=none" hides ZVOL device nodes # 3. Verify "volmode=full" exposes a fully functional device # 4. Verify "volmode=dev" hides partition info on the device # 5. Verify "volmode=default" behaves accordingly to "volmode" module parameter # 6. Verify "volmode" property is inherited correctly # 7. Verify "volmode" behaves correctly at import time # 8. Verify "volmode" behaves accordingly to zvol_inhibit_dev (Linux only) # # NOTE: changing volmode may need to remove minors, which could be open, so call # udev_wait() before we "zfs set volmode=". verify_runnable "global" function cleanup { datasetexists $VOLFS && log_must_busy zfs destroy -r $VOLFS datasetexists $ZVOL && log_must_busy zfs destroy -r $ZVOL log_must zfs inherit volmode $TESTPOOL udev_wait sysctl_inhibit_dev 0 sysctl_volmode 1 udev_cleanup } # # Set zvol_inhibit_dev tunable to $value # function sysctl_inhibit_dev # value { typeset value="$1" if is_linux; then log_note "Setting zvol_inhibit_dev tunable to $value" log_must set_tunable32 VOL_INHIBIT_DEV $value fi } # # Set volmode tunable to $value # function sysctl_volmode # value { typeset value="$1" log_note "Setting volmode tunable to $value" log_must set_tunable32 VOL_MODE $value } # # Exercise open and close, read and write operations # function test_io # dev { typeset dev=$1 log_must dd if=/dev/zero of=$dev count=1 log_must dd if=$dev of=/dev/null count=1 } log_assert "Verify that ZFS volume property 'volmode' works as intended" log_onexit cleanup VOLFS="$TESTPOOL/volfs" ZVOL="$TESTPOOL/vol" ZDEV="${ZVOL_DEVDIR}/$ZVOL" SUBZVOL="$VOLFS/subvol" SUBZDEV="${ZVOL_DEVDIR}/$SUBZVOL" log_must zfs create -o mountpoint=none $VOLFS log_must zfs create -V $VOLSIZE -s $SUBZVOL log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait +blockdev_exists $ZDEV +blockdev_exists $SUBZDEV test_io $ZDEV test_io $SUBZDEV # 1. Verify "volmode" property does not accept invalid values typeset badvals=("off" "on" "1" "nope" "-") for badval in ${badvals[@]} do log_mustnot zfs set volmode="$badval" $ZVOL done # 2. Verify "volmode=none" hides ZVOL device nodes log_must zfs set volmode=none $ZVOL blockdev_missing $ZDEV log_must_busy zfs destroy $ZVOL # 3. Verify "volmode=full" exposes a fully functional device log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait log_must zfs set volmode=full $ZVOL blockdev_exists $ZDEV test_io $ZDEV log_must verify_partition $ZDEV udev_wait # 3.1 Verify "volmode=geom" is an alias for "volmode=full" log_must zfs set volmode=geom $ZVOL blockdev_exists $ZDEV if [[ "$(get_prop 'volmode' $ZVOL)" != "full" ]]; then log_fail " Volmode value 'geom' is not an alias for 'full'" fi udev_wait log_must_busy zfs destroy $ZVOL # 4. Verify "volmode=dev" hides partition info on the device log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait log_must zfs set volmode=dev $ZVOL blockdev_exists $ZDEV test_io $ZDEV log_mustnot verify_partition $ZDEV udev_wait log_must_busy zfs destroy $ZVOL # 5. Verify "volmode=default" behaves accordingly to "volmode" module parameter # 5.1 Verify sysctl "volmode=full" sysctl_volmode 1 log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait log_must zfs set volmode=default $ZVOL blockdev_exists $ZDEV log_must verify_partition $ZDEV udev_wait log_must_busy zfs destroy $ZVOL # 5.2 Verify sysctl "volmode=dev" sysctl_volmode 2 log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait log_must zfs set volmode=default $ZVOL blockdev_exists $ZDEV log_mustnot verify_partition $ZDEV udev_wait log_must_busy zfs destroy $ZVOL # 5.2 Verify sysctl "volmode=none" sysctl_volmode 3 log_must zfs create -V $VOLSIZE -s $ZVOL udev_wait log_must zfs set volmode=default $ZVOL blockdev_missing $ZDEV # 6. Verify "volmode" property is inherited correctly log_must zfs inherit volmode $ZVOL # 6.1 Check volmode=full case log_must zfs set volmode=full $TESTPOOL verify_inherited 'volmode' 'full' $ZVOL $TESTPOOL blockdev_exists $ZDEV # 6.2 Check volmode=none case log_must zfs set volmode=none $TESTPOOL verify_inherited 'volmode' 'none' $ZVOL $TESTPOOL blockdev_missing $ZDEV # 6.3 Check volmode=dev case log_must zfs set volmode=dev $TESTPOOL verify_inherited 'volmode' 'dev' $ZVOL $TESTPOOL blockdev_exists $ZDEV # 6.4 Check volmode=default case sysctl_volmode 1 log_must zfs set volmode=default $TESTPOOL verify_inherited 'volmode' 'default' $ZVOL $TESTPOOL blockdev_exists $ZDEV # 6.5 Check inheritance on multiple levels log_must zfs inherit volmode $SUBZVOL udev_wait log_must zfs set volmode=none $VOLFS udev_wait log_must zfs set volmode=full $TESTPOOL verify_inherited 'volmode' 'none' $SUBZVOL $VOLFS blockdev_missing $SUBZDEV blockdev_exists $ZDEV # 7. Verify "volmode" behaves correctly at import time log_must zpool export $TESTPOOL blockdev_missing $ZDEV blockdev_missing $SUBZDEV log_must zpool import $TESTPOOL blockdev_exists $ZDEV blockdev_missing $SUBZDEV log_must_busy zfs destroy $ZVOL log_must_busy zfs destroy $SUBZVOL # 8. Verify "volmode" behaves accordingly to zvol_inhibit_dev (Linux only) if is_linux; then sysctl_inhibit_dev 1 # 7.1 Verify device nodes not are not created with "volmode=full" sysctl_volmode 1 log_must zfs create -V $VOLSIZE -s $ZVOL blockdev_missing $ZDEV log_must zfs set volmode=full $ZVOL blockdev_missing $ZDEV log_must_busy zfs destroy $ZVOL # 7.1 Verify device nodes not are not created with "volmode=dev" sysctl_volmode 2 log_must zfs create -V $VOLSIZE -s $ZVOL blockdev_missing $ZDEV log_must zfs set volmode=dev $ZVOL blockdev_missing $ZDEV log_must_busy zfs destroy $ZVOL # 7.1 Verify device nodes not are not created with "volmode=none" sysctl_volmode 3 log_must zfs create -V $VOLSIZE -s $ZVOL blockdev_missing $ZDEV log_must zfs set volmode=none $ZVOL blockdev_missing $ZDEV fi log_pass "Verify that ZFS volume property 'volmode' works as intended"