diff mbox series

[2/2] xfs: test inobtcount upgrade

Message ID 160382542877.1203756.11339393830951325848.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfstests: add inode btree blocks counters to the AGI header | expand

Commit Message

Darrick J. Wong Oct. 27, 2020, 7:03 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Make sure we can actually upgrade filesystems to support inobtcounts.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs        |   16 ++++++++++++
 tests/xfs/910     |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/910.out |    3 ++
 tests/xfs/group   |    1 +
 4 files changed, 92 insertions(+)
 create mode 100755 tests/xfs/910
 create mode 100644 tests/xfs/910.out

Comments

Brian Foster Oct. 29, 2020, 5:40 p.m. UTC | #1
On Tue, Oct 27, 2020 at 12:03:48PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure we can actually upgrade filesystems to support inobtcounts.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/xfs        |   16 ++++++++++++
>  tests/xfs/910     |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/910.out |    3 ++
>  tests/xfs/group   |    1 +
>  4 files changed, 92 insertions(+)
>  create mode 100755 tests/xfs/910
>  create mode 100644 tests/xfs/910.out
> 
> 
...
> diff --git a/tests/xfs/910 b/tests/xfs/910
> new file mode 100755
> index 00000000..1924d9ea
> --- /dev/null
> +++ b/tests/xfs/910
> @@ -0,0 +1,72 @@
...
> +
> +# Now upgrade to inobtcount support
> +_scratch_xfs_admin -O inobtcount >> $seqres.full
> +_check_scratch_fs
> +_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' -c 'agi 0' -c 'p' >> $seqres.full
> +
> +# Mount again, look at our files
> +_scratch_mount >> $seqres.full
> +cat $SCRATCH_MNT/urk
> +

I think we probably want some more explicit form of validation here.
Perhaps dump the inobt block counters from the above xfs_db command to
the golden output..? As it is, we can comment out the xfs_admin command
and the test still passes.

> +# success, all done
> +echo Silence is golden.

We can also probably drop this if we have some other form of output from
the test.

Brian

> +status=0
> +exit
> diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> new file mode 100644
> index 00000000..83992f49
> --- /dev/null
> +++ b/tests/xfs/910.out
> @@ -0,0 +1,3 @@
> +QA output created by 910
> +moo
> +Silence is golden.
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 4b0caea4..862df3be 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -524,6 +524,7 @@
>  760 auto quick rw collapse punch insert zero prealloc
>  761 auto quick realtime
>  763 auto quick rw realtime
> +910 auto quick inobtcount
>  915 auto quick quota
>  917 auto quick db
>  918 auto quick db
>
Darrick J. Wong Oct. 29, 2020, 8:31 p.m. UTC | #2
On Thu, Oct 29, 2020 at 01:40:23PM -0400, Brian Foster wrote:
> On Tue, Oct 27, 2020 at 12:03:48PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Make sure we can actually upgrade filesystems to support inobtcounts.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/xfs        |   16 ++++++++++++
> >  tests/xfs/910     |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/910.out |    3 ++
> >  tests/xfs/group   |    1 +
> >  4 files changed, 92 insertions(+)
> >  create mode 100755 tests/xfs/910
> >  create mode 100644 tests/xfs/910.out
> > 
> > 
> ...
> > diff --git a/tests/xfs/910 b/tests/xfs/910
> > new file mode 100755
> > index 00000000..1924d9ea
> > --- /dev/null
> > +++ b/tests/xfs/910
> > @@ -0,0 +1,72 @@
> ...
> > +
> > +# Now upgrade to inobtcount support
> > +_scratch_xfs_admin -O inobtcount >> $seqres.full
> > +_check_scratch_fs
> > +_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' -c 'agi 0' -c 'p' >> $seqres.full
> > +
> > +# Mount again, look at our files
> > +_scratch_mount >> $seqres.full
> > +cat $SCRATCH_MNT/urk
> > +
> 
> I think we probably want some more explicit form of validation here.
> Perhaps dump the inobt block counters from the above xfs_db command to
> the golden output..? As it is, we can comment out the xfs_admin command
> and the test still passes.

Ok.

> > +# success, all done
> > +echo Silence is golden.
> 
> We can also probably drop this if we have some other form of output from
> the test.

Will do.  Thanks for reviewing!

> Brian
> 
> > +status=0
> > +exit
> > diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> > new file mode 100644
> > index 00000000..83992f49
> > --- /dev/null
> > +++ b/tests/xfs/910.out
> > @@ -0,0 +1,3 @@
> > +QA output created by 910
> > +moo
> > +Silence is golden.
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index 4b0caea4..862df3be 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -524,6 +524,7 @@
> >  760 auto quick rw collapse punch insert zero prealloc
> >  761 auto quick realtime
> >  763 auto quick rw realtime
> > +910 auto quick inobtcount
> >  915 auto quick quota
> >  917 auto quick db
> >  918 auto quick db
> > 
>
Eric Sandeen Nov. 18, 2020, 4:44 p.m. UTC | #3
On 10/27/20 2:03 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure we can actually upgrade filesystems to support inobtcounts.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/xfs        |   16 ++++++++++++
>  tests/xfs/910     |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/910.out |    3 ++
>  tests/xfs/group   |    1 +
>  4 files changed, 92 insertions(+)
>  create mode 100755 tests/xfs/910
>  create mode 100644 tests/xfs/910.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> index 3f5c14ba..e548a0a1 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -978,3 +978,19 @@ _require_xfs_copy()
>  	[ "$USE_EXTERNAL" = yes ] && \
>  		_notrun "Cannot xfs_copy with external devices"
>  }
> +
> +_require_xfs_mkfs_inobtcount()
> +{
> +	_scratch_mkfs_xfs_supported -m inobtcount=1 >/dev/null 2>&1 \
> +	   || _notrun "mkfs.xfs doesn't have inobtcount feature"
> +}

I'd like to also add:

+_require_xfs_admin_upgrade()
+{
+	local feature="$1"
+
+	_require_scratch
+	# Catch missing "-O" or missing feature handling
+	_scratch_xfs_admin -O $feature 2>&1 | grep "illegal option\|Cannot change" \
+		&& _notrun "xfs_admin does not support upgrading $1"
+}

and then:

...

> +# real QA test starts here
> +_supported_fs xfs
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +_require_xfs_mkfs_inobtcount
> +_require_xfs_scratch_inobtcount

+_require_xfs_admin_upgrade "inobtcount"

to be sure that the upgrade command is also supported by xfs_admin.  By the time
we get to release, both mkfs & xfs_admin should both support it, but I'm hedging
my bets on the upgrade path just a little,and it seems best to explicitly test
both requirements.

that helper can be re-used on the bigtime upgrade test as well and anything else
that requires an xfs_admin upgrade path ...

Thanks,
-Eric
Darrick J. Wong Nov. 20, 2020, 1:53 a.m. UTC | #4
On Wed, Nov 18, 2020 at 10:44:40AM -0600, Eric Sandeen wrote:
> On 10/27/20 2:03 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Make sure we can actually upgrade filesystems to support inobtcounts.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/xfs        |   16 ++++++++++++
> >  tests/xfs/910     |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/910.out |    3 ++
> >  tests/xfs/group   |    1 +
> >  4 files changed, 92 insertions(+)
> >  create mode 100755 tests/xfs/910
> >  create mode 100644 tests/xfs/910.out
> > 
> > 
> > diff --git a/common/xfs b/common/xfs
> > index 3f5c14ba..e548a0a1 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -978,3 +978,19 @@ _require_xfs_copy()
> >  	[ "$USE_EXTERNAL" = yes ] && \
> >  		_notrun "Cannot xfs_copy with external devices"
> >  }
> > +
> > +_require_xfs_mkfs_inobtcount()
> > +{
> > +	_scratch_mkfs_xfs_supported -m inobtcount=1 >/dev/null 2>&1 \
> > +	   || _notrun "mkfs.xfs doesn't have inobtcount feature"
> > +}
> 
> I'd like to also add:
> 
> +_require_xfs_admin_upgrade()
> +{
> +	local feature="$1"
> +
> +	_require_scratch
> +	# Catch missing "-O" or missing feature handling
> +	_scratch_xfs_admin -O $feature 2>&1 | grep "illegal option\|Cannot change" \
> +		&& _notrun "xfs_admin does not support upgrading $1"
> +}

Well it occurred to me that the xfs_db version command has a help
screen that lists all of the things that it knows how to upgrade.
So, it should be easy enough to detect whether or not it makes sense to
test an upgrade path.  Thanks for the suggestion, sorry I was rambling
about this being harder a few days ago... :/

--D

> 
> and then:
> 
> ...
> 
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > +_require_xfs_mkfs_inobtcount
> > +_require_xfs_scratch_inobtcount
> 
> +_require_xfs_admin_upgrade "inobtcount"
> 
> to be sure that the upgrade command is also supported by xfs_admin.  By the time
> we get to release, both mkfs & xfs_admin should both support it, but I'm hedging
> my bets on the upgrade path just a little,and it seems best to explicitly test
> both requirements.
> 
> that helper can be re-used on the bigtime upgrade test as well and anything else
> that requires an xfs_admin upgrade path ...
> 
> Thanks,
> -Eric
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 3f5c14ba..e548a0a1 100644
--- a/common/xfs
+++ b/common/xfs
@@ -978,3 +978,19 @@  _require_xfs_copy()
 	[ "$USE_EXTERNAL" = yes ] && \
 		_notrun "Cannot xfs_copy with external devices"
 }
+
+_require_xfs_mkfs_inobtcount()
+{
+	_scratch_mkfs_xfs_supported -m inobtcount=1 >/dev/null 2>&1 \
+	   || _notrun "mkfs.xfs doesn't have inobtcount feature"
+}
+
+_require_xfs_scratch_inobtcount()
+{
+	_require_scratch
+
+	_scratch_mkfs -m inobtcount=1 > /dev/null
+	_try_scratch_mount || \
+		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
+	_scratch_unmount
+}
diff --git a/tests/xfs/910 b/tests/xfs/910
new file mode 100755
index 00000000..1924d9ea
--- /dev/null
+++ b/tests/xfs/910
@@ -0,0 +1,72 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 910
+#
+# Check that we can upgrade a filesystem to support inobtcount and that
+# everything works properly after the upgrade.
+
+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
+
+# We have very specific formatting parameters, so don't let things get complex
+# with realtime devices and external logs.
+unset USE_EXTERNAL
+
+# real QA test starts here
+_supported_fs xfs
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+_require_xfs_mkfs_inobtcount
+_require_xfs_scratch_inobtcount
+
+rm -f $seqres.full
+
+# Make sure we can't format a filesystem with inobtcount and not finobt.
+_scratch_mkfs -m crc=1,inobtcount=1,finobt=0 &> $seqres.full && \
+	echo "Should not be able to format with inobtcount but not finobt."
+
+# Make sure we can't upgrade a filesystem to inobtcount without finobt.
+_scratch_mkfs -m crc=1,inobtcount=0,finobt=0 &> $seqres.full
+_scratch_xfs_admin -O inobtcount >> $seqres.full && \
+	echo "Should not be able to upgrade to inobtcount without finobt."
+
+# Format V5 filesystem without inode btree counter support and populate it
+_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
+_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
+_scratch_mount >> $seqres.full
+
+echo moo > $SCRATCH_MNT/urk
+
+_scratch_unmount
+_check_scratch_fs
+
+# Now upgrade to inobtcount support
+_scratch_xfs_admin -O inobtcount >> $seqres.full
+_check_scratch_fs
+_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' -c 'agi 0' -c 'p' >> $seqres.full
+
+# Mount again, look at our files
+_scratch_mount >> $seqres.full
+cat $SCRATCH_MNT/urk
+
+# success, all done
+echo Silence is golden.
+status=0
+exit
diff --git a/tests/xfs/910.out b/tests/xfs/910.out
new file mode 100644
index 00000000..83992f49
--- /dev/null
+++ b/tests/xfs/910.out
@@ -0,0 +1,3 @@ 
+QA output created by 910
+moo
+Silence is golden.
diff --git a/tests/xfs/group b/tests/xfs/group
index 4b0caea4..862df3be 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -524,6 +524,7 @@ 
 760 auto quick rw collapse punch insert zero prealloc
 761 auto quick realtime
 763 auto quick rw realtime
+910 auto quick inobtcount
 915 auto quick quota
 917 auto quick db
 918 auto quick db