diff mbox

[v4] xfs/424: test xfs_db to ensure type size taken into account with new type

Message ID 20170717220949.4253-1-billodo@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bill O'Donnell July 17, 2017, 10:09 p.m. UTC
xfs_db should take type size into account when setting type.
If type size isn't updated whenever type is set, a false crc
error can occur due to the stale size. This test checks for
that false crc error.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
v2: Clarify commit message and test comments. Add a few more test cases.
v3: Add more test cases. Use _scratch_xfs_db instead of $XFS_DB_PROG to
    accomodate fses with external logs. Remove superfluous daddr and type
    commands.
v4: Skip select tests and make a corresponding note in the comments. Add
    test for type inode (note: depends on pending xfsprogs patch
    xfs_db: properly set inode type).

 tests/xfs/424     | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/424.out |  1 +
 tests/xfs/group   |  1 +
 3 files changed, 99 insertions(+)
 create mode 100755 tests/xfs/424
 create mode 100644 tests/xfs/424.out

Comments

Eryu Guan July 20, 2017, 4:08 a.m. UTC | #1
On Mon, Jul 17, 2017 at 05:09:49PM -0500, Bill O'Donnell wrote:
> xfs_db should take type size into account when setting type.
> If type size isn't updated whenever type is set, a false crc
> error can occur due to the stale size. This test checks for
> that false crc error.
> 
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
> ---
> v2: Clarify commit message and test comments. Add a few more test cases.
> v3: Add more test cases. Use _scratch_xfs_db instead of $XFS_DB_PROG to
>     accomodate fses with external logs. Remove superfluous daddr and type
>     commands.
> v4: Skip select tests and make a corresponding note in the comments. Add
>     test for type inode (note: depends on pending xfsprogs patch
>     xfs_db: properly set inode type).

Eric, Darrick, do you have any more comments on this test? Thanks a lot
for your reviews on previous versions!

I have some nitpicks from the fstests point of view, though :)

> 
>  tests/xfs/424     | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/424.out |  1 +
>  tests/xfs/group   |  1 +
>  3 files changed, 99 insertions(+)
>  create mode 100755 tests/xfs/424
>  create mode 100644 tests/xfs/424.out
> 
> diff --git a/tests/xfs/424 b/tests/xfs/424
> new file mode 100755
> index 00000000..cfce18e1
> --- /dev/null
> +++ b/tests/xfs/424
> @@ -0,0 +1,97 @@
> +#! /bin/bash
> +# FS QA Test 424
> +#
> +# xfs_db should take type size into account when setting type.
> +# If type size isn't updated whenever type is set, a false crc
> +# error can occur due to the stale size. This test checks for
> +# that false crc error.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017 Red Hat, Inc.  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.*
> +}
> +
> +_filter_dbval()

I'd name it without the leading underscore, as it's a local function.

> +{
> +    awk '{ print $4 }'
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# Modify as appropriate
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch
> +
> +# real QA test starts here
> +_scratch_unmount >> $seqres.full 2>&1

This is not needed, _require_scratch will umount and _fail if umount
failed.

> +
> +# for different sector sizes, ensure no CRC errors are falsely reported.
> +
> +# Supported types include: agf, agfl, agi, attr3, bmapbta,
> +# bmapbtd, bnobt, cntbt, data, dir3, dqblk, inobt, inodata,
> +# inode, log, rtbitmap, rtsummary, sb, symlink, text, finobt.
> +# For various sector sizes, test some types that involve type size.
> +#
> +# NOTE: skip attr3, bmapbta, bmapbtd, dir3, dqblk, inodata, symlink
> +# rtbitmap, rtsummary, log
> +#
> +for SECTOR_SIZE in 512 1024 2048 4096; do
> +    $MKFS_XFS_PROG -f -s size=$SECTOR_SIZE $SCRATCH_DEV > /dev/null
> +
> +    for TYPE in agf agi agfl sb; do
> +	DADDR=`_scratch_xfs_db -c "$TYPE" -c "daddr" | _filter_dbval`
> +	_scratch_xfs_db -c "daddr $DADDR" -c "type $TYPE"
> +    done
> +
> +    DADDR=`_scratch_xfs_db -c "sb" -c "addr rootino" -c "daddr" | _filter_dbval`
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type inode"
> +    DADDR=`_scratch_xfs_db -c "agf" -c "addr bnoroot" -c "daddr" | _filter_dbval`
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type bnobt"
> +    DADDR=`_scratch_xfs_db -c "agf" -c "addr cntroot" -c "daddr" | _filter_dbval`
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type cntbt"
> +    DADDR=`_scratch_xfs_db -c "agi" -c "addr root" -c "daddr" | _filter_dbval`
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type inobt"
> +    DADDR=`_scratch_xfs_db -c "agi" -c "addr free_root" -c "daddr" | _filter_dbval`
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type finobt"
> +
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type text"
> +    _scratch_xfs_db -c "daddr $DADDR" -c "type data"

Please use tab for indention.

> +done

And need to echo "Silence is golden" somewhere in the test to indicate
we don't expect any output from the test.

Thanks,
Eryu

> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/424.out b/tests/xfs/424.out
> new file mode 100644
> index 00000000..d879a949
> --- /dev/null
> +++ b/tests/xfs/424.out
> @@ -0,0 +1 @@
> +QA output created by 424
> diff --git a/tests/xfs/group b/tests/xfs/group
> index ffdb0615..75c8280c 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -421,3 +421,4 @@
>  421 auto quick clone dedupe
>  422 dangerous_scrub dangerous_online_repair
>  423 dangerous_scrub
> +424 auto quick db
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe fstests" 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/xfs/424 b/tests/xfs/424
new file mode 100755
index 00000000..cfce18e1
--- /dev/null
+++ b/tests/xfs/424
@@ -0,0 +1,97 @@ 
+#! /bin/bash
+# FS QA Test 424
+#
+# xfs_db should take type size into account when setting type.
+# If type size isn't updated whenever type is set, a false crc
+# error can occur due to the stale size. This test checks for
+# that false crc error.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Red Hat, Inc.  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.*
+}
+
+_filter_dbval()
+{
+    awk '{ print $4 }'
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# Modify as appropriate
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+
+# real QA test starts here
+_scratch_unmount >> $seqres.full 2>&1
+
+# for different sector sizes, ensure no CRC errors are falsely reported.
+
+# Supported types include: agf, agfl, agi, attr3, bmapbta,
+# bmapbtd, bnobt, cntbt, data, dir3, dqblk, inobt, inodata,
+# inode, log, rtbitmap, rtsummary, sb, symlink, text, finobt.
+# For various sector sizes, test some types that involve type size.
+#
+# NOTE: skip attr3, bmapbta, bmapbtd, dir3, dqblk, inodata, symlink
+# rtbitmap, rtsummary, log
+#
+for SECTOR_SIZE in 512 1024 2048 4096; do
+    $MKFS_XFS_PROG -f -s size=$SECTOR_SIZE $SCRATCH_DEV > /dev/null
+
+    for TYPE in agf agi agfl sb; do
+	DADDR=`_scratch_xfs_db -c "$TYPE" -c "daddr" | _filter_dbval`
+	_scratch_xfs_db -c "daddr $DADDR" -c "type $TYPE"
+    done
+
+    DADDR=`_scratch_xfs_db -c "sb" -c "addr rootino" -c "daddr" | _filter_dbval`
+    _scratch_xfs_db -c "daddr $DADDR" -c "type inode"
+    DADDR=`_scratch_xfs_db -c "agf" -c "addr bnoroot" -c "daddr" | _filter_dbval`
+    _scratch_xfs_db -c "daddr $DADDR" -c "type bnobt"
+    DADDR=`_scratch_xfs_db -c "agf" -c "addr cntroot" -c "daddr" | _filter_dbval`
+    _scratch_xfs_db -c "daddr $DADDR" -c "type cntbt"
+    DADDR=`_scratch_xfs_db -c "agi" -c "addr root" -c "daddr" | _filter_dbval`
+    _scratch_xfs_db -c "daddr $DADDR" -c "type inobt"
+    DADDR=`_scratch_xfs_db -c "agi" -c "addr free_root" -c "daddr" | _filter_dbval`
+    _scratch_xfs_db -c "daddr $DADDR" -c "type finobt"
+
+    _scratch_xfs_db -c "daddr $DADDR" -c "type text"
+    _scratch_xfs_db -c "daddr $DADDR" -c "type data"
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/424.out b/tests/xfs/424.out
new file mode 100644
index 00000000..d879a949
--- /dev/null
+++ b/tests/xfs/424.out
@@ -0,0 +1 @@ 
+QA output created by 424
diff --git a/tests/xfs/group b/tests/xfs/group
index ffdb0615..75c8280c 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -421,3 +421,4 @@ 
 421 auto quick clone dedupe
 422 dangerous_scrub dangerous_online_repair
 423 dangerous_scrub
+424 auto quick db