2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle. All Rights Reserved.
7 # This is a regression test which ends up with a kernel oops in btrfs.
8 # It occurs when btrfs's read repair happens while reading a compressed
10 # The patch to fix it is
11 # Btrfs: fix kernel oops while reading compressed data
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
35 # real QA test starts here
37 # Modify as appropriate.
40 _require_fail_make_request
41 _require_scratch_dev_pool 2
42 _scratch_dev_pool_get 2
44 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
47 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
48 echo 1000 > $DEBUGFS_MNT/fail_make_request/times
49 echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
50 echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
51 echo 1 > $SYSFS_BDEV/make-it-fail
56 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
57 echo 0 > $DEBUGFS_MNT/fail_make_request/times
58 echo 0 > $DEBUGFS_MNT/fail_make_request/task-filter
59 echo 0 > $SYSFS_BDEV/make-it-fail
62 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
64 # It doesn't matter which compression algorithm we use.
65 _scratch_mount -ocompress
67 # Create a file with all data being compressed
68 $XFS_IO_PROG -f -c "pwrite -W 0 8K" $SCRATCH_MNT/foobar | _filter_xfs_io
70 # Raid1 consists of two copies and btrfs decides which copy to read by reader's
71 # %pid. Now we inject errors to copy #1 and copy #0 is good. We want to read
72 # the bad copy to trigger read-repair.
73 while [[ -z $result ]]; do
74 # invalidate the page cache
75 $XFS_IO_PROG -f -c "fadvise -d 0 8K" $SCRATCH_MNT/foobar
80 if [ \$((\$\$ % 2)) == 1 ]; then
81 echo 1 > /proc/\$\$/make-it-fail
82 exec $XFS_IO_PROG -c \"pread 0 8K\" \$SCRATCH_MNT/foobar