btrfs: Add new test for qgroup assign functionality
PATCH v5 1/1 btrfs: Add new test for qgroup assign functionality
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".
---
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
v4:
- Add rescan command for assign no shared
- Use _check_scratch_fs for checking
v5:
- Remove trailing whitespaces
--- tests/btrfs/221 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/221.out | 2 + tests/btrfs/group | 1 + 3 files changed, 119 insertions(+) create mode 100755 tests/btrfs/221 create mode 100644 tests/btrfs/221.out
tests/btrfs/221 new file +116 -0
@@ -0,0 +1,116 @@ +#! /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 + _check_scratch_fs +} + +# 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 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 + + $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 + _check_scratch_fs +} + +# 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 + _check_scratch_fs +} + + +assign_no_shared_test + +assign_shared_test + +snapshot_test + +# success, all done +echo "Silence is golden" +status=0 +exit
tests/btrfs/221.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 221 +Silence is golden
tests/btrfs/group +1 -0
@@ -222,3 +222,4 @@ 218 auto quick volume 219 auto quick volume 220 auto quick +221 auto quick qgroup
Signature · 1 line
2.25.1
Quoted 7 lines · Sidong Yang
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
Quoted 6 lines
Each cases create subvolumes and assign qgroup in their own way and check with the command "btrfs check".
Signed-off-by Sidong Yang <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Reviewed-by Eryu Guan <[email protected]>
Please don't add "Reviewed-by" tag before it's provided explicitly, Qu and I have given review comments but that doesn't mean we provide a "Reviewed-by" tag.
Quoted 73 lines
---
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
v4:
- Add rescan command for assign no shared
- Use_check_scratch_fsfor checking
v5:
- Remove trailing whitespaces--- tests/btrfs/221 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/221.out | 2 + tests/btrfs/group | 1 + 3 files changed, 119 insertions(+) create mode 100755 tests/btrfs/221 create mode 100644 tests/btrfs/221.outtests/btrfs/221 new file +46
-0@@ -0,0 +1,116 @@ +#! /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
tests/btrfs/221 line 56
Quoted 10 lines
tests/btrfs/221 new file +10
-0+ + 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
Seems you miss the comment about using "_cp_reflink" helper.
Thanks,
Eryu
Quoted 79 lines
tests/btrfs/221 new file +60
-0+ + $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 + _check_scratch_fs +} + +# 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 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 + + $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 + _check_scratch_fs +} + +# 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 + _check_scratch_fs +} + + +assign_no_shared_test + +assign_shared_test + +snapshot_test + +# success, all done +echo "Silence is golden" +status=0 +exittests/btrfs/221.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 221 +Silence is goldentests/btrfs/group +1
-0@@ -222,3 +222,4 @@ 218 auto quick volume 219 auto quick volume 220 auto quick +221 auto quick qgroupSignature · 1 line
2.25.1
Quoted 11 lines · Eryu Guan
Quoted 10 lines · Sidong Yang
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 extentsEach cases create subvolumes and assign qgroup in their own way and check with the command "btrfs check".
Quoted 7 lines
Quoted 3 lines
Signed-off-by Sidong Yang <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Reviewed-by Eryu Guan <[email protected]>Please don't add "Reviewed-by" tag before it's provided explicitly, Qu and I have given review comments but that doesn't mean we provide a "Reviewed-by" tag.
Thanks! I should take care of it next time.
Quoted 78 lines
Quoted 78 lines
---
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
v4:
- Add rescan command for assign no shared
- Use_check_scratch_fsfor checking
v5:
- Remove trailing whitespaces--- tests/btrfs/221 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/221.out | 2 + tests/btrfs/group | 1 + 3 files changed, 119 insertions(+) create mode 100755 tests/btrfs/221 create mode 100644 tests/btrfs/221.outtests/btrfs/221 new file +50
-0@@ -0,0 +1,116 @@ +#! /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
Quoted 8 lines
tests/btrfs/221 line 56
Quoted 6 lines
tests/btrfs/221 new file +6
-0+ + $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/file1Seems you miss the comment about using "
_cp_reflink" helper.
Yes, I missed it sorry.
I'll write a new patch right away.
Thanks so much!
Thanks,
Sidong
Quoted 83 lines
Thanks,
EryuQuoted 79 lines
tests/btrfs/221 new file +60
-0+ + $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 + _check_scratch_fs +} + +# 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 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 + + $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 + _check_scratch_fs +} + +# 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 + _check_scratch_fs +} + + +assign_no_shared_test + +assign_shared_test + +snapshot_test + +# success, all done +echo "Silence is golden" +status=0 +exittests/btrfs/221.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 221 +Silence is goldentests/btrfs/group +1
-0@@ -222,3 +222,4 @@ 218 auto quick volume 219 auto quick volume 220 auto quick +221 auto quick qgroupSignature · 1 line
2.25.1