]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/replacement/replacement_002_pos.ksh
aae6d78a712afd2f7213e4e4e04c25f3b0d153a2
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/replacement
/replacement.cfg
37 # Attaching disks during I/O should pass for supported pools.
40 # 1. Create multidisk pools (stripe/mirror/raidz) and
41 # start some random I/O
42 # 2. Attach a disk to the pool.
43 # 3. Verify the integrity of the file system and the resilvering.
46 verify_runnable
"global"
50 if [[ -n "$child_pids" ]]; then
51 for wait_pid
in $child_pids
57 if poolexists
$TESTPOOL1; then
58 destroy_pool
$TESTPOOL1
61 [[ -e $TESTDIR ]] && log_must
$RM -rf $TESTDIR/*
64 log_assert
"Replacing a disk during I/O completes."
67 options_display
="default options"
71 [[ -n "$HOLES_FILESIZE" ]] && options
=" $options -f $HOLES_FILESIZE "
73 [[ -n "$HOLES_BLKSIZE" ]] && options
="$options -b $HOLES_BLKSIZE "
75 [[ -n "$HOLES_COUNT" ]] && options
="$options -c $HOLES_COUNT "
77 [[ -n "$HOLES_SEED" ]] && options
="$options -s $HOLES_SEED "
79 [[ -n "$HOLES_FILEOFFSET" ]] && options
="$options -o $HOLES_FILEOFFSET "
81 options
="$options -r "
83 [[ -n "$options" ]] && options_display
=$options
96 while [[ $i -lt $iters ]]; do
97 log_note
"Invoking $FILE_TRUNC with: $options_display"
98 $FILE_TRUNC $options $TESTDIR/$TESTFILE.
$i &
103 child_pids
="$child_pids $pid"
107 log_must
$ZPOOL attach
$opt $TESTPOOL1 $disk1 $disk2
111 for wait_pid
in $child_pids
117 log_must
$ZPOOL export $TESTPOOL1
118 log_must
$ZPOOL import
-d $TESTDIR $TESTPOOL1
119 log_must
$ZFS umount
$TESTPOOL1/$TESTFS1
120 log_must
$ZDB -cdui $TESTPOOL1/$TESTFS1
121 log_must
$ZFS mount
$TESTPOOL1/$TESTFS1
127 while [[ $i != 2 ]]; do
128 $MKFILE 100m
$TESTDIR/$TESTFILE1.
$i
129 specials_list
="$specials_list $TESTDIR/$TESTFILE1.$i"
135 # Create a replacement disk special file.
137 $MKFILE 100m
$TESTDIR/$REPLACEFILE
139 for op
in "" "-f"; do
140 create_pool
$TESTPOOL1 mirror
$specials_list
141 log_must
$ZFS create
$TESTPOOL1/$TESTFS1
142 log_must
$ZFS set mountpoint
=$TESTDIR1 $TESTPOOL1/$TESTFS1
144 attach_test
"$opt" $TESTDIR/$TESTFILE1.1
$TESTDIR/$REPLACEFILE
146 $ZPOOL iostat
-v $TESTPOOL1 |
grep "$TESTDIR/$REPLACEFILE"
147 if [[ $?
-ne 0 ]]; then
148 log_fail
"$REPLACEFILE is not present."
151 destroy_pool
$TESTPOOL1
154 log_note
"Verify 'zpool attach' fails with non-mirrors."
156 for type in "" "raidz" "raidz1"; do
157 for op
in "" "-f"; do
158 create_pool
$TESTPOOL1 $type $specials_list
159 log_must
$ZFS create
$TESTPOOL1/$TESTFS1
160 log_must
$ZFS set mountpoint
=$TESTDIR1 $TESTPOOL1/$TESTFS1
162 log_mustnot
$ZPOOL attach
"$opt" $TESTDIR/$TESTFILE1.1 \
163 $TESTDIR/$REPLACEFILE
165 $ZPOOL iostat
-v $TESTPOOL1 |
grep "$TESTDIR/$REPLACEFILE"
166 if [[ $?
-eq 0 ]]; then
167 log_fail
"$REPLACEFILE should not be present."
170 destroy_pool
$TESTPOOL1