2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
5 # FS QA Test No. btrfs/013
7 # Regression test for balance with prealloc extents. This checks to make sure
8 # we are balacing prealloc'ed extents properly by making sure we don't have any
9 # csum errors. Unfortunately this manifests itself with no csum which means
10 # userspace doesn't get an error when reading the file back so we have to grok
11 # dmesg to see if there was a csum error.
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
20 status=1 # failure is the default!
27 trap "_cleanup ; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # real QA test starts here
36 _require_xfs_io_command "falloc"
40 _scratch_mkfs > /dev/null 2>&1
43 nr_csum_no_found=$(dmesg | grep -c "no csum found")
44 nr_csum_failed=$(dmesg | grep -c "csum failed")
48 new_csum_no_found=$(dmesg | grep -c "no csum found")
49 new_csum_failed=$(dmesg | grep -c "csum failed")
51 if [ $nr_csum_no_found -eq $new_csum_no_found -a \
52 $nr_csum_failed -eq $new_csum_failed ]; then
57 $XFS_IO_PROG -f -c "falloc 0 1M" -c "pwrite 16k 8k" -c "fsync" \
58 $SCRATCH_MNT/foo > $seqres.full 2>&1
59 _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
62 $XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \
65 # This sucks but unfortunately it is the only way to be sure something didn't go
67 _check_csum_error || _fail "csum detected, please check dmesg"
69 echo "Silence is golden"