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.
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.
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]
24 # Copyright 2017, loli10K. All rights reserved.
25 # Copyright (c) 2020, 2024 by Delphix. All rights reserved.
28 .
$STF_SUITE/include
/libtest.shlib
29 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_add
/zpool_add.kshlib
33 # 'zpool add -o ashift=<n> ...' should work with different ashift
37 # 1. Create a pool with default values.
38 # 2. Verify 'zpool add -o ashift=<n>' works with allowed values (9-16).
39 # 3. Verify setting kernel tunable for file vdevs works correctly.
40 # 4. Verify 'zpool add -o ashift=<n>' doesn't accept other invalid values.
43 verify_runnable
"global"
47 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT
$orig_ashift
48 poolexists
$TESTPOOL && destroy_pool
$TESTPOOL
52 log_assert
"zpool add -o ashift=<n>' works with different ashift values"
55 disk1
=$TEST_BASE_DIR/disk1
56 disk2
=$TEST_BASE_DIR/disk2
57 log_must mkfile
$SIZE $disk1
58 log_must mkfile
$SIZE $disk2
60 logical_ashift
=$
(get_tunable VDEV_FILE_LOGICAL_ASHIFT
)
61 orig_ashift
=$
(get_tunable VDEV_FILE_PHYSICAL_ASHIFT
)
62 max_auto_ashift
=$
(get_tunable VDEV_MAX_AUTO_ASHIFT
)
65 typeset ashifts
=("9" "10" "11" "12" "13" "14" "15" "16")
66 for ashift
in ${ashifts[@]}
69 # Need to add the --allow-ashift-mismatch option to disable the
70 # ashift mismatch checks in zpool add.
72 if [[ $ashift -eq $orig_ashift ]]; then
75 opt
="--allow-ashift-mismatch"
78 log_must zpool create
$TESTPOOL $disk1
79 log_must zpool add
$opt -o ashift
=$ashift $TESTPOOL $disk2
80 log_must verify_ashift
$disk2 $ashift
82 # clean things for the next run
83 log_must zpool destroy
$TESTPOOL
84 log_must zpool labelclear
$disk1
85 log_must zpool labelclear
$disk2
88 # Make sure we can also set the ashift using the tunable.
90 log_must zpool create
$TESTPOOL $disk1
91 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT
$ashift
92 log_must zpool add
$opt $TESTPOOL $disk2
93 exp
=$
(( (ashift
<= max_auto_ashift
) ? ashift
: logical_ashift
))
94 log_must verify_ashift
$disk2 $exp
96 # clean things for the next run
97 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT
$orig_ashift
98 log_must zpool destroy
$TESTPOOL
99 log_must zpool labelclear
$disk1
100 log_must zpool labelclear
$disk2
103 typeset badvals
=("off" "on" "1" "8" "17" "1b" "ff" "-")
104 for badval
in ${badvals[@]}
106 log_must zpool create
$TESTPOOL $disk1
107 log_mustnot zpool add
-o ashift
="$badval" $TESTPOOL $disk2
108 # clean things for the next run
109 log_must zpool destroy
$TESTPOOL
110 log_must zpool labelclear
$disk1
111 log_mustnot zpool labelclear
$disk2
114 log_pass
"zpool add -o ashift=<n>' works with different ashift values"