Skip to content

Commit

Permalink
ZTS: Fix create-o_ashift test case
Browse files Browse the repository at this point in the history
The function that fills the uberblock ring buffer on every device label
has been reworked to avoid occasional failures caused by a race
condition that prevents 'zpool sync' from writing some uberblock
sequentially: this happens when the pool sync ioctl dispatch code calls
txg_wait_synced() while we're already waiting for a TXG to sync.

Signed-off-by: loli10K <[email protected]>
Requires-builders: style test
  • Loading branch information
loli10K committed Dec 17, 2017
1 parent f6940bb commit 59001cf
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 38 deletions.
11 changes: 6 additions & 5 deletions TEST
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
#TEST_PREPARE_SHARES="yes"

### SPLAT
#TEST_SPLAT_SKIP="yes"
TEST_SPLAT_SKIP="yes"
#TEST_SPLAT_OPTIONS="-acvx"

### ztest
#TEST_ZTEST_SKIP="yes"
TEST_ZTEST_SKIP="yes"
#TEST_ZTEST_TIMEOUT=1800
#TEST_ZTEST_DIR="/var/tmp/"
#TEST_ZTEST_OPTIONS="-V"
#TEST_ZTEST_CORE_DIR="/mnt/zloop"

### zimport
#TEST_ZIMPORT_SKIP="yes"
TEST_ZIMPORT_SKIP="yes"
#TEST_ZIMPORT_DIR="/var/tmp/zimport"
#TEST_ZIMPORT_VERSIONS="master installed"
#TEST_ZIMPORT_POOLS="zol-0.6.1 zol-0.6.2 master installed"
#TEST_ZIMPORT_OPTIONS="-c"

### xfstests
#TEST_XFSTESTS_SKIP="yes"
TEST_XFSTESTS_SKIP="yes"
#TEST_XFSTESTS_URL="https://github.com/behlendorf/xfstests/archive/"
#TEST_XFSTESTS_VER="zfs.tar.gz"
#TEST_XFSTESTS_POOL="tank"
Expand All @@ -39,10 +39,11 @@
#TEST_ZFSTESTS_ITERS="1"
#TEST_ZFSTESTS_OPTIONS="-vx"
#TEST_ZFSTESTS_RUNFILE="linux.run"
TEST_ZFSTESTS_RUNFILE="create-o_ashift.run"
#TEST_ZFSTESTS_TAGS="functional"

### zfsstress
#TEST_ZFSSTRESS_SKIP="yes"
TEST_ZFSSTRESS_SKIP="yes"
#TEST_ZFSSTRESS_URL="https://github.com/nedbass/zfsstress/archive/"
#TEST_ZFSSTRESS_VER="master.tar.gz"
#TEST_ZFSSTRESS_RUNTIME=300
Expand Down
8 changes: 4 additions & 4 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2788,17 +2788,17 @@ dump_label(const char *dev)
exit(1);
}

if (ioctl(fd, BLKFLSBUF) != 0)
(void) printf("failed to invalidate cache '%s' : %s\n", path,
strerror(errno));

if (fstat64_blk(fd, &statbuf) != 0) {
(void) printf("failed to stat '%s': %s\n", path,
strerror(errno));
(void) close(fd);
exit(1);
}

if (S_ISBLK(statbuf.st_mode) && ioctl(fd, BLKFLSBUF) != 0)
(void) printf("failed to invalidate cache '%s' : %s\n", path,
strerror(errno));

avl_create(&config_tree, cksum_record_compare,
sizeof (cksum_record_t), offsetof(cksum_record_t, link));
avl_create(&uberblock_tree, cksum_record_compare,
Expand Down
34 changes: 34 additions & 0 deletions tests/runfiles/create-o_ashift.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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.
#

[DEFAULT]
pre = setup
quiet = False
pre_user = root
user = root
timeout = 600
post_user = root
post = cleanup
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/cli_root/zpool_create]
tests = ['create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift',
'create-o_ashift', 'create-o_ashift', 'create-o_ashift']
tags = ['functional', 'cli_root', 'zpool_create']

Original file line number Diff line number Diff line change
Expand Up @@ -42,54 +42,47 @@

verify_runnable "global"

# See issue: https://github.com/zfsonlinux/zfs/issues/6924
if is_linux; then
log_unsupported "Test case occasionally fails"
fi

function cleanup
{
poolexists $TESTPOOL && destroy_pool $TESTPOOL
destroy_pool $TESTPOOL
log_must rm -f $disk
}

#
# Commit the specified number of TXGs to the provided pool
# We use 'zpool sync' here because we can't force it via sync(1) like on illumos
# $1 pool name
# $2 number of txg syncs
# Fill the uberblock ring in every <device> label: we do this by committing
# TXGs to the provided <pool> until every slot contains a valid uberblock.
# NOTE: We use 'zpool sync' here because we can't force it via sync(1) like on
# illumos
#
function txg_sync
function write_device_uberblocks # <device> <pool>
{
typeset pool=$1
typeset -i count=$2
typeset -i i=0;
typeset device=$1
typeset pool=$2

while [ $i -lt $count ]
while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ]
do
log_must sync_pool $pool true
((i = i + 1))
done
}

#
# Verify device $1 labels contains $2 valid uberblocks in every label
# $1 device
# $2 uberblocks count
# Verify every label on <device> contains <count> (valid) uberblocks
#
function verify_device_uberblocks
function verify_device_uberblocks # <device> <count>
{
typeset device=$1
typeset ubcount=$2

zdb -quuul $device | egrep '^(\s+)?Uberblock' |
egrep -v 'invalid$' | awk \
-v ubcount=$ubcount '{ uberblocks[$0]++; }
END { for (i in uberblocks) {
count++;
if (uberblocks[i] != 4) { exit 1; }
}
if (count != ubcount) { exit 1; } }'
awk -v ubcount=$ubcount 'BEGIN { count=0 } { uberblocks[$0]++; }
END {
for (i in uberblocks) {
if (i ~ /invalid/) { continue; }
if (uberblocks[i] != 4) { exit 1; }
count++;
}
if (count != ubcount) { exit 1; }
}'

return $?
}
Expand All @@ -115,8 +108,7 @@ do
log_fail "Pool was created without setting ashift value to "\
"$ashift (current = $pprop)"
fi
# force 128 txg sync to fill the uberblock ring
txg_sync $TESTPOOL 128
write_device_uberblocks $disk $TESTPOOL
verify_device_uberblocks $disk ${ubcount[$i]}
if [[ $? -ne 0 ]]
then
Expand Down

0 comments on commit 59001cf

Please sign in to comment.