summaryrefslogtreecommitdiff
path: root/114
blob: 5f7c23db288e06ed4df1d44a364dc81f31be8fb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#! /bin/sh
# FS QA Test No. 114
#
# Test some parent ptr stuff
#
#-----------------------------------------------------------------------
# Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
#-----------------------------------------------------------------------
#
# creator
owner=tes@crackle.melbourne.sgi.com

seq=`basename $0`
echo "QA output created by $seq"

here=`pwd`
tmp=/tmp/$$
status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_cleanup()
{
    cd /
    rm -f $tmp.*
}


_check_paths()
{
	_path=$1 # might want to only check this path

	sync; sleep 1
	echo ""
	echo "Check parent"
	if ! xfs_io -x -c 'parent -c' $SCRATCH_MNT | _filter_num; then
		exit 1
	fi
}

_print_names()
{
	echo ""
	echo "Print out hardlink names for given path, $1"
	echo ""

	xfs_io -x -c parent $1 | awk '/p_ino.*=/ {$3 = "inodeXXX"; print; next} {print}' 
}

_test_create()
{
	echo ""
	echo "Testing create"
	echo ""

	# Test out some creations
	cd $SCRATCH_MNT
	touch file1

	mkdir dir2
	touch dir2/file2

	mkdir dir2/dir3
	touch dir2/dir3/file3

	mkdir dir2/dir3/dir4

	p=dir2/dir3/dir4/file4
	touch $p

	#_print_names $p >>$here/$seq.full
	_print_names $p | tee -a $here/$seq.full

	_check_paths $SCRATCH_MNT/$p
}

_test_symlink()
{
	echo ""
	echo "Testing symlink"
	echo ""

	d=sym1/sym2/sym3
	f=$d/sym4_f

	mkdir -p $d
        ln -s $f symlink1
	ln symlink1 hlink1
	ln symlink1 hlink2
	ln symlink1 hlink3
	_check_paths $SCRATCH_MNT/symlink1
	_check_paths $SCRATCH_MNT/hlink1
	_check_paths $SCRATCH_MNT/hlink2
	_check_paths $SCRATCH_MNT/hlink3
}

#
# create hardlinks from the same dir
# and some from different dirs
#
# test out removing hardlinks too
#
_test_hardlink()
{
	echo ""
	echo "Testing hardlink"
	echo ""

	d=dir2/dir3/dir4
	d2=dir2/dir5/dir6
	mkdir -p $d
	mkdir -p $d2
	p=$d/file4
	touch $p

	# create hardlinks
	paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6"
	for x in $paths; do
		ln $p $x
	done

	_print_names $p >>$here/$seq.full

	echo ""
	echo "print out names and check after created hardlinks"
	echo ""
	for x in $paths; do
		_print_names $x | tee -a $here/$seq.full
		_check_paths $SCRATCH_MNT/$x
	done


	echo ""
	echo "now try removing half of the hardlinks"
	echo ""
	paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6"
	i=0
	for x in $paths; do
		i=`expr $i + 1`
		j=`expr $i % 2`
		if [ $j -eq 0 ]; then
			echo "rm'ing $x"
			rm $x
		fi
	done

	echo ""
	echo "print out names and check after removed hardlinks"
	echo ""
	for x in $paths; do
		if [ -e $x ]; then 
			_print_names $x | tee -a $here/$seq.full
			_check_paths $SCRATCH_MNT/$x
		fi
	done

}

#
# in dir, file1 to file2 where file2 does not exist
# in dir, file1 to file2 where file2 does exist 
# dir/file1 to dir2/file2 where file2 does not exist
# dir/file1 to dir2/file2 where file2 does exist
# dir to dir2 where dir2 does not exist
# dir to dir/dir3 - not allowed
#
#
_test_rename()
{
	echo ""
	echo "Testing rename"
	echo ""

	echo ""
	echo "1. in dir, file1 to file2 where file2 does not exist" 
	echo ""
	d1=$SCRATCH_MNT/ren1/ren2/ren3/ren4
	mkdir -p $d1
	p1=$d1/f1
	p2=$d1/f2
	touch $p1
	mv $p1 $p2
	_check_paths $p2

	echo ""
	echo "2. in dir, file1 to file2 where file2 does exist" 
	echo ""
	touch $p1
	mv $p1 $p2
	_check_paths $p2

	echo ""
	echo "3. dir/file1 to dir2/file2 where file2 does not exist"
	echo ""
	d2=$SCRATCH_MNT/ren1/ren2/ren3/ren5
	mkdir -p $d2
	p3=$d2/f3
	touch $p1
	mv $p1 $p3
	_check_paths $p3

	echo ""
	echo "4. dir/file1 to dir2/file2 where file2 does exist"
	echo ""
	d2=$SCRATCH_MNT/ren1/ren2/ren3/ren5
	p3=$d2/f3
	touch $p1
	mv $p1 $p3
	_check_paths $p3

	echo ""
	echo "5. dir to dir2 where dir2 does not exist"
	echo ""
	d3=$SCRATCH_MNT/ren1/ren2/ren3/ren6
	mv $d1 $d3
	_check_paths $d3
}

_filter_num()
{
	tee -a $here/$seq.full |\
	sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
	    -e 's/[0-9][0-9]* paths/P paths/g' \
	    -e 's/seed = [0-9][0-9]*/seed = S/'
}


_test_fsstress()
{
	echo ""
	echo "Testing fsstress"
	echo ""

	out=$SCRATCH_MNT/fsstress.$$
	count=1000
	args="-z \
-f rmdir=10 -f link=10 -f creat=10 \
-f mkdir=10 -f rename=30 -f unlink=10 \
-f symlink=10 \
-n $count -d $out -p 3"

	echo "fsstress $args" | sed -e "s#$out#outdir#"
	if ! $FSSTRESS_PROG $args | _filter_num
	then
		echo "    fsstress $args returned $?"
		cat $tmp.out | tee -a $here/$seq.full
		status=1
	fi

	_check_paths
}


_test_dirstress()
{
	echo ""
	echo "Testing dirstress"
	echo ""

	out=$SCRATCH_MNT/dirstress.$$
	count=1000

	if ! mkdir $out
	then
	    echo "!! couldn't mkdir $out"
	    status=1
	    exit
	fi

	args="-d $out -f $count -k -p 3 -n 1"
	echo "dirstress $args" | sed -e "s#$out#outdir#"
	if ! $here/src/dirstress $args >$tmp.out 2>&1 | _filter_num
	then
		echo "    dirstress failed"
		echo "*** dirstress $args" | tee -a $here/$seq.full
		cat $tmp.out >>$here/$seq.full
		status=1
		exit
	fi

	args="-d $out -f $count -k -p 3 -n 5"
	echo "dirstress $args" | sed -e "s#$out#outdir#"
	if ! $here/src/dirstress $args >$tmp.out 2>&1 | _filter_num
	then
		echo "    dirstress failed"
		echo "*** dirstress $args" | tee -a $here/$seq.full
		cat $tmp.out >>$here/$seq.full
		status=1
		exit
	fi

	_check_paths
}

# get standard environment, filters and checks
. ./common.rc
. ./common.filter

_supported_fs xfs
_supported_os IRIX

_require_scratch
_need_to_be_root

rm -f $here/$seq.full

echo "mkfs"
_scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
    || _fail "mkfs scratch failed"
_scratch_mkfs_xfs -i parent=1 >>$here/$seq.full 2>&1 \
    || _notrun "parent inodes not supported"

echo "mount"
_scratch_mount >>$here/$seq.full 2>&1 \
    || _fail "mount failed: $MOUNT_OPTIONS"

# real QA test starts here

verbose=false

_test_create
_test_hardlink
_test_rename
_test_symlink

# stress testing with verification by parent checking programs
_test_fsstress
_test_dirstress

# success, all done
status=0
exit