1*4e8d558cSMartin Matuska#!/bin/ksh -p 2*4e8d558cSMartin Matuska# 3*4e8d558cSMartin Matuska# CDDL HEADER START 4*4e8d558cSMartin Matuska# 5*4e8d558cSMartin Matuska# The contents of this file are subject to the terms of the 6*4e8d558cSMartin Matuska# Common Development and Distribution License (the "License"). 7*4e8d558cSMartin Matuska# You may not use this file except in compliance with the License. 8*4e8d558cSMartin Matuska# 9*4e8d558cSMartin Matuska# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*4e8d558cSMartin Matuska# or http://www.opensolaris.org/os/licensing. 11*4e8d558cSMartin Matuska# See the License for the specific language governing permissions 12*4e8d558cSMartin Matuska# and limitations under the License. 13*4e8d558cSMartin Matuska# 14*4e8d558cSMartin Matuska# When distributing Covered Code, include this CDDL HEADER in each 15*4e8d558cSMartin Matuska# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*4e8d558cSMartin Matuska# If applicable, add the following below this CDDL HEADER, with the 17*4e8d558cSMartin Matuska# fields enclosed by brackets "[]" replaced with your own identifying 18*4e8d558cSMartin Matuska# information: Portions Copyright [yyyy] [name of copyright owner] 19*4e8d558cSMartin Matuska# 20*4e8d558cSMartin Matuska# CDDL HEADER END 21*4e8d558cSMartin Matuska# 22*4e8d558cSMartin Matuska 23*4e8d558cSMartin Matuska# 24*4e8d558cSMartin Matuska# Copyright (c) 2023 Hewlett Packard Enterprise Development LP. 25*4e8d558cSMartin Matuska# 26*4e8d558cSMartin Matuska 27*4e8d558cSMartin Matuska. $STF_SUITE/include/libtest.shlib 28*4e8d558cSMartin Matuska. $STF_SUITE/tests/functional/redundancy/redundancy.kshlib 29*4e8d558cSMartin Matuska 30*4e8d558cSMartin Matuska# 31*4e8d558cSMartin Matuska# DESCRIPTION: 32*4e8d558cSMartin Matuska# Verify 'zpool clear' doesn't cause concurrent resilvers 33*4e8d558cSMartin Matuska# 34*4e8d558cSMartin Matuska# STRATEGY: 35*4e8d558cSMartin Matuska# 1. Create N(10) virtual disk files. 36*4e8d558cSMartin Matuska# 2. Create draid pool based on the virtual disk files. 37*4e8d558cSMartin Matuska# 3. Fill the filesystem with directories and files. 38*4e8d558cSMartin Matuska# 4. Force-fault 2 vdevs and verify distributed spare is kicked in. 39*4e8d558cSMartin Matuska# 5. Free the distributed spare by replacing the faulty drive. 40*4e8d558cSMartin Matuska# 6. Run zpool clear and verify that it does not initiate 2 resilvers 41*4e8d558cSMartin Matuska# concurrently while distributed spare gets kicked in. 42*4e8d558cSMartin Matuska# 43*4e8d558cSMartin Matuska 44*4e8d558cSMartin Matuskaverify_runnable "global" 45*4e8d558cSMartin Matuska 46*4e8d558cSMartin Matuskatypeset -ir devs=10 47*4e8d558cSMartin Matuskatypeset -ir nparity=1 48*4e8d558cSMartin Matuskatypeset -ir ndata=8 49*4e8d558cSMartin Matuskatypeset -ir dspare=1 50*4e8d558cSMartin Matuska 51*4e8d558cSMartin Matuskafunction cleanup 52*4e8d558cSMartin Matuska{ 53*4e8d558cSMartin Matuska poolexists "$TESTPOOL" && destroy_pool "$TESTPOOL" 54*4e8d558cSMartin Matuska 55*4e8d558cSMartin Matuska for i in {0..$devs}; do 56*4e8d558cSMartin Matuska log_must rm -f "$BASEDIR/vdev$i" 57*4e8d558cSMartin Matuska done 58*4e8d558cSMartin Matuska 59*4e8d558cSMartin Matuska for dir in $BASEDIR; do 60*4e8d558cSMartin Matuska if [[ -d $dir ]]; then 61*4e8d558cSMartin Matuska log_must rm -rf $dir 62*4e8d558cSMartin Matuska fi 63*4e8d558cSMartin Matuska done 64*4e8d558cSMartin Matuska 65*4e8d558cSMartin Matuska zed_stop 66*4e8d558cSMartin Matuska zed_cleanup 67*4e8d558cSMartin Matuska} 68*4e8d558cSMartin Matuska 69*4e8d558cSMartin Matuskalog_assert "Verify zpool clear on draid pool doesn't cause concurrent resilvers" 70*4e8d558cSMartin Matuskalog_onexit cleanup 71*4e8d558cSMartin Matuska 72*4e8d558cSMartin Matuskasetup_test_env $TESTPOOL draid${nparity}:${ndata}d:${dspare}s $devs 73*4e8d558cSMartin Matuska 74*4e8d558cSMartin Matuska# ZED needed for sequential resilver 75*4e8d558cSMartin Matuskazed_setup 76*4e8d558cSMartin Matuskalog_must zed_start 77*4e8d558cSMartin Matuska 78*4e8d558cSMartin Matuskalog_must zpool offline -f $TESTPOOL $BASEDIR/vdev5 79*4e8d558cSMartin Matuskalog_must wait_vdev_state $TESTPOOL draid1-0-0 "ONLINE" 60 80*4e8d558cSMartin Matuskalog_must zpool wait -t resilver $TESTPOOL 81*4e8d558cSMartin Matuskalog_must zpool offline -f $TESTPOOL $BASEDIR/vdev6 82*4e8d558cSMartin Matuska 83*4e8d558cSMartin Matuskalog_must zpool labelclear -f $BASEDIR/vdev5 84*4e8d558cSMartin Matuskalog_must zpool labelclear -f $BASEDIR/vdev6 85*4e8d558cSMartin Matuska 86*4e8d558cSMartin Matuskalog_must zpool replace -w $TESTPOOL $BASEDIR/vdev5 87*4e8d558cSMartin Matuskasync_pool $TESTPOOL 88*4e8d558cSMartin Matuska 89*4e8d558cSMartin Matuskalog_must zpool events -c 90*4e8d558cSMartin Matuskalog_must zpool clear $TESTPOOL 91*4e8d558cSMartin Matuskalog_must wait_vdev_state $TESTPOOL draid1-0-0 "ONLINE" 60 92*4e8d558cSMartin Matuskalog_must zpool wait -t resilver $TESTPOOL 93*4e8d558cSMartin Matuskalog_must zpool wait -t scrub $TESTPOOL 94*4e8d558cSMartin Matuska 95*4e8d558cSMartin Matuskanof_resilver=$(zpool events | grep -c resilver_start) 96*4e8d558cSMartin Matuskaif [ $nof_resilver = 1 ] ; then 97*4e8d558cSMartin Matuska log_must verify_pool $TESTPOOL 98*4e8d558cSMartin Matuska log_pass "zpool clear on draid pool doesn't cause concurrent resilvers" 99*4e8d558cSMartin Matuskaelse 100*4e8d558cSMartin Matuska log_fail "FAIL: sequential and healing resilver initiated concurrently" 101*4e8d558cSMartin Matuskafi 102