xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / generic / 068
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 068
6 #
7 # Test case to reproduce xfs_freeze hang under filsystem load.
8 # The fail case for this test is a hang on an xfs_freeze.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=0        # success is the default!
17
18 ITERATIONS=10
19
20 _cleanup()
21 {
22     cd /
23
24     trap 0 1 2 3 15
25     exit $status
26 }
27
28 trap "_cleanup" 0 1 2 3 15
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # real QA test starts here
35 _supported_fs generic
36
37 _require_scratch
38 _require_freeze
39
40 echo "*** init FS"
41
42 rm -f $seqres.full
43 _scratch_unmount >/dev/null 2>&1
44 echo "*** MKFS ***"                         >>$seqres.full
45 echo ""                                     >>$seqres.full
46 _scratch_mkfs                               >>$seqres.full 2>&1 \
47     || _fail "mkfs failed"
48 _scratch_mount
49
50 touch $tmp.running
51
52 # start fsstress loop in a background block
53 {
54     STRESS_DIR="$SCRATCH_MNT/fsstress_test_dir"
55     mkdir "$STRESS_DIR"
56
57     procs=2
58     nops=200
59     while [ -f "$tmp.running" ]
60       do
61       # We do both read & write IO - not only is this more realistic,
62       # but it also potentially tests atime updates
63       FSSTRESS_ARGS=`_scale_fsstress_args -d $STRESS_DIR -p $procs -n $nops $FSSTRESS_AVOID`
64       $FSSTRESS_PROG $FSSTRESS_ARGS > /dev/null 2>&1
65     done
66
67     rm -r $STRESS_DIR/*
68     rmdir $STRESS_DIR
69 } &
70
71 # start fstest -m loop in a background block; this gets us mmap coverage
72 {
73     FSTEST_DIR="$SCRATCH_MNT/fstest_test_dir"
74     mkdir "$FSTEST_DIR"
75
76     procs=2
77     while [ -f "$tmp.running" ]
78       do
79       $here/src/fstest -m -p $FSTEST_DIR  -n $procs -f 4 > /dev/null 2>&1
80     done
81
82     rm -rf $FSTEST_DIR/*
83     rmdir $FSTEST_DIR
84 } &
85
86 i=0
87 let ITERATIONS=$ITERATIONS-1
88
89 echo | tee -a $seqres.full
90 while [ $i -le $ITERATIONS ]
91 do
92         echo "*** iteration: $i" | tee -a $seqres.full
93         echo "*** freezing \$SCRATCH_MNT" | tee -a $seqres.full
94         xfs_freeze -f "$SCRATCH_MNT" | tee -a $seqres.full
95         [ $? != 0 ] && echo xfs_freeze -f "$SCRATCH_MNT" failed | \
96             tee -a $seqres.full
97         sleep 2
98
99         echo "*** thawing  \$SCRATCH_MNT" | tee -a $seqres.full
100         xfs_freeze -u "$SCRATCH_MNT" | tee -a $seqres.full
101         [ $? != 0 ] && echo xfs_freeze -u "$SCRATCH_MNT" failed | \
102             tee -a $seqres.full
103         sleep 2
104
105         echo  | tee -a $seqres.full
106         let i=$i+1
107 done
108
109 # stop fsstress iterations
110 rm $tmp.running
111
112 # wait for fsstresses to finish
113 wait
114
115 exit 1