]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_ashift.ksh
MFV 2.0-rc2
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / tests / zfs-tests / tests / functional / cli_root / zpool_set / zpool_set_ashift.ksh
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 (c) 2020 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 #
34 # zpool set can modify 'ashift' property
35 #
36 # STRATEGY:
37 # 1. Create a pool
38 # 2. Verify that we can set 'ashift' only to allowed values on that pool
39 #
40
41 verify_runnable "global"
42
43 function cleanup
44 {
45         log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift
46         destroy_pool $TESTPOOL1
47         rm -f $disk
48 }
49
50 typeset goodvals=("0" "9" "10" "11" "12" "13" "14" "15" "16")
51 typeset badvals=("off" "on" "1" "8" "17" "1b" "ff" "-")
52
53 log_onexit cleanup
54
55 log_assert "zpool set can modify 'ashift' property"
56
57 orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT)
58 #
59 # Set the file vdev's ashift to the max. Overriding
60 # the ashift using the -o ashift property should still
61 # be honored.
62 #
63 log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT 16
64
65 disk=$TEST_BASE_DIR/disk
66 log_must mkfile $SIZE $disk
67 log_must zpool create $TESTPOOL1 $disk
68
69 for ashift in ${goodvals[@]}
70 do
71         log_must zpool set ashift=$ashift $TESTPOOL1
72         typeset value=$(get_pool_prop ashift $TESTPOOL1)
73         if [[ "$ashift" != "$value" ]]; then
74                 log_fail "'zpool set' did not update ashift value to $ashift "\
75                     "(current = $value)"
76         fi
77 done
78
79 for ashift in ${badvals[@]}
80 do
81         log_mustnot zpool set ashift=$ashift $TESTPOOL1
82         typeset value=$(get_pool_prop ashift $TESTPOOL1)
83         if [[ "$ashift" == "$value" ]]; then
84                 log_fail "'zpool set' incorrectly set ashift value to $value"
85         fi
86 done
87
88 log_pass "zpool set can modify 'ashift' property"