]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_parallel_pos.ksh
Parallel pool import
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / zpool_import_parallel_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 https://opensource.org/licenses/CDDL-1.0.
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 2007 Sun Microsystems, Inc.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2023 Klara, Inc.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
34 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
35
36 # test uses 8 vdevs
37 export MAX_NUM=8
38
39 #
40 # DESCRIPTION:
41 #       Verify that pool imports can occur in parallel
42 #
43 # STRATEGY:
44 #       1. Create 8 pools
45 #       2. Generate some ZIL records
46 #       3. Export the pools
47 #       4. Import half of the pools synchronously to baseline sequential cost
48 #       5. Import the other half asynchronously to demonstrate parallel savings
49 #       6. Export 4 pools
50 #       7. Test zpool import -a
51 #
52
53 verify_runnable "global"
54
55 #
56 # override the minimum sized vdevs
57 #
58 VDEVSIZE=$((512 * 1024 * 1024))
59 increase_device_sizes $VDEVSIZE
60
61 POOLNAME="import_pool"
62
63 function cleanup
64 {
65         zinject -c all
66         log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 0
67         log_must set_tunable64 METASLAB_DEBUG_LOAD 0
68
69         for i in {0..$(($MAX_NUM - 1))}; do
70                 destroy_pool $POOLNAME-$i
71         done
72         # reset the devices
73         increase_device_sizes 0
74         increase_device_sizes $FILE_SIZE
75 }
76
77 log_assert "Pool imports can occur in parallel"
78
79 log_onexit cleanup
80
81 log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 1
82 log_must set_tunable64 METASLAB_DEBUG_LOAD 1
83
84
85 #
86 # create some exported pools with import delay injectors
87 #
88 for i in {0..$(($MAX_NUM - 1))}; do
89         log_must zpool create $POOLNAME-$i $DEVICE_DIR/${DEVICE_FILE}$i
90         log_must zpool export $POOLNAME-$i
91         log_must zinject -P import -s 12 $POOLNAME-$i
92 done
93 wait
94
95 #
96 # import half of the pools synchronously
97 #
98 SECONDS=0
99 for i in {0..3}; do
100         log_must zpool import -d $DEVICE_DIR -f $POOLNAME-$i
101 done
102 sequential_time=$SECONDS
103 log_note "sequentially imported 4 pools in $sequential_time seconds"
104
105 #
106 # import half of the pools in parallel
107 #
108 SECONDS=0
109 for i in {4..7}; do
110         log_must zpool import -d $DEVICE_DIR -f $POOLNAME-$i &
111 done
112 wait
113 parallel_time=$SECONDS
114 log_note "asyncronously imported 4 pools in $parallel_time seconds"
115
116 log_must test $parallel_time -lt $(($sequential_time / 3))
117
118 #
119 # export pools with import delay injectors
120 #
121 for i in {4..7}; do
122         log_must zpool export $POOLNAME-$i
123         log_must zinject -P import -s 12 $POOLNAME-$i
124 done
125 wait
126
127 #
128 # now test zpool import -a
129 #
130 SECONDS=0
131 log_must zpool import -a -d $DEVICE_DIR -f
132 parallel_time=$SECONDS
133 log_note "asyncronously imported 4 pools in $parallel_time seconds"
134
135 log_must test $parallel_time -lt $(($sequential_time / 3))
136
137 log_pass "Pool imports occur in parallel"