]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_resilver.ksh
ffc841f7662e4e570f4244163f908ebb7dcb0a49
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_split / zpool_split_resilver.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2018, Nexenta Systems, Inc. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
19
20 #
21 # DESCRIPTION:
22 # 'zpool split' should fail if resilver in progress for a disk
23 #
24 # STRATEGY:
25 # The first scenario:
26 # 1. Create a mirror pool
27 # 2. Offline the first VDEV
28 # 3. Put some data
29 # 4. Online the first VDEV
30 # 5. Verify 'zpool split' must fail
31 #
32 # The second scenario:
33 # 1. Create a mirror pool
34 # 2. Offline the second VDEV
35 # 3. Put some data
36 # 4. Online the second VDEV
37 # 5. Verify 'zpool split' must fail
38 #
39
40 verify_runnable "both"
41
42 function cleanup
43 {
44 log_must zinject -c all
45 destroy_pool $TESTPOOL
46 destroy_pool $TESTPOOL2
47 rm -f $DEVICE1 $DEVICE2
48 }
49
50 function setup_mirror
51 {
52 truncate -s $DEVSIZE $DEVICE1
53 truncate -s $DEVSIZE $DEVICE2
54 log_must zpool create -f $TESTPOOL mirror $DEVICE1 $DEVICE2
55 }
56
57 function zpool_split #disk_to_be_offline/online
58 {
59 typeset disk=$1
60
61 setup_mirror
62
63 # offline a disk, so it will not be fully sync before split
64 log_must zpool offline $TESTPOOL $disk
65
66 # Create 2G of additional data
67 mntpnt=$(get_prop mountpoint $TESTPOOL)
68 log_must file_write -b 2097152 -c 1024 -o create -d 0 -f $mntpnt/biggerfile
69 log_must sync
70
71 # slow-down resilvering, so it will not finish too early
72 log_must set_tunable64 zfs_scan_vdev_limit $ZFS_SCAN_VDEV_LIMIT_SLOW
73 log_must zinject -d $DEVICE1 -D 50:1 $TESTPOOL
74 log_must zinject -d $DEVICE2 -D 50:1 $TESTPOOL
75
76 log_must zpool online $TESTPOOL $disk
77
78 typeset i=0
79 while ! is_pool_resilvering $TESTPOOL; do
80 if (( i > 10 )); then
81 log_fail "resilvering is not started"
82 fi
83 ((i += 1))
84 sleep 1
85 done
86
87 log_mustnot zpool split $TESTPOOL $TESTPOOL2
88
89 log_must set_tunable64 zfs_scan_vdev_limit $ZFS_SCAN_VDEV_LIMIT_DEFAULT
90 }
91
92 log_assert "Verify 'zpool split' will fail if resilver in progress for a disk"
93 log_onexit cleanup
94
95 DEVSIZE='3g'
96 DEVICE1="$TEST_BASE_DIR/device-1"
97 DEVICE2="$TEST_BASE_DIR/device-2"
98
99 ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024))
100 ZFS_SCAN_VDEV_LIMIT_DEFAULT=$(get_tunable zfs_scan_vdev_limit)
101
102 log_note "Verify ZFS prevents main pool curruption during 'split'"
103 zpool_split $DEVICE1
104
105 cleanup
106
107 log_note "Verify ZFS prevents new pool curruption during 'split'"
108 zpool_split $DEVICE2
109
110 log_pass "'zpool split' failed as expected"