diff mbox

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

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

Commit Message

Bill O'Donnell July 14, 2017, 2:27 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.

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

Comments

Eric Sandeen July 14, 2017, 3:42 p.m. UTC | #1
On 07/14/2017 09:27 AM, 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.
> 
>  tests/xfs/424     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/424.out |  1 +
>  tests/xfs/group   |  1 +
>  3 files changed, 79 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..3b67cdf2
> --- /dev/null
> +++ b/tests/xfs/424
> @@ -0,0 +1,77 @@
> +#! /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.

This leaves me wondering why we don't test most of the above ;)

> +# For various sector sizes, test some types that involve type size.
> +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV

Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?

Interesting, I didn't know that a bare "agf" works, but it does (and is documented
as such).  fair enough.

It'd be very easy to add just a few more types to this, i.e.:  (leaving the extra
 type & daddr setting in place for now)

DADDR=`$XFS_DB_PROG -c "sb" -c "addr rootino" -c "daddr" $SCRATCH_DEV | _filter_dbval`
$XFS_DB_PROG -c "type inode" -c "daddr 42" -c "daddr $DADDR" -c "type inode" $SCRATCH_DEV

DADDR=`$XFS_DB_PROG -c "agf" -c "addr bnoroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
$XFS_DB_PROG -c "type bnobt" -c "daddr 42" -c "daddr $DADDR" -c "type bnobt" $SCRATCH_DEV

DADDR=`$XFS_DB_PROG -c "agf" -c "addr cntroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
$XFS_DB_PROG -c "type cntbt" -c "daddr 42" -c "daddr $DADDR" -c "type cntbt" $SCRATCH_DEV

DADDR=`$XFS_DB_PROG -c "agi" -c "addr root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
$XFS_DB_PROG -c "type inobt" -c "daddr 42" -c "daddr $DADDR" -c "type inobt" $SCRATCH_DEV

DADDR=`$XFS_DB_PROG -c "agi" -c "addr free_root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
$XFS_DB_PROG -c "type finobt" -c "daddr 42" -c "daddr $DADDR" -c "type finobt" $SCRATCH_DEV

others such as attr, dir, symlink would require more filesystem preparation I guess.

Thanks,
-Eric

> +    done
> +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
> 
--
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
Bill O'Donnell July 14, 2017, 4:47 p.m. UTC | #2
On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:
> 
> 
> On 07/14/2017 09:27 AM, 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.
> > 
> >  tests/xfs/424     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/424.out |  1 +
> >  tests/xfs/group   |  1 +
> >  3 files changed, 79 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..3b67cdf2
> > --- /dev/null
> > +++ b/tests/xfs/424
> > @@ -0,0 +1,77 @@
> > +#! /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.
> 
> This leaves me wondering why we don't test most of the above ;)
> 
> > +# For various sector sizes, test some types that involve type size.
> > +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> > +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
> 
> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
It's drawn from the reproducer test case.
The first "-c $TYPE" sets the object, "daddr 42" is an arbitrary address set. Without
the daddr change and change-back, the test will pass even without the recent xfs_db
xfsprogs change.

> 
> Interesting, I didn't know that a bare "agf" works, but it does (and is documented
> as such).  fair enough.
> 
> It'd be very easy to add just a few more types to this, i.e.:  (leaving the extra
>  type & daddr setting in place for now)

ok. I'll add a few more.

> 
> DADDR=`$XFS_DB_PROG -c "sb" -c "addr rootino" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type inode" -c "daddr 42" -c "daddr $DADDR" -c "type inode" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agf" -c "addr bnoroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type bnobt" -c "daddr 42" -c "daddr $DADDR" -c "type bnobt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agf" -c "addr cntroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type cntbt" -c "daddr 42" -c "daddr $DADDR" -c "type cntbt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agi" -c "addr root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type inobt" -c "daddr 42" -c "daddr $DADDR" -c "type inobt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agi" -c "addr free_root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type finobt" -c "daddr 42" -c "daddr $DADDR" -c "type finobt" $SCRATCH_DEV
> 
> others such as attr, dir, symlink would require more filesystem preparation I guess.
> 
> Thanks,
> -Eric
> 
> > +    done
> > +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
> > 
--
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
Darrick J. Wong July 14, 2017, 5:39 p.m. UTC | #3
On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:
> 
> 
> On 07/14/2017 09:27 AM, 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.
> > 
> >  tests/xfs/424     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/424.out |  1 +
> >  tests/xfs/group   |  1 +
> >  3 files changed, 79 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..3b67cdf2
> > --- /dev/null
> > +++ b/tests/xfs/424
> > @@ -0,0 +1,77 @@
> > +#! /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.
> 
> This leaves me wondering why we don't test most of the above ;)

Same here.

> > +# For various sector sizes, test some types that involve type size.
> > +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> > +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
> 
> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
> 
> Interesting, I didn't know that a bare "agf" works, but it does (and is documented
> as such).  fair enough.
> 
> It'd be very easy to add just a few more types to this, i.e.:  (leaving the extra
>  type & daddr setting in place for now)
> 
> DADDR=`$XFS_DB_PROG -c "sb" -c "addr rootino" -c "daddr" $SCRATCH_DEV | _filter_dbval`

/me wonders if this ought to be wrapped up into a helper ala
_scratch_xfs_get_metadata_field in common/fuzzy?

> $XFS_DB_PROG -c "type inode" -c "daddr 42" -c "daddr $DADDR" -c "type inode" $SCRATCH_DEV

_scratch_xfs_db, not $XFS_DB_PROG...$SCRATCH_DEV, or else this won't
work with fses with external logs.

> DADDR=`$XFS_DB_PROG -c "agf" -c "addr bnoroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type bnobt" -c "daddr 42" -c "daddr $DADDR" -c "type bnobt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agf" -c "addr cntroot" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type cntbt" -c "daddr 42" -c "daddr $DADDR" -c "type cntbt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agi" -c "addr root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type inobt" -c "daddr 42" -c "daddr $DADDR" -c "type inobt" $SCRATCH_DEV
> 
> DADDR=`$XFS_DB_PROG -c "agi" -c "addr free_root" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> $XFS_DB_PROG -c "type finobt" -c "daddr 42" -c "daddr $DADDR" -c "type finobt" $SCRATCH_DEV
> 
> others such as attr, dir, symlink would require more filesystem preparation I guess.

_scratch_populate_cached?

--D

> 
> Thanks,
> -Eric
> 
> > +    done
> > +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
> > 
> --
> 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
Eric Sandeen July 14, 2017, 7:01 p.m. UTC | #4
On 07/14/2017 11:47 AM, Bill O'Donnell wrote:
> On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:


>>> +# 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.
>>
>> This leaves me wondering why we don't test most of the above ;)
>>
>>> +# For various sector sizes, test some types that involve type size.
>>> +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
>>> +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
>>
>> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
> It's drawn from the reproducer test case.
> The first "-c $TYPE" sets the object, "daddr 42" is an arbitrary address set. Without
> the daddr change and change-back, the test will pass even without the recent xfs_db
> xfsprogs change.

Really?  Not here, xfsprogs-4.5.0 :

# xfs_db -c "daddr 2" -c "type agi" fsfile
Metadata CRC error detected at xfs_agi block 0x2/0x200


-Eric
--
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
Bill O'Donnell July 14, 2017, 7:11 p.m. UTC | #5
On Fri, Jul 14, 2017 at 02:01:31PM -0500, Eric Sandeen wrote:
> 
> 
> On 07/14/2017 11:47 AM, Bill O'Donnell wrote:
> > On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:
> 
> 
> >>> +# 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.
> >>
> >> This leaves me wondering why we don't test most of the above ;)
> >>
> >>> +# For various sector sizes, test some types that involve type size.
> >>> +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> >>> +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
> >>
> >> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
> > It's drawn from the reproducer test case.
> > The first "-c $TYPE" sets the object, "daddr 42" is an arbitrary address set. Without
> > the daddr change and change-back, the test will pass even without the recent xfs_db
> > xfsprogs change.
> 
> Really?  Not here, xfsprogs-4.5.0 :
> 
> # xfs_db -c "daddr 2" -c "type agi" fsfile
> Metadata CRC error detected at xfs_agi block 0x2/0x200

Ahh, ok, you're correct - I'll modify the test accordingly.
Thanks-
Bill


> 
> 
> -Eric
--
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
Bill O'Donnell July 14, 2017, 7:58 p.m. UTC | #6
On Fri, Jul 14, 2017 at 02:11:01PM -0500, Bill O'Donnell wrote:
> On Fri, Jul 14, 2017 at 02:01:31PM -0500, Eric Sandeen wrote:
> > 
> > 
> > On 07/14/2017 11:47 AM, Bill O'Donnell wrote:
> > > On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:
> > 
> > 
> > >>> +# 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.
> > >>
> > >> This leaves me wondering why we don't test most of the above ;)
> > >>
> > >>> +# For various sector sizes, test some types that involve type size.
> > >>> +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
> > >>> +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
> > >>
> > >> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
> > > It's drawn from the reproducer test case.
> > > The first "-c $TYPE" sets the object, "daddr 42" is an arbitrary address set. Without
> > > the daddr change and change-back, the test will pass even without the recent xfs_db
> > > xfsprogs change.
> > 
> > Really?  Not here, xfsprogs-4.5.0 :
> > 
> > # xfs_db -c "daddr 2" -c "type agi" fsfile
> > Metadata CRC error detected at xfs_agi block 0x2/0x200
> 
> Ahh, ok, you're correct - I'll modify the test accordingly.

Wait. I still think the object has to get set with "-c $TYPE". If not
the crc error occurs even with the new xfs_db code:
# xfs_db -V
xfs_db version 4.12.0-rc2
# xfs_db /dev/sda6
xfs_db> daddr
current daddr is 0
xfs_db> daddr 2
xfs_db> type agi
Metadata CRC error detected at xfs_agi block 0x2/0x1000
Metadata CRC error detected at xfs_agi block 0x2/0x1000

And error is gone when the object is set and the daddr gets
set to the correct value.
[root@localhost xfsprogs-dev3]# xfs_db /dev/sda6
xfs_db> agi
xfs_db> daddr
current daddr is 16
xfs_db> daddr 2
xfs_db> daddr 16
xfs_db> type agi


> --
> 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
Eric Sandeen July 14, 2017, 9:43 p.m. UTC | #7
On 07/14/2017 02:58 PM, Bill O'Donnell wrote:
> On Fri, Jul 14, 2017 at 02:11:01PM -0500, Bill O'Donnell wrote:
>> On Fri, Jul 14, 2017 at 02:01:31PM -0500, Eric Sandeen wrote:
>>>
>>>
>>> On 07/14/2017 11:47 AM, Bill O'Donnell wrote:
>>>> On Fri, Jul 14, 2017 at 10:42:57AM -0500, Eric Sandeen wrote:
>>>
>>>
>>>>>> +# 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.
>>>>>
>>>>> This leaves me wondering why we don't test most of the above ;)
>>>>>
>>>>>> +# For various sector sizes, test some types that involve type size.
>>>>>> +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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
>>>>>> +	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
>>>>>
>>>>> Hm is there a reason for the first "-c $TYPE" or even the "daddr 42" in the line just above?
>>>> It's drawn from the reproducer test case.
>>>> The first "-c $TYPE" sets the object, "daddr 42" is an arbitrary address set. Without
>>>> the daddr change and change-back, the test will pass even without the recent xfs_db
>>>> xfsprogs change.
>>>
>>> Really?  Not here, xfsprogs-4.5.0 :
>>>
>>> # xfs_db -c "daddr 2" -c "type agi" fsfile
>>> Metadata CRC error detected at xfs_agi block 0x2/0x200
>>
>> Ahh, ok, you're correct - I'll modify the test accordingly.
> 
> Wait. I still think the object has to get set with "-c $TYPE". If not
> the crc error occurs even with the new xfs_db code:
> # xfs_db -V
> xfs_db version 4.12.0-rc2
> # xfs_db /dev/sda6
> xfs_db> daddr
> current daddr is 0
> xfs_db> daddr 2
> xfs_db> type agi
> Metadata CRC error detected at xfs_agi block 0x2/0x1000
> Metadata CRC error detected at xfs_agi block 0x2/0x1000

You've set daddr to 2... presumably on a 4k sector fs ...

> 
> And error is gone when the object is set and the daddr gets
> set to the correct value.
> [root@localhost xfsprogs-dev3]# xfs_db /dev/sda6
> xfs_db> agi
> xfs_db> daddr
> current daddr is 16

... but the agi is at daddr 16, not 2.

IOWS, you've told it the wrong type for daddr 2 (which is halfway through
the first superblock; daddr 2 is not the beginning of any on-disk structure)
so if you ask it to tell you about that block as an
AGI, it'll tell you that it's corrupted, because it's /not/ an agi.

> xfs_db> daddr 2
> xfs_db> daddr 16

If you correctly tell it to show you block 16 as an AGI...

> xfs_db> type agi

... it works.

-Eric
--
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..3b67cdf2
--- /dev/null
+++ b/tests/xfs/424
@@ -0,0 +1,77 @@ 
+#! /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
+_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.
+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=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV | _filter_dbval`
+	$XFS_DB_PROG -c "$TYPE" -c "daddr 42" -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
+    done
+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