From: Qu Wenruo Date: Thu, 4 Dec 2025 04:41:08 +0000 (+1030) Subject: fstests: btrfs: add a new test case to verify quick qgroup inherit X-Git-Tag: v2026.01.05~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1da7f10cd89d3392f68cadf7c08f43107c9c0295;p=xfstests-dev.git 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. Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: Zorro Lang --- diff --git a/tests/btrfs/340 b/tests/btrfs/340 new file mode 100755 index 00000000..fc3b8d62 --- /dev/null +++ b/tests/btrfs/340 @@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 SUSE S.A. All Rights Reserved. +# +# FS QA Test No. 340 +# +# 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 diff --git a/tests/btrfs/340.out b/tests/btrfs/340.out new file mode 100644 index 00000000..e975ae5c --- /dev/null +++ b/tests/btrfs/340.out @@ -0,0 +1,2 @@ +QA output created by 340 +Silence is golden