From: Sidong Yang <realwakka@gmail.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
Qu Wenruo <wqu@suse.com>
Cc: Sidong Yang <realwakka@gmail.com>,
Josef Bacik <josef@toxicpanda.com>, Eryu Guan <guan@eryu.me>
Subject: [PATCH v3] btrfs: Add new test for qgroup assign functionality
Date: Thu, 24 Sep 2020 04:11:45 +0000 [thread overview]
Message-ID: <20200924041146.32577-1-realwakka@gmail.com> (raw)
This new test will test btrfs's qgroup assign functionality. The
test has 3 cases.
- assign, no shared extents
- assign, shared extents
- snapshot -i, shared extents
Each cases create subvolumes and assign qgroup in their own way
and check with the command "btrfs check".
Cc: Qu Wenruo <wqu@suse.com>
Cc: Eryu Guan <guan@eryu.me>
Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
v2:
- Create new test and use the cases
v3:
- Fix some minor mistakes
- Make that write some data before assign or snapshot in test
- Put mkfs & mount pair in test function
---
tests/btrfs/221 | 118 ++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/221.out | 2 +
tests/btrfs/group | 1 +
3 files changed, 121 insertions(+)
create mode 100755 tests/btrfs/221
create mode 100644 tests/btrfs/221.out
diff --git a/tests/btrfs/221 b/tests/btrfs/221
new file mode 100755
index 00000000..71591765
--- /dev/null
+++ b/tests/btrfs/221
@@ -0,0 +1,118 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Sidong Yang. All Rights Reserved.
+#
+# FS QA Test 221
+#
+# Test the assign functionality of qgroups
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+
+_require_scratch
+_require_btrfs_qgroup_report
+_require_cp_reflink
+
+# Test assign qgroup for submodule with shared extents by reflink
+assign_shared_test()
+{
+ _scratch_mkfs > /dev/null 2>&1
+ _scratch_mount
+
+ echo "=== qgroup assign shared test ===" >> $seqres.full
+ $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+ $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full
+
+ _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1
+ cp --reflink=always "$SCRATCH_MNT"/a/file1 "$SCRATCH_MNT"/b/file1
+
+ $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT
+ $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/a 1/100 $SCRATCH_MNT
+ $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/b 1/100 $SCRATCH_MNT
+
+ _scratch_unmount
+ $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+ [ $? -eq 0 ] || _fail "btrfs check failed"
+}
+
+# Test assign qgroup for submodule without shared extents
+assign_no_shared_test()
+{
+ _scratch_mkfs > /dev/null 2>&1
+ _scratch_mount
+
+ echo "=== qgroup assign no shared test ===" >> $seqres.full
+ $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+ $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT
+
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full
+
+ $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/a 1/100 $SCRATCH_MNT
+ $BTRFS_UTIL_PROG qgroup assign $SCRATCH_MNT/b 1/100 $SCRATCH_MNT
+ _scratch_unmount
+
+ $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+ [ $? -eq 0 ] || _fail "btrfs check failed"
+}
+
+# Test snapshot with assigning qgroup for submodule
+snapshot_test()
+{
+ _scratch_mkfs > /dev/null 2>&1
+ _scratch_mount
+
+ echo "=== qgroup snapshot test ===" >> $seqres.full
+ $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+ $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full
+ _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1
+ subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
+ $BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
+ _scratch_unmount
+
+ $BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+ [ $? -eq 0 ] || _fail "btrfs check failed"
+}
+
+
+assign_no_shared_test
+
+assign_shared_test
+
+snapshot_test
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/221.out b/tests/btrfs/221.out
new file mode 100644
index 00000000..aa4351cd
--- /dev/null
+++ b/tests/btrfs/221.out
@@ -0,0 +1,2 @@
+QA output created by 221
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 1b5fa695..cdda38f3 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -222,3 +222,4 @@
218 auto quick volume
219 auto quick volume
220 auto quick
+221 auto quick qgroup
--
2.25.1
next reply other threads:[~2020-09-24 4:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 4:11 Sidong Yang [this message]
2020-09-24 5:08 ` [PATCH v3] btrfs: Add new test for qgroup assign functionality Qu Wenruo
2020-09-24 14:28 ` Sidong Yang
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=20200924041146.32577-1-realwakka@gmail.com \
--to=realwakka@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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;
as well as URLs for NNTP newsgroup(s).