xfstests: remove stale machine configs
[xfstests-dev.git] / 305
1 #! /bin/bash
2 # FSQA Test No. 305
3 #
4 # Run fsstress and fio(dio/aio and mmap) and simulate disk failure
5 # check filesystem consistency at the end.
6 #
7 #-----------------------------------------------------------------------
8 # (c) 2013 Dmitry Monakhov
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 _supported_fs ext3 ext4 xfs btrfs reiserfs
37 _supported_os Linux
38 _need_to_be_root
39 _require_scratch
40 _require_fail_make_request
41
42 # TODO: Function are common enough to be moved to common.blkdev
43 SCRATCH_REAL_DEV=`readlink -f $SCRATCH_DEV`
44 SCRATCH_BDEV=`basename $SCRATCH_REAL_DEV`
45
46 allow_fail_make_request()
47 {
48     echo "Allow global fail_make_request feature"
49     echo 100 > $DEBUGFS_MNT/fail_make_request/probability
50     echo 9999999 > $DEBUGFS_MNT/fail_make_request/times
51     echo 0 >  /sys/kernel/debug/fail_make_request/verbose
52 }
53
54 disallow_fail_make_request()
55 {
56     echo "Disallow global fail_make_request feature"
57     echo 0 > $DEBUGFS_MNT/fail_make_request/probability
58     echo 0 > $DEBUGFS_MNT/fail_make_request/times
59 }
60
61 start_fail_scratch_dev()
62 {
63     echo "Force SCRATCH_DEV device failure"
64     echo " echo 1 > /sys/block/$SCRATCH_BDEV/make-it-fail" >> $here/$seq.full
65     echo 1 > /sys/block/$SCRATCH_BDEV/make-it-fail
66
67 }
68
69 stop_fail_scratch_dev()
70 {
71     echo "Make SCRATCH_DEV device operable again"
72     echo " echo 0 > /sys/block/$SCRATCH_BDEV/make-it-fail" >> $here/$seq.full
73     echo 0 > /sys/block/$SCRATCH_BDEV/make-it-fail
74
75 }
76
77 _cleanup()
78 {
79     poweron_scratch_dev
80     disallow_fail_make_request
81 }
82 trap "_cleanup; exit \$status" 1 2 3 15
83
84 RUN_TIME=$((20+10*$TIME_FACTOR))
85 NUM_JOBS=$((4*LOAD_FACTOR))
86 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
87 FILE_SIZE=$((BLK_DEV_SIZE * 512))
88
89 cat >$tmp-$seq.fio <<EOF
90 ###########
91 # $seq test's fio activity
92 # Filenames derived from jobsname and jobid like follows:
93 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
94 [global]
95 ioengine=libaio
96 bs=4k
97 directory=${SCRATCH_MNT}
98 filesize=${FILE_SIZE}
99 size=9999T
100 continue_on_error=write
101 ignore_error=EIO,ENOSPC:EIO
102 error_dump=0
103
104 [stress_dio_aio_activity]
105 create_on_open=1
106 fallocate=none
107 iodepth=128*${LOAD_FACTOR}
108 direct=1
109 buffered=0
110 numjobs=${NUM_JOBS}
111 rw=randwrite
112 runtime=40+${RUN_TIME}
113 time_based
114
115 [stress_mmap_activity]
116 ioengine=mmap
117 create_on_open=0
118 fallocate=1
119 fdatasync=40960
120 filesize=8M
121 size=9999T
122 numjobs=${NUM_JOBS}
123 rw=randwrite
124 runtime=40+${RUN_TIME}
125 time_based
126
127 EOF
128
129 _require_fio $tmp-$seq.fio
130
131 # Disable all sync operations to get higher load
132 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0 -f setattr=1"
133
134 _workout()
135 {
136         out=$SCRATCH_MNT/fsstress.$$
137         args=`_scale_fsstress_args -p 1 -n999999999 -f setattr=0 $FSSTRESS_AVOID -d $out`
138         echo ""
139         echo "Start fsstress.."
140         echo ""
141         echo "fsstress $args" >> $here/$seq.full
142         $FSSTRESS_PROG $args > /dev/null 2>&1 &
143         fs_pid=$!
144         echo "Start fio.."
145         cat $tmp-$seq.fio >>  $seq.full
146         $FIO_PROG $tmp-$seq.fio >> $here/$seq.full 2>&1 &
147         fio_pid=$!
148
149         # Let's it work for awhile, and force device failure
150         sleep $RUN_TIME
151         start_fail_scratch_dev
152         # After device turns in to failed state filesystem may yet not know about
153         # that so buffered write(2) may succeed, but any integrity operations
154         # such as (sync, fsync, fdatasync, direct-io) should fail.
155         dd if=/dev/zero of=$SCRATCH_MNT/touch_failed_filesystem count=1 bs=4k conv=fsync \
156             >> $here/$seq.full 2>&1 && \
157             _fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
158
159         kill $fs_pid
160         wait $fs_pid
161         wait $fio_pid
162
163         # We expect that broken FS still can be umounted
164         run_check umount $SCRATCH_DEV
165         # Once filesystem was umounted no one is able to write to block device
166         # It is now safe to bring device back to normal state
167         stop_fail_scratch_dev
168
169         # In order to check that filesystem is able to recover journal on mount(2)
170         # perform mount/umount, after that all errors should be fixed
171         run_check _scratch_mount
172         run_check _scratch_unmount
173         _check_scratch_fs
174 }
175
176 # real QA test starts here
177
178 _scratch_mkfs >> $here/$seq.full 2>&1 || _fail "mkfs failed"
179 _scratch_mount || _fail "mount failed"
180 allow_fail_make_request
181 _workout
182 status=$?
183 disallow_fail_make_request
184 exit