blob: e820fd9d573205f84b565cc1f137e69704e83a68 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 171
#
# Test if btrfs can clear high level childless qgroup's accounting numbers
# during rescan.
#
# Fixed by the following kernel patch:
# "btrfs: qgroup: Dirty all qgroups before rescan"
#
. ./common/preamble
_begin_fstest auto quick qgroup
. ./common/filter
. ./common/filter.btrfs
_supported_fs btrfs
_require_scratch
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
# Populate the fs
$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/subvol" > /dev/null
_pwrite_byte 0xcdcd 0 1M "$SCRATCH_MNT/subvol/file1" > /dev/null
# Ensure that buffered file data is persisted, so we won't have an
# empty file in the snapshot.
sync
$BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/subvol" \
"$SCRATCH_MNT/snapshot" > /dev/null
$BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
_qgroup_rescan $SCRATCH_MNT > /dev/null
# Create high level qgroup
$BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT"
$BTRFS_UTIL_PROG qgroup assign "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \
2>&1 | _filter_btrfs_qgroup_assign_warnings
# Above assignment will mark qgroup inconsistent due to the shared extents
# between subvol/snapshot/high level qgroup, do rescan here.
_qgroup_rescan $SCRATCH_MNT > /dev/null
# Now remove the qgroup relationship and make 1/0 childless
# Due to the shared extent outside of 1/0, we will mark qgroup inconsistent
# and keep the number of qgroup 1/0.
$BTRFS_UTIL_PROG qgroup remove "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \
2>&1 | _filter_btrfs_qgroup_assign_warnings
# Above removal also marks qgroup inconsistent, rescan again
_qgroup_rescan $SCRATCH_MNT > /dev/null
# After the test, btrfs check will verify qgroup numbers to catch any
# corruption.
echo "Silence is golden"
# success, all done
status=0
exit
|