1 #!/usr/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 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . ${STF_SUITE}/include/libtest.shlib
29
30 # Check that creating and destroying datasets with files that have
31 # attributes do not cause the depletion of the storage pool space.
32 #
33 # @parameter: $1 the pool from which to draw the test file systems
34 # @return: 0 if all the work completed OK.
35 # @use: TOTAL_COUNT log_note log_assert
36
37 typeset -i child=0
38 typeset -i count=0
39 typeset -i failures=0
40 typeset -i i=0
41 typeset dataset=$1
42 typeset ddirb=${TEST_BASE_DIR%%/}/dir.$$
43 typeset tmplogbase=/tmp/${0##*/}.$$
44 typeset pids=
45 typeset tfilesys=
46 typeset tmntpnt=
47
48 function remove_entities
49 {
50 [[ -n $runpids ]] && kill -9 $runpids
51 [[ -n $tmntpnt ]] && zfs umount -f $tmntpnt
52 [[ -n $tfilesys ]] && zfs destroy -f $tfilesys
53 [[ -d $tmntpnt ]] && rm -rf $tmntpnt
54 }
55
56 # execute many runat commands.
57 # @parameter: $1 directory to perform the runat in
58 # @return: 0 if all the runats completed
59 # @use: count RUNAT CP
60 function many_runat
61 {
62 typeset dir=$1
63 typeset file=$dir/$$
64 typeset -i iter=0
65 typeset -i iter2=0
66 typeset -i status=0
67 typeset -i failed=0
68
69 while (( iter <= count )); do
70 log_must mkfile 1m $file
71 iter2=0
72 while (( iter2 <= iter )); do
73 runat $file "cp $file $iter"
74 status=$?
75 if (( $status != 0 )); then
76 log_note "runat $file \"cp $file $iter2\"" \
77 "failed with $status"
78 (( failed = failed + 1 ))
79 fi
80 (( iter2 = iter2 + 1 ))
81 done
82 (( iter = iter + 1 ))
83 lockfs -f $dir
84 log_must rm -f $file
85 done
86 if (( failed != 0 )); then
87 return 1
88 else
89 return 0
90 fi
91 }
92
93 log_onexit remove_entities
94
95 (( count = TOTAL_COUNT * NUM_CREATORS ))
96
97 while (( i < count )); do
98 typeset -i j=0
99 typeset -i pid=0
100 tmntpnt=$ddirb.$i
101 tfilesys=$dataset/tcwda.$$.$i
102
103 log_must mkdir -p $tmntpnt
104 log_must zfs create $tfilesys
105 log_must zfs set mountpoint=$tmntpnt $tfilesys
106 while (( j <= NUM_CREATORS )); do
107 many_runat $tmntpnt >$tmplogbase.$j 2>&1 &
108 pids="$pids $!"
109 (( j = j + 1 ))
110 done
111
112 j=0
113 for pid in $pids; do
114 wait $pid
115 status=$?
116 if (( $status != 0 )); then
117 log_note "exattr_create_destroy failed: $status"
118 cat $tmplogbase.$j
119 (( failures = failures + 1 ))
120 fi
121 log_must rm -f $tmplogbase.$j
122 (( j = j + 1 ))
123 done
124 pids=
125 log_must rm -rf $tmntpnt/*
126 log_must zfs unmount $tmntpnt
127 log_must zfs destroy $tfilesys
128 log_must rm -rf $tmntpnt
129 tfilesys=
130 tmntpnt=
131 (( i = i + 1 ))
132 done
133
134 if (( failures > 0 )); then
135 log_fail "There were $failures exattr failures in this run"
136 fi
137
138 log_pass