generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 072
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. 072
6 #
7 # Test truncate/collapse range race.
8 # And this test is also a regression test for kernel commit 23fffa9,
9 #    fs: move falloc collapse range check into the filesystem methods
10 # If the race occurs, it will trigger a BUG_ON().
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22         rm -f $tmp.*
23 }
24
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_test
34 _require_xfs_io_command "fcollapse"
35
36 testfile=$TEST_DIR/testfile.$seq
37 NCPUS=`$here/src/feature -o`
38 # cap NCPUS to 8 at maximum to avoid long run time on hosts with many cpus
39 if [ $NCPUS -gt 8 ]; then
40         NCPUS=8
41 fi
42 OUTER_LOOPS=$((10 * $NCPUS * $LOAD_FACTOR))
43 INNER_LOOPS=$((50 * $NCPUS * $LOAD_FACTOR))
44 # fcollapse/truncate continuously and simultaneously a same file
45 for ((i=1; i <= OUTER_LOOPS; i++)); do
46         for ((i=1; i <= INNER_LOOPS; i++)); do
47                 $XFS_IO_PROG -f -c 'truncate 100k' \
48                         -c 'fcollapse 0 16k' $testfile > /dev/null 2>&1
49         done &
50         for ((i=1; i <= INNER_LOOPS; i++)); do
51                 $XFS_IO_PROG -f -c 'truncate 0' $testfile > /dev/null 2>&1
52         done &
53 done
54 wait
55
56 echo "Silence is golden"
57 status=0
58 exit