]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/raidz/raidz_expand_002_pos.ksh
RAID-Z expansion feature
[mirror_zfs.git] / tests / zfs-tests / tests / functional / raidz / raidz_expand_002_pos.ksh
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 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 (c) 2020 by vStack. All rights reserved.
25 #
26
27 . $STF_SUITE/include/libtest.shlib
28
29 #
30 # DESCRIPTION:
31 # 'zpool attach poolname raidz ...' should attach new devive to the pool.
32 #
33 # STRATEGY:
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
41
42 typeset -r devs=6
43 typeset -r dev_size_mb=512
44
45 typeset -a disks
46
47 prefetch_disable=$(get_tunable PREFETCH_DISABLE)
48
49 function cleanup
50 {
51 poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
52
53 for i in {0..$devs}; do
54 log_must rm -f "$TEST_BASE_DIR/dev-$i"
55 done
56
57 log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable
58 }
59
60 log_onexit cleanup
61
62 log_must set_tunable32 PREFETCH_DISABLE 1
63
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
69 done
70
71 nparity=$((RANDOM%(3) + 1))
72 raid=raidz$nparity
73 dir=$TEST_BASE_DIR
74 pool=$TESTPOOL
75 opts="-o cachefile=none"
76
77 log_must zpool create -f $opts $pool $raid ${disks[1..$(($nparity+1))]}
78 log_must zfs set primarycache=metadata $pool
79
80 log_must zfs create $pool/fs
81 log_must fill_fs /$pool/fs 1 512 100 1024 R
82
83 log_must zfs create -o compress=on $pool/fs2
84 log_must fill_fs /$pool/fs2 1 512 100 1024 R
85
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
88
89 typeset pool_size=$(get_pool_prop size $pool)
90
91 for disk in ${disks[$(($nparity+2))..$devs]}; do
92 log_must dd if=/dev/urandom of=/${pool}/FILE-$RANDOM bs=1M \
93 count=64
94
95 log_must zpool attach -w $pool ${raid}-0 $disk
96
97 # Wait some time for pool size increase
98 sleep 5
99
100 # Confirm that disk was attached to the pool
101 log_must zpool get -H path $TESTPOOL $disk
102
103 typeset expand_size=$(get_pool_prop size $pool)
104 if [[ "$expand_size" -le "$pool_size" ]]; then
105 log_fail "pool $pool not expanded"
106 fi
107
108 verify_pool $pool
109
110 pool_size=$expand_size
111 done
112
113 zpool destroy "$pool"
114
115 log_pass "raidz expansion test succeeded."