dfd8c41bd6bdc184549bc778aa265aed5cacd963
[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 _supported_os Linux
31
32 _require_scratch
33 _require_xfs_io_command "falloc"
34
35 rm -f $seqres.full
36
37 BLOCKSIZE=4096
38
39 for SUNIT_K in 8 16 32 64 128; do
40         let SUNIT_BYTES=$SUNIT_K*1024
41         let SUNIT_BLOCKS=$SUNIT_BYTES/$BLOCKSIZE
42
43         echo "=== mkfs with su $SUNIT_BLOCKS blocks x 4 ==="
44         export MKFS_OPTIONS=""
45         _scratch_mkfs_geom $SUNIT_BYTES 4 $BLOCKSIZE >> $seqres.full 2>&1
46         _scratch_mount
47
48         for SIZE_MULT in 1 2 8 64 256; do
49                 let SIZE=$SIZE_MULT*$SUNIT_BYTES
50
51                 echo "=== Testing size ${SIZE_MULT}*${SUNIT_K}k on ${SUNIT_K}k stripe ==="
52                 for FILE in 1 2 3 4; do
53                         $XFS_IO_PROG -f -c "falloc 0 $SIZE" \
54                                 $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
55                                         >> $seqres.full 2>&1
56                         $XFS_IO_PROG -f -c "pwrite -b $SIZE 0 $SIZE" \
57                                 $SCRATCH_MNT/file-$FILE-$SIZE-write \
58                                         >> $seqres.full 2>&1
59                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
60                                 $SUNIT_BLOCKS | _filter_scratch
61                         src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
62                                 $SUNIT_BLOCKS | _filter_scratch
63                 done
64         done
65
66         echo "=== Testing size 1g falloc on ${SUNIT_K}k stripe ==="
67         $XFS_IO_PROG -f -c "falloc 0 1g" \
68             $SCRATCH_MNT/file-1g-falloc >> $seqres.full 2>&1
69         src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS \
70             | _filter_scratch
71
72         rm -f $SCRATCH_MNT/file-1g-falloc | _filter_scratch
73
74         echo "=== Testing size 1073745920 falloc on ${SUNIT_K}k stripe ==="
75         $XFS_IO_PROG -f -c "falloc 0 1073745920" \
76                 $SCRATCH_MNT/file-1073745920-falloc >> $seqres.full 2>&1
77         src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
78                 $SUNIT_BLOCKS | _filter_scratch
79
80         _scratch_unmount
81 done
82
83 status=0
84 exit