Print this page
NEX-15891 Latest grep from illumos broke zvol_swap tests and swapadd
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
4206 history_003_pos relies on exact size of history log and entries
4207 history_008_pos depends on obsolete internal history log message
4208 Typo in zfs_main.c: "posxiuser"
4209 Populate zfstest with the remainder of the STF tests
Reviewed by: Sonu Pillai <sonu.pillai@delphix.com>
Reviewed by: Will Guyette <will.guyette@delphix.com>
Reviewed by: Eric Diven <eric.diven@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/zvol/zvol_common.shlib
+++ new/usr/src/test/zfs-tests/tests/functional/zvol/zvol_common.shlib
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26
27 27 #
28 28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29 29 #
30 30
31 31 . $STF_SUITE/include/libtest.shlib
32 32 . $STF_SUITE/tests/functional/zvol/zvol.cfg
33 33
34 34 #
35 35 # Create a simple zvol volume
36 36 #
37 37 # Where disk_device: is the name of the disk to be used
38 38 # volume_size: is the size of the volume, e.g. 2G
39 39 #
40 40 function default_zvol_setup # disk_device volume_size
41 41 {
42 42 typeset disk=$1
43 43 typeset size=$2
44 44 typeset savedumpdev
45 45 typeset -i output
46 46
47 47 create_pool $TESTPOOL "$disk"
48 48
49 49 log_must zfs create -V $size $TESTPOOL/$TESTVOL
50 50 }
51 51
52 52 #
53 53 # Destroy the default zvol which was setup using
54 54 # default_zvol_setup().
55 55 #
56 56 function default_zvol_cleanup
57 57 {
58 58 if datasetexists $TESTPOOL/$TESTVOL ; then
59 59 log_must zfs destroy $TESTPOOL/$TESTVOL
60 60 fi
61 61
62 62 destroy_pool $TESTPOOL
63 63 }
64 64
65 65 function get_dumpdevice
66 66 {
67 67 typeset ret=$(dumpadm | grep "Dump device:" | awk '{print $3}')
68 68 echo $ret
69 69 }
70 70
71 71 function set_dumpsize
72 72 {
73 73 typeset volume=$1
74 74
75 75 if [[ -z $volume ]] ; then
76 76 log_note "No volume specified."
77 77 return 1
78 78 fi
79 79
80 80 log_must zfs set volsize=64m $volume
81 81
82 82 output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | \
83 83 tail -1 | awk '{print $3}')
84 84
85 85 if [[ -n $output ]]; then
86 86 (( output = output / 1024 / 1024 ))
87 87 (( output = output + output / 5 ))
88 88 log_must zfs set volsize=${output}m $volume
89 89 fi
90 90 return 0
91 91 }
92 92
93 93 function safe_dumpadm
94 94 {
95 95 typeset device=$1
96 96
97 97 if [[ -z $device || $device == "none" ]] ; then
98 98 log_note "No dump device volume specified."
99 99 return 1
100 100 fi
101 101 if [[ $device == "/dev/zvol/dsk/"* ]] ; then
102 102 typeset volume=${device#/dev/zvol/dsk/}
103 103 set_dumpsize $volume
104 104 log_must dumpadm -d $device
105 105 else
106 106 log_must swapadd
107 107 if ! is_swap_inuse $device ; then
108 108 log_must swap -a $device
109 109 fi
110 110 log_must dumpadm -d swap
111 111 fi
112 112 }
113 113
114 114 function is_zvol_dumpified
115 115 {
116 116 typeset volume=$1
117 117
118 118 if [[ -z $volume ]] ; then
119 119 log_note "No volume specified."
120 120 return 1
121 121 fi
122 122
123 123 zdb -dddd $volume 2 | grep "dumpsize" > /dev/null 2>&1
124 124 return $?
125 125 }
|
↓ open down ↓ |
125 lines elided |
↑ open up ↑ |
126 126
127 127 function is_swap_inuse
128 128 {
129 129 typeset device=$1
130 130
131 131 if [[ -z $device ]] ; then
132 132 log_note "No device specified."
133 133 return 1
134 134 fi
135 135
136 - swap -l | grep -w $device > /dev/null 2>&1
136 + swap -l | nawk 'BEGIN {rc=1} {if ($1 == "'$device'") { rc=0}} END {exit rc}'
137 137 return $?
138 138 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX