2 # FS QA Test No. btrfs/122
4 # Test that qgroup counts are valid after snapshot creation. This has
5 # been broken in btrfs since Linux v4.1
7 #-----------------------------------------------------------------------
8 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
45 # remove previous $seqres.full before test
48 # real QA test starts here
52 _require_btrfs_qgroup_report
56 # Force a small leaf size to make it easier to blow out our root
58 _scratch_mkfs "--nodesize 16384" >/dev/null
60 _run_btrfs_util_prog quota enable $SCRATCH_MNT
62 mkdir "$SCRATCH_MNT/snaps"
64 # First make some simple snapshots - the bug was initially reproduced like this
65 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty1"
66 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty2"
68 # This forces the fs tree out past level 0, adding at least one tree
69 # block which must be properly accounted for when we make our next
71 mkdir "$SCRATCH_MNT/data"
72 for i in `seq 0 640`; do
73 $XFS_IO_PROG -f -c "pwrite 0 1M" "$SCRATCH_MNT/data/file$i" > /dev/null 2>&1
77 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap1"
78 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap2"
83 # qgroup will be checked by fstest at _check_scratch_fs()