diff mbox

[v3] xfstests: btrfs: add test case for qgroup account on shared extents

Message ID 1418805047-24636-1-git-send-email-bo.li.liu@oracle.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Liu Bo Dec. 17, 2014, 8:30 a.m. UTC
This is a regression test of
'commit fcebe4562dec ("Btrfs: rework qgroup accounting")'

It can produce qgroup related warnings.

The fix is https://patchwork.kernel.org/patch/5499981/
"Btrfs: fix a warning of qgroup account on shared extents"

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
---
v3: - remove trailing whilespace.
    - add the fix link for more details of the problem.

v2: - use new seq number 017 instead 080
    - use 'cloner' to get shared extents
    - use XFS_IO_PROG instead

 tests/btrfs/017     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/017.out |  3 +++
 tests/btrfs/group   |  1 +
 3 files changed, 81 insertions(+)
 create mode 100755 tests/btrfs/017
 create mode 100644 tests/btrfs/017.out

Comments

Satoru Takeuchi Dec. 17, 2014, 10 a.m. UTC | #1
Hi Liu,

(2014/12/17 17:30), Liu Bo wrote:
> This is a regression test of
> 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")'
> 
> It can produce qgroup related warnings.
> 
> The fix is https://patchwork.kernel.org/patch/5499981/
> "Btrfs: fix a warning of qgroup account on shared extents"
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> Reviewed-by: Eryu Guan <eguan@redhat.com>

It looks good to me.

Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Tested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

* Test result

** The latest upstream kernel without your patch

Failed as follows.

results/btrfs/017.out.bad
===============================================================================
QA output created by 017
-4096 4096
-12288 -4096
===============================================================================

** The latest upstream kernel with your patch

Succeeded.

Thanks,
Satoru

> ---
> v3: - remove trailing whilespace.
>      - add the fix link for more details of the problem.
> 
> v2: - use new seq number 017 instead 080
>      - use 'cloner' to get shared extents
>      - use XFS_IO_PROG instead
> 
>   tests/btrfs/017     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   tests/btrfs/017.out |  3 +++
>   tests/btrfs/group   |  1 +
>   3 files changed, 81 insertions(+)
>   create mode 100755 tests/btrfs/017
>   create mode 100644 tests/btrfs/017.out
> 
> diff --git a/tests/btrfs/017 b/tests/btrfs/017
> new file mode 100755
> index 0000000..b0390d5
> --- /dev/null
> +++ b/tests/btrfs/017
> @@ -0,0 +1,77 @@
> +#! /bin/bash
> +# FS QA Test No. 017
> +#
> +# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
> +# this will throw a warning into dmesg.
> +#
> +# For more details, the fix is https://patchwork.kernel.org/patch/5499981/
> +# "Btrfs: fix a warning of qgroup account on shared extents"
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Liu Bo.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +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
> +
> +# real QA test starts here
> +
> +_need_to_be_root
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_cloner
> +
> +run_check _scratch_mkfs "--nodesize 4096"
> +run_check _scratch_mount
> +
> +run_check $XFS_IO_PROG -f -d -c "pwrite 0 8K" $SCRATCH_MNT/foo
> +
> +_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
> +
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink2
> +
> +_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
> +
> +rm -fr $SCRATCH_MNT/* >/dev/null 2>&1
> +
> +_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
> +
> +$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2" "$3}'
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/017.out b/tests/btrfs/017.out
> new file mode 100644
> index 0000000..e25e631
> --- /dev/null
> +++ b/tests/btrfs/017.out
> @@ -0,0 +1,3 @@
> +QA output created by 017
> +4096 4096
> +4096 4096
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index abb2fe4..e29999b 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -19,6 +19,7 @@
>   014 auto balance
>   015 auto quick snapshot
>   016 auto quick send
> +017 auto quick qgroup
>   018 auto quick subvol
>   019 auto quick send
>   020 auto quick replace
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Chinner Dec. 18, 2014, 12:05 a.m. UTC | #2
On Wed, Dec 17, 2014 at 04:30:47PM +0800, Liu Bo wrote:
> This is a regression test of
> 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")'
> 
> It can produce qgroup related warnings.
> 
> The fix is https://patchwork.kernel.org/patch/5499981/
> "Btrfs: fix a warning of qgroup account on shared extents"
....
> +#! /bin/bash
> +# FS QA Test No. 017
> +#
> +# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
> +# this will throw a warning into dmesg.
> +#
> +# For more details, the fix is https://patchwork.kernel.org/patch/5499981/
> +# "Btrfs: fix a warning of qgroup account on shared extents"

Please describe the test directly.

> +
> +_need_to_be_root
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_cloner
> +
> +run_check _scratch_mkfs "--nodesize 4096"
> +run_check _scratch_mount

No, please don't use run_check like this.

Errors will end up in the output file, and that will cause the test
to fail.

> +run_check $XFS_IO_PROG -f -d -c "pwrite 0 8K" $SCRATCH_MNT/foo

Same - filter the output, and errors will be verbose and cause a
failure.

> +
> +_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
> +
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink
> +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink2

Filter the output, not "run_check".

If CLONER_PROG is silent when it fails, then it is broken and needs
fixing because users need to know that something failed and they
don't check exit codes.

> +_run_btrfs_util_prog quota enable $SCRATCH_MNT
> +_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
> +
> +rm -fr $SCRATCH_MNT/* >/dev/null 2>&1

Don't redirect the output. If an unlink fails, we want to know about
it.

> +_run_btrfs_util_prog filesystem sync $SCRATCH_MNT

What's wrong with "sync"?

> +$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2" "$3}'

You can do regex matches with awk.

Cheers,

Dave.
Liu Bo Dec. 19, 2014, 8:29 a.m. UTC | #3
On Thu, Dec 18, 2014 at 11:05:30AM +1100, Dave Chinner wrote:
> On Wed, Dec 17, 2014 at 04:30:47PM +0800, Liu Bo wrote:
> > This is a regression test of
> > 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")'
> > 
> > It can produce qgroup related warnings.
> > 
> > The fix is https://patchwork.kernel.org/patch/5499981/
> > "Btrfs: fix a warning of qgroup account on shared extents"
> ....
> > +#! /bin/bash
> > +# FS QA Test No. 017
> > +#
> > +# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
> > +# this will throw a warning into dmesg.
> > +#
> > +# For more details, the fix is https://patchwork.kernel.org/patch/5499981/
> > +# "Btrfs: fix a warning of qgroup account on shared extents"
> 
> Please describe the test directly.
> 
> > +
> > +_need_to_be_root
> > +_supported_fs btrfs
> > +_supported_os Linux
> > +_require_scratch
> > +_require_cloner
> > +
> > +run_check _scratch_mkfs "--nodesize 4096"
> > +run_check _scratch_mount
> 
> No, please don't use run_check like this.
> 
> Errors will end up in the output file, and that will cause the test
> to fail.
> 
> > +run_check $XFS_IO_PROG -f -d -c "pwrite 0 8K" $SCRATCH_MNT/foo
> 
> Same - filter the output, and errors will be verbose and cause a
> failure.
> 
> > +
> > +_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
> > +
> > +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
> > +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink
> > +run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink2
> 
> Filter the output, not "run_check".
> 
> If CLONER_PROG is silent when it fails, then it is broken and needs
> fixing because users need to know that something failed and they
> don't check exit codes.
> 
> > +_run_btrfs_util_prog quota enable $SCRATCH_MNT
> > +_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
> > +
> > +rm -fr $SCRATCH_MNT/* >/dev/null 2>&1
> 
> Don't redirect the output. If an unlink fails, we want to know about
> it.
> 
> > +_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
> 
> What's wrong with "sync"?
> 
> > +$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2" "$3}'
> 
> You can do regex matches with awk.

Thanks for reviewing this.

Thanks,

-liubo

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/btrfs/017 b/tests/btrfs/017
new file mode 100755
index 0000000..b0390d5
--- /dev/null
+++ b/tests/btrfs/017
@@ -0,0 +1,77 @@ 
+#! /bin/bash
+# FS QA Test No. 017
+#
+# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
+# this will throw a warning into dmesg.
+#
+# For more details, the fix is https://patchwork.kernel.org/patch/5499981/
+# "Btrfs: fix a warning of qgroup account on shared extents"
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Liu Bo.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+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
+
+# real QA test starts here
+
+_need_to_be_root
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_cloner
+
+run_check _scratch_mkfs "--nodesize 4096"
+run_check _scratch_mount
+
+run_check $XFS_IO_PROG -f -d -c "pwrite 0 8K" $SCRATCH_MNT/foo
+
+_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
+
+run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
+run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink
+run_check $CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink2
+
+_run_btrfs_util_prog quota enable $SCRATCH_MNT
+_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
+
+rm -fr $SCRATCH_MNT/* >/dev/null 2>&1
+
+_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2" "$3}'
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/017.out b/tests/btrfs/017.out
new file mode 100644
index 0000000..e25e631
--- /dev/null
+++ b/tests/btrfs/017.out
@@ -0,0 +1,3 @@ 
+QA output created by 017
+4096 4096
+4096 4096
diff --git a/tests/btrfs/group b/tests/btrfs/group
index abb2fe4..e29999b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -19,6 +19,7 @@ 
 014 auto balance
 015 auto quick snapshot
 016 auto quick send
+017 auto quick qgroup
 018 auto quick subvol
 019 auto quick send
 020 auto quick replace