fstests: btrfs: add a new test case to verify quick qgroup inherit
PATCH 1/1 fstests: btrfs: add a new test case to verify quick qgroup inherit
[BUG]
There is a bug report that simple quota exposed a bug in the quick qgroup inherit, that if there is a multi-level qgroup parent relationship, only the direct parent got updated.
[TEST CASE]
The test case will create the following subvolume and qgroups first:
- A new subvolume at '/subv1'
- Qgroup 1/1
- Qgroup 2/1
And subvolume '/subv1' is assgiend to qgroup 1/1, so 1/1 is the direct parent.
Then qgroup 1/1 is also assigned to 2/1, so 2/1 is an indirect parent of subvolume '/subv1'.
Then the trigger part is to creating a snapshot of '/subv1' and also assigned the new snapshot into qgroup 1/1 during the snapshot creation.
Since 1/1 is the parent of '/subv1' and the new snapshot, and qgroup 1/1 fully owns '/subv1', we can do a quick inherit.
After the triggering part, just finish the test case and the fsck after the test case should detect any qgroup inconsistency.
--- tests/btrfs/339 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/339.out | 2 ++ 2 files changed, 47 insertions(+) create mode 100755 tests/btrfs/339 create mode 100644 tests/btrfs/339.out
tests/btrfs/339 new file +45 -0
@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 SUSE S.A. All Rights Reserved. +# +# FS QA Test 339 +# +# Make sure when doing a quick inherit for snapshot, all parent qgroups +# including direct and indirect parents are properly updated. +# +. ./common/preamble +_begin_fstest auto quick qgroup + +_fixed_by_kernel_commit xxxxxxxxxxxx \ + "btrfs: qgroup: update all parent qgroups when doing quick inherit" + +# For the automatic fsck at unmount. +_require_scratch +_require_btrfs_qgroup_report + +# This will imply mkfs and enable regular qgroup. +_require_scratch_qgroup +_scratch_mount + +# Create a subvolume along with qgroups 1/1 and 2/1. +# The subvolume qgroup is assgiend to 1/1, and 1/1 is assigned to 2/1. +_btrfs subvolume create $SCRATCH_MNT/subv1 +subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT subv1) +_btrfs qgroup create 1/1 $SCRATCH_MNT +_btrfs qgroup create 2/1 $SCRATCH_MNT +_btrfs qgroup assign 1/1 2/1 $SCRATCH_MNT +_btrfs qgroup assign 0/$subvolid 1/1 $SCRATCH_MNT + +# All above assign should result quick update, no need for a full rescan +echo "Before quick inherit:" >> $seqres.full +_btrfs qgroup show -p --sync $SCRATCH_MNT >> $seqres.full + +# The next snapshot creation will create a snapshot and assign it to 1/1, +# which is the same parent of the source subvolume, and we can do a quick inherit +# without marking qgroup inconsistent. +_btrfs subv snap -i 1/1 $SCRATCH_MNT/subv1 $SCRATCH_MNT/snap1 +echo "After quick inherit:" >> $seqres.full +_btrfs qgroup show -p --sync $SCRATCH_MNT >> $seqres.full + +echo "Silence is golden" +_exit 0
tests/btrfs/339.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 339 +Silence is golden
Signature · 1 line
2.51.2
Quoted 20 lines · Qu Wenruo
[BUG]
There is a bug report that simple quota exposed a bug in the quick qgroup inherit, that if there is a multi-level qgroup parent relationship, only the direct parent got updated.[TEST CASE]
The test case will create the following subvolume and qgroups first:- A new subvolume at '/subv1'
- Qgroup 1/1
- Qgroup 2/1And subvolume '/subv1' is assgiend to qgroup 1/1, so 1/1 is the direct parent.
Then qgroup 1/1 is also assigned to 2/1, so 2/1 is an indirect parent of subvolume '/subv1'.Then the trigger part is to creating a snapshot of '/subv1' and also assigned the new snapshot into qgroup 1/1 during the snapshot creation.
Quoted 7 lines
Since 1/1 is the parent of '/subv1' and the new snapshot, and qgroup 1/1 fully owns '/subv1', we can do a quick inherit.
After the triggering part, just finish the test case and the fsck after the test case should detect any qgroup inconsistency.
Signed-off-by Qu Wenruo <[email protected]>