Linux 6.12 compat: META
[zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_attach / attach-o_ashift.ksh
blob574cb7654d10048c45a7fc8e36b18803ee008170
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
24 # Copyright 2017, loli10K. All rights reserved.
25 # Copyright (c) 2020 by Delphix. All rights reserved.
28 . $STF_SUITE/include/libtest.shlib
29 . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
32 # DESCRIPTION:
33 # 'zpool attach -o ashift=<n> ...' should work with different ashift
34 # values.
36 # STRATEGY:
37 # 1. Create various pools with different ashift values.
38 # 2. Verify 'attach' works.
41 verify_runnable "global"
43 function cleanup
45 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift
46 poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
47 rm -f $disk1 $disk2
50 log_assert "zpool attach -o ashift=<n>' works with different ashift values"
51 log_onexit cleanup
53 disk1=$TEST_BASE_DIR/disk1
54 disk2=$TEST_BASE_DIR/disk2
55 log_must truncate -s $SIZE $disk1
56 log_must truncate -s $SIZE $disk2
58 orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT)
60 # Set the file vdev's ashift to the max. Overriding
61 # the ashift using the -o ashift property should still
62 # be honored.
64 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT 16
66 typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
67 for ashift in ${ashifts[@]}
69 log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1
70 log_must verify_ashift $disk1 $ashift
71 log_must zpool attach $TESTPOOL1 $disk1 $disk2
72 log_must verify_ashift $disk2 $ashift
73 # clean things for the next run
74 log_must zpool destroy $TESTPOOL1
75 log_must zpool labelclear $disk1
76 log_must zpool labelclear $disk2
77 done
79 typeset badvals=("off" "on" "1" "8" "17" "1b" "ff" "-")
80 for badval in ${badvals[@]}
82 log_must zpool create $TESTPOOL1 $disk1
83 log_mustnot zpool attach -o ashift=$badval $TESTPOOL1 $disk1 $disk2
84 log_must zpool destroy $TESTPOOL1
85 log_must zpool labelclear $disk1
86 log_mustnot zpool labelclear $disk2
87 done
89 log_pass "zpool attach -o ashift=<n>' works with different ashift values"