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 37export 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 53verify_runnable "global" 54 55# 56# override the minimum sized vdevs 57# 58VDEVSIZE=$((512 * 1024 * 1024)) 59increase_device_sizes $VDEVSIZE 60 61POOLNAME="import_pool" 62 63function 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 77log_assert "Pool imports can occur in parallel" 78 79log_onexit cleanup 80 81log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 1 82log_must set_tunable64 METASLAB_DEBUG_LOAD 1 83 84 85# 86# create some exported pools with import delay injectors 87# 88for 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 92done 93wait 94 95# 96# import half of the pools synchronously 97# 98SECONDS=0 99for i in {0..3}; do 100 log_must zpool import -d $DEVICE_DIR -f $POOLNAME-$i 101done 102sequential_time=$SECONDS 103log_note "sequentially imported 4 pools in $sequential_time seconds" 104 105# 106# import half of the pools in parallel 107# 108SECONDS=0 109for i in {4..7}; do 110 log_must zpool import -d $DEVICE_DIR -f $POOLNAME-$i & 111done 112wait 113parallel_time=$SECONDS 114log_note "asyncronously imported 4 pools in $parallel_time seconds" 115 116log_must test $parallel_time -lt $(($sequential_time / 3)) 117 118# 119# export pools with import delay injectors 120# 121for i in {4..7}; do 122 log_must zpool export $POOLNAME-$i 123 log_must zinject -P import -s 12 $POOLNAME-$i 124done 125wait 126 127# 128# now test zpool import -a 129# 130SECONDS=0 131log_must zpool import -a -d $DEVICE_DIR -f 132parallel_time=$SECONDS 133log_note "asyncronously imported 4 pools in $parallel_time seconds" 134 135log_must test $parallel_time -lt $(($sequential_time / 3)) 136 137log_pass "Pool imports occur in parallel" 138