xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / generic / 223
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Eric Sandeen.  All Rights Reserved.
4 #
5 # FS QA Test No. 223
6 #
7 # File alignment tests
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16
17 _cleanup()
18 {
19     rm -f $tmp.*
20 }
21
22 trap "_cleanup ; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs generic
30
31 _require_scratch
32 _require_xfs_io_command "falloc"
33
34 rm -f $seqres.full
35
36 BLOCKSIZE=4096
37
38 for SUNIT_K in 8 16 32 64 128; do
39         let SUNIT_BYTES=$SUNIT_K*1024
40         let SUNIT_BLOCKS=$SUNIT_BYTES/$BLOCKSIZE
41
42         echo "=== mkfs with su $SUNIT_BLOCKS blocks x 4 ==="
43         _scratch_mkfs_geom $SUNIT_BYTES 4 $BLOCKSIZE >> $seqres.full 2>&1
44         _scratch_mount
45
46         # This test checks for stripe alignments of space allocations on the
47         # filesystem.  Make sure all files get created on the main device,
48         # which for XFS means no rt files.
49         test "$FSTYP" = "xfs" && \
50                 _xfs_force_bdev data $SCRATCH_MNT
51
52         for SIZE_MULT in 1 2 8 64 256; do
53                 let SIZE=$SIZE_MULT*$SUNIT_BYTES
54
55                 echo "=== Testing size ${SIZE_MULT}*${SUNIT_K}k on ${SUNIT_K}k stripe ==="
56                 for FILE in 1 2 3 4; do
57                         $XFS_IO_PROG -f -c "falloc 0 $SIZE" \
58                                 $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
59                                         >> $seqres.full 2>&1
60                         $XFS_IO_PROG -f -c "pwrite -b $SIZE 0 $SIZE" \
61                                 $SCRATCH_MNT/file-$FILE-$SIZE-write \
62                                         >> $seqres.full 2>&1
63                         $here/src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
64                                 $SUNIT_BLOCKS | _filter_scratch
65                         $here/src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
66                                 $SUNIT_BLOCKS | _filter_scratch
67                 done
68         done
69
70         echo "=== Testing size 1g falloc on ${SUNIT_K}k stripe ==="
71         $XFS_IO_PROG -f -c "falloc 0 1g" \
72             $SCRATCH_MNT/file-1g-falloc >> $seqres.full 2>&1
73         $here/src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS \
74             | _filter_scratch
75
76         rm -f $SCRATCH_MNT/file-1g-falloc | _filter_scratch
77
78         echo "=== Testing size 1073745920 falloc on ${SUNIT_K}k stripe ==="
79         $XFS_IO_PROG -f -c "falloc 0 1073745920" \
80                 $SCRATCH_MNT/file-1073745920-falloc >> $seqres.full 2>&1
81         $here/src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
82                 $SUNIT_BLOCKS | _filter_scratch
83
84         _scratch_unmount
85 done
86
87 status=0
88 exit