From 6bb6410570e6aeb19ae82d9287922927432f8c74 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Sun, 29 Aug 2021 08:56:58 -0700 Subject: [PATCH] ZTS: Waiting for zvols to be available The ZTS block_device_wait helper function should use -e when waiting for a file to appear since it will be either a block special device or a symlink. This didn't cause any failures but when a device path was specified the function would wait longer than needed. Additionally update the most flakey test cases to pass the file path to block_device_wait to try and improve the test reliability. The udev behavior on Fedora in particular can result in frequent false positives. Reviewed-by: George Melikov Reviewed-by: John Kennedy Signed-off-by: Brian Behlendorf Closes #12515 --- tests/zfs-tests/include/blkdev.shlib | 2 +- .../functional/cli_root/zfs_copies/zfs_copies.kshlib | 2 +- .../functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh | 8 ++++---- .../tests/functional/rsend/recv_dedup_encrypted_zvol.ksh | 2 +- .../functional/rsend/send-c_stream_size_estimate.ksh | 2 +- .../tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index 3f29d4f594..bcba8ee759 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -93,7 +93,7 @@ function block_device_wait typeset missing=false typeset dev for dev in "${@}"; do - if ! [[ -f $dev ]]; then + if ! [[ -e $dev ]]; then missing=true break fi 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 e886de432a..c2ccb24384 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 @@ -87,7 +87,7 @@ function do_vol_test log_must zfs create -V $VOLSIZE -o copies=$copies $vol log_must zfs set refreservation=none $vol - block_device_wait + block_device_wait $vol_r_path case "$type" in "ext2") diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh index 3623d2bca1..0cacb7a98f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh @@ -117,26 +117,26 @@ log_must diff $SRC_FILE $obj if is_global_zone; then vol=$TESTPOOL/$TESTFS/vol.$$ ; volclone=$TESTPOOL/$TESTFS/volclone.$$ log_must zfs create -V 100M $vol - block_device_wait obj=$(target_obj $vol) + block_device_wait $obj log_must dd if=$SRC_FILE of=$obj bs=$BS count=$CNT snap=${vol}@snap.$$ log_must zfs snapshot $snap log_must zfs clone $snap $volclone - block_device_wait # Rename dataset & clone log_must zfs rename $vol ${vol}-new log_must zfs rename $volclone ${volclone}-new - block_device_wait # Compare source file and target file obj=$(target_obj ${vol}-new) + block_device_wait $obj log_must dd if=$obj of=$DST_FILE bs=$BS count=$CNT log_must diff $SRC_FILE $DST_FILE obj=$(target_obj ${volclone}-new) + block_device_wait $obj log_must dd if=$obj of=$DST_FILE bs=$BS count=$CNT log_must diff $SRC_FILE $DST_FILE @@ -144,10 +144,10 @@ if is_global_zone; then log_must zfs rename ${vol}-new $vol log_must zfs rename $snap ${snap}-new log_must zfs clone ${snap}-new $volclone - block_device_wait # Compare source file and target file obj=$(target_obj $volclone) + block_device_wait $obj log_must dd if=$obj of=$DST_FILE bs=$BS count=$CNT log_must diff $SRC_FILE $DST_FILE fi diff --git a/tests/zfs-tests/tests/functional/rsend/recv_dedup_encrypted_zvol.ksh b/tests/zfs-tests/tests/functional/rsend/recv_dedup_encrypted_zvol.ksh index 569fcd893e..daf559d264 100755 --- a/tests/zfs-tests/tests/functional/rsend/recv_dedup_encrypted_zvol.ksh +++ b/tests/zfs-tests/tests/functional/rsend/recv_dedup_encrypted_zvol.ksh @@ -52,7 +52,7 @@ log_must eval "bzcat <$sendfile_compressed >$sendfile" log_must eval "zstream redup $sendfile | zfs recv $TESTPOOL/recv" log_must zfs load-key $TESTPOOL/recv -block_device_wait +block_device_wait $volfile log_must eval "bzcat <$volfile_compressed >$volfile" log_must diff $volfile $recvdev diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh index 840b5f0859..b3edb1c457 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh @@ -65,7 +65,7 @@ for compress in "${compress_prop_vals[@]}"; do datasetexists $send_vol && log_must_busy zfs destroy -r $send_vol log_must zfs create -o compress=$compress $send_ds log_must zfs create -V 1g -o compress=$compress $send_vol - block_device_wait + block_device_wait $send_voldev typeset dir=$(get_prop mountpoint $send_ds) log_must cp $file $dir diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh index be72576707..cf1e6359bd 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh @@ -62,7 +62,7 @@ for vbs in 8192 16384 32768 65536 131072; do # Create a sparse volume to test larger sizes log_must zfs create -s -b $vbs -V $volsize $vol - block_device_wait + block_device_wait $swapname log_must swap_setup $swapname new_volsize=$(get_prop volsize $vol)