2017-09-27 10:35:51 -06:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:50 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2017 Oracle. All Rights Reserved.
|
|
|
|
|
#
|
2017-09-27 10:35:51 -06:00
|
|
|
# FS QA Test btrfs/150
|
|
|
|
|
#
|
|
|
|
|
# This is a regression test which ends up with a kernel oops in btrfs.
|
|
|
|
|
# It occurs when btrfs's read repair happens while reading a compressed
|
|
|
|
|
# extent.
|
|
|
|
|
# The patch to fix it is
|
|
|
|
|
# Btrfs: fix kernel oops while reading compressed data
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
seqres=$RESULT_DIR/$seq
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
cd /
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
|
|
|
|
|
# remove previous $seqres.full before test
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
|
|
|
|
|
# Modify as appropriate.
|
|
|
|
|
_supported_fs btrfs
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_fail_make_request
|
|
|
|
|
_require_scratch_dev_pool 2
|
2018-02-20 14:34:32 +09:00
|
|
|
_scratch_dev_pool_get 2
|
2017-09-27 10:35:51 -06:00
|
|
|
|
|
|
|
|
SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
|
|
|
|
|
enable_io_failure()
|
|
|
|
|
{
|
|
|
|
|
echo 100 > $DEBUGFS_MNT/fail_make_request/probability
|
|
|
|
|
echo 1000 > $DEBUGFS_MNT/fail_make_request/times
|
|
|
|
|
echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
|
|
|
|
|
echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
|
|
|
|
|
echo 1 > $SYSFS_BDEV/make-it-fail
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disable_io_failure()
|
|
|
|
|
{
|
|
|
|
|
echo 0 > $DEBUGFS_MNT/fail_make_request/probability
|
|
|
|
|
echo 0 > $DEBUGFS_MNT/fail_make_request/times
|
|
|
|
|
echo 0 > $DEBUGFS_MNT/fail_make_request/task-filter
|
|
|
|
|
echo 0 > $SYSFS_BDEV/make-it-fail
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
|
|
|
|
|
|
|
|
|
|
# It doesn't matter which compression algorithm we use.
|
|
|
|
|
_scratch_mount -ocompress
|
|
|
|
|
|
|
|
|
|
# Create a file with all data being compressed
|
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -W 0 8K" $SCRATCH_MNT/foobar | _filter_xfs_io
|
|
|
|
|
|
|
|
|
|
# Raid1 consists of two copies and btrfs decides which copy to read by reader's
|
|
|
|
|
# %pid. Now we inject errors to copy #1 and copy #0 is good. We want to read
|
|
|
|
|
# the bad copy to trigger read-repair.
|
|
|
|
|
while [[ -z $result ]]; do
|
|
|
|
|
# invalidate the page cache
|
|
|
|
|
$XFS_IO_PROG -f -c "fadvise -d 0 8K" $SCRATCH_MNT/foobar
|
|
|
|
|
|
|
|
|
|
enable_io_failure
|
|
|
|
|
|
|
|
|
|
result=$(bash -c "
|
|
|
|
|
if [ \$((\$\$ % 2)) == 1 ]; then
|
|
|
|
|
echo 1 > /proc/\$\$/make-it-fail
|
|
|
|
|
exec $XFS_IO_PROG -c \"pread 0 8K\" \$SCRATCH_MNT/foobar
|
|
|
|
|
fi")
|
|
|
|
|
|
|
|
|
|
disable_io_failure
|
|
|
|
|
done
|
|
|
|
|
|
2018-02-20 14:34:32 +09:00
|
|
|
_scratch_dev_pool_put
|
2017-09-27 10:35:51 -06:00
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|