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 http://www.opensolaris.org/os/licensing. 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) 2023 by iXsystems, Inc. 25# 26 27. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# 'zpool attach poolname raidz ...' should fail if raidz_expansion 32# feature is not enabled. 33# 34# STRATEGY: 35# 1. Create raidz pool with raidz_expansion feature disabled 36# 2. Attempt to attach a device to the raidz vdev 37# 3. Verify that device attached failed 38# 4. Destroy the raidz pool 39 40typeset -r devs=4 41typeset -r dev_size_mb=128 42typeset -a disks 43 44function cleanup 45{ 46 log_pos zpool status "$TESTPOOL" 47 48 poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL" 49 50 for i in {0..$devs}; do 51 log_must rm -f "$TEST_BASE_DIR/dev-$i" 52 done 53} 54 55log_onexit cleanup 56 57for i in {0..$devs}; do 58 device=$TEST_BASE_DIR/dev-$i 59 log_must truncate -s ${dev_size_mb}M "$device" 60 if [[ $i -ne $devs ]]; then 61 disks[${#disks[*]}+1]=$device 62 fi 63done 64 65# create a pool with raidz_expansion feature disabled 66log_must zpool create -f -o cachefile=none -o feature@raidz_expansion=disabled \ 67 "$TESTPOOL" raidz1 "${disks[@]}" 68status=$(zpool list -H -o feature@raidz_expansion "$TESTPOOL") 69if [[ "$status" != "disabled" ]]; then 70 log_fail "raidz_expansion feature was not disabled" 71fi 72 73# expecting attach to fail 74log_mustnot_expect "raidz_expansion feature must be enabled" zpool attach -f \ 75 "$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs" 76log_must zpool destroy "$TESTPOOL" 77 78log_pass "raidz attach failed with feature disabled as expected" 79