xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 203
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Christoph Hellwig.
4 #
5 # FS QA Test No. 203
6 #
7 # Test out reallocation of the extent array in xfs_io.
8 # Based on a testcase from Tomasz Majkowski <moosh009@gmail.com>.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17
18 _write_holes()
19 {
20         file=$1
21         holes=$2
22         let writes=$holes+1
23         let fsize=$(($writes * 0x100000))
24
25         # prevent EOF preallocation from affecting results
26         $XFS_IO_PROG -f $file -c "truncate $fsize"
27
28         offset=0
29         for i in `seq 0 $writes`; do
30                 $XFS_IO_PROG -f $file -c "pwrite -b 64k -q $offset 64k"
31                 let offset=$offset+0x100000
32         done
33 }
34
35 #       0: [0..7]: 104..111
36 #       1: [8..2047]: hole
37 _filter_bmap()
38 {
39         _filter_scratch |
40         awk '$3 ~ /hole/ { print $1, $2, $3; next }
41              {print $1, $2; next}'
42 }
43
44 _cleanup()
45 {
46         rm -f $SCRATCH_MNT/r??
47 }
48 trap "_cleanup; exit \$status" 0 1 2 3 15
49
50 rm -f $seqres.full
51
52 # get standard environment, filters and checks
53 . ./common/rc
54 . ./common/filter
55
56 # real QA test starts here
57 _supported_fs xfs
58 _require_scratch
59 _scratch_mkfs > /dev/null 2>&1
60 _scratch_mount > /dev/null 2>&1
61
62 for i in 10 14 15 16 17 28 29 30 31; do
63         rm -f $SCRATCH_MNT/hole_file
64         _write_holes $SCRATCH_MNT/hole_file${i} ${i}
65 done
66
67 for i in 10 14 15 16 17 28 29 30 31; do
68         xfs_bmap $SCRATCH_MNT/hole_file${i} | _filter_bmap
69         echo
70 done
71
72 # success, all done
73 echo "*** done"
74 status=0