xfs: Add test for too-small device with stripe geometry
[xfstests-dev.git] / tests / btrfs / 013
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/013
6 #
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.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19
20 status=1        # failure is the default!
21
22 _cleanup()
23 {
24         rm -f $tmp.*
25 }
26
27 trap "_cleanup ; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_fs btrfs
35 _require_scratch
36
37 rm -f $seqres.full
38
39 _scratch_mkfs > /dev/null 2>&1
40 _scratch_mount
41
42 nr_csum_no_found=$(dmesg | grep -c "no csum found")
43 nr_csum_failed=$(dmesg | grep -c "csum failed")
44
45 _check_csum_error()
46 {
47         new_csum_no_found=$(dmesg | grep -c "no csum found")
48         new_csum_failed=$(dmesg | grep -c "csum failed")
49
50         if [ $nr_csum_no_found -eq $new_csum_no_found -a \
51              $nr_csum_failed -eq $new_csum_failed ]; then
52                 return 0
53         fi
54         return 1
55 }
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
59 _scratch_unmount
60 _scratch_mount
61 $XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \
62         _fail "pread failed"
63
64 # This sucks but unfortunately it is the only way to be sure something didn't go
65 # wrong.
66 _check_csum_error || _fail "csum detected, please check dmesg"
67
68 echo "Silence is golden"
69 status=0 ; exit