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 2017, loli10K. All rights reserved. 25# Copyright (c) 2020, 2024 by Delphix. All rights reserved. 26# 27 28. $STF_SUITE/include/libtest.shlib 29. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib 30 31# 32# DESCRIPTION: 33# 'zpool add' should use the ashift pool property value as default. 34# 35# STRATEGY: 36# 1. Create a pool with default values. 37# 2. Verify 'zpool add' uses the ashift pool property value when adding 38# a new device. 39# 3. Verify the default ashift value can still be overridden by manually 40# specifying '-o ashift=<n>' from the command line. 41# 42 43verify_runnable "global" 44 45function cleanup 46{ 47 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift 48 poolexists $TESTPOOL && destroy_pool $TESTPOOL 49 log_must rm -f $disk1 $disk2 50} 51 52log_assert "'zpool add' uses the ashift pool property value as default." 53log_onexit cleanup 54 55disk1=$TEST_BASE_DIR/disk1 56disk2=$TEST_BASE_DIR/disk2 57log_must mkfile $SIZE $disk1 58log_must mkfile $SIZE $disk2 59 60orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT) 61# 62# Set the file vdev's ashift to the max. Overriding 63# the ashift using the -o ashift property should still 64# be honored. 65# 66log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT 16 67 68typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") 69for ashift in ${ashifts[@]} 70do 71 if [ $ashift -eq $orig_ashift ];then 72 opt="" 73 else 74 opt="--allow-ashift-mismatch" 75 fi 76 log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 77 log_must zpool add $opt $TESTPOOL $disk2 78 log_must verify_ashift $disk2 $ashift 79 80 # clean things for the next run 81 log_must zpool destroy $TESTPOOL 82 log_must zpool labelclear $disk1 83 log_must zpool labelclear $disk2 84done 85 86for ashift in ${ashifts[@]} 87do 88 for cmdval in ${ashifts[@]} 89 do 90 if [ $ashift -eq $cmdval ];then 91 opt="" 92 else 93 opt="--allow-ashift-mismatch" 94 fi 95 log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 96 log_must zpool add $opt -o ashift=$cmdval $TESTPOOL $disk2 97 log_must verify_ashift $disk2 $cmdval 98 99 # clean things for the next run 100 log_must zpool destroy $TESTPOOL 101 log_must zpool labelclear $disk1 102 log_must zpool labelclear $disk2 103 done 104done 105 106log_pass "'zpool add' uses the ashift pool property value." 107