ad8b1bac4d797ad0c0fb0ddaec7242dca379f7a6
[xfstests-dev.git] / tests / xfs / 285
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 285
6 #
7 # Race fio and xfs_scrub for a while to see if we crash or livelock.
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 trap "_cleanup; exit \$status" 0 1 2 3 7 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/fuzzy
28 . ./common/inject
29
30 # real QA test starts here
31 _supported_os Linux
32 _supported_fs xfs
33 _require_test_program "feature"
34 _require_command "$KILLALL_PROG" killall
35 _require_command "$TIMEOUT_PROG" timeout
36 _require_scrub
37 _require_scratch
38
39 echo "Format and populate"
40 _scratch_mkfs > "$seqres.full" 2>&1
41 _scratch_mount
42
43 STRESS_DIR="$SCRATCH_MNT/testdir"
44 mkdir -p $STRESS_DIR
45
46 cpus=$(( $(src/feature -o) * 4 * LOAD_FACTOR))
47 $FSSTRESS_PROG -d $STRESS_DIR -p $cpus -n $((cpus * 100000)) $FSSTRESS_AVOID >/dev/null 2>&1 &
48 $XFS_SCRUB_PROG -d -T -v -n $SCRATCH_MNT >> $seqres.full
49
50 killstress() {
51         sleep $(( 60 * TIME_FACTOR ))
52         $KILLALL_PROG -q $FSSTRESS_PROG
53 }
54
55 echo "Concurrent scrub"
56 start=$(date +%s)
57 end=$((start + (60 * TIME_FACTOR) ))
58 killstress &
59 echo "Scrub started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full
60 while [ "$(date +%s)" -lt "$end" ]; do
61         $TIMEOUT_PROG -s TERM $(( end - $(date +%s) + 2 )) $XFS_SCRUB_PROG -d -T -v -n $SCRATCH_MNT >> $seqres.full 2>&1
62 done
63
64 echo "Test done"
65 echo "Scrub finished at $(date)" >> $seqres.full
66 $KILLALL_PROG -q $FSSTRESS_PROG
67
68 # success, all done
69 status=0
70 exit