From 2939286ddacee526d182d01b948e2e37f5f9de1b Mon Sep 17 00:00:00 2001 From: loli10K Date: Tue, 20 Mar 2018 08:34:58 +0100 Subject: [PATCH] [WIP] Fix "add_nested_replacing_spare" test case Use 'zpool reopen' instead of 'zpool scrub' to kick in the spare device: this is required to avoid spurious failures caused by a race condition in events processing by the ZFS Event Daemon: P1 (zpool scrub) P2 (zed) --- zfs_ioc_pool_scan() -> dsl_scan() -> vdev_reopen() -> vdev_set_state(VDEV_STATE_CANT_OPEN) zfs_ioc_vdev_attach() -> spa_vdev_attach() -> dsl_resilver_restart() -> dsl_sync_task() -> dsl_scan_setup_check() <- dsl_scan_setup_check(): EBUSY Signed-off-by: loli10K Requires-builders: test --- TEST | 11 ++-- module/zfs/zfs_ioctl.c | 6 +-- tests/runfiles/temp.run | 50 +++++++++++++++++++ .../zpool_add/add_nested_replacing_spare.ksh | 2 +- 4 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 tests/runfiles/temp.run diff --git a/TEST b/TEST index 4c593a457078..89a042d1dc0c 100644 --- a/TEST +++ b/TEST @@ -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" @@ -39,10 +39,11 @@ #TEST_ZFSTESTS_ITERS="1" #TEST_ZFSTESTS_OPTIONS="-vx" #TEST_ZFSTESTS_RUNFILE="linux.run" +TEST_ZFSTESTS_RUNFILE="temp.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 diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 8ef4cc46f09b..1e987dc885c4 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -1732,12 +1732,12 @@ zfs_ioc_pool_scan(zfs_cmd_t *zc) spa_t *spa; int error; - if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) - return (error); - if (zc->zc_flags >= POOL_SCRUB_FLAGS_END) return (SET_ERROR(EINVAL)); + if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) + return (error); + if (zc->zc_flags == POOL_SCRUB_PAUSE) error = spa_scrub_pause_resume(spa, POOL_SCRUB_PAUSE); else if (zc->zc_cookie == POOL_SCAN_NONE) diff --git a/tests/runfiles/temp.run b/tests/runfiles/temp.run new file mode 100644 index 000000000000..023ac89b7338 --- /dev/null +++ b/tests/runfiles/temp.run @@ -0,0 +1,50 @@ +# +# 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_add] +tests = ['add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare', + 'add_nested_replacing_spare', 'add_nested_replacing_spare'] +tags = ['functional', 'cli_root', 'zpool_add'] + diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh index b38079852d1c..ec94df8356ab 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh @@ -79,7 +79,7 @@ do # 2.1 Fault a device, verify the spare is kicked in log_must zinject -d $FAULT_DEV -e nxio -T all -f 100 $TESTPOOL - log_must zpool scrub $TESTPOOL + log_must zpool reopen $TESTPOOL log_must wait_vdev_state $TESTPOOL $FAULT_DEV "UNAVAIL" 60 log_must wait_vdev_state $TESTPOOL $SPARE_DEV1 "ONLINE" 60 log_must wait_hotspare_state $TESTPOOL $SPARE_DEV1 "INUSE"