2 # FSQA Test No. generic/019
4 # Run fsstress and fio(dio/aio and mmap) and simulate disk failure
5 # check filesystem consistency at the end.
7 #-----------------------------------------------------------------------
8 # (c) 2013 Dmitry Monakhov
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.
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.
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
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
33 status=1 # failure is the default!
35 # get standard environment, filters and checks
41 _require_fail_make_request
43 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
45 allow_fail_make_request()
47 echo "Allow global fail_make_request feature"
48 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
49 echo 9999999 > $DEBUGFS_MNT/fail_make_request/times
50 echo 0 > /sys/kernel/debug/fail_make_request/verbose
53 disallow_fail_make_request()
55 echo "Disallow global fail_make_request feature"
56 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
57 echo 0 > $DEBUGFS_MNT/fail_make_request/times
60 start_fail_scratch_dev()
62 echo "Force SCRATCH_DEV device failure"
63 echo " echo 1 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
64 echo 1 > $SYSFS_BDEV/make-it-fail
67 stop_fail_scratch_dev()
69 echo "Make SCRATCH_DEV device operable again"
70 echo " echo 0 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
71 echo 0 > $SYSFS_BDEV/make-it-fail
77 disallow_fail_make_request
80 trap "_cleanup; exit \$status" 1 2 3 15
82 RUN_TIME=$((20+10*$TIME_FACTOR))
83 NUM_JOBS=$((4*LOAD_FACTOR))
84 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
85 FILE_SIZE=$((BLK_DEV_SIZE * 512))
87 cat >$fio_config <<EOF
89 # $seq test's fio activity
90 # Filenames derived from jobsname and jobid like follows:
91 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
95 directory=${SCRATCH_MNT}
98 continue_on_error=write
99 ignore_error=EIO,ENOSPC:EIO
102 [stress_dio_aio_activity]
105 iodepth=128*${LOAD_FACTOR}
110 runtime=40+${RUN_TIME}
113 [stress_mmap_activity]
122 runtime=40+${RUN_TIME}
127 _require_fio $fio_config
129 # Disable all sync operations to get higher load
130 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0 -f setattr=1"
134 out=$SCRATCH_MNT/fsstress.$$
135 args=`_scale_fsstress_args -p 1 -n999999999 -f setattr=0 $FSSTRESS_AVOID -d $out`
137 echo "Start fsstress.."
139 echo "fsstress $args" >> $seqres.full
140 $FSSTRESS_PROG $args > /dev/null 2>&1 &
143 cat $fio_config >> $seqres.full
144 $FIO_PROG $fio_config >> $seqres.full 2>&1 &
147 # Let's it work for awhile, and force device failure
149 start_fail_scratch_dev
150 # After device turns in to failed state filesystem may yet not know about
151 # that so buffered write(2) may succeed, but any integrity operations
152 # such as (sync, fsync, fdatasync, direct-io) should fail.
153 dd if=/dev/zero of=$SCRATCH_MNT/touch_failed_filesystem count=1 bs=4k conv=fsync \
154 >> $seqres.full 2>&1 && \
155 _fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
157 kill $fs_pid &> /dev/null
161 # We expect that broken FS still can be umounted
162 run_check _scratch_unmount
163 # Once filesystem was umounted no one is able to write to block device
164 # It is now safe to bring device back to normal state
165 stop_fail_scratch_dev
167 # In order to check that filesystem is able to recover journal on mount(2)
168 # perform mount/umount, after that all errors should be fixed
169 run_check _scratch_mount
170 run_check _scratch_unmount
173 # real QA test starts here
176 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
177 _scratch_mount || _fail "mount failed"
178 allow_fail_make_request
181 disallow_fail_make_request