Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZTS: Make do_vol_test() more deterministic #16379

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function do_vol_test
vol=$TESTPOOL/$TESTVOL1
vol_b_path=$ZVOL_DEVDIR/$TESTPOOL/$TESTVOL1

log_must zfs create -V $VOLSIZE -o copies=$copies $vol
log_must zfs create -V $VOLSIZE -o compression=off -o copies=$copies \
$vol
log_must zfs set refreservation=none $vol
block_device_wait $vol_b_path

Expand Down Expand Up @@ -116,31 +117,30 @@ function do_vol_test
else
log_must zpool create $TESTPOOL1 $vol_b_path
fi
log_must zfs create $TESTPOOL1/$TESTFS1
log_must zfs create -o compression=off $TESTPOOL1/$TESTFS1
sync_pool $TESTPOOL1
;;
*)
log_unsupported "$type test not implemented"
;;
esac

((nfilesize = copies * ${FILESIZE%m}))
sync_pool $TESTPOOL
pre_used=$(get_prop used $vol)
((target_size = pre_used + nfilesize))

if [[ $type == "zfs" ]]; then
log_must mkfile $FILESIZE /$TESTPOOL1/$TESTFS1/$FILE
sync_pool $TESTPOOL1
else
log_must mkfile $FILESIZE $mntp/$FILE
log_must sync
fi

sync_pool $TESTPOOL
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))
((nfilesize = copies * ${FILESIZE%m}))
if ((used < nfilesize)); then
log_fail "The space is not charged correctly while setting" \
"copies as $copies ($used < $nfilesize)" \
Expand Down
Loading