1#!/usr/local/bin/ksh93 -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 2023 Axcient. All rights reserved. 25# Use is subject to license terms. 26# 27 28. $STF_SUITE/tests/hotspare/hotspare.kshlib 29. $STF_SUITE/tests/zfsd/zfsd.kshlib 30. $STF_SUITE/include/libtest.kshlib 31. $STF_SUITE/include/libgnop.kshlib 32 33log_assert "ZFSD will automatically replace a multi-pool spare that disappears and reappears" 34 35ensure_zfsd_running 36 37set_disks 38 39typeset DISK0_NOP=${DISK0}.nop 40typeset DISK1_NOP=${DISK1}.nop 41typeset DISK2_NOP=${DISK2}.nop 42 43log_must create_gnops $DISK0 $DISK1 $DISK2 44 45# Create pools on the supplied disks 46create_pool $TESTPOOL $DISK0_NOP spare $DISK2_NOP 47create_pool $TESTPOOL1 $DISK1_NOP spare $DISK2_NOP 48 49# Disable the spare disk. 50log_must destroy_gnop $DISK2 51 52# Check to make sure ZFS sees the disk as removed 53wait_for_pool_dev_state_change 20 $DISK2_NOP REMOVED 54wait_for_pool_dev_state_change 20 $DISK2_NOP REMOVED $TESTPOOL1 55 56# Re-enable the disk 57log_must create_gnop $DISK2 58 59# Disk should auto-join the zpools 60wait_for_pool_dev_state_change 20 $DISK2_NOP AVAIL 61wait_for_pool_dev_state_change 20 $DISK2_NOP AVAIL $TESTPOOL1 62 63$ZPOOL status $TESTPOOL 64$ZPOOL status $TESTPOOL1 65destroy_pool $TESTPOOL 66destroy_pool $TESTPOOL1 67log_must $RM -rf /$TESTPOOL 68 69log_pass 70