|
| 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 2009 Sun Microsystems, Inc. All rights reserved. |
| 25 | +# Use is subject to license terms. |
| 26 | +# |
| 27 | + |
| 28 | +# |
| 29 | +# Copyright (c) 2012, 2018 by Delphix. All rights reserved. |
| 30 | +# |
| 31 | + |
| 32 | +. $STF_SUITE/include/libtest.shlib |
| 33 | +. $STF_SUITE/include/blkdev.shlib |
| 34 | +. $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg |
| 35 | + |
| 36 | +# |
| 37 | +# DESCRIPTION: |
| 38 | +# |
| 39 | +# STRATEGY: |
| 40 | +# 1) Create a scsi_debug device and a pool based on it |
| 41 | +# 2) Expand the device and rescan the scsi bus |
| 42 | +# 3) Reopen the pool and check that it detects new available space |
| 43 | +# 4) Online the device and check that the pool has been expanded |
| 44 | +# |
| 45 | + |
| 46 | +verify_runnable "global" |
| 47 | + |
| 48 | +function cleanup |
| 49 | +{ |
| 50 | + if poolexists $TESTPOOL1; then |
| 51 | + log_must zpool destroy $TESTPOOL1 |
| 52 | + fi |
| 53 | + unload_scsi_debug |
| 54 | +} |
| 55 | + |
| 56 | +log_onexit cleanup |
| 57 | + |
| 58 | +log_assert "zpool based on scsi device can be expanded with zpool online -e" |
| 59 | + |
| 60 | +# run scsi_debug to create a device |
| 61 | +MINVDEVSIZE_MB=$((MINVDEVSIZE / 1048576)) |
| 62 | +load_scsi_debug $MINVDEVSIZE_MB 1 1 1 '512b' |
| 63 | +block_device_wait |
| 64 | +SDISK=$(get_debug_device) |
| 65 | +log_must zpool create $TESTPOOL1 $SDISK |
| 66 | + |
| 67 | +typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1) |
| 68 | +if [[ $autoexp != "off" ]]; then |
| 69 | + log_fail "zpool $TESTPOOL1 autoexpand should be off but is $autoexp" |
| 70 | +fi |
| 71 | + |
| 72 | +typeset prev_size=$(get_pool_prop size $TESTPOOL1) |
| 73 | +log_note "original pool size: $prev_size" |
| 74 | + |
| 75 | +# resize the scsi_debug device |
| 76 | +echo "5" > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb |
| 77 | +# rescan the device to detect the new size |
| 78 | +echo "1" > /sys/class/block/$SDISK/device/rescan |
| 79 | +block_device_wait |
| 80 | + |
| 81 | +# reopen the pool so ZFS can see the new space |
| 82 | +log_must zpool reopen $TESTPOOL1 |
| 83 | + |
| 84 | +typeset expandsize=$(get_pool_prop expandsize $TESTPOOL1) |
| 85 | +log_note "pool expandsize: $expandsize" |
| 86 | +if [[ "$zpool_expandsize" = "-" ]]; then |
| 87 | + log_fail "pool $TESTPOOL1 did not detect any " \ |
| 88 | + "expandsize after reopen" |
| 89 | +fi |
| 90 | + |
| 91 | +# online the device so the zpool will use the new space |
| 92 | +log_must zpool online -e $TESTPOOL1 $SDISK |
| 93 | + |
| 94 | +typeset new_size=$(get_pool_prop size $TESTPOOL1) |
| 95 | +log_note "new pool size: $new_size" |
| 96 | +if [[ $new_size -le $prev_size ]]; then |
| 97 | + log_fail "pool $TESTPOOL1 did not expand " \ |
| 98 | + "after LUN expansion and zpool online -e" |
| 99 | +fi |
| 100 | + |
| 101 | +log_pass "zpool based on scsi_debug can be expanded with reopen and online -e" |
0 commit comments