fstests: renumber tests after merge
[xfstests-dev.git] / tests / xfs / 517
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2020 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 517
6 #
7 # Race freeze and fsmap 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         $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT > /dev/null 2>&1
22         rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/fuzzy
29 . ./common/inject
30 . ./common/xfs
31
32 # real QA test starts here
33 _supported_os Linux
34 _supported_fs xfs
35 _require_xfs_scratch_rmapbt
36 _require_xfs_io_command "fsmap"
37 _require_command "$KILLALL_PROG" killall
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 for i in $(seq 0 9); do
47         mkdir -p $STRESS_DIR/$i
48         for j in $(seq 0 9); do
49                 mkdir -p $STRESS_DIR/$i/$j
50                 for k in $(seq 0 9); do
51                         echo x > $STRESS_DIR/$i/$j/$k
52                 done
53         done
54 done
55
56 cpus=$(( $(src/feature -o) * 4 * LOAD_FACTOR))
57
58 echo "Concurrent fsmap and freeze"
59 filter_output() {
60         egrep -v '(Device or resource busy|Invalid argument)'
61 }
62 freeze_loop() {
63         end="$1"
64
65         while [ "$(date +%s)" -lt $end ]; do
66                 $XFS_IO_PROG -x -c 'freeze' $SCRATCH_MNT 2>&1 | filter_output
67                 $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT 2>&1 | filter_output
68         done
69 }
70 fsmap_loop() {
71         end="$1"
72
73         while [ "$(date +%s)" -lt $end ]; do
74                 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > /dev/null
75         done
76 }
77 stress_loop() {
78         end="$1"
79
80         FSSTRESS_ARGS=$(_scale_fsstress_args -p 4 -d $SCRATCH_MNT -n 2000 $FSSTRESS_AVOID)
81         while [ "$(date +%s)" -lt $end ]; do
82                 $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full
83         done
84 }
85
86 start=$(date +%s)
87 end=$((start + (30 * TIME_FACTOR) ))
88
89 echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full
90 stress_loop $end &
91 freeze_loop $end &
92 fsmap_loop $end &
93
94 # Wait until 2 seconds after the loops should have finished...
95 while [ "$(date +%s)" -lt $((end + 2)) ]; do
96         sleep 1
97 done
98
99 # ...and clean up after the loops in case they didn't do it themselves.
100 $KILLALL_PROG -TERM xfs_io fsstress >> $seqres.full 2>&1
101 $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
102
103 echo "Loop finished at $(date)" >> $seqres.full
104 echo "Test done"
105
106 # success, all done
107 status=0
108 exit