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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_mount
/zfs_mount.kshlib
34 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_import
/zpool_import.cfg
38 # Once a pool has been exported, and one or more devices are
39 # move to other place, import should handle this kind of situation
41 # - Regular, report error while any number of devices failing.
42 # - Mirror could withstand (N-1) devices failing
43 # before data integrity is compromised
44 # - Raidz could withstand one devices failing
45 # before data integrity is compromised
46 # Verify that is true.
49 # 1. Create test pool upon device files using the various combinations.
53 # 2. Create necessary filesystem and test files.
54 # 3. Export the test pool.
55 # 4. Move one or more device files to other directory
56 # 5. Verify 'zpool import -d' with the new directory
57 # will handle moved files successfullly.
58 # Using the various combinations.
60 # - Alternate Root Specified
63 verify_runnable
"global"
65 set -A vdevs
"" "mirror" "raidz"
66 set -A options
"" "-R $ALTER_ROOT"
70 cd $DEVICE_DIR || log_fail
"Unable change directory to $DEVICE_DIR"
71 [[ -e $DEVICE_DIR/$DEVICE_ARCHIVE ]] && \
72 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
74 poolexists
$TESTPOOL1 || \
75 log_must zpool import
-d $DEVICE_DIR $TESTPOOL1
77 cleanup_filesystem
$TESTPOOL1 $TESTFS
79 destroy_pool
$TESTPOOL1
88 while (( i
< $MAX_NUM )); do
89 typeset dev_file
=${DEVICE_DIR}/${DEVICE_FILE}$i
90 if [[ ! -e ${dev_file} ]]; then
91 log_must mkfile
$FILE_SIZE ${dev_file}
96 log_must
rm -f $DEVICE_DIR/$DEVICE_ARCHIVE
97 cd $CWD || log_fail
"Unable change directory to $CWD"
99 [[ -d $ALTER_ROOT ]] && \
100 log_must
rm -rf $ALTER_ROOT
102 [[ -d $BACKUP_DEVICE_DIR ]] && \
103 log_must
rm -rf $BACKUP_DEVICE_DIR
106 log_onexit cleanup_all
108 log_assert
"Verify that import could handle moving device."
112 [[ ! -d $BACKUP_DEVICE_DIR ]] &&
113 log_must mkdir
-p $BACKUP_DEVICE_DIR
115 cd $DEVICE_DIR || log_fail
"Unable change directory to $DEVICE_DIR"
120 typeset basedir backup
123 while (( i
< ${#vdevs[*]} )); do
126 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
128 setup_filesystem
"$DEVICE_FILES" \
129 $TESTPOOL1 $TESTFS $TESTDIR1 \
132 guid
=$
(get_config
$TESTPOOL1 pool_guid
)
135 log_must
cp $MYTESTFILE $TESTDIR1/$TESTFILE0
137 log_must zfs umount
$TESTDIR1
140 while (( j
< ${#options[*]} )); do
145 # Restore all device files.
147 [[ -n $backup ]] && \
148 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
150 log_must
rm -f $BACKUP_DEVICE_DIR/*
152 for device
in $DEVICE_FILES ; do
154 poolexists
$TESTPOOL1 && \
155 log_must zpool
export $TESTPOOL1
158 # Backup all device files while filesystem prepared.
160 if [[ -z $backup ]] ; then
161 log_must
tar cf
$DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}*
165 log_must
mv $device $BACKUP_DEVICE_DIR
167 (( count
= count
+ 1 ))
170 case "${vdevs[i]}" in
171 'mirror') (( count
< $GROUP_NUM )) && \
174 'raidz') (( count
== 1 )) && \
179 typeset target
=$TESTPOOL1
180 if (( RANDOM
% 2 == 0 )) ; then
182 log_note
"Import by guid."
184 $action zpool import \
185 -d $DEVICE_DIR ${options[j]} $target
197 log_pass
"Import could handle moving device."