From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] fstests: btrfs: add a new test case to verify quick qgroup inherit
Date: Thu, 4 Dec 2025 15:11:08 +1030 [thread overview]
Message-ID: <20251204044108.181671-1-wqu@suse.com> (raw)
[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 <wqu@suse.com>
---
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
diff --git a/tests/btrfs/339 b/tests/btrfs/339
new file mode 100755
index 00000000..6581b61b
--- /dev/null
+++ b/tests/btrfs/339
@@ -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
diff --git a/tests/btrfs/339.out b/tests/btrfs/339.out
new file mode 100644
index 00000000..293ea808
--- /dev/null
+++ b/tests/btrfs/339.out
@@ -0,0 +1,2 @@
+QA output created by 339
+Silence is golden
--
2.51.2
next reply other threads:[~2025-12-04 4:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 4:41 Qu Wenruo [this message]
2025-12-15 18:28 ` [PATCH] fstests: btrfs: add a new test case to verify quick qgroup inherit David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251204044108.181671-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox