4 # This is a regression test which ends up with a kernel oops in btrfs.
5 # It occurs when btrfs's read repair happens while reading a compressed
7 # The patch to fix it is
8 # Btrfs: fix kernel oops while reading compressed data
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2017 Oracle. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
47 # remove previous $seqres.full before test
50 # real QA test starts here
52 # Modify as appropriate.
56 _require_fail_make_request
57 _require_scratch_dev_pool 2
58 _scratch_dev_pool_get 2
60 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
63 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
64 echo 1000 > $DEBUGFS_MNT/fail_make_request/times
65 echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
66 echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
67 echo 1 > $SYSFS_BDEV/make-it-fail
72 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
73 echo 0 > $DEBUGFS_MNT/fail_make_request/times
74 echo 0 > $DEBUGFS_MNT/fail_make_request/task-filter
75 echo 0 > $SYSFS_BDEV/make-it-fail
78 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
80 # It doesn't matter which compression algorithm we use.
81 _scratch_mount -ocompress
83 # Create a file with all data being compressed
84 $XFS_IO_PROG -f -c "pwrite -W 0 8K" $SCRATCH_MNT/foobar | _filter_xfs_io
86 # Raid1 consists of two copies and btrfs decides which copy to read by reader's
87 # %pid. Now we inject errors to copy #1 and copy #0 is good. We want to read
88 # the bad copy to trigger read-repair.
89 while [[ -z $result ]]; do
90 # invalidate the page cache
91 $XFS_IO_PROG -f -c "fadvise -d 0 8K" $SCRATCH_MNT/foobar
96 if [ \$((\$\$ % 2)) == 1 ]; then
97 echo 1 > /proc/\$\$/make-it-fail
98 exec $XFS_IO_PROG -c \"pread 0 8K\" \$SCRATCH_MNT/foobar
104 _scratch_dev_pool_put