8a1c2d77a513ba8d5af30b6eed015267c33e7d35
[xfstests-dev.git] / 203
1 #! /bin/sh
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 # creator
25 owner=hch@lst.de
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33
34 _write_holes()
35 {
36         file=$1
37         holes=$2
38         let writes=$holes+1
39
40         offset=0
41         for i in `seq 0 $writes`; do
42                 xfs_io -f $file -c "pwrite -q $offset 1"
43                 let offset=$offset+0x100000
44         done
45 }
46
47 #       0: [0..7]: 104..111
48 #       1: [8..2047]: hole
49 _filter_bmap()
50 {
51         awk '$3 ~ /hole/ { print $1, $2, $3; next }
52              {print $1, $2; next}'
53 }
54
55 _cleanup()
56 {
57         rm -f $TEST_DIR/hole_file*
58         rm -f $TEST_DIR/r??
59 }
60 trap "_cleanup; exit \$status" 0 1 2 3 15
61
62 # get standard environment, filters and checks
63 . ./common.rc
64 . ./common.filter
65
66 # real QA test starts here
67 _supported_fs xfs
68 _supported_os Linux
69
70
71 for i in 10 14 15 16 17 28 29 30 31; do
72         rm -f $TEST_DIR/hole_file
73         _write_holes $TEST_DIR/hole_file${i} ${i}
74 done
75
76 for i in 10 14 15 16 17 28 29 30 31; do
77         xfs_bmap $TEST_DIR/hole_file${i} | _filter_bmap
78         echo
79 done
80
81 # success, all done
82 echo "*** done"
83 rm -f $seq.full
84 status=0