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