xfs/004: don't fail test due to realtime files
[xfstests-dev.git] / tests / xfs / 531
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Chandan Babu R.  All Rights Reserved.
4 #
5 # FS QA Test 531
6 #
7 # Verify that XFS does not cause inode fork's extent count to overflow when
8 # punching out an extent.
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 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/inject
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 _supported_fs xfs
35 _require_scratch
36 _require_xfs_debug
37 _require_xfs_io_command "fpunch"
38 _require_xfs_io_command "finsert"
39 _require_xfs_io_command "fcollapse"
40 _require_xfs_io_command "fzero"
41 _require_xfs_io_error_injection "reduce_max_iextents"
42
43 echo "Format and mount fs"
44 _scratch_mkfs >> $seqres.full
45 _scratch_mount >> $seqres.full
46
47 bsize=$(_get_file_block_size $SCRATCH_MNT)
48 nr_blks=30
49
50 testfile=$SCRATCH_MNT/testfile
51
52 for op in fpunch finsert fcollapse fzero; do
53         echo "* $op regular file"
54
55         echo "Create \$testfile"
56         touch $testfile
57
58         echo "Inject reduce_max_iextents error tag"
59         _scratch_inject_error reduce_max_iextents 1
60
61         $XFS_IO_PROG -f -s \
62                      -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \
63                      $testfile  >> $seqres.full
64
65         echo "$op alternating blocks"
66         for i in $(seq 1 2 $((nr_blks - 1))); do
67                 $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \
68                        >> $seqres.full 2>&1
69                 [[ $? != 0 ]] && break
70         done
71
72         echo "Verify \$testfile's extent count"
73
74         nextents=$(_xfs_get_fsxattr nextents $testfile)
75         if (( $nextents > 10 )); then
76                 echo "Extent count overflow check failed: nextents = $nextents"
77                 exit 1
78         fi
79
80         echo "Disable reduce_max_iextents error tag"
81         _scratch_inject_error reduce_max_iextents 0
82
83         rm $testfile
84 done
85
86 # success, all done
87 status=0
88 exit