Files
apfstests/tests/generic/019
T

167 lines
3.9 KiB
Bash
Raw Normal View History

2013-02-20 10:42:15 +00:00
#! /bin/bash
2018-06-09 11:35:42 +10:00
# SPDX-License-Identifier: GPL-2.0
#
2014-04-04 17:18:43 +11:00
# FSQA Test No. generic/019
2013-02-20 10:42:15 +00:00
#
# Run fsstress and fio(dio/aio and mmap) and simulate disk failure
# check filesystem consistency at the end.
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
2013-02-20 10:42:15 +00:00
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
fio_config=$tmp.fio
2013-02-20 10:42:15 +00:00
status=1 # failure is the default!
# get standard environment, filters and checks
2013-03-15 12:28:04 +00:00
. ./common/rc
. ./common/filter
2014-04-04 17:18:43 +11:00
_supported_fs generic
2013-02-20 10:42:15 +00:00
_supported_os Linux
_require_scratch
_require_fail_make_request
2015-05-26 12:51:57 +10:00
SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
2013-02-20 10:42:15 +00:00
allow_fail_make_request()
{
echo "Allow global fail_make_request feature"
echo 100 > $DEBUGFS_MNT/fail_make_request/probability
echo 9999999 > $DEBUGFS_MNT/fail_make_request/times
echo 0 > /sys/kernel/debug/fail_make_request/verbose
}
disallow_fail_make_request()
{
echo "Disallow global fail_make_request feature"
echo 0 > $DEBUGFS_MNT/fail_make_request/probability
echo 0 > $DEBUGFS_MNT/fail_make_request/times
}
start_fail_scratch_dev()
{
echo "Force SCRATCH_DEV device failure"
2015-05-26 12:51:57 +10:00
echo " echo 1 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
echo 1 > $SYSFS_BDEV/make-it-fail
2013-02-20 10:42:15 +00:00
}
stop_fail_scratch_dev()
{
echo "Make SCRATCH_DEV device operable again"
2015-05-26 12:51:57 +10:00
echo " echo 0 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
echo 0 > $SYSFS_BDEV/make-it-fail
2013-02-20 10:42:15 +00:00
}
_cleanup()
{
poweron_scratch_dev
disallow_fail_make_request
rm -f $tmp.*
2013-02-20 10:42:15 +00:00
}
trap "_cleanup; exit \$status" 1 2 3 15
RUN_TIME=$((20+10*$TIME_FACTOR))
NUM_JOBS=$((4*LOAD_FACTOR))
BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
FILE_SIZE=$((BLK_DEV_SIZE * 512))
cat >$fio_config <<EOF
2013-02-20 10:42:15 +00:00
###########
# $seq test's fio activity
# Filenames derived from jobsname and jobid like follows:
# ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
[global]
ioengine=libaio
bs=4k
directory=${SCRATCH_MNT}
filesize=${FILE_SIZE}
size=9999T
continue_on_error=write
ignore_error=EIO,ENOSPC:EIO
error_dump=0
[stress_dio_aio_activity]
create_on_open=1
fallocate=none
iodepth=128*${LOAD_FACTOR}
direct=1
buffered=0
numjobs=${NUM_JOBS}
rw=randwrite
runtime=40+${RUN_TIME}
time_based
[stress_mmap_activity]
ioengine=mmap
create_on_open=0
fallocate=1
fdatasync=40960
filesize=8M
size=9999T
numjobs=${NUM_JOBS}
rw=randwrite
runtime=40+${RUN_TIME}
time_based
EOF
_require_fio $fio_config
2013-02-20 10:42:15 +00:00
# Disable all sync operations to get higher load
FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0 -f setattr=1"
_workout()
{
out=$SCRATCH_MNT/fsstress.$$
args=`_scale_fsstress_args -p 1 -n999999999 -f setattr=0 $FSSTRESS_AVOID -d $out`
echo ""
echo "Start fsstress.."
echo ""
echo "fsstress $args" >> $seqres.full
2013-02-20 10:42:15 +00:00
$FSSTRESS_PROG $args > /dev/null 2>&1 &
fs_pid=$!
echo "Start fio.."
cat $fio_config >> $seqres.full
$FIO_PROG $fio_config >> $seqres.full 2>&1 &
2013-02-20 10:42:15 +00:00
fio_pid=$!
# Let's it work for awhile, and force device failure
sleep $RUN_TIME
start_fail_scratch_dev
# After device turns in to failed state filesystem may yet not know about
# that so buffered write(2) may succeed, but any integrity operations
# such as (sync, fsync, fdatasync, direct-io) should fail.
dd if=/dev/zero of=$SCRATCH_MNT/touch_failed_filesystem count=1 bs=4k conv=fsync \
>> $seqres.full 2>&1 && \
2013-02-20 10:42:15 +00:00
_fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
2017-06-06 16:37:22 +03:00
kill $fs_pid &> /dev/null
2013-02-20 10:42:15 +00:00
wait $fs_pid
wait $fio_pid
# We expect that broken FS still can be umounted
2015-12-21 18:07:43 +11:00
run_check _scratch_unmount
2013-02-20 10:42:15 +00:00
# Once filesystem was umounted no one is able to write to block device
# It is now safe to bring device back to normal state
stop_fail_scratch_dev
# In order to check that filesystem is able to recover journal on mount(2)
# perform mount/umount, after that all errors should be fixed
_scratch_mount
2013-02-20 10:42:15 +00:00
run_check _scratch_unmount
}
# real QA test starts here
rm -f $seqres.full
_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_mount
2013-02-20 10:42:15 +00:00
allow_fail_make_request
_workout
status=$?
disallow_fail_make_request
exit