btrfs: test incremental send after renaming and linking file
[xfstests-dev.git] / tests / btrfs / 123
1 #! /bin/bash
2 # FS QA Test 123
3 #
4 # Test if btrfs leaks qgroup numbers for data extents
5 #
6 # Due to balance code is doing trick tree block swap, which doing
7 # non-standard extent reference update, qgroup can't handle it correctly,
8 # and leads to corrupted qgroup numbers.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 # remove previous $seqres.full before test
48 rm -f $seqres.full
49
50 # real QA test starts here
51
52 # Modify as appropriate.
53 _supported_fs btrfs
54 _supported_os Linux
55 _require_scratch
56 _require_btrfs_qgroup_report
57
58 _scratch_mkfs >/dev/null
59 # Need to use inline extents to fill metadata rapidly
60 _scratch_mount "-o max_inline=2048"
61
62 # create 64K inlined metadata, which will ensure there is a 2-level
63 # metadata. Even for maximum nodesize(64K)
64 for i in $(seq 32); do
65         _pwrite_byte 0xcdcdcdcd 0 2k $SCRATCH_MNT/small_$i | _filter_xfs_io
66 done
67
68 # then a large data write to make the quota corruption obvious enough
69 _pwrite_byte 0xcdcdcdcd 0 32m $SCRATCH_MNT/large | _filter_xfs_io
70 sync
71
72 # enable quota and rescan to get correct number
73 _run_btrfs_util_prog quota enable $SCRATCH_MNT
74 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
75
76 # now balance data block groups to corrupt qgroup
77 _run_btrfs_util_prog balance start -d $SCRATCH_MNT
78
79 _scratch_unmount
80 # qgroup will be check at _check_scratch_fs() by fstest
81
82 # success, all done
83 status=0
84 exit