1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright (c) 2018 Datto Inc. 25# 26 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib 29. $STF_SUITE/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg 30 31# 32# DESCRIPTION: 33# "Verify 'zpool resilver' restarts in-progress resilvers" 34# 35# STRATEGY: 36# 1. Write some data and detatch the first drive so it has resilver 37# work to do 38# 2. Repeat the process with a second disk 39# 3. Reattach the drives, causing the second drive's resilver to be 40# deferred 41# 4. Manually restart the resilver with all drives 42# 43 44verify_runnable "global" 45 46function cleanup 47{ 48 log_must set_tunable32 zfs_scan_suspend_progress 0 49 log_must rm -f $mntpnt/biggerfile1 50 log_must rm -f $mntpnt/biggerfile2 51} 52 53log_onexit cleanup 54 55log_assert "Verify 'zpool resilver' restarts in-progress resilvers" 56 57mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) 58 59# 1. Write some data and detatch the first drive so it has resilver work to do 60log_must file_write -b 524288 -c 1024 -o create -d 0 -f $mntpnt/biggerfile1 61log_must sync 62log_must zpool detach $TESTPOOL $DISK2 63 64# 2. Repeat the process with a second disk 65log_must file_write -b 524288 -c 1024 -o create -d 0 -f $mntpnt/biggerfile2 66log_must sync 67log_must zpool detach $TESTPOOL $DISK3 68 69# 3. Reattach the drives, causing the second drive's resilver to be deferred 70log_must set_tunable32 zfs_scan_suspend_progress 1 71 72log_must zpool attach $TESTPOOL $DISK1 $DISK2 73log_must is_pool_resilvering $TESTPOOL true 74 75log_must zpool attach $TESTPOOL $DISK1 $DISK3 76log_must is_pool_resilvering $TESTPOOL true 77 78# 4. Manually restart the resilver with all drives 79log_must zpool resilver $TESTPOOL 80log_must is_deferred_scan_started $TESTPOOL 81log_must set_tunable32 zfs_scan_suspend_progress 0 82log_must wait_for_resilver_end $TESTPOOL $MAXTIMEOUT 83log_must check_state $TESTPOOL "$DISK2" "online" 84log_must check_state $TESTPOOL "$DISK3" "online" 85 86log_pass "Verified 'zpool resilver' restarts in-progress resilvers" 87