845f1f2c8930e2608edfcebb56b8be51c2e32198
[xfstests-dev.git] / 109
1 #! /bin/sh
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 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common.rc
23 . ./common.filter
24
25 # real QA test starts here
26 _supported_fs xfs
27 _supported_os Linux XFS
28 _require_scratch
29
30 populate()
31 {
32         # "faststart" lets us effectively skip (re-)population
33         [ "X$faststart" != "X" ] && rm -f $SCRATCH_MNT/F*
34
35         # create many small files using most available space
36         echo "creating small files..."
37         i=0
38         while [ $i -le $files -a "X$faststart" = "X" ]; do
39                 file=$SCRATCH_MNT/f$i
40                 xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null
41                 let i=$i+1
42         done
43
44         # remove every second file, freeing up lots of space
45         echo "removing small files..."
46         i=1
47         while [ $i -le $files -a "X$faststart" = "X" ]; do
48                 rm $SCRATCH_MNT/f$i
49                 let i=$i+2
50         done
51
52         echo "flushing changes via umount/mount."
53         umount $SCRATCH_DEV
54         _scratch_mount
55 }
56
57 allocate()
58 {
59         # now try to hit the deadlock
60         echo "starting parallel allocators..."
61         i=0
62         while [ $i -le 10 ]; do
63                 file=$SCRATCH_MNT/F$i
64                 {
65                         j=0
66                         while [ $j -lt 100 ]; do
67                                 xfs_io -f -c 'pwrite -b 64k 0 16m' $file \
68                                         >/dev/null 2>&1
69                                 rm $file
70                                 let j=$j+1
71                         done
72                 } &
73                 let i=$i+1
74         done
75
76         wait
77         echo "all done!"
78 }
79
80 # real QA test starts here
81 umount $SCRATCH_DEV 2>/dev/null
82 _scratch_mount
83
84 # see if faststart is possible (and requested)
85 files=2000
86 faststart=""
87 if [ -n "$FASTSTART" -a -f $SCRATCH_MNT/f0 ]; then
88         faststart="-N"  # causes us to skip the mkfs step
89 fi
90 umount $SCRATCH_DEV
91
92 _scratch_mkfs_xfs -dsize=160m,agcount=4 $faststart | _filter_mkfs 2>$tmp.mkfs
93 cat $tmp.mkfs >>$seq.full
94 _scratch_mount
95
96 populate
97 allocate
98 status=0
99 exit