2 # SPDX-License-Identifier: GPL-2.0
5 # FSQA Test No. generic/019
7 # Run fsstress and fio(dio/aio and mmap) and simulate disk failure
8 # check filesystem consistency at the end.
11 _begin_fstest aio dangerous enospc rw stress
15 # Import common functions.
19 _require_block_device $SCRATCH_DEV
20 _require_fail_make_request
22 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
24 allow_fail_make_request()
26 echo "Allow global fail_make_request feature"
27 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
28 echo 9999999 > $DEBUGFS_MNT/fail_make_request/times
29 echo 0 > /sys/kernel/debug/fail_make_request/verbose
32 disallow_fail_make_request()
34 echo "Disallow global fail_make_request feature"
35 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
36 echo 0 > $DEBUGFS_MNT/fail_make_request/times
39 start_fail_scratch_dev()
41 echo "Force SCRATCH_DEV device failure"
42 echo " echo 1 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
43 echo 1 > $SYSFS_BDEV/make-it-fail
46 stop_fail_scratch_dev()
48 echo "Make SCRATCH_DEV device operable again"
49 echo " echo 0 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
50 echo 0 > $SYSFS_BDEV/make-it-fail
53 # Override the default cleanup function.
56 disallow_fail_make_request
60 RUN_TIME=$((20+10*$TIME_FACTOR))
61 NUM_JOBS=$((4*LOAD_FACTOR))
62 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
63 FILE_SIZE=$((BLK_DEV_SIZE * 512))
65 cat >$fio_config <<EOF
67 # $seq test's fio activity
68 # Filenames derived from jobsname and jobid like follows:
69 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
73 directory=${SCRATCH_MNT}
76 continue_on_error=write
77 ignore_error=EIO,ENOSPC:EIO
80 [stress_dio_aio_activity]
83 iodepth=128*${LOAD_FACTOR}
88 runtime=40+${RUN_TIME}
91 [stress_mmap_activity]
100 runtime=40+${RUN_TIME}
105 _require_fio $fio_config
107 # Disable all sync operations to get higher load
108 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0 -f setattr=1"
112 out=$SCRATCH_MNT/fsstress.$$
113 args=`_scale_fsstress_args -p 1 -n999999999 -f setattr=0 $FSSTRESS_AVOID -d $out`
115 echo "Start fsstress.."
117 echo "fsstress $args" >> $seqres.full
118 $FSSTRESS_PROG $args > /dev/null 2>&1 &
121 cat $fio_config >> $seqres.full
122 $FIO_PROG $fio_config >> $seqres.full 2>&1 &
125 # Let's it work for awhile, and force device failure
127 start_fail_scratch_dev
128 # After device turns in to failed state filesystem may yet not know about
129 # that so buffered write(2) may succeed, but any integrity operations
130 # such as (sync, fsync, fdatasync, direct-io) should fail.
131 dd if=/dev/zero of=$SCRATCH_MNT/touch_failed_filesystem count=1 bs=4k conv=fsync \
132 >> $seqres.full 2>&1 && \
133 _fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
135 kill $fs_pid &> /dev/null
139 # We expect that broken FS still can be umounted
140 run_check _scratch_unmount
141 # Once filesystem was umounted no one is able to write to block device
142 # It is now safe to bring device back to normal state
143 stop_fail_scratch_dev
145 # In order to check that filesystem is able to recover journal on mount(2)
146 # perform mount/umount, after that all errors should be fixed
148 run_check _scratch_unmount
151 # real QA test starts here
153 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
155 allow_fail_make_request