1*5711d393Sloli#!/bin/ksh -p 2*5711d393Sloli# 3*5711d393Sloli# CDDL HEADER START 4*5711d393Sloli# 5*5711d393Sloli# The contents of this file are subject to the terms of the 6*5711d393Sloli# Common Development and Distribution License (the "License"). 7*5711d393Sloli# You may not use this file except in compliance with the License. 8*5711d393Sloli# 9*5711d393Sloli# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*5711d393Sloli# or http://www.opensolaris.org/os/licensing. 11*5711d393Sloli# See the License for the specific language governing permissions 12*5711d393Sloli# and limitations under the License. 13*5711d393Sloli# 14*5711d393Sloli# When distributing Covered Code, include this CDDL HEADER in each 15*5711d393Sloli# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*5711d393Sloli# If applicable, add the following below this CDDL HEADER, with the 17*5711d393Sloli# fields enclosed by brackets "[]" replaced with your own identifying 18*5711d393Sloli# information: Portions Copyright [yyyy] [name of copyright owner] 19*5711d393Sloli# 20*5711d393Sloli# CDDL HEADER END 21*5711d393Sloli# 22*5711d393Sloli 23*5711d393Sloli# 24*5711d393Sloli# Copyright 2017, loli10K. All rights reserved. 25*5711d393Sloli# Copyright 2019 Joyent, Inc. 26*5711d393Sloli# 27*5711d393Sloli 28*5711d393Sloli. $STF_SUITE/include/libtest.shlib 29*5711d393Sloli. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib 30*5711d393Sloli 31*5711d393Sloli# 32*5711d393Sloli# DESCRIPTION: 33*5711d393Sloli# 'zpool add' should use the ashift pool property value as default. 34*5711d393Sloli# 35*5711d393Sloli# STRATEGY: 36*5711d393Sloli# 1. Create a pool with default values. 37*5711d393Sloli# 2. Verify 'zpool add' uses the ashift pool property value when adding 38*5711d393Sloli# a new device. 39*5711d393Sloli# 3. Verify the default ashift value can still be overridden by manually 40*5711d393Sloli# specifying '-o ashift=<n>' from the command line. 41*5711d393Sloli# 42*5711d393Sloli 43*5711d393Sloliverify_runnable "global" 44*5711d393Sloli 45*5711d393Slolifunction cleanup 46*5711d393Sloli{ 47*5711d393Sloli poolexists $TESTPOOL && destroy_pool $TESTPOOL 48*5711d393Sloli log_must rm -f $disk1 $disk2 49*5711d393Sloli} 50*5711d393Sloli 51*5711d393Slolilog_assert "'zpool add' uses the ashift pool property value as default." 52*5711d393Slolilog_onexit cleanup 53*5711d393Sloli 54*5711d393Slolidisk1=$TEST_BASE_DIR/$FILEDISK0 55*5711d393Slolidisk2=$TEST_BASE_DIR/$FILEDISK1 56*5711d393Slolilog_must mkfile $SIZE $disk1 57*5711d393Slolilog_must mkfile $SIZE $disk2 58*5711d393Sloli 59*5711d393Slolitypeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") 60*5711d393Slolifor ashift in ${ashifts[@]} 61*5711d393Slolido 62*5711d393Sloli log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 63*5711d393Sloli log_must zpool add $TESTPOOL $disk2 64*5711d393Sloli verify_ashift $disk2 $ashift 65*5711d393Sloli if [[ $? -ne 0 ]] 66*5711d393Sloli then 67*5711d393Sloli log_fail "Device was added without setting ashift value to "\ 68*5711d393Sloli "$ashift" 69*5711d393Sloli fi 70*5711d393Sloli # clean things for the next run 71*5711d393Sloli log_must zpool destroy $TESTPOOL 72*5711d393Sloli log_must zpool labelclear $disk1 73*5711d393Sloli log_must zpool labelclear $disk2 74*5711d393Slolidone 75*5711d393Sloli 76*5711d393Slolifor ashift in ${ashifts[@]} 77*5711d393Slolido 78*5711d393Sloli for cmdval in ${ashifts[@]} 79*5711d393Sloli do 80*5711d393Sloli log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 81*5711d393Sloli log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2 82*5711d393Sloli verify_ashift $disk2 $cmdval 83*5711d393Sloli if [[ $? -ne 0 ]] 84*5711d393Sloli then 85*5711d393Sloli log_fail "Device was added without setting ashift " \ 86*5711d393Sloli "value to $cmdval" 87*5711d393Sloli fi 88*5711d393Sloli # clean things for the next run 89*5711d393Sloli log_must zpool destroy $TESTPOOL 90*5711d393Sloli log_must zpool labelclear $disk1 91*5711d393Sloli log_must zpool labelclear $disk2 92*5711d393Sloli done 93*5711d393Slolidone 94*5711d393Sloli 95*5711d393Slolilog_pass "'zpool add' uses the ashift pool property value." 96