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 spare that disappears and reappears in the same location, with the same devname" 34 35ensure_zfsd_running 36 37set_disks 38 39typeset DISK0_NOP=${DISK0}.nop 40typeset DISK1_NOP=${DISK1}.nop 41 42log_must create_gnops $DISK0 $DISK1 43 44# Create a pool on the supplied disks 45create_pool $TESTPOOL $DISK0_NOP spare $DISK1_NOP 46 47# Disable the first disk. 48log_must destroy_gnop $DISK1 49 50# Check to make sure ZFS sees the disk as removed 51wait_for_pool_dev_state_change 20 $DISK1_NOP REMOVED 52 53# Re-enable the disk 54log_must create_gnop $DISK1 55 56# Disk should auto-join the zpool 57wait_for_pool_dev_state_change 20 $DISK1_NOP AVAIL 58 59$ZPOOL status $TESTPOOL 60destroy_pool $TESTPOOL 61log_must $RM -rf /$TESTPOOL 62 63log_pass 64