]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/replacement/rebuild_raidz.ksh
Add device rebuild feature
[mirror_zfs.git] / tests / zfs-tests / tests / functional / replacement / rebuild_raidz.ksh
1 #!/bin/ksh -p
2
3 #
4 # CDDL HEADER START
5 #
6 # This file and its contents are supplied under the terms of the
7 # Common Development and Distribution License ("CDDL"), version 1.0.
8 # You may only use this file in accordance with the terms of version
9 # 1.0 of the CDDL.
10 #
11 # A full copy of the text of the CDDL should have accompanied this
12 # source. A copy of the CDDL is also available via the Internet at
13 # http://www.illumos.org/license/CDDL.
14 #
15 # CDDL HEADER END
16 #
17
18 #
19 # Copyright (c) 2019, Datto Inc. All rights reserved.
20 # Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
21 #
22
23 . $STF_SUITE/include/libtest.shlib
24 . $STF_SUITE/tests/functional/replacement/replacement.cfg
25
26 #
27 # DESCRIPTION:
28 # Executing 'zpool replace -s' for raidz vdevs failed. Sequential
29 # resilvers are only allowed for stripe/mirror pools.
30 #
31 # STRATEGY:
32 # 1. Create a raidz pool, verify 'zpool replace -s' fails
33 # 2. Create a stripe/mirror pool, verify 'zpool replace -s' passes
34 #
35
36 function cleanup
37 {
38 log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
39 $ORIG_SCAN_SUSPEND_PROGRESS
40 destroy_pool $TESTPOOL1
41 rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE
42 }
43
44 log_assert "Sequential resilver is not allowed for raidz vdevs"
45
46 ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
47
48 log_onexit cleanup
49
50 log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]} $SPARE_VDEV_FILE
51
52 # raidz[1-3]
53 for vdev_type in "raidz" "raidz2" "raidz3"; do
54 log_must zpool create -f $TESTPOOL1 $vdev_type ${VDEV_FILES[@]}
55 log_mustnot zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} \
56 $SPARE_VDEV_FILE
57 destroy_pool $TESTPOOL1
58 done
59
60 # stripe
61 log_must zpool create $TESTPOOL1 ${VDEV_FILES[@]}
62 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
63 destroy_pool $TESTPOOL1
64
65 # mirror
66 log_must zpool create $TESTPOOL1 mirror ${VDEV_FILES[0]} ${VDEV_FILES[1]}
67 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
68 destroy_pool $TESTPOOL1
69
70 log_pass "Sequential resilver is not allowed for raidz vdevs"