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 recoveryloop
15 # Import common functions.
17 . ./common/fail_make_request
20 _require_block_device $SCRATCH_DEV
21 _require_fail_make_request
23 # Override the default cleanup function.
26 kill $fs_pid $fio_pid &> /dev/null
27 _disallow_fail_make_request
32 RUN_TIME=$((20+10*$TIME_FACTOR))
33 test -n "$SOAK_DURATION" && RUN_TIME="$SOAK_DURATION"
34 NUM_JOBS=$((4*LOAD_FACTOR))
35 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
36 FILE_SIZE=$((BLK_DEV_SIZE * 512))
38 # Don't fail the test just because fio or fsstress dump cores
41 cat >$fio_config <<EOF
43 # $seq test's fio activity
44 # Filenames derived from jobsname and jobid like follows:
45 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
49 directory=${SCRATCH_MNT}
52 continue_on_error=write
53 ignore_error=EIO,ENOSPC:EIO
56 [stress_dio_aio_activity]
59 iodepth=128*${LOAD_FACTOR}
64 runtime=40+${RUN_TIME}
67 [stress_mmap_activity]
76 runtime=40+${RUN_TIME}
81 _require_fio $fio_config
83 # Disable all sync operations to get higher load
84 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0 -f setattr=1"
88 out=$SCRATCH_MNT/fsstress.$$
89 args=`_scale_fsstress_args -p 1 -n999999999 -f setattr=0 $FSSTRESS_AVOID -d $out`
91 echo "Start fsstress.."
93 echo "fsstress $args" >> $seqres.full
94 $FSSTRESS_PROG $args > /dev/null 2>&1 &
97 cat $fio_config >> $seqres.full
98 $FIO_PROG $fio_config >> $seqres.full 2>&1 &
101 # Let's it work for awhile, and force device failure
103 _start_fail_scratch_dev
104 # After device turns in to failed state filesystem may yet not know about
105 # that so buffered write(2) may succeed, but any integrity operations
106 # such as (sync, fsync, fdatasync, direct-io) should fail.
107 dd if=/dev/zero of=$SCRATCH_MNT/touch_failed_filesystem count=1 bs=4k conv=fsync \
108 >> $seqres.full 2>&1 && \
109 _fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
111 kill $fs_pid &> /dev/null
117 # We expect that broken FS still can be umounted
118 run_check _scratch_unmount
119 # Once filesystem was umounted no one is able to write to block device
120 # It is now safe to bring device back to normal state
121 _stop_fail_scratch_dev
123 # In order to check that filesystem is able to recover journal on mount(2)
124 # perform mount/umount, after that all errors should be fixed
126 run_check _scratch_unmount
129 # real QA test starts here
131 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
133 _allow_fail_make_request