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.
41 _require_fail_make_request
42 _require_scratch_dev_pool 2
43 _scratch_dev_pool_get 2
45 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
48 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
49 echo 1000 > $DEBUGFS_MNT/fail_make_request/times
50 echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
51 echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
52 echo 1 > $SYSFS_BDEV/make-it-fail
57 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
58 echo 0 > $DEBUGFS_MNT/fail_make_request/times
59 echo 0 > $DEBUGFS_MNT/fail_make_request/task-filter
60 echo 0 > $SYSFS_BDEV/make-it-fail
63 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
65 # It doesn't matter which compression algorithm we use.
66 _scratch_mount -ocompress
68 # Create a file with all data being compressed
69 $XFS_IO_PROG -f -c "pwrite -W 0 8K" $SCRATCH_MNT/foobar | _filter_xfs_io
71 # Raid1 consists of two copies and btrfs decides which copy to read by reader's
72 # %pid. Now we inject errors to copy #1 and copy #0 is good. We want to read
73 # the bad copy to trigger read-repair.
74 while [[ -z $result ]]; do
75 # invalidate the page cache
76 $XFS_IO_PROG -f -c "fadvise -d 0 8K" $SCRATCH_MNT/foobar
81 if [ \$((\$\$ % 2)) == 1 ]; then
82 echo 1 > /proc/\$\$/make-it-fail
83 exec $XFS_IO_PROG -c \"pread 0 8K\" \$SCRATCH_MNT/foobar