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 (c) 2020 by vStack. All rights reserved.
27 .
$STF_SUITE/include
/libtest.shlib
31 # 'zpool attach poolname raidz ...' should attach new devive to the pool.
34 # 1. Create block device files for the test raidz pool
35 # 2. For each parity value [1..3]
36 # - create raidz pool with minimum block device files required
37 # - for each free test block device
38 # - attach to the pool
39 # - verify the raidz pool
40 # - destroy the raidz pool
43 typeset
-r dev_size_mb
=512
47 prefetch_disable
=$
(get_tunable PREFETCH_DISABLE
)
51 poolexists
"$TESTPOOL" && log_must_busy zpool destroy
"$TESTPOOL"
53 for i
in {0..
$devs}; do
54 log_must
rm -f "$TEST_BASE_DIR/dev-$i"
57 log_must set_tunable32 PREFETCH_DISABLE
$prefetch_disable
62 log_must set_tunable32 PREFETCH_DISABLE
1
64 # Disk files which will be used by pool
65 for i
in {0..$
(($devs))}; do
66 device
=$TEST_BASE_DIR/dev-
$i
67 log_must truncate
-s ${dev_size_mb}M
$device
68 disks
[${#disks[*]}+1]=$device
71 nparity
=$
((RANDOM
%(3) + 1))
75 opts
="-o cachefile=none"
77 log_must zpool create
-f $opts $pool $raid ${disks[1..$(($nparity+1))]}
78 log_must zfs
set primarycache
=metadata
$pool
80 log_must zfs create
$pool/fs
81 log_must fill_fs
/$pool/fs
1 512 100 1024 R
83 log_must zfs create
-o compress=on
$pool/fs2
84 log_must fill_fs
/$pool/fs2
1 512 100 1024 R
86 log_must zfs create
-o compress=on
-o recordsize
=8k
$pool/fs3
87 log_must fill_fs
/$pool/fs3
1 512 100 1024 R
89 typeset pool_size
=$
(get_pool_prop size
$pool)
91 for disk
in ${disks[$(($nparity+2))..$devs]}; do
92 log_must
dd if=/dev
/urandom of
=/${pool}/FILE-
$RANDOM bs
=1M \
95 log_must zpool attach
-w $pool ${raid}-0 $disk
97 # Wait some time for pool size increase
100 # Confirm that disk was attached to the pool
101 log_must zpool get
-H path
$TESTPOOL $disk
103 typeset expand_size
=$
(get_pool_prop size
$pool)
104 if [[ "$expand_size" -le "$pool_size" ]]; then
105 log_fail
"pool $pool not expanded"
110 pool_size
=$expand_size
113 zpool destroy
"$pool"
115 log_pass
"raidz expansion test succeeded."