1#!/usr/local/bin/ksh93 2# 3# Copyright (c) 2017 Spectra Logic Corporation 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions, and the following disclaimer, 11# without modification. 12# 2. Redistributions in binary form must reproduce at minimum a disclaimer 13# substantially similar to the "NO WARRANTY" disclaimer below 14# ("Disclaimer") and any redistribution must be conditioned upon 15# including a substantially similar Disclaimer requirement for further 16# binary redistribution. 17# 18# NO WARRANTY 19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# POSSIBILITY OF SUCH DAMAGES. 30# 31 32. $STF_SUITE/include/libtest.kshlib 33set_disks 34 35# A destroyed pool cannot be imported, even if an out-of-date non-destroyed 36# label is present 37# 38# This situation arose when a user activated a spare, removed the spare disk, 39# destroyed the pool, reinserted the spare disk, and then tried to import the 40# pool. Since the pool was destroyed, nothing should've happened. But the 41# spare disk had a non-destroyed label, so zpool tried to import it. A panic 42# ensued. 43# 44# More generally, this situation can happen any time the following things happen: 45# 1) A disk gets removed with its label intact 46# 2) The pool's configuration changes 47# 3) The pool gets destroyed 48# 4) Somebody tries to import the pool 49 50log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1} 51 52# Offline a disk so it's label won't get updated by the upcoming destroy 53log_must $ZPOOL offline $TESTPOOL ${DISK0} 54 55# Now change the pool's configuration, so DISK0's label will be out-of-date 56log_must $ZPOOL attach $TESTPOOL ${DISK1} ${DISK2} 57 58# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed 59# state, leaving DISK0's label as the most recent non-destroyed label 60log_must $ZPOOL destroy $TESTPOOL 61 62# Now try to import the pool. It should fail. 63log_mustnot $ZPOOL import $TESTPOOL 64 65log_pass 66