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
39 _scratch_mkfs > /dev/null 2>&1
42 nr_csum_no_found=$(dmesg | grep -c "no csum found")
43 nr_csum_failed=$(dmesg | grep -c "csum failed")
47 new_csum_no_found=$(dmesg | grep -c "no csum found")
48 new_csum_failed=$(dmesg | grep -c "csum failed")
50 if [ $nr_csum_no_found -eq $new_csum_no_found -a \
51 $nr_csum_failed -eq $new_csum_failed ]; then
56 $XFS_IO_PROG -f -c "falloc 0 1M" -c "pwrite 16k 8k" -c "fsync" \
57 $SCRATCH_MNT/foo > $seqres.full 2>&1
58 _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
61 $XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \
64 # This sucks but unfortunately it is the only way to be sure something didn't go
66 _check_csum_error || _fail "csum detected, please check dmesg"
68 echo "Silence is golden"