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 _begin_fstest auto quick dangerous
16 # Import common functions.
19 # real QA test starts here
21 # Modify as appropriate.
24 _require_fail_make_request
25 _require_scratch_dev_pool 2
26 _scratch_dev_pool_get 2
28 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
31 echo 100 > $DEBUGFS_MNT/fail_make_request/probability
32 echo 1000 > $DEBUGFS_MNT/fail_make_request/times
33 echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
34 echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
35 echo 1 > $SYSFS_BDEV/make-it-fail
40 echo 0 > $DEBUGFS_MNT/fail_make_request/probability
41 echo 0 > $DEBUGFS_MNT/fail_make_request/times
42 echo 0 > $DEBUGFS_MNT/fail_make_request/task-filter
43 echo 0 > $SYSFS_BDEV/make-it-fail
46 _check_minimal_fs_size $(( 1024 * 1024 * 1024 ))
47 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
49 # It doesn't matter which compression algorithm we use.
50 _scratch_mount -ocompress
52 # Create a file with all data being compressed
53 $XFS_IO_PROG -f -c "pwrite -W 0 8K" $SCRATCH_MNT/foobar | _filter_xfs_io
55 # Raid1 consists of two copies and btrfs decides which copy to read by reader's
56 # %pid. Now we inject errors to copy #1 and copy #0 is good. We want to read
57 # the bad copy to trigger read-repair.
58 while [[ -z $result ]]; do
59 # invalidate the page cache
60 $XFS_IO_PROG -f -c "fadvise -d 0 8K" $SCRATCH_MNT/foobar
65 if [ \$((\$\$ % 2)) == 1 ]; then
66 echo 1 > /proc/\$\$/make-it-fail
67 exec $XFS_IO_PROG -c \"pread 0 8K\" \$SCRATCH_MNT/foobar