fstests: check for filesystem FS_IOC_FSSETXATTR support
[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 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 7 15
19
20 _cleanup()
21 {
22         cd /
23         rm -rf $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/fuzzy
30 . ./common/inject
31 . ./common/xfs
32
33 # real QA test starts here
34 _supported_os Linux
35 _supported_fs xfs
36 _require_xfs_scratch_rmapbt
37 _require_xfs_io_command "scrub"
38 _require_xfs_io_error_injection "force_repair"
39 _require_command "$KILLALL_PROG" killall
40
41 echo "Format and populate"
42 _scratch_mkfs > "$seqres.full" 2>&1
43 _scratch_mount
44
45 STRESS_DIR="$SCRATCH_MNT/testdir"
46 mkdir -p $STRESS_DIR
47
48 for i in $(seq 0 9); do
49         mkdir -p $STRESS_DIR/$i
50         for j in $(seq 0 9); do
51                 mkdir -p $STRESS_DIR/$i/$j
52                 for k in $(seq 0 9); do
53                         echo x > $STRESS_DIR/$i/$j/$k
54                 done
55         done
56 done
57
58 cpus=$(( $(src/feature -o) * 4 * LOAD_FACTOR))
59
60 echo "Concurrent repair"
61 filter_output() {
62         egrep -v '(Device or resource busy|Invalid argument)'
63 }
64 freeze_loop() {
65         end="$1"
66
67         while [ "$(date +%s)" -lt $end ]; do
68                 $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT 2>&1 | filter_output
69         done
70 }
71 repair_loop() {
72         end="$1"
73
74         while [ "$(date +%s)" -lt $end ]; do
75                 $XFS_IO_PROG -x -c 'repair rmapbt 0' -c 'repair rmapbt 1' $SCRATCH_MNT 2>&1 | filter_output
76         done
77 }
78 stress_loop() {
79         end="$1"
80
81         FSSTRESS_ARGS=$(_scale_fsstress_args -p 4 -d $SCRATCH_MNT -n 2000 $FSSTRESS_AVOID)
82         while [ "$(date +%s)" -lt $end ]; do
83                 $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full
84         done
85 }
86 $XFS_IO_PROG -x -c 'inject force_repair' $SCRATCH_MNT
87
88 start=$(date +%s)
89 end=$((start + (30 * TIME_FACTOR) ))
90
91 echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full
92 stress_loop $end &
93 freeze_loop $end &
94 repair_loop $end &
95
96 # Wait until 2 seconds after the loops should have finished...
97 while [ "$(date +%s)" -lt $((end + 2)) ]; do
98         sleep 1
99 done
100
101 # ...and clean up after the loops in case they didn't do it themselves.
102 $KILLALL_PROG -TERM xfs_io fsstress >> $seqres.full 2>&1
103 $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
104
105 echo "Loop finished at $(date)" >> $seqres.full
106 echo "Test done"
107
108 # success, all done
109 status=0
110 exit