summaryrefslogtreecommitdiff
path: root/tests/btrfs/122
blob: 04170d30d1fe7602d3f0775ac87a0e9bfac98ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. btrfs/122
#
# Test that qgroup counts are valid after snapshot creation. This has
# been broken in btrfs since Linux v4.1
#
. ./common/preamble
_begin_fstest auto quick snapshot qgroup

. ./common/filter

_supported_fs btrfs
_require_scratch
_require_btrfs_qgroup_report

_scratch_mkfs >> $seqres.full
_scratch_mount
_btrfs quota enable $SCRATCH_MNT

mkdir "$SCRATCH_MNT/snaps"

# First make some simple snapshots - the bug was initially reproduced like this
_btrfs subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty1"
_btrfs subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/empty2"

# This forces the fs tree out past level 0, adding at least one tree
# block which must be properly accounted for when we make our next
# snapshots.
mkdir "$SCRATCH_MNT/data"
for i in `seq 0 640`; do
	$XFS_IO_PROG -f -c "pwrite 0 1M" "$SCRATCH_MNT/data/file$i" > /dev/null 2>&1
done

# Snapshot twice.
_btrfs subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap1"
_btrfs subvolume snapshot $SCRATCH_MNT "$SCRATCH_MNT/snaps/snap2"

_scratch_unmount

# qgroup will be checked by fstest at _check_scratch_fs()
status=0
exit