1#!/bin/ksh -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 https://opensource.org/licenses/CDDL-1.0. 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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30# Copyright (c) 2020 Lawrence Livermore National Security, LLC. 31# 32 33. $STF_SUITE/include/libtest.shlib 34. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg 35 36# 37# DESCRIPTION: 38# For draid, one destroyed pools devices was removed or used by other 39# pool, it still can be imported correctly. 40# 41# STRATEGY: 42# 1. Create a draid pool A with N disks. 43# 2. Destroy this pool A. 44# 3. Create another pool B with 1 disk which was used by pool A. 45# 4. Verify import this draid pool can succeed. 46# 47 48verify_runnable "global" 49 50function cleanup 51{ 52 destroy_pool $TESTPOOL2 53 destroy_pool $TESTPOOL1 54 55 log_must rm -rf $DEVICE_DIR/* 56 typeset i=0 57 while (( i < $MAX_NUM )); do 58 log_must mkfile $FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i 59 ((i += 1)) 60 done 61} 62 63log_assert "For draid, one destroyed pools devices was removed or used by " \ 64 "other pool, it still can be imported correctly." 65log_onexit cleanup 66 67log_must zpool create $TESTPOOL1 draid $VDEV0 $VDEV1 $VDEV2 $VDEV3 68typeset guid=$(get_config $TESTPOOL1 pool_guid) 69typeset target=$TESTPOOL1 70if (( RANDOM % 2 == 0 )) ; then 71 target=$guid 72 log_note "Import by guid." 73fi 74log_must zpool destroy $TESTPOOL1 75 76log_must zpool create $TESTPOOL2 $VDEV0 77log_must zpool import -d $DEVICE_DIR -D -f $target 78log_must zpool destroy $TESTPOOL1 79 80log_must zpool destroy $TESTPOOL2 81log_must rm -rf $VDEV0 82log_must zpool import -d $DEVICE_DIR -D -f $target 83log_must zpool destroy $TESTPOOL1 84 85log_note "For draid, two destroyed pool's devices were used, import failed." 86log_must mkfile $FILE_SIZE $VDEV0 87log_must zpool create $TESTPOOL2 $VDEV0 $VDEV1 88log_mustnot zpool import -d $DEVICE_DIR -D -f $target 89log_must zpool destroy $TESTPOOL2 90 91log_pass "zpool import -D draid passed." 92