2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/122
7 # Test that qgroup counts are valid after snapshot creation. This has
8 # been broken in btrfs since Linux v4.1
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
35 _require_btrfs_qgroup_report
39 # Force a small leaf size to make it easier to blow out our root
41 _scratch_mkfs "--nodesize 16384" >/dev/null
43 _run_btrfs_util_prog quota enable $SCRATCH_MNT
45 mkdir "$SCRATCH_MNT/snaps"
47 # First make some simple snapshots - the bug was initially reproduced like this
48 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty1"
49 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty2"
51 # This forces the fs tree out past level 0, adding at least one tree
52 # block which must be properly accounted for when we make our next
54 mkdir "$SCRATCH_MNT/data"
55 for i in `seq 0 640`; do
56 $XFS_IO_PROG -f -c "pwrite 0 1M" "$SCRATCH_MNT/data/file$i" > /dev/null 2>&1
60 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap1"
61 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap2"
66 # qgroup will be checked by fstest at _check_scratch_fs()