xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh (revision a61ed2ce7a86a4d6428f2a83eb4739fae945447e)
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 2017, loli10K. All rights reserved.
25# Copyright 2019 Joyent, Inc.
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	poolexists $TESTPOOL && destroy_pool $TESTPOOL
48	log_must rm -f $disk1 $disk2
49}
50
51log_assert "'zpool add' uses the ashift pool property value as default."
52log_onexit cleanup
53
54disk1=$TEST_BASE_DIR/$FILEDISK0
55disk2=$TEST_BASE_DIR/$FILEDISK1
56log_must mkfile $SIZE $disk1
57log_must mkfile $SIZE $disk2
58
59typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
60for ashift in ${ashifts[@]}
61do
62	log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
63	log_must zpool add $TESTPOOL $disk2
64	verify_ashift $disk2 $ashift
65	if [[ $? -ne 0 ]]
66	then
67		log_fail "Device was added without setting ashift value to "\
68		    "$ashift"
69	fi
70	# clean things for the next run
71	log_must zpool destroy $TESTPOOL
72	log_must zpool labelclear $disk1
73	log_must zpool labelclear $disk2
74done
75
76for ashift in ${ashifts[@]}
77do
78	for cmdval in ${ashifts[@]}
79	do
80		log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
81		log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2
82		verify_ashift $disk2 $cmdval
83		if [[ $? -ne 0 ]]
84		then
85			log_fail "Device was added without setting ashift " \
86			    "value to $cmdval"
87		fi
88		# clean things for the next run
89		log_must zpool destroy $TESTPOOL
90		log_must zpool labelclear $disk1
91		log_must zpool labelclear $disk2
92	done
93done
94
95log_pass "'zpool add' uses the ashift pool property value."
96