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# $FreeBSD$ 32 33. $STF_SUITE/include/libtest.kshlib 34set_disks 35 36# A destroyed pool cannot be imported, even if an out-of-date non-destroyed 37# label is present 38# 39# This situation arose when a user activated a spare, removed the spare disk, 40# destroyed the pool, reinserted the spare disk, and then tried to import the 41# pool. Since the pool was destroyed, nothing should've happened. But the 42# spare disk had a non-destroyed label, so zpool tried to import it. A panic 43# ensued. 44# 45# More generally, this situation can happen any time the following things happen: 46# 1) A disk gets removed with its label intact 47# 2) The pool's configuration changes 48# 3) The pool gets destroyed 49# 4) Somebody tries to import the pool 50 51log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1} 52 53# Offline a disk so it's label won't get updated by the upcoming destroy 54log_must $ZPOOL offline $TESTPOOL ${DISK0} 55 56# Now change the pool's configuration, so DISK0's label will be out-of-date 57log_must $ZPOOL attach $TESTPOOL ${DISK1} ${DISK2} 58 59# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed 60# state, leaving DISK0's label as the most recent non-destroyed label 61log_must $ZPOOL destroy $TESTPOOL 62 63# Now try to import the pool. It should fail. 64log_mustnot $ZPOOL import $TESTPOOL 65 66log_pass 67