xfstests: introduce a common directory
[xfstests-dev.git] / tests / xfs / 203
1 #! /bin/bash
2 # FS QA Test No. 203
3 #
4 # Test out reallocation of the extent array in xfs_io.
5 # Based on a testcase from Tomasz Majkowski <moosh009@gmail.com>.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2009 Christoph Hellwig.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _write_holes()
36 {
37         file=$1
38         holes=$2
39         let writes=$holes+1
40         let fsize=$(($writes * 0x100000))
41
42         # prevent EOF preallocation from affecting results
43         xfs_io -f $file -c "truncate $fsize"
44
45         offset=0
46         for i in `seq 0 $writes`; do
47                 xfs_io -f $file -c "pwrite -q $offset 64k"
48                 let offset=$offset+0x100000
49         done
50 }
51
52 #       0: [0..7]: 104..111
53 #       1: [8..2047]: hole
54 _filter_bmap()
55 {
56         _filter_scratch |
57         awk '$3 ~ /hole/ { print $1, $2, $3; next }
58              {print $1, $2; next}'
59 }
60
61 _cleanup()
62 {
63         rm -f $SCRATCH_MNT/r??
64 }
65 trap "_cleanup; exit \$status" 0 1 2 3 15
66
67 rm -f $seqres.full
68
69 # get standard environment, filters and checks
70 . ./common/rc
71 . ./common/filter
72
73 # real QA test starts here
74 _supported_fs xfs
75 _supported_os Linux
76 _require_scratch
77 _scratch_mkfs > /dev/null 2>&1
78 _scratch_mount > /dev/null 2>&1
79
80 for i in 10 14 15 16 17 28 29 30 31; do
81         rm -f $SCRATCH_MNT/hole_file
82         _write_holes $SCRATCH_MNT/hole_file${i} ${i}
83 done
84
85 for i in 10 14 15 16 17 28 29 30 31; do
86         xfs_bmap $SCRATCH_MNT/hole_file${i} | _filter_bmap
87         echo
88 done
89
90 # success, all done
91 echo "*** done"
92 status=0