1d583b39bSJohn Wren Kennedy#!/bin/ksh -p 2d583b39bSJohn Wren Kennedy# 3d583b39bSJohn Wren Kennedy# CDDL HEADER START 4d583b39bSJohn Wren Kennedy# 5d583b39bSJohn Wren Kennedy# The contents of this file are subject to the terms of the 6d583b39bSJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7d583b39bSJohn Wren Kennedy# You may not use this file except in compliance with the License. 8d583b39bSJohn Wren Kennedy# 9d583b39bSJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10d583b39bSJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11d583b39bSJohn Wren Kennedy# See the License for the specific language governing permissions 12d583b39bSJohn Wren Kennedy# and limitations under the License. 13d583b39bSJohn Wren Kennedy# 14d583b39bSJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15d583b39bSJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16d583b39bSJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17d583b39bSJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18d583b39bSJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19d583b39bSJohn Wren Kennedy# 20d583b39bSJohn Wren Kennedy# CDDL HEADER END 21d583b39bSJohn Wren Kennedy# 22d583b39bSJohn Wren Kennedy 23d583b39bSJohn Wren Kennedy# 24d583b39bSJohn Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25d583b39bSJohn Wren Kennedy# Use is subject to license terms. 26d583b39bSJohn Wren Kennedy# 27d583b39bSJohn Wren Kennedy 28d583b39bSJohn Wren Kennedy# 291d32ba66SJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30d583b39bSJohn Wren Kennedy# 31d583b39bSJohn Wren Kennedy 32d583b39bSJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 33d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg 34d583b39bSJohn Wren Kennedy 35d583b39bSJohn Wren Kennedy# 36d583b39bSJohn Wren Kennedy# DESCRIPTION: 37d583b39bSJohn Wren Kennedy# Resilver prevent scrub from starting until the resilver completes 38d583b39bSJohn Wren Kennedy# 39d583b39bSJohn Wren Kennedy# STRATEGY: 40d583b39bSJohn Wren Kennedy# 1. Setup a mirror pool and filled with data. 41d583b39bSJohn Wren Kennedy# 2. Detach one of devices 42*e4c795beSTom Caputi# 3. Create a file for the resilver to work on so it takes some time 43*e4c795beSTom Caputi# 4. Export/import the pool to ensure the cache is dropped 44*e4c795beSTom Caputi# 5. Verify scrub failed until the resilver completed 45d583b39bSJohn Wren Kennedy# 46d583b39bSJohn Wren Kennedy 47a3874b8bSToomas Soomefunction cleanup 48a3874b8bSToomas Soome{ 49*e4c795beSTom Caputi log_must set_tunable32 zfs_scan_suspend_progress 0 50*e4c795beSTom Caputi rm -f $mntpnt/extra 51a3874b8bSToomas Soome} 52a3874b8bSToomas Soome 53d583b39bSJohn Wren Kennedyverify_runnable "global" 54d583b39bSJohn Wren Kennedy 55*e4c795beSTom Caputilog_onexit cleanup 56*e4c795beSTom Caputi 57d583b39bSJohn Wren Kennedylog_assert "Resilver prevent scrub from starting until the resilver completes" 58d583b39bSJohn Wren Kennedy 59*e4c795beSTom Caputimntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) 60*e4c795beSTom Caputi 61*e4c795beSTom Caputi# Temporarily prevent scan progress so our test doesn't race 62*e4c795beSTom Caputilog_must set_tunable32 zfs_scan_suspend_progress 1 63*e4c795beSTom Caputi 64*e4c795beSTom Caputiwhile ! is_pool_resilvering $TESTPOOL; do 65*e4c795beSTom Caputi log_must zpool detach $TESTPOOL $DISK2 66*e4c795beSTom Caputi log_must file_write -b 1048576 -c 128 -o create -d 0 -f $mntpnt/extra 67*e4c795beSTom Caputi log_must zpool export $TESTPOOL 68*e4c795beSTom Caputi log_must zpool import $TESTPOOL 69*e4c795beSTom Caputi log_must zpool attach $TESTPOOL $DISK1 $DISK2 70*e4c795beSTom Caputidone 71*e4c795beSTom Caputi 72d583b39bSJohn Wren Kennedylog_must is_pool_resilvering $TESTPOOL 731d32ba66SJohn Wren Kennedylog_mustnot zpool scrub $TESTPOOL 74d583b39bSJohn Wren Kennedy 75*e4c795beSTom Caputilog_must set_tunable32 zfs_scan_suspend_progress 0 76d583b39bSJohn Wren Kennedywhile ! is_pool_resilvered $TESTPOOL; do 771d32ba66SJohn Wren Kennedy sleep 1 78d583b39bSJohn Wren Kennedydone 79d583b39bSJohn Wren Kennedy 80d583b39bSJohn Wren Kennedylog_pass "Resilver prevent scrub from starting until the resilver completes" 81