xfstests: cleanup duplicates in all tests
[xfstests-dev.git] / tests / xfs / 109
1 #! /bin/bash
2 # FS QA Test No. 109
3 #
4 # ENOSPC deadlock case from Asano Masahiro.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37
38 # real QA test starts here
39 _supported_fs xfs
40 _supported_os Linux XFS
41 _require_scratch
42
43 populate()
44 {
45         # "faststart" lets us effectively skip (re-)population
46         [ "X$faststart" != "X" ] && rm -f $SCRATCH_MNT/F*
47
48         # create many small files using most available space
49         echo "creating small files..."
50         i=0
51         while [ $i -le $files -a "X$faststart" = "X" ]; do
52                 file=$SCRATCH_MNT/f$i
53                 xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null
54                 let i=$i+1
55         done
56
57         # remove every second file, freeing up lots of space
58         echo "removing small files..."
59         i=1
60         while [ $i -le $files -a "X$faststart" = "X" ]; do
61                 rm $SCRATCH_MNT/f$i
62                 let i=$i+2
63         done
64
65         echo "flushing changes via umount/mount."
66         umount $SCRATCH_DEV
67         _scratch_mount
68 }
69
70 allocate()
71 {
72         # now try to hit the deadlock
73         echo "starting parallel allocators..."
74         i=0
75         while [ $i -le 10 ]; do
76                 file=$SCRATCH_MNT/F$i
77                 {
78                         j=0
79                         while [ $j -lt 100 ]; do
80                                 xfs_io -f -c 'pwrite -b 64k 0 16m' $file \
81                                         >/dev/null 2>&1
82                                 rm $file
83                                 let j=$j+1
84                         done
85                 } &
86                 let i=$i+1
87         done
88
89         wait
90         echo "all done!"
91 }
92
93 # real QA test starts here
94 umount $SCRATCH_DEV 2>/dev/null
95 _scratch_mount
96
97 # see if faststart is possible (and requested)
98 files=2000
99 faststart=""
100 if [ -n "$FASTSTART" -a -f $SCRATCH_MNT/f0 ]; then
101         faststart="-N"  # causes us to skip the mkfs step
102 fi
103 umount $SCRATCH_DEV
104
105 _scratch_mkfs_xfs -dsize=160m,agcount=4 $faststart | _filter_mkfs 2>$tmp.mkfs
106 cat $tmp.mkfs >>$seqres.full
107 _scratch_mount
108
109 populate
110 allocate
111 status=0
112 exit