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 2016 Spectra Logic All rights reserved. 25# Use is subject to license terms. 26# 27 28. $STF_SUITE/include/libtest.kshlib 29 30################################################################################# 31# 32# __stc_assertion_start 33# 34# ID: zpool_import_missing_005_pos 35# 36# DESCRIPTION: 37# Verify that a pool can still be imported even if its devices' names 38# have changed, for all types of devices. This is a test of vdev_geom's 39# import_by_guid functionality. 40# STRATEGY: 41# 1. Create a supply of file-backed md devices 42# 2. Create a disk-backed pool with regular, cache, log, and spare vdevs 43# 3. Export it 44# 4. Cause all the md devices names to change 45# 5. Verify 'zpool import' can import it 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2015-01-4) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "global" 58 59log_assert "Verify that all types of vdevs of a disk-backed exported pool can be imported even if they have been renamed" 60 61# Create md devices so we can control their devnames 62# Use high devnames so we'll be unlikely to have collisions 63typeset -i REGULAR_U=4000 64typeset -i LOG_U=4001 65typeset -i CACHE_U=4002 66typeset -i SPARE_U=4003 67typeset -i REGULAR_ALTU=5000 68typeset -i LOG_ALTU=5001 69typeset -i CACHE_ALTU=5002 70typeset -i SPARE_ALTU=5003 71typeset REGULAR=${TMPDIR}/regular 72typeset LOG=${TMPDIR}/log 73typeset CACHE=${TMPDIR}/cache 74typeset SPARE=${TMPDIR}/spare 75 76function cleanup 77{ 78 destroy_pool $TESTPOOL 79 $MDCONFIG -d -u $REGULAR_U 2>/dev/null 80 $MDCONFIG -d -u $LOG_U 2>/dev/null 81 $MDCONFIG -d -u $CACHE_U 2>/dev/null 82 $MDCONFIG -d -u $SPARE_U 2>/dev/null 83 $MDCONFIG -d -u $REGULAR_ALTU 2>/dev/null 84 $MDCONFIG -d -u $LOG_ALTU 2>/dev/null 85 $MDCONFIG -d -u $CACHE_ALTU 2>/dev/null 86 $MDCONFIG -d -u $SPARE_ALTU 2>/dev/null 87 $RM -f $REGULAR 88 $RM -f $CACHE 89 $RM -f $LOG 90 $RM -f $SPARE 91} 92log_onexit cleanup 93 94log_must $TRUNCATE -s 64m $REGULAR 95log_must $TRUNCATE -s 64m $LOG 96log_must $TRUNCATE -s 64m $CACHE 97log_must $TRUNCATE -s 64m $SPARE 98log_must $MDCONFIG -t vnode -a -f $REGULAR -u $REGULAR_U 99log_must $MDCONFIG -t vnode -a -f $LOG -u $LOG_U 100log_must $MDCONFIG -t vnode -a -f $CACHE -u $CACHE_U 101log_must $MDCONFIG -t vnode -a -f $SPARE -u $SPARE_U 102 103log_must $ZPOOL create $TESTPOOL md$REGULAR_U log md$LOG_U cache md$CACHE_U spare md$SPARE_U 104log_must $ZPOOL export $TESTPOOL 105# Now destroy the md devices, then recreate them with different names 106log_must $MDCONFIG -d -u $REGULAR_U 107log_must $MDCONFIG -d -u $LOG_U 108log_must $MDCONFIG -d -u $CACHE_U 109log_must $MDCONFIG -d -u $SPARE_U 110log_must $MDCONFIG -t vnode -a -f $REGULAR -u $REGULAR_ALTU 111log_must $MDCONFIG -t vnode -a -f $LOG -u $LOG_ALTU 112log_must $MDCONFIG -t vnode -a -f $CACHE -u $CACHE_ALTU 113log_must $MDCONFIG -t vnode -a -f $SPARE -u $SPARE_ALTU 114 115log_must $ZPOOL import $TESTPOOL 116zpool status $TESTPOOL 117log_must check_state $TESTPOOL md${REGULAR_ALTU} ONLINE 118log_must check_state $TESTPOOL md${LOG_ALTU} ONLINE 119log_must check_state $TESTPOOL md${CACHE_ALTU} ONLINE 120log_must check_state $TESTPOOL md${SPARE_ALTU} AVAIL 121 122log_pass 123