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 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 attach -o ashift=<n> ...' should work with different ashift 34# values. 35# 36# STRATEGY: 37# 1. Create various pools with different ashift values. 38# 2. Verify 'attach' works. 39# 40 41verify_runnable "global" 42 43function cleanup 44{ 45 log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift 46 poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1 47 rm -f $disk1 $disk2 48} 49 50log_assert "zpool attach -o ashift=<n>' works with different ashift values" 51log_onexit cleanup 52 53disk1=$TEST_BASE_DIR/disk1 54disk2=$TEST_BASE_DIR/disk2 55log_must truncate -s $SIZE $disk1 56log_must truncate -s $SIZE $disk2 57 58orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT) 59# 60# Set the file vdev's ashift to the max. Overriding 61# the ashift using the -o ashift property should still 62# be honored. 63# 64log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT 16 65 66typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16") 67for ashift in ${ashifts[@]} 68do 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 77done 78 79typeset badvals=("off" "on" "1" "8" "17" "1b" "ff" "-") 80for badval in ${badvals[@]} 81do 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 87done 88 89log_pass "zpool attach -o ashift=<n>' works with different ashift values" 90