Skip to content

Commit

Permalink
ZTS: Waiting for zvols to be available
Browse files Browse the repository at this point in the history
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 <mail@gmelikov.ru>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12515
  • Loading branch information
behlendorf committed Aug 31, 2021
1 parent 5eaecd3 commit d9f4962
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/zfs-tests/include/blkdev.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,37 +117,37 @@ 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

# Rename snapshot and re-clone dataset
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d9f4962

Please sign in to comment.