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