Skip to content

Commit

Permalink
OpenZFS 6404 - zvol_swap_006_pos can occasionally fail due to swaplen…
Browse files Browse the repository at this point in the history
… being < 16

Authored by: Matthew Ahrens <mahrens@delphix.com>
6405 zvol test setup is non deterministic
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Will Andrews <will@freebsd.org>
Approved by: Dan McDonald <danmcd@omniti.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

OpenZFS-issue: https://www.illumos.org/issues/6404
OpenZFS-commit: openzfs/openzfs@24e268f
Closes #5792

Porting notes:
- Converted zfs to $ZFS until OpenZFS 7290 is ported.
  openzfs/openzfs@1d32ba6
  • Loading branch information
ahrens authored and behlendorf committed Feb 15, 2017
1 parent f9caf08 commit 3d3fe9f
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 16 deletions.
4 changes: 1 addition & 3 deletions tests/zfs-tests/tests/functional/zvol/zvol_common.shlib
Expand Up @@ -25,7 +25,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -48,8 +48,6 @@ function default_zvol_setup # disk_device volume_size

log_must $ZFS create -V $size $TESTPOOL/$TESTVOL
block_device_wait

set_dumpsize $TESTPOOL/$TESTVOL
}

#
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -44,13 +44,16 @@

verify_runnable "global"

volsize=$($ZFS get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
typeset dumpdev=$(get_dumpdevice)

if [[ $dumpdev != $savedumpdev ]] ; then
safe_dumpadm $savedumpdev
fi
$ZFS set volsize=$volsize $TESTPOOL/$TESTVOL
}

log_assert "Verify that a ZFS volume can act as dump device."
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -43,6 +43,8 @@

verify_runnable "global"

volsize=$($ZFS get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
snapexists $TESTPOOL/$TESTVOL@snap && \
Expand All @@ -52,6 +54,7 @@ function cleanup
(( $? == 0 )) && log_must $UMOUNT $TESTDIR

[[ -e $TESTDIR ]] && $RM -rf $TESTDIR
$ZFS set volsize=$volsize $TESTPOOL/$TESTVOL
}

log_assert "Verify that ZFS volume snapshot could be fscked"
Expand All @@ -61,6 +64,8 @@ TESTVOL='testvol'
BLOCKSZ=$(( 1024 * 1024 ))
NUM_WRITES=40

log_must $ZFS set volsize=128m $TESTPOOL/$TESTVOL

$ECHO "y" | $NEWFS -v ${ZVOL_RDEVDIR}/$TESTPOOL/$TESTVOL >/dev/null 2>&1
(( $? != 0 )) && log_fail "Unable to newfs(1M) $TESTPOOL/$TESTVOL"

Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -45,6 +45,8 @@

verify_runnable "global"

volsize=$($ZFS get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
typeset dumpdev=$(get_dumpdevice)
Expand All @@ -55,6 +57,7 @@ function cleanup
if poolexists $TESTPOOL1 ; then
destroy_pool $TESTPOOL1
fi
$ZFS set volsize=$volsize $TESTPOOL/$TESTVOL
}

log_assert "Verify zpool creation and newfs on dump zvol is denied."
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -44,6 +44,8 @@

verify_runnable "global"

volsize=$($ZFS get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
typeset dumpdev=$(get_dumpdevice)
Expand All @@ -62,6 +64,7 @@ function cleanup
log_must $ZFS destroy $TESTPOOL/$TESTVOL@$snap
fi
done
$ZFS set volsize=$volsize $TESTPOOL/$TESTVOL
}

function verify_snapshot
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -44,6 +44,8 @@

verify_runnable "global"

volsize=$($ZFS get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
$SWAP -l | $GREP $voldev > /dev/null 2>&1
Expand All @@ -55,6 +57,7 @@ function cleanup
if [[ $dumpdev != $savedumpdev ]] ; then
safe_dumpadm $savedumpdev
fi
$ZFS set volsize=$volsize $TESTPOOL/$TESTVOL
}

log_assert "Verify a device cannot be dump and swap at the same time."
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -44,12 +44,15 @@

verify_runnable "global"

volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL)

function cleanup
{
typeset dumpdev=$(get_dumpdevice)
if [[ $dumpdev != $savedumpdev ]] ; then
safe_dumpadm $savedumpdev
fi
zfs set volsize=$volsize $TESTPOOL/$TESTVOL
}

log_assert "zfs volume as dumpdevice should have 128k volblocksize"
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand Down Expand Up @@ -54,7 +54,7 @@ log_assert "For an added swap zvol, (2G <= volsize <= 16G)"

log_onexit cleanup

for vbs in 512 1024 2048 4096 8192 16384 32768 65536 131072; do
for vbs in 8192 16384 32768 65536 131072; do
for multiplier in 1 32 16384 131072; do
((volsize = vbs * multiplier))
vol="$TESTPOOL/vol_$volsize"
Expand Down
Expand Up @@ -26,7 +26,7 @@
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
Expand Down Expand Up @@ -75,13 +75,13 @@ log_note "Verify volume can be add as several segments."
#
# swaplow swaplen
set -A swap_opt $((pageblocks)) \
$((pageblocks * ((RANDOM % 50) + 1) + (RANDOM % pageblocks) )) \
$((RANDOM % (50 * pageblocks) + 2 * pageblocks)) \
$((volblocks / 3)) \
$((pageblocks * ((RANDOM % 50) + 1) + (RANDOM % pageblocks) )) \
$((RANDOM % (50 * pageblocks) + 2 * pageblocks)) \
$((volblocks / 2)) \
$((pageblocks * ((RANDOM % 50) + 1) + (RANDOM % pageblocks) )) \
$((RANDOM % (50 * pageblocks) + 2 * pageblocks)) \
$(((volblocks*2) / 3)) \
$((pageblocks * ((RANDOM % 50) + 1) + (RANDOM % pageblocks) ))
$((RANDOM % (50 * pageblocks) + 2 * pageblocks))

swapname=${ZVOL_DEVDIR}/$vol
typeset -i i=0 count=0
Expand Down

0 comments on commit 3d3fe9f

Please sign in to comment.