btrfs: Verify falloc on multiple holes won't leak qgroup reserved data space
[xfstests-dev.git] / tests / btrfs / 033
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/033
6 #
7 # Regression test for iterating backrefs
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16
17 _cleanup()
18 {
19     rm -f $tmp.*
20 }
21
22 trap "_cleanup ; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs btrfs
30 _supported_os Linux
31 _require_scratch
32
33 _scratch_mkfs > /dev/null 2>&1
34 _scratch_mount
35
36 touch $SCRATCH_MNT/foo
37
38 # get file with fragments by using backwards writes.
39 for i in `seq 10240 -1 1`; do
40         $XFS_IO_PROG -f -d -c "pwrite $(($i * 4096)) 4096" \
41                 $SCRATCH_MNT/foo > /dev/null
42 done
43
44 # get some snapshots here to make sure we are really
45 # suffering from walking backrefs.
46 for i in `seq 0 50`; do
47         $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
48                 $SCRATCH_MNT/snap_$i >> $seqres.full 2>&1
49 done
50
51 $BTRFS_UTIL_PROG send -f $SCRATCH_MNT/send_file \
52         $SCRATCH_MNT/snap_1 >> $seqres.full 2>&1
53
54 echo "Silence is golden"
55 status=0 ; exit