xfstests: 223 - test file alignment on stripe geometry
[xfstests-dev.git] / 223
1 #! /bin/bash
2 # FS QA Test No. 223
3 #
4 # File alignment tests
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 Eric Sandeen.  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 # creator
25 owner=sandeen@sandeen.net
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 _cleanup()
35 {
36     rm -f $tmp.*
37 }
38
39 trap "_cleanup ; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./common.filter
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os Linux
48
49 _require_scratch
50 _require_xfs_io_falloc
51
52 rm -f $seq.full
53
54 _filter_scratch()
55 {
56         sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
57 }
58
59 BLOCKSIZE=4096
60
61 for SUNIT_K in 8 16 32 64 128; do
62         let SUNIT_BYTES=$SUNIT_K*1024
63         let SUNIT_BLOCKS=$SUNIT_BYTES/$BLOCKSIZE
64
65         echo "=== mkfs with su $SUNIT_BLOCKS blocks x 4 ==="
66         _scratch_mkfs_geom $SUNIT_BYTES 4 $BLOCKSIZE &>> $seq.full
67         _scratch_mount
68
69         for SIZE_MULT in 1 2 8 64 256; do
70                 let SIZE=$SIZE_MULT*$SUNIT_BYTES
71
72                 echo "=== Testing size ${SIZE_MULT}*${SUNIT_K}k on ${SUNIT_K}k stripe ==="
73                 for FILE in 1 2 3 4; do
74                         xfs_io -F -f -c "falloc 0 $SIZE" \
75                                 $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
76                                         &>> $seq.full
77                         xfs_io -F -f -c "pwrite 0 $SIZE" \
78                                 $SCRATCH_MNT/file-$FILE-$SIZE-write \
79                                         &>> $seq.full
80                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
81                                 $SUNIT_BLOCKS | _filter_scratch
82                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
83                                 $SUNIT_BLOCKS | _filter_scratch
84                 done
85         done
86
87         echo "=== Testing size 1g falloc on ${SUNIT_K}k stripe ==="
88         xfs_io -F -f -c "falloc 0 1g" $SCRATCH_MNT/file-1g-falloc &>> $seq.full
89         src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS
90
91         rm -f $SCRATCH_MNT/file-1g-falloc | _filter_scratch
92
93         echo "=== Testing size 1073745920 falloc on ${SUNIT_K}k stripe ==="
94         xfs_io -F -f -c "falloc 0 1073745920" \
95                 $SCRATCH_MNT/file-1073745920-falloc &>> $seq.full
96         src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
97                 $SUNIT_BLOCKS | _filter_scratch
98
99         _scratch_unmount
100 done
101
102 status=0
103 exit