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 _begin_fstest auto quick balance
16 # Import common functions.
19 # real QA test starts here
22 _require_xfs_io_command "falloc"
24 _scratch_mkfs > /dev/null 2>&1
27 nr_csum_no_found=$(dmesg | grep -c "no csum found")
28 nr_csum_failed=$(dmesg | grep -c "csum failed")
32 new_csum_no_found=$(dmesg | grep -c "no csum found")
33 new_csum_failed=$(dmesg | grep -c "csum failed")
35 if [ $nr_csum_no_found -eq $new_csum_no_found -a \
36 $nr_csum_failed -eq $new_csum_failed ]; then
41 $XFS_IO_PROG -f -c "falloc 0 1M" -c "pwrite 16k 8k" -c "fsync" \
42 $SCRATCH_MNT/foo > $seqres.full 2>&1
43 _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
46 $XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \
49 # This sucks but unfortunately it is the only way to be sure something didn't go
51 _check_csum_error || _fail "csum detected, please check dmesg"
53 echo "Silence is golden"