Skip to content

Commit

Permalink
Fix add_nested_replacing_spare test case
Browse files Browse the repository at this point in the history
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 <ezomori.nozomu@gmail.com>
  • Loading branch information
loli10K committed Apr 2, 2018
1 parent 10adee2 commit 2f9f138
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2f9f138

Please sign in to comment.