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 (c) 2020 Lawrence Livermore National Security, LLC. 25 26. $STF_SUITE/include/libtest.shlib 27 28# 29# DESCRIPTION: 30# Verify allowed striped widths (data+parity) and hot spares may be 31# configured at pool creation time. 32# 33# STRATEGY: 34# 1) Test valid stripe/spare combinations given the number of children. 35# 2) Test invalid stripe/spare/children combinations outside the allow limits. 36# 37 38verify_runnable "global" 39 40function cleanup 41{ 42 poolexists $TESTPOOL && destroy_pool $TESTPOOL 43 44 rm -f $draid_vdevs 45 rmdir $TESTDIR 46} 47 48log_assert "'zpool create <pool> draid:#d:#c:#s <vdevs>'" 49 50log_onexit cleanup 51 52mkdir $TESTDIR 53 54# Generate 10 random valid configurations to test. 55for (( i=0; i<10; i++ )); do 56 parity=$(random_int_between 1 3) 57 spares=$(random_int_between 0 3) 58 data=$(random_int_between 1 16) 59 60 (( min_children = (data + parity + spares) )) 61 children=$(random_int_between $min_children 32) 62 63 draid="draid${parity}:${data}d:${children}c:${spares}s" 64 65 draid_vdevs=$(echo $TESTDIR/file.{01..$children}) 66 log_must truncate -s $MINVDEVSIZE $draid_vdevs 67 68 log_must zpool create $TESTPOOL $draid $draid_vdevs 69 log_must poolexists $TESTPOOL 70 destroy_pool $TESTPOOL 71 72 rm -f $draid_vdevs 73done 74 75children=32 76draid_vdevs=$(echo $TESTDIR/file.{01..$children}) 77log_must truncate -s $MINVDEVSIZE $draid_vdevs 78 79mkdir $TESTDIR 80log_must truncate -s $MINVDEVSIZE $draid_vdevs 81 82# Out of order and unknown suffixes should fail. 83log_mustnot zpool create $TESTPOOL draid:d8 $draid_vdevs 84log_mustnot zpool create $TESTPOOL draid:s3 $draid_vdevs 85log_mustnot zpool create $TESTPOOL draid:c32 $draid_vdevs 86log_mustnot zpool create $TESTPOOL draid:10x $draid_vdevs 87log_mustnot zpool create $TESTPOOL draid:x10 $draid_vdevs 88 89# Exceeds maximum data disks (limited by total children) 90log_must zpool create $TESTPOOL draid2:30d $draid_vdevs 91log_must destroy_pool $TESTPOOL 92log_mustnot zpool create $TESTPOOL draid2:31d $draid_vdevs 93 94# At least one data disk must be requested. 95log_mustnot zpool create $TESTPOOL draid2:0d $draid_vdevs 96 97# Check invalid parity levels. 98log_mustnot zpool create $TESTPOOL draid0 $draid_vdevs 99log_mustnot zpool create $TESTPOOL draid4 $draid_vdevs 100 101# Spares are limited: spares < children - (parity + data). 102log_must zpool create $TESTPOOL draid2:20d:10s $draid_vdevs 103log_must destroy_pool $TESTPOOL 104log_mustnot zpool create $TESTPOOL draid2:20d:11s $draid_vdevs 105 106# The required children argument is enforced. 107log_mustnot zpool create $TESTPOOL draid2:0c $draid_vdevs 108log_mustnot zpool create $TESTPOOL draid2:31c $draid_vdevs 109log_must zpool create $TESTPOOL draid2:32c $draid_vdevs 110destroy_pool $TESTPOOL 111 112log_pass "'zpool create <pool> draid:#d:#c:#s <vdevs>'" 113