1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26
27 #
28 # Copyright 2017 Nexenta Systems, Inc.
29 #
30
31 . ${STF_SUITE}/include/libtest.shlib
32 . ${STF_SUITE}/tests/stress/include/stress.cfg
33
34 function create_write_fs
35 {
36 typeset pool=$1
37 typeset opt=$2
38 typeset -i cinit=200
39 typeset -i hinit=1000000
40 typeset -i loop=0
41
42 while (( loop < 3 )); do
43 log_note "Create 3 file systems and write files."
44
45 typeset suffix=$opt.$loop
46 log_must zfs create $pool/fs.$suffix
47 log_must zfs set mountpoint=/$pool/dir.$suffix $pool/fs.$suffix
48
49 file_write -o create -f /$pool/dir.$suffix/file.$suffix \
50 -b 65536 -c $cinit -d 0 2>&1 > /dev/null &
51 child_pids="$child_pids $!"
52
53 log_must sleep 30
54
55 file_write -o overwrite -f /$pool/dir.$suffix/file.$suffix \
56 -s $hinit -b 65536 -c 20000 -d 0 2>&1 > /dev/null &
57 child_pids="$child_pids $!"
58
59 (( cinit *= 10 ))
60 (( hinit *= 10 ))
61 (( loop += 1 ))
62 done
63 }
64
65 function cleanup
66 {
67 typeset pool=$(zpool list -H -o name | grep $TESTPOOL)
68
69 typeset fs
70 for fs in $(zfs list -H -o name -t filesystem); do
71 [[ `echo $fs | awk -F'/' '{print $1}'` != $pool ]] && continue
72
73 if datasetexists $fs; then
74 typeset mpt=$(get_prop mountpoint $fs)
75 zfs destroy -Rf $fs 2>&1 > /dev/null
76 rm -rf $mpt 2>&1 > /dev/null
77 fi
78 done
79 }
80
81 function get_pools
82 {
83 echo $(zpool list -H -o name | grep $TESTPOOL);
84 }