fstests: move test group info to test files
[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 . ./common/preamble
10 _begin_fstest auto quick fsmap freeze
11
12 _register_cleanup "_cleanup" BUS
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         cd /
18         $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT > /dev/null 2>&1
19         rm -rf $tmp.*
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/fuzzy
25 . ./common/inject
26 . ./common/xfs
27
28 # real QA test starts here
29 _supported_fs xfs
30 _require_xfs_scratch_rmapbt
31 _require_xfs_io_command "fsmap"
32 _require_command "$KILLALL_PROG" killall
33
34 echo "Format and populate"
35 _scratch_mkfs > "$seqres.full" 2>&1
36 _scratch_mount
37
38 STRESS_DIR="$SCRATCH_MNT/testdir"
39 mkdir -p $STRESS_DIR
40
41 for i in $(seq 0 9); do
42         mkdir -p $STRESS_DIR/$i
43         for j in $(seq 0 9); do
44                 mkdir -p $STRESS_DIR/$i/$j
45                 for k in $(seq 0 9); do
46                         echo x > $STRESS_DIR/$i/$j/$k
47                 done
48         done
49 done
50
51 cpus=$(( $(src/feature -o) * 4 * LOAD_FACTOR))
52
53 echo "Concurrent fsmap and freeze"
54 filter_output() {
55         egrep -v '(Device or resource busy|Invalid argument)'
56 }
57 freeze_loop() {
58         end="$1"
59
60         while [ "$(date +%s)" -lt $end ]; do
61                 $XFS_IO_PROG -x -c 'freeze' $SCRATCH_MNT 2>&1 | filter_output
62                 $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT 2>&1 | filter_output
63         done
64 }
65 fsmap_loop() {
66         end="$1"
67
68         while [ "$(date +%s)" -lt $end ]; do
69                 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > /dev/null
70         done
71 }
72 stress_loop() {
73         end="$1"
74
75         FSSTRESS_ARGS=$(_scale_fsstress_args -p 4 -d $SCRATCH_MNT -n 2000 $FSSTRESS_AVOID)
76         while [ "$(date +%s)" -lt $end ]; do
77                 $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full
78         done
79 }
80
81 start=$(date +%s)
82 end=$((start + (30 * TIME_FACTOR) ))
83
84 echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full
85 stress_loop $end &
86 freeze_loop $end &
87 fsmap_loop $end &
88
89 # Wait until 2 seconds after the loops should have finished...
90 while [ "$(date +%s)" -lt $((end + 2)) ]; do
91         sleep 1
92 done
93
94 # ...and clean up after the loops in case they didn't do it themselves.
95 $KILLALL_PROG -TERM xfs_io fsstress >> $seqres.full 2>&1
96 $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
97
98 echo "Loop finished at $(date)" >> $seqres.full
99 echo "Test done"
100
101 # success, all done
102 status=0
103 exit