]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_006_pos.ksh
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 http://www.opensolaris.org/os/licensing.
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/zvol
/zvol_common.shlib
37 # A volume can be added as several segments, but overlapping segments
41 # 1. Figure out three groups swaplow and swaplen.
42 # 2. Verify different volume segments can be added correctly.
43 # 3. Verify overlapping swap volume are not allowed.
46 verify_runnable
"global"
52 while ((count
> 0)); do
53 log_must
$SWAP -d $swapname ${swap_opt[$i]}
60 log_assert
"Verify volume can be add as several segments, but overlapping " \
64 # swap -a won't allow the use of multiple segments of the same volume unless
65 # libdiskmgmt is disabled with the environment variable below.
66 typeset
-x NOINUSE_CHECK
=1
68 typeset vol
=$TESTPOOL/$TESTVOL
69 typeset
-i pageblocks volblocks
70 ((pageblocks
= $
($PAGESIZE) / 512))
71 ((volblocks
= $
(get_prop volsize
$vol) / 512))
73 log_note
"Verify volume can be add as several segments."
77 set -A swap_opt $
((pageblocks
)) \
78 $
((pageblocks
* ((RANDOM
% 50) + 1) + (RANDOM
% pageblocks
) )) \
80 $
((pageblocks
* ((RANDOM
% 50) + 1) + (RANDOM
% pageblocks
) )) \
82 $
((pageblocks
* ((RANDOM
% 50) + 1) + (RANDOM
% pageblocks
) )) \
83 $
(((volblocks
*2) / 3)) \
84 $
((pageblocks
* ((RANDOM
% 50) + 1) + (RANDOM
% pageblocks
) ))
86 swapname
=${ZVOL_DEVDIR}/$vol
87 typeset
-i i
=0 count
=0
89 if is_swap_inuse
$swapname ; then
90 log_must
$SWAP -d $swapname
93 while ((i
< ${#swap_opt[@]})); do
94 log_must
$SWAP -a $swapname ${swap_opt[$i]} ${swap_opt[((i+1))]}
100 log_note
"Verify overlapping swap volume are not allowed"
102 while ((i
< ${#swap_opt[@]})); do
103 log_mustnot
$SWAP -a $swapname ${swap_opt[$i]}
108 log_pass
"Verify volume can be added as several segments passed."