All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header
@ 2021-04-21  0:22 Darrick J. Wong
  2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
  0 siblings, 2 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-21  0:22 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

Hi all,

Years ago, Christoph diagnosed a problem where freeing an inode on a
totally full filesystem could fail due to finobt expansion not being
able to allocate enough blocks.  He solved the problem by using the
per-AG block reservation system to ensure that there are always enough
blocks for finobt expansion, but that came at the cost of having to walk
the entire finobt at mount time.  This new feature solves that
performance regression by adding inode btree block counts to the AGI
header.  The patches in this series amend fstests to handle the new
metadata fields and to test that upgrades work properly.

v2: move the xfs_admin functional test into a separate patch file and
    split them into one test for basic functionality and another for
    the extended functionality testing that modifies the test run config

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything.  Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=inobt-counters

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=inobt-counters

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=inobt-counters
---
 common/xfs        |   23 +++++++++++
 tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/764.out |   17 ++++++++
 tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/773.out |   19 +++++++++
 tests/xfs/910     |   98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/910.out |   23 +++++++++++
 tests/xfs/group   |    3 +
 8 files changed, 390 insertions(+)
 create mode 100755 tests/xfs/764
 create mode 100644 tests/xfs/764.out
 create mode 100755 tests/xfs/773
 create mode 100644 tests/xfs/773.out
 create mode 100755 tests/xfs/910
 create mode 100644 tests/xfs/910.out


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-21  0:22 [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header Darrick J. Wong
@ 2021-04-21  0:22 ` Darrick J. Wong
  2021-04-21 18:00   ` Brian Foster
                     ` (2 more replies)
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
  1 sibling, 3 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-21  0:22 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

From: Darrick J. Wong <djwong@kernel.org>

Currently, the only functional testing for xfs_admin is xfs/287, which
checks that one can add 32-bit project ids to a V4 filesystem.  This
obviously isn't an exhaustive test of all the CLI arguments, and
historically there have been xfs configurations that don't even work.

Therefore, introduce a couple of new tests -- one that will test the
simple options with the default configuration, and a second test that
steps a bit outside of the test run configuration to make sure that we
do the right thing for external devices.  The second test already caught
a nasty bug in xfsprogs 5.11.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/xfs        |   21 ++++++++++
 tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/764.out |   17 ++++++++
 tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/773.out |   19 +++++++++
 tests/xfs/group   |    2 +
 6 files changed, 266 insertions(+)
 create mode 100755 tests/xfs/764
 create mode 100644 tests/xfs/764.out
 create mode 100755 tests/xfs/773
 create mode 100644 tests/xfs/773.out


diff --git a/common/xfs b/common/xfs
index c2384146..5abc7034 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1142,3 +1142,24 @@ _check_scratch_xfs_features()
 	echo "${output[@]}"
 	test "${found}" -eq "$#"
 }
+
+# Decide if xfs_repair knows how to set (or clear) a filesystem feature.
+_require_xfs_repair_upgrade()
+{
+	local type="$1"
+
+	$XFS_REPAIR_PROG -c "$type=garbagevalue" 2>&1 | \
+		grep -q 'unknown option' && \
+		_notrun "xfs_repair does not support upgrading fs with $type"
+}
+
+_require_xfs_scratch_inobtcount()
+{
+	_require_scratch
+
+	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
+		_notrun "mkfs.xfs doesn't have inobtcount feature"
+	_try_scratch_mount || \
+		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
+	_scratch_unmount
+}
diff --git a/tests/xfs/764 b/tests/xfs/764
new file mode 100755
index 00000000..ebdf8883
--- /dev/null
+++ b/tests/xfs/764
@@ -0,0 +1,93 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 764
+#
+# Functional testing for xfs_admin to make sure that it handles option parsing
+# correctly for functionality that's relevant to V5 filesystems.  It doesn't
+# test the options that apply only to V4 filesystems because that disk format
+# is deprecated.
+
+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
+_supported_fs xfs
+_require_scratch
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+note() {
+	echo "$@" | tee -a $seqres.full
+}
+
+note "S0: Initialize filesystem"
+_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
+_scratch_xfs_db -c label -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S1: Set a filesystem label"
+_scratch_xfs_admin -L newlabel >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S2: Clear filesystem label"
+_scratch_xfs_admin -L -- >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S3: Try to set oversized label"
+_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S4: Set filesystem UUID"
+_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S5: Zero out filesystem UUID"
+_scratch_xfs_admin -U nil >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S6: Randomize filesystem UUID"
+old_uuid="$(_scratch_xfs_db -c uuid)"
+_scratch_xfs_admin -U generate >> $seqres.full
+new_uuid="$(_scratch_xfs_db -c uuid)"
+if [ "$new_uuid" = "$old_uuid" ]; then
+	echo "UUID randomization failed? $old_uuid == $new_uuid"
+fi
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S7: Restore original filesystem UUID"
+if _check_scratch_xfs_features V5 >/dev/null; then
+	# Only V5 supports the metauuid feature that enables us to restore the
+	# original UUID after a change.
+	_scratch_xfs_admin -U restore >> $seqres.full
+	_scratch_xfs_db -c uuid
+else
+	echo "UUID = babababa-baba-baba-baba-babababababa"
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/764.out b/tests/xfs/764.out
new file mode 100644
index 00000000..8da929ec
--- /dev/null
+++ b/tests/xfs/764.out
@@ -0,0 +1,17 @@
+QA output created by 764
+S0: Initialize filesystem
+label = "origlabel"
+UUID = babababa-baba-baba-baba-babababababa
+S1: Set a filesystem label
+label = "newlabel"
+S2: Clear filesystem label
+label = ""
+S3: Try to set oversized label
+label = "thisismuchto"
+S4: Set filesystem UUID
+UUID = deaddead-dead-dead-dead-deaddeaddead
+S5: Zero out filesystem UUID
+UUID = 00000000-0000-0000-0000-000000000000
+S6: Randomize filesystem UUID
+S7: Restore original filesystem UUID
+UUID = babababa-baba-baba-baba-babababababa
diff --git a/tests/xfs/773 b/tests/xfs/773
new file mode 100755
index 00000000..f184962a
--- /dev/null
+++ b/tests/xfs/773
@@ -0,0 +1,114 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 773
+#
+# Functional testing for xfs_admin to ensure that it parses arguments correctly
+# with regards to data devices that are files, external logs, and realtime
+# devices.
+#
+# Because this test synthesizes log and rt devices (by modifying the test run
+# configuration), it does /not/ require the ability to mount the scratch
+# filesystem.  This increases test coverage while isolating the weird bits to a
+# single test.
+#
+# This is partially a regression test for "xfs_admin: pick up log arguments
+# correctly", insofar as the issue fixed by that patch was discovered with an
+# earlier revision of this test.
+
+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.* $fake_logfile $fake_rtfile $fake_datafile
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_test
+_require_scratch_nocheck
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+# Create some fake sparse files for testing external devices and whatnot
+fake_datafile=$TEST_DIR/scratch.data
+rm -f $fake_datafile
+truncate -s 500m $fake_datafile
+
+fake_logfile=$TEST_DIR/scratch.log
+rm -f $fake_logfile
+truncate -s 500m $fake_logfile
+
+fake_rtfile=$TEST_DIR/scratch.rt
+rm -f $fake_rtfile
+truncate -s 500m $fake_rtfile
+
+# Save the original variables
+orig_ddev=$SCRATCH_DEV
+orig_external=$USE_EXTERNAL
+orig_logdev=$SCRATCH_LOGDEV
+orig_rtdev=$SCRATCH_RTDEV
+
+scenario() {
+	echo "$@" | tee -a $seqres.full
+
+	SCRATCH_DEV=$orig_ddev
+	USE_EXTERNAL=$orig_external
+	SCRATCH_LOGDEV=$orig_logdev
+	SCRATCH_RTDEV=$orig_rtdev
+}
+
+check_label() {
+	_scratch_mkfs -L oldlabel >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+}
+
+scenario "S1: Check that label setting with file image"
+SCRATCH_DEV=$fake_datafile
+check_label -f
+
+scenario "S2: Check that setting with logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+check_label
+
+scenario "S3: Check that setting with rtdev works"
+USE_EXTERNAL=yes
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S4: Check that setting with rtdev + logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S5: Check that setting with nortdev + nologdev works"
+USE_EXTERNAL=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+check_label
+
+scenario "S6: Check that setting with bdev incorrectly flagged as file works"
+check_label -f
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/773.out b/tests/xfs/773.out
new file mode 100644
index 00000000..954bfb85
--- /dev/null
+++ b/tests/xfs/773.out
@@ -0,0 +1,19 @@
+QA output created by 773
+S1: Check that label setting with file image
+label = "oldlabel"
+label = "newlabel"
+S2: Check that setting with logdev works
+label = "oldlabel"
+label = "newlabel"
+S3: Check that setting with rtdev works
+label = "oldlabel"
+label = "newlabel"
+S4: Check that setting with rtdev + logdev works
+label = "oldlabel"
+label = "newlabel"
+S5: Check that setting with nortdev + nologdev works
+label = "oldlabel"
+label = "newlabel"
+S6: Check that setting with bdev incorrectly flagged as file works
+label = "oldlabel"
+label = "newlabel"
diff --git a/tests/xfs/group b/tests/xfs/group
index 461ae2b2..a2309465 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -522,5 +522,7 @@
 537 auto quick
 538 auto stress
 539 auto quick mount
+764 auto quick repair
 768 auto quick repair
 770 auto repair
+773 auto quick repair


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/2] xfs: test inobtcount upgrade
  2021-04-21  0:22 [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header Darrick J. Wong
  2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
@ 2021-04-21  0:22 ` Darrick J. Wong
  2021-04-21  5:52   ` Amir Goldstein
                     ` (3 more replies)
  1 sibling, 4 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-21  0:22 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

From: Darrick J. Wong <djwong@kernel.org>

Make sure we can actually upgrade filesystems to support inode btree
counters.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/xfs        |    8 +++-
 tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/910.out |   23 ++++++++++++
 tests/xfs/group   |    1 +
 4 files changed, 127 insertions(+), 3 deletions(-)
 create mode 100755 tests/xfs/910
 create mode 100644 tests/xfs/910.out


diff --git a/common/xfs b/common/xfs
index 5abc7034..3d660858 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1153,13 +1153,15 @@ _require_xfs_repair_upgrade()
 		_notrun "xfs_repair does not support upgrading fs with $type"
 }
 
-_require_xfs_scratch_inobtcount()
+# Require that the scratch device exists, that mkfs can format with inobtcount
+# enabled, and that the kernel can mount such a filesystem.
+_require_scratch_xfs_inobtcount()
 {
 	_require_scratch
 
 	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
-		_notrun "mkfs.xfs doesn't have inobtcount feature"
+		_notrun "mkfs.xfs doesn't support inobtcount feature"
 	_try_scratch_mount || \
-		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
+		_notrun "kernel doesn't support xfs inobtcount feature"
 	_scratch_unmount
 }
diff --git a/tests/xfs/910 b/tests/xfs/910
new file mode 100755
index 00000000..237d0a35
--- /dev/null
+++ b/tests/xfs/910
@@ -0,0 +1,98 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  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
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch_xfs_inobtcount
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+_require_xfs_repair_upgrade 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 V4 filesystem
+_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
+_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
+_check_scratch_xfs_features INOBTCNT
+
+# 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=1 2>> $seqres.full
+_check_scratch_xfs_features INOBTCNT
+
+# Format V5 filesystem without inode btree counter support and populate it.
+_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
+_scratch_mount
+
+mkdir $SCRATCH_MNT/stress
+$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
+echo moo > $SCRATCH_MNT/urk
+
+_scratch_unmount
+
+# Upgrade filesystem to have the counters and inject failure into repair and
+# make sure that the only path forward is to re-run repair on the filesystem.
+echo "Fail partway through upgrading"
+XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
+test $? -eq 137 || echo "repair should have been killed??"
+_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
+_try_scratch_mount &> $tmp.mount
+res=$?
+_filter_scratch < $tmp.mount
+if [ $res -eq 0 ]; then
+	echo "needsrepair should have prevented mount"
+	_scratch_unmount
+fi
+
+echo "Re-run repair to finish upgrade"
+_scratch_xfs_repair 2>> $seqres.full
+_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
+
+echo "Filesystem should be usable again"
+_scratch_mount
+$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
+_scratch_unmount
+_check_scratch_fs
+_check_scratch_xfs_features INOBTCNT
+
+echo "Make sure we have nonzero counters"
+_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
+	sed -e 's/= [1-9]*/= NONZERO/g'
+
+echo "Make sure we can't re-add inobtcount"
+_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
+
+echo "Mount again, look at our files"
+_scratch_mount >> $seqres.full
+cat $SCRATCH_MNT/urk
+
+status=0
+exit
diff --git a/tests/xfs/910.out b/tests/xfs/910.out
new file mode 100644
index 00000000..1bf040d5
--- /dev/null
+++ b/tests/xfs/910.out
@@ -0,0 +1,23 @@
+QA output created by 910
+Running xfs_repair to upgrade filesystem.
+Inode btree count feature only supported on V5 filesystems.
+FEATURES: INOBTCNT:NO
+Running xfs_repair to upgrade filesystem.
+Inode btree count feature requires free inode btree.
+FEATURES: INOBTCNT:NO
+Fail partway through upgrading
+Adding inode btree counts to filesystem.
+FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
+mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
+Re-run repair to finish upgrade
+FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
+Filesystem should be usable again
+FEATURES: INOBTCNT:YES
+Make sure we have nonzero counters
+ino_blocks = NONZERO
+fino_blocks = NONZERO
+Make sure we can't re-add inobtcount
+Running xfs_repair to upgrade filesystem.
+Filesystem already has inode btree counts.
+Mount again, look at our files
+moo
diff --git a/tests/xfs/group b/tests/xfs/group
index a2309465..bd47333c 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -526,3 +526,4 @@
 768 auto quick repair
 770 auto repair
 773 auto quick repair
+910 auto quick inobtcount


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/2] xfs: test inobtcount upgrade
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
@ 2021-04-21  5:52   ` Amir Goldstein
  2021-04-22  0:50     ` Darrick J. Wong
  2021-04-21 18:00   ` Brian Foster
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Amir Goldstein @ 2021-04-21  5:52 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eryu Guan, linux-xfs, fstests, Eryu Guan

On Wed, Apr 21, 2021 at 3:23 AM Darrick J. Wong <djwong@kernel.org> wrote:
>
> From: Darrick J. Wong <djwong@kernel.org>
>
> Make sure we can actually upgrade filesystems to support inode btree
> counters.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  common/xfs        |    8 +++-
>  tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/910.out |   23 ++++++++++++
>  tests/xfs/group   |    1 +
>  4 files changed, 127 insertions(+), 3 deletions(-)
>  create mode 100755 tests/xfs/910
>  create mode 100644 tests/xfs/910.out
>
>
> diff --git a/common/xfs b/common/xfs
> index 5abc7034..3d660858 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1153,13 +1153,15 @@ _require_xfs_repair_upgrade()
>                 _notrun "xfs_repair does not support upgrading fs with $type"
>  }
>
> -_require_xfs_scratch_inobtcount()
> +# Require that the scratch device exists, that mkfs can format with inobtcount
> +# enabled, and that the kernel can mount such a filesystem.
> +_require_scratch_xfs_inobtcount()
>  {
>         _require_scratch
>
>         _scratch_mkfs -m inobtcount=1 &> /dev/null || \
> -               _notrun "mkfs.xfs doesn't have inobtcount feature"
> +               _notrun "mkfs.xfs doesn't support inobtcount feature"
>         _try_scratch_mount || \
> -               _notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> +               _notrun "kernel doesn't support xfs inobtcount feature"
>         _scratch_unmount
>  }
> diff --git a/tests/xfs/910 b/tests/xfs/910
> new file mode 100755
> index 00000000..237d0a35
> --- /dev/null
> +++ b/tests/xfs/910
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_scratch_xfs_inobtcount
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +_require_xfs_repair_upgrade 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 V4 filesystem
> +_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# 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=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# Format V5 filesystem without inode btree counter support and populate it.
> +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
> +_scratch_mount
> +
> +mkdir $SCRATCH_MNT/stress
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +echo moo > $SCRATCH_MNT/urk
> +
> +_scratch_unmount
> +
> +# Upgrade filesystem to have the counters and inject failure into repair and
> +# make sure that the only path forward is to re-run repair on the filesystem.
> +echo "Fail partway through upgrading"
> +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
> +test $? -eq 137 || echo "repair should have been killed??"
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +_try_scratch_mount &> $tmp.mount
> +res=$?
> +_filter_scratch < $tmp.mount
> +if [ $res -eq 0 ]; then
> +       echo "needsrepair should have prevented mount"
> +       _scratch_unmount
> +fi
> +
> +echo "Re-run repair to finish upgrade"
> +_scratch_xfs_repair 2>> $seqres.full
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +
> +echo "Filesystem should be usable again"
> +_scratch_mount
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +_scratch_unmount
> +_check_scratch_fs
> +_check_scratch_xfs_features INOBTCNT
> +
> +echo "Make sure we have nonzero counters"
> +_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
> +       sed -e 's/= [1-9]*/= NONZERO/g'
> +

I don't think = 100 translates to = NONZERO...

> +echo "Make sure we can't re-add inobtcount"
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +
> +echo "Mount again, look at our files"
> +_scratch_mount >> $seqres.full
> +cat $SCRATCH_MNT/urk
> +
> +status=0
> +exit
> diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> new file mode 100644
> index 00000000..1bf040d5
> --- /dev/null
> +++ b/tests/xfs/910.out
> @@ -0,0 +1,23 @@
> +QA output created by 910
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature only supported on V5 filesystems.
> +FEATURES: INOBTCNT:NO
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature requires free inode btree.
> +FEATURES: INOBTCNT:NO
> +Fail partway through upgrading
> +Adding inode btree counts to filesystem.
> +FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
> +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
> +Re-run repair to finish upgrade
> +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
> +Filesystem should be usable again
> +FEATURES: INOBTCNT:YES
> +Make sure we have nonzero counters
> +ino_blocks = NONZERO
> +fino_blocks = NONZERO
> +Make sure we can't re-add inobtcount
> +Running xfs_repair to upgrade filesystem.
> +Filesystem already has inode btree counts.
> +Mount again, look at our files
> +moo

This test is quite rigid in the format of messages expected from
xfs_repair. I suppose there is no precedent here...

> diff --git a/tests/xfs/group b/tests/xfs/group
> index a2309465..bd47333c 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -526,3 +526,4 @@
>  768 auto quick repair
>  770 auto repair
>  773 auto quick repair
> +910 auto quick inobtcount
>
+repair?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
@ 2021-04-21 18:00   ` Brian Foster
  2021-04-21 20:39     ` Darrick J. Wong
  2021-04-22  0:29   ` Allison Henderson
  2021-04-22  0:51   ` [PATCH v2.1 " Darrick J. Wong
  2 siblings, 1 reply; 17+ messages in thread
From: Brian Foster @ 2021-04-21 18:00 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On Tue, Apr 20, 2021 at 05:22:50PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Currently, the only functional testing for xfs_admin is xfs/287, which
> checks that one can add 32-bit project ids to a V4 filesystem.  This
> obviously isn't an exhaustive test of all the CLI arguments, and
> historically there have been xfs configurations that don't even work.
> 
> Therefore, introduce a couple of new tests -- one that will test the
> simple options with the default configuration, and a second test that
> steps a bit outside of the test run configuration to make sure that we
> do the right thing for external devices.  The second test already caught
> a nasty bug in xfsprogs 5.11.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  common/xfs        |   21 ++++++++++
>  tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/764.out |   17 ++++++++
>  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/773.out |   19 +++++++++
>  tests/xfs/group   |    2 +
>  6 files changed, 266 insertions(+)
>  create mode 100755 tests/xfs/764
>  create mode 100644 tests/xfs/764.out
>  create mode 100755 tests/xfs/773
>  create mode 100644 tests/xfs/773.out
> 
> 
...
> diff --git a/tests/xfs/773 b/tests/xfs/773
> new file mode 100755
> index 00000000..f184962a
> --- /dev/null
> +++ b/tests/xfs/773
> @@ -0,0 +1,114 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 773
> +#
> +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> +# with regards to data devices that are files, external logs, and realtime
> +# devices.
> +#
> +# Because this test synthesizes log and rt devices (by modifying the test run
> +# configuration), it does /not/ require the ability to mount the scratch
> +# filesystem.  This increases test coverage while isolating the weird bits to a
> +# single test.
> +#
> +# This is partially a regression test for "xfs_admin: pick up log arguments
> +# correctly", insofar as the issue fixed by that patch was discovered with an
> +# earlier revision of this test.
> +
> +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.* $fake_logfile $fake_rtfile $fake_datafile
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_test
> +_require_scratch_nocheck
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +
> +rm -f $seqres.full
> +
> +# Create some fake sparse files for testing external devices and whatnot
> +fake_datafile=$TEST_DIR/scratch.data
> +rm -f $fake_datafile
> +truncate -s 500m $fake_datafile
> +
> +fake_logfile=$TEST_DIR/scratch.log
> +rm -f $fake_logfile
> +truncate -s 500m $fake_logfile
> +
> +fake_rtfile=$TEST_DIR/scratch.rt
> +rm -f $fake_rtfile
> +truncate -s 500m $fake_rtfile
> +

I think it's usually good practice to incorporate $seq into filenames
created on the test device.

> +# Save the original variables
> +orig_ddev=$SCRATCH_DEV
> +orig_external=$USE_EXTERNAL
> +orig_logdev=$SCRATCH_LOGDEV
> +orig_rtdev=$SCRATCH_RTDEV
> +
> +scenario() {
> +	echo "$@" | tee -a $seqres.full
> +
> +	SCRATCH_DEV=$orig_ddev
> +	USE_EXTERNAL=$orig_external
> +	SCRATCH_LOGDEV=$orig_logdev
> +	SCRATCH_RTDEV=$orig_rtdev
> +}
> +
> +check_label() {
> +	_scratch_mkfs -L oldlabel >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +}
> +
> +scenario "S1: Check that label setting with file image"
> +SCRATCH_DEV=$fake_datafile
> +check_label -f
> +
> +scenario "S2: Check that setting with logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +check_label
> +
> +scenario "S3: Check that setting with rtdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S4: Check that setting with rtdev + logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S5: Check that setting with nortdev + nologdev works"
> +USE_EXTERNAL=
> +SCRATCH_LOGDEV=
> +SCRATCH_RTDEV=
> +check_label
> +
> +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> +check_label -f
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> new file mode 100644
> index 00000000..954bfb85
> --- /dev/null
> +++ b/tests/xfs/773.out
> @@ -0,0 +1,19 @@
> +QA output created by 773
> +S1: Check that label setting with file image
> +label = "oldlabel"
> +label = "newlabel"
> +S2: Check that setting with logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S3: Check that setting with rtdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S4: Check that setting with rtdev + logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S5: Check that setting with nortdev + nologdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S6: Check that setting with bdev incorrectly flagged as file works
> +label = "oldlabel"
> +label = "newlabel"
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 461ae2b2..a2309465 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -522,5 +522,7 @@
>  537 auto quick
>  538 auto stress
>  539 auto quick mount
> +764 auto quick repair
>  768 auto quick repair
>  770 auto repair
> +773 auto quick repair
> 

Both of these tests are primarily targeted at xfs_admin, right? If so,
I'm not sure the repair group makes much sense. With the nits fixed up:

Reviewed-by: Brian Foster <bfoster@redhat.com>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/2] xfs: test inobtcount upgrade
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
  2021-04-21  5:52   ` Amir Goldstein
@ 2021-04-21 18:00   ` Brian Foster
  2021-04-22  0:29   ` Allison Henderson
  2021-04-22  0:53   ` [PATCH v2.1 " Darrick J. Wong
  3 siblings, 0 replies; 17+ messages in thread
From: Brian Foster @ 2021-04-21 18:00 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On Tue, Apr 20, 2021 at 05:22:57PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Make sure we can actually upgrade filesystems to support inode btree
> counters.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---

LGTM:

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  common/xfs        |    8 +++-
>  tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/910.out |   23 ++++++++++++
>  tests/xfs/group   |    1 +
>  4 files changed, 127 insertions(+), 3 deletions(-)
>  create mode 100755 tests/xfs/910
>  create mode 100644 tests/xfs/910.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> index 5abc7034..3d660858 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1153,13 +1153,15 @@ _require_xfs_repair_upgrade()
>  		_notrun "xfs_repair does not support upgrading fs with $type"
>  }
>  
> -_require_xfs_scratch_inobtcount()
> +# Require that the scratch device exists, that mkfs can format with inobtcount
> +# enabled, and that the kernel can mount such a filesystem.
> +_require_scratch_xfs_inobtcount()
>  {
>  	_require_scratch
>  
>  	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
> -		_notrun "mkfs.xfs doesn't have inobtcount feature"
> +		_notrun "mkfs.xfs doesn't support inobtcount feature"
>  	_try_scratch_mount || \
> -		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> +		_notrun "kernel doesn't support xfs inobtcount feature"
>  	_scratch_unmount
>  }
> diff --git a/tests/xfs/910 b/tests/xfs/910
> new file mode 100755
> index 00000000..237d0a35
> --- /dev/null
> +++ b/tests/xfs/910
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_scratch_xfs_inobtcount
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +_require_xfs_repair_upgrade 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 V4 filesystem
> +_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# 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=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# Format V5 filesystem without inode btree counter support and populate it.
> +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
> +_scratch_mount
> +
> +mkdir $SCRATCH_MNT/stress
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +echo moo > $SCRATCH_MNT/urk
> +
> +_scratch_unmount
> +
> +# Upgrade filesystem to have the counters and inject failure into repair and
> +# make sure that the only path forward is to re-run repair on the filesystem.
> +echo "Fail partway through upgrading"
> +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
> +test $? -eq 137 || echo "repair should have been killed??"
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +_try_scratch_mount &> $tmp.mount
> +res=$?
> +_filter_scratch < $tmp.mount
> +if [ $res -eq 0 ]; then
> +	echo "needsrepair should have prevented mount"
> +	_scratch_unmount
> +fi
> +
> +echo "Re-run repair to finish upgrade"
> +_scratch_xfs_repair 2>> $seqres.full
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +
> +echo "Filesystem should be usable again"
> +_scratch_mount
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +_scratch_unmount
> +_check_scratch_fs
> +_check_scratch_xfs_features INOBTCNT
> +
> +echo "Make sure we have nonzero counters"
> +_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
> +	sed -e 's/= [1-9]*/= NONZERO/g'
> +
> +echo "Make sure we can't re-add inobtcount"
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +
> +echo "Mount again, look at our files"
> +_scratch_mount >> $seqres.full
> +cat $SCRATCH_MNT/urk
> +
> +status=0
> +exit
> diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> new file mode 100644
> index 00000000..1bf040d5
> --- /dev/null
> +++ b/tests/xfs/910.out
> @@ -0,0 +1,23 @@
> +QA output created by 910
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature only supported on V5 filesystems.
> +FEATURES: INOBTCNT:NO
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature requires free inode btree.
> +FEATURES: INOBTCNT:NO
> +Fail partway through upgrading
> +Adding inode btree counts to filesystem.
> +FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
> +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
> +Re-run repair to finish upgrade
> +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
> +Filesystem should be usable again
> +FEATURES: INOBTCNT:YES
> +Make sure we have nonzero counters
> +ino_blocks = NONZERO
> +fino_blocks = NONZERO
> +Make sure we can't re-add inobtcount
> +Running xfs_repair to upgrade filesystem.
> +Filesystem already has inode btree counts.
> +Mount again, look at our files
> +moo
> diff --git a/tests/xfs/group b/tests/xfs/group
> index a2309465..bd47333c 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -526,3 +526,4 @@
>  768 auto quick repair
>  770 auto repair
>  773 auto quick repair
> +910 auto quick inobtcount
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-21 18:00   ` Brian Foster
@ 2021-04-21 20:39     ` Darrick J. Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-21 20:39 UTC (permalink / raw)
  To: Brian Foster; +Cc: guaneryu, linux-xfs, fstests, guan

On Wed, Apr 21, 2021 at 02:00:38PM -0400, Brian Foster wrote:
> On Tue, Apr 20, 2021 at 05:22:50PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Currently, the only functional testing for xfs_admin is xfs/287, which
> > checks that one can add 32-bit project ids to a V4 filesystem.  This
> > obviously isn't an exhaustive test of all the CLI arguments, and
> > historically there have been xfs configurations that don't even work.
> > 
> > Therefore, introduce a couple of new tests -- one that will test the
> > simple options with the default configuration, and a second test that
> > steps a bit outside of the test run configuration to make sure that we
> > do the right thing for external devices.  The second test already caught
> > a nasty bug in xfsprogs 5.11.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  common/xfs        |   21 ++++++++++
> >  tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/764.out |   17 ++++++++
> >  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/773.out |   19 +++++++++
> >  tests/xfs/group   |    2 +
> >  6 files changed, 266 insertions(+)
> >  create mode 100755 tests/xfs/764
> >  create mode 100644 tests/xfs/764.out
> >  create mode 100755 tests/xfs/773
> >  create mode 100644 tests/xfs/773.out
> > 
> > 
> ...
> > diff --git a/tests/xfs/773 b/tests/xfs/773
> > new file mode 100755
> > index 00000000..f184962a
> > --- /dev/null
> > +++ b/tests/xfs/773
> > @@ -0,0 +1,114 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 773
> > +#
> > +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> > +# with regards to data devices that are files, external logs, and realtime
> > +# devices.
> > +#
> > +# Because this test synthesizes log and rt devices (by modifying the test run
> > +# configuration), it does /not/ require the ability to mount the scratch
> > +# filesystem.  This increases test coverage while isolating the weird bits to a
> > +# single test.
> > +#
> > +# This is partially a regression test for "xfs_admin: pick up log arguments
> > +# correctly", insofar as the issue fixed by that patch was discovered with an
> > +# earlier revision of this test.
> > +
> > +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.* $fake_logfile $fake_rtfile $fake_datafile
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_test
> > +_require_scratch_nocheck
> > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > +
> > +rm -f $seqres.full
> > +
> > +# Create some fake sparse files for testing external devices and whatnot
> > +fake_datafile=$TEST_DIR/scratch.data
> > +rm -f $fake_datafile
> > +truncate -s 500m $fake_datafile
> > +
> > +fake_logfile=$TEST_DIR/scratch.log
> > +rm -f $fake_logfile
> > +truncate -s 500m $fake_logfile
> > +
> > +fake_rtfile=$TEST_DIR/scratch.rt
> > +rm -f $fake_rtfile
> > +truncate -s 500m $fake_rtfile
> > +
> 
> I think it's usually good practice to incorporate $seq into filenames
> created on the test device.

Ok fixed.

> > +# Save the original variables
> > +orig_ddev=$SCRATCH_DEV
> > +orig_external=$USE_EXTERNAL
> > +orig_logdev=$SCRATCH_LOGDEV
> > +orig_rtdev=$SCRATCH_RTDEV
> > +
> > +scenario() {
> > +	echo "$@" | tee -a $seqres.full
> > +
> > +	SCRATCH_DEV=$orig_ddev
> > +	USE_EXTERNAL=$orig_external
> > +	SCRATCH_LOGDEV=$orig_logdev
> > +	SCRATCH_RTDEV=$orig_rtdev
> > +}
> > +
> > +check_label() {
> > +	_scratch_mkfs -L oldlabel >> $seqres.full
> > +	_scratch_xfs_db -c label
> > +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> > +	_scratch_xfs_db -c label
> > +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +}
> > +
> > +scenario "S1: Check that label setting with file image"
> > +SCRATCH_DEV=$fake_datafile
> > +check_label -f
> > +
> > +scenario "S2: Check that setting with logdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_LOGDEV=$fake_logfile
> > +check_label
> > +
> > +scenario "S3: Check that setting with rtdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_RTDEV=$fake_rtfile
> > +check_label
> > +
> > +scenario "S4: Check that setting with rtdev + logdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_LOGDEV=$fake_logfile
> > +SCRATCH_RTDEV=$fake_rtfile
> > +check_label
> > +
> > +scenario "S5: Check that setting with nortdev + nologdev works"
> > +USE_EXTERNAL=
> > +SCRATCH_LOGDEV=
> > +SCRATCH_RTDEV=
> > +check_label
> > +
> > +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> > +check_label -f
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> > new file mode 100644
> > index 00000000..954bfb85
> > --- /dev/null
> > +++ b/tests/xfs/773.out
> > @@ -0,0 +1,19 @@
> > +QA output created by 773
> > +S1: Check that label setting with file image
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S2: Check that setting with logdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S3: Check that setting with rtdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S4: Check that setting with rtdev + logdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S5: Check that setting with nortdev + nologdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S6: Check that setting with bdev incorrectly flagged as file works
> > +label = "oldlabel"
> > +label = "newlabel"
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index 461ae2b2..a2309465 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -522,5 +522,7 @@
> >  537 auto quick
> >  538 auto stress
> >  539 auto quick mount
> > +764 auto quick repair
> >  768 auto quick repair
> >  770 auto repair
> > +773 auto quick repair
> > 
> 
> Both of these tests are primarily targeted at xfs_admin, right? If so,
> I'm not sure the repair group makes much sense. With the nits fixed up:
> 
> Reviewed-by: Brian Foster <bfoster@redhat.com>

Will fix the groups; thanks for the review!

--D

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
  2021-04-21 18:00   ` Brian Foster
@ 2021-04-22  0:29   ` Allison Henderson
  2021-04-22  0:51   ` [PATCH v2.1 " Darrick J. Wong
  2 siblings, 0 replies; 17+ messages in thread
From: Allison Henderson @ 2021-04-22  0:29 UTC (permalink / raw)
  To: Darrick J. Wong, guaneryu; +Cc: linux-xfs, fstests, guan



On 4/20/21 5:22 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Currently, the only functional testing for xfs_admin is xfs/287, which
> checks that one can add 32-bit project ids to a V4 filesystem.  This
> obviously isn't an exhaustive test of all the CLI arguments, and
> historically there have been xfs configurations that don't even work.
> 
> Therefore, introduce a couple of new tests -- one that will test the
> simple options with the default configuration, and a second test that
> steps a bit outside of the test run configuration to make sure that we
> do the right thing for external devices.  The second test already caught
> a nasty bug in xfsprogs 5.11.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Ok, I followed it through and I think it makes sense.  With Brians 
comments fixed:
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
>   common/xfs        |   21 ++++++++++
>   tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
>   tests/xfs/764.out |   17 ++++++++
>   tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   tests/xfs/773.out |   19 +++++++++
>   tests/xfs/group   |    2 +
>   6 files changed, 266 insertions(+)
>   create mode 100755 tests/xfs/764
>   create mode 100644 tests/xfs/764.out
>   create mode 100755 tests/xfs/773
>   create mode 100644 tests/xfs/773.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> index c2384146..5abc7034 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1142,3 +1142,24 @@ _check_scratch_xfs_features()
>   	echo "${output[@]}"
>   	test "${found}" -eq "$#"
>   }
> +
> +# Decide if xfs_repair knows how to set (or clear) a filesystem feature.
> +_require_xfs_repair_upgrade()
> +{
> +	local type="$1"
> +
> +	$XFS_REPAIR_PROG -c "$type=garbagevalue" 2>&1 | \
> +		grep -q 'unknown option' && \
> +		_notrun "xfs_repair does not support upgrading fs with $type"
> +}
> +
> +_require_xfs_scratch_inobtcount()
> +{
> +	_require_scratch
> +
> +	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
> +		_notrun "mkfs.xfs doesn't have inobtcount feature"
> +	_try_scratch_mount || \
> +		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> +	_scratch_unmount
> +}
> diff --git a/tests/xfs/764 b/tests/xfs/764
> new file mode 100755
> index 00000000..ebdf8883
> --- /dev/null
> +++ b/tests/xfs/764
> @@ -0,0 +1,93 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 764
> +#
> +# Functional testing for xfs_admin to make sure that it handles option parsing
> +# correctly for functionality that's relevant to V5 filesystems.  It doesn't
> +# test the options that apply only to V4 filesystems because that disk format
> +# is deprecated.
> +
> +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
> +_supported_fs xfs
> +_require_scratch
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +
> +rm -f $seqres.full
> +
> +note() {
> +	echo "$@" | tee -a $seqres.full
> +}
> +
> +note "S0: Initialize filesystem"
> +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
> +_scratch_xfs_db -c label -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S1: Set a filesystem label"
> +_scratch_xfs_admin -L newlabel >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S2: Clear filesystem label"
> +_scratch_xfs_admin -L -- >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S3: Try to set oversized label"
> +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S4: Set filesystem UUID"
> +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
> +_scratch_xfs_db -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S5: Zero out filesystem UUID"
> +_scratch_xfs_admin -U nil >> $seqres.full
> +_scratch_xfs_db -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S6: Randomize filesystem UUID"
> +old_uuid="$(_scratch_xfs_db -c uuid)"
> +_scratch_xfs_admin -U generate >> $seqres.full
> +new_uuid="$(_scratch_xfs_db -c uuid)"
> +if [ "$new_uuid" = "$old_uuid" ]; then
> +	echo "UUID randomization failed? $old_uuid == $new_uuid"
> +fi
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S7: Restore original filesystem UUID"
> +if _check_scratch_xfs_features V5 >/dev/null; then
> +	# Only V5 supports the metauuid feature that enables us to restore the
> +	# original UUID after a change.
> +	_scratch_xfs_admin -U restore >> $seqres.full
> +	_scratch_xfs_db -c uuid
> +else
> +	echo "UUID = babababa-baba-baba-baba-babababababa"
> +fi
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/764.out b/tests/xfs/764.out
> new file mode 100644
> index 00000000..8da929ec
> --- /dev/null
> +++ b/tests/xfs/764.out
> @@ -0,0 +1,17 @@
> +QA output created by 764
> +S0: Initialize filesystem
> +label = "origlabel"
> +UUID = babababa-baba-baba-baba-babababababa
> +S1: Set a filesystem label
> +label = "newlabel"
> +S2: Clear filesystem label
> +label = ""
> +S3: Try to set oversized label
> +label = "thisismuchto"
> +S4: Set filesystem UUID
> +UUID = deaddead-dead-dead-dead-deaddeaddead
> +S5: Zero out filesystem UUID
> +UUID = 00000000-0000-0000-0000-000000000000
> +S6: Randomize filesystem UUID
> +S7: Restore original filesystem UUID
> +UUID = babababa-baba-baba-baba-babababababa
> diff --git a/tests/xfs/773 b/tests/xfs/773
> new file mode 100755
> index 00000000..f184962a
> --- /dev/null
> +++ b/tests/xfs/773
> @@ -0,0 +1,114 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 773
> +#
> +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> +# with regards to data devices that are files, external logs, and realtime
> +# devices.
> +#
> +# Because this test synthesizes log and rt devices (by modifying the test run
> +# configuration), it does /not/ require the ability to mount the scratch
> +# filesystem.  This increases test coverage while isolating the weird bits to a
> +# single test.
> +#
> +# This is partially a regression test for "xfs_admin: pick up log arguments
> +# correctly", insofar as the issue fixed by that patch was discovered with an
> +# earlier revision of this test.
> +
> +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.* $fake_logfile $fake_rtfile $fake_datafile
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_test
> +_require_scratch_nocheck
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +
> +rm -f $seqres.full
> +
> +# Create some fake sparse files for testing external devices and whatnot
> +fake_datafile=$TEST_DIR/scratch.data
> +rm -f $fake_datafile
> +truncate -s 500m $fake_datafile
> +
> +fake_logfile=$TEST_DIR/scratch.log
> +rm -f $fake_logfile
> +truncate -s 500m $fake_logfile
> +
> +fake_rtfile=$TEST_DIR/scratch.rt
> +rm -f $fake_rtfile
> +truncate -s 500m $fake_rtfile
> +
> +# Save the original variables
> +orig_ddev=$SCRATCH_DEV
> +orig_external=$USE_EXTERNAL
> +orig_logdev=$SCRATCH_LOGDEV
> +orig_rtdev=$SCRATCH_RTDEV
> +
> +scenario() {
> +	echo "$@" | tee -a $seqres.full
> +
> +	SCRATCH_DEV=$orig_ddev
> +	USE_EXTERNAL=$orig_external
> +	SCRATCH_LOGDEV=$orig_logdev
> +	SCRATCH_RTDEV=$orig_rtdev
> +}
> +
> +check_label() {
> +	_scratch_mkfs -L oldlabel >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +}
> +
> +scenario "S1: Check that label setting with file image"
> +SCRATCH_DEV=$fake_datafile
> +check_label -f
> +
> +scenario "S2: Check that setting with logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +check_label
> +
> +scenario "S3: Check that setting with rtdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S4: Check that setting with rtdev + logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S5: Check that setting with nortdev + nologdev works"
> +USE_EXTERNAL=
> +SCRATCH_LOGDEV=
> +SCRATCH_RTDEV=
> +check_label
> +
> +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> +check_label -f
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> new file mode 100644
> index 00000000..954bfb85
> --- /dev/null
> +++ b/tests/xfs/773.out
> @@ -0,0 +1,19 @@
> +QA output created by 773
> +S1: Check that label setting with file image
> +label = "oldlabel"
> +label = "newlabel"
> +S2: Check that setting with logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S3: Check that setting with rtdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S4: Check that setting with rtdev + logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S5: Check that setting with nortdev + nologdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S6: Check that setting with bdev incorrectly flagged as file works
> +label = "oldlabel"
> +label = "newlabel"
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 461ae2b2..a2309465 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -522,5 +522,7 @@
>   537 auto quick
>   538 auto stress
>   539 auto quick mount
> +764 auto quick repair
>   768 auto quick repair
>   770 auto repair
> +773 auto quick repair
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/2] xfs: test inobtcount upgrade
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
  2021-04-21  5:52   ` Amir Goldstein
  2021-04-21 18:00   ` Brian Foster
@ 2021-04-22  0:29   ` Allison Henderson
  2021-04-22  0:53   ` [PATCH v2.1 " Darrick J. Wong
  3 siblings, 0 replies; 17+ messages in thread
From: Allison Henderson @ 2021-04-22  0:29 UTC (permalink / raw)
  To: Darrick J. Wong, guaneryu; +Cc: linux-xfs, fstests, guan



On 4/20/21 5:22 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Make sure we can actually upgrade filesystems to support inode btree
> counters.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Seems ok to me
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
>   common/xfs        |    8 +++-
>   tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   tests/xfs/910.out |   23 ++++++++++++
>   tests/xfs/group   |    1 +
>   4 files changed, 127 insertions(+), 3 deletions(-)
>   create mode 100755 tests/xfs/910
>   create mode 100644 tests/xfs/910.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> index 5abc7034..3d660858 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1153,13 +1153,15 @@ _require_xfs_repair_upgrade()
>   		_notrun "xfs_repair does not support upgrading fs with $type"
>   }
>   
> -_require_xfs_scratch_inobtcount()
> +# Require that the scratch device exists, that mkfs can format with inobtcount
> +# enabled, and that the kernel can mount such a filesystem.
> +_require_scratch_xfs_inobtcount()
>   {
>   	_require_scratch
>   
>   	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
> -		_notrun "mkfs.xfs doesn't have inobtcount feature"
> +		_notrun "mkfs.xfs doesn't support inobtcount feature"
>   	_try_scratch_mount || \
> -		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> +		_notrun "kernel doesn't support xfs inobtcount feature"
>   	_scratch_unmount
>   }
> diff --git a/tests/xfs/910 b/tests/xfs/910
> new file mode 100755
> index 00000000..237d0a35
> --- /dev/null
> +++ b/tests/xfs/910
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_scratch_xfs_inobtcount
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +_require_xfs_repair_upgrade 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 V4 filesystem
> +_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# 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=1 2>> $seqres.full
> +_check_scratch_xfs_features INOBTCNT
> +
> +# Format V5 filesystem without inode btree counter support and populate it.
> +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
> +_scratch_mount
> +
> +mkdir $SCRATCH_MNT/stress
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +echo moo > $SCRATCH_MNT/urk
> +
> +_scratch_unmount
> +
> +# Upgrade filesystem to have the counters and inject failure into repair and
> +# make sure that the only path forward is to re-run repair on the filesystem.
> +echo "Fail partway through upgrading"
> +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
> +test $? -eq 137 || echo "repair should have been killed??"
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +_try_scratch_mount &> $tmp.mount
> +res=$?
> +_filter_scratch < $tmp.mount
> +if [ $res -eq 0 ]; then
> +	echo "needsrepair should have prevented mount"
> +	_scratch_unmount
> +fi
> +
> +echo "Re-run repair to finish upgrade"
> +_scratch_xfs_repair 2>> $seqres.full
> +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> +
> +echo "Filesystem should be usable again"
> +_scratch_mount
> +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> +_scratch_unmount
> +_check_scratch_fs
> +_check_scratch_xfs_features INOBTCNT
> +
> +echo "Make sure we have nonzero counters"
> +_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
> +	sed -e 's/= [1-9]*/= NONZERO/g'
> +
> +echo "Make sure we can't re-add inobtcount"
> +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> +
> +echo "Mount again, look at our files"
> +_scratch_mount >> $seqres.full
> +cat $SCRATCH_MNT/urk
> +
> +status=0
> +exit
> diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> new file mode 100644
> index 00000000..1bf040d5
> --- /dev/null
> +++ b/tests/xfs/910.out
> @@ -0,0 +1,23 @@
> +QA output created by 910
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature only supported on V5 filesystems.
> +FEATURES: INOBTCNT:NO
> +Running xfs_repair to upgrade filesystem.
> +Inode btree count feature requires free inode btree.
> +FEATURES: INOBTCNT:NO
> +Fail partway through upgrading
> +Adding inode btree counts to filesystem.
> +FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
> +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
> +Re-run repair to finish upgrade
> +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
> +Filesystem should be usable again
> +FEATURES: INOBTCNT:YES
> +Make sure we have nonzero counters
> +ino_blocks = NONZERO
> +fino_blocks = NONZERO
> +Make sure we can't re-add inobtcount
> +Running xfs_repair to upgrade filesystem.
> +Filesystem already has inode btree counts.
> +Mount again, look at our files
> +moo
> diff --git a/tests/xfs/group b/tests/xfs/group
> index a2309465..bd47333c 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -526,3 +526,4 @@
>   768 auto quick repair
>   770 auto repair
>   773 auto quick repair
> +910 auto quick inobtcount
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/2] xfs: test inobtcount upgrade
  2021-04-21  5:52   ` Amir Goldstein
@ 2021-04-22  0:50     ` Darrick J. Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-22  0:50 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Eryu Guan, linux-xfs, fstests, Eryu Guan

On Wed, Apr 21, 2021 at 08:52:39AM +0300, Amir Goldstein wrote:
> On Wed, Apr 21, 2021 at 3:23 AM Darrick J. Wong <djwong@kernel.org> wrote:
> >
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Make sure we can actually upgrade filesystems to support inode btree
> > counters.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  common/xfs        |    8 +++-
> >  tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/910.out |   23 ++++++++++++
> >  tests/xfs/group   |    1 +
> >  4 files changed, 127 insertions(+), 3 deletions(-)
> >  create mode 100755 tests/xfs/910
> >  create mode 100644 tests/xfs/910.out
> >
> >
> > diff --git a/common/xfs b/common/xfs
> > index 5abc7034..3d660858 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -1153,13 +1153,15 @@ _require_xfs_repair_upgrade()
> >                 _notrun "xfs_repair does not support upgrading fs with $type"
> >  }
> >
> > -_require_xfs_scratch_inobtcount()
> > +# Require that the scratch device exists, that mkfs can format with inobtcount
> > +# enabled, and that the kernel can mount such a filesystem.
> > +_require_scratch_xfs_inobtcount()

<groan> I clearly changed the wrong patch in response to reviewer
comments, sorry, will resubmit...

> >  {
> >         _require_scratch
> >
> >         _scratch_mkfs -m inobtcount=1 &> /dev/null || \
> > -               _notrun "mkfs.xfs doesn't have inobtcount feature"
> > +               _notrun "mkfs.xfs doesn't support inobtcount feature"
> >         _try_scratch_mount || \
> > -               _notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> > +               _notrun "kernel doesn't support xfs inobtcount feature"
> >         _scratch_unmount
> >  }
> > diff --git a/tests/xfs/910 b/tests/xfs/910
> > new file mode 100755
> > index 00000000..237d0a35
> > --- /dev/null
> > +++ b/tests/xfs/910
> > @@ -0,0 +1,98 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  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
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_scratch_xfs_inobtcount
> > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > +_require_xfs_repair_upgrade 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 V4 filesystem
> > +_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
> > +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> > +_check_scratch_xfs_features INOBTCNT
> > +
> > +# 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=1 2>> $seqres.full
> > +_check_scratch_xfs_features INOBTCNT
> > +
> > +# Format V5 filesystem without inode btree counter support and populate it.
> > +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
> > +_scratch_mount
> > +
> > +mkdir $SCRATCH_MNT/stress
> > +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> > +echo moo > $SCRATCH_MNT/urk
> > +
> > +_scratch_unmount
> > +
> > +# Upgrade filesystem to have the counters and inject failure into repair and
> > +# make sure that the only path forward is to re-run repair on the filesystem.
> > +echo "Fail partway through upgrading"
> > +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
> > +test $? -eq 137 || echo "repair should have been killed??"
> > +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> > +_try_scratch_mount &> $tmp.mount
> > +res=$?
> > +_filter_scratch < $tmp.mount
> > +if [ $res -eq 0 ]; then
> > +       echo "needsrepair should have prevented mount"
> > +       _scratch_unmount
> > +fi
> > +
> > +echo "Re-run repair to finish upgrade"
> > +_scratch_xfs_repair 2>> $seqres.full
> > +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
> > +
> > +echo "Filesystem should be usable again"
> > +_scratch_mount
> > +$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
> > +_scratch_unmount
> > +_check_scratch_fs
> > +_check_scratch_xfs_features INOBTCNT
> > +
> > +echo "Make sure we have nonzero counters"
> > +_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
> > +       sed -e 's/= [1-9]*/= NONZERO/g'
> > +
> 
> I don't think = 100 translates to = NONZERO...

Urk, yes, will fix.

> > +echo "Make sure we can't re-add inobtcount"
> > +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
> > +
> > +echo "Mount again, look at our files"
> > +_scratch_mount >> $seqres.full
> > +cat $SCRATCH_MNT/urk
> > +
> > +status=0
> > +exit
> > diff --git a/tests/xfs/910.out b/tests/xfs/910.out
> > new file mode 100644
> > index 00000000..1bf040d5
> > --- /dev/null
> > +++ b/tests/xfs/910.out
> > @@ -0,0 +1,23 @@
> > +QA output created by 910
> > +Running xfs_repair to upgrade filesystem.
> > +Inode btree count feature only supported on V5 filesystems.
> > +FEATURES: INOBTCNT:NO
> > +Running xfs_repair to upgrade filesystem.
> > +Inode btree count feature requires free inode btree.
> > +FEATURES: INOBTCNT:NO
> > +Fail partway through upgrading
> > +Adding inode btree counts to filesystem.
> > +FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
> > +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
> > +Re-run repair to finish upgrade
> > +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
> > +Filesystem should be usable again
> > +FEATURES: INOBTCNT:YES
> > +Make sure we have nonzero counters
> > +ino_blocks = NONZERO
> > +fino_blocks = NONZERO
> > +Make sure we can't re-add inobtcount
> > +Running xfs_repair to upgrade filesystem.
> > +Filesystem already has inode btree counts.
> > +Mount again, look at our files
> > +moo
> 
> This test is quite rigid in the format of messages expected from
> xfs_repair. I suppose there is no precedent here...

<shrug> There /is/ precedent -- if we ever need to change the stdout, we
filter the golden output.

--D

> 
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index a2309465..bd47333c 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -526,3 +526,4 @@
> >  768 auto quick repair
> >  770 auto repair
> >  773 auto quick repair
> > +910 auto quick inobtcount
> >
> +repair?
> 
> Thanks,
> Amir.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2.1 1/2] xfs: functional testing of V5-relevant options
  2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
  2021-04-21 18:00   ` Brian Foster
  2021-04-22  0:29   ` Allison Henderson
@ 2021-04-22  0:51   ` Darrick J. Wong
  2 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-22  0:51 UTC (permalink / raw)
  To: guaneryu; +Cc: linux-xfs, fstests, guan, bfoster, allison.henderson

From: Darrick J. Wong <djwong@kernel.org>

Currently, the only functional testing for xfs_admin is xfs/287, which
checks that one can add 32-bit project ids to a V4 filesystem.  This
obviously isn't an exhaustive test of all the CLI arguments, and
historically there have been xfs configurations that don't even work.

Therefore, introduce a couple of new tests -- one that will test the
simple options with the default configuration, and a second test that
steps a bit outside of the test run configuration to make sure that we
do the right thing for external devices.  The second test already caught
a nasty bug in xfsprogs 5.11.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
---
v2.1: add sequence number to synthesized external devices, change groups
---
 common/xfs        |   10 +++++
 tests/xfs/764     |   93 +++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/764.out |   17 ++++++++
 tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/773.out |   19 +++++++++
 tests/xfs/group   |    2 +
 6 files changed, 255 insertions(+)
 create mode 100755 tests/xfs/764
 create mode 100644 tests/xfs/764.out
 create mode 100755 tests/xfs/773
 create mode 100644 tests/xfs/773.out

diff --git a/common/xfs b/common/xfs
index ba6523ad..4f1a4dba 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1128,3 +1128,13 @@ _check_scratch_xfs_features()
 	echo "${output[@]}"
 	test "${found}" -eq "$#"
 }
+
+# Decide if xfs_repair knows how to set (or clear) a filesystem feature.
+_require_xfs_repair_upgrade()
+{
+	local type="$1"
+
+	$XFS_REPAIR_PROG -c "$type=garbagevalue" 2>&1 | \
+		grep -q 'unknown option' && \
+		_notrun "xfs_repair does not support upgrading fs with $type"
+}
diff --git a/tests/xfs/764 b/tests/xfs/764
new file mode 100755
index 00000000..ebdf8883
--- /dev/null
+++ b/tests/xfs/764
@@ -0,0 +1,93 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 764
+#
+# Functional testing for xfs_admin to make sure that it handles option parsing
+# correctly for functionality that's relevant to V5 filesystems.  It doesn't
+# test the options that apply only to V4 filesystems because that disk format
+# is deprecated.
+
+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
+_supported_fs xfs
+_require_scratch
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+note() {
+	echo "$@" | tee -a $seqres.full
+}
+
+note "S0: Initialize filesystem"
+_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
+_scratch_xfs_db -c label -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S1: Set a filesystem label"
+_scratch_xfs_admin -L newlabel >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S2: Clear filesystem label"
+_scratch_xfs_admin -L -- >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S3: Try to set oversized label"
+_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S4: Set filesystem UUID"
+_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S5: Zero out filesystem UUID"
+_scratch_xfs_admin -U nil >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S6: Randomize filesystem UUID"
+old_uuid="$(_scratch_xfs_db -c uuid)"
+_scratch_xfs_admin -U generate >> $seqres.full
+new_uuid="$(_scratch_xfs_db -c uuid)"
+if [ "$new_uuid" = "$old_uuid" ]; then
+	echo "UUID randomization failed? $old_uuid == $new_uuid"
+fi
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S7: Restore original filesystem UUID"
+if _check_scratch_xfs_features V5 >/dev/null; then
+	# Only V5 supports the metauuid feature that enables us to restore the
+	# original UUID after a change.
+	_scratch_xfs_admin -U restore >> $seqres.full
+	_scratch_xfs_db -c uuid
+else
+	echo "UUID = babababa-baba-baba-baba-babababababa"
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/764.out b/tests/xfs/764.out
new file mode 100644
index 00000000..8da929ec
--- /dev/null
+++ b/tests/xfs/764.out
@@ -0,0 +1,17 @@
+QA output created by 764
+S0: Initialize filesystem
+label = "origlabel"
+UUID = babababa-baba-baba-baba-babababababa
+S1: Set a filesystem label
+label = "newlabel"
+S2: Clear filesystem label
+label = ""
+S3: Try to set oversized label
+label = "thisismuchto"
+S4: Set filesystem UUID
+UUID = deaddead-dead-dead-dead-deaddeaddead
+S5: Zero out filesystem UUID
+UUID = 00000000-0000-0000-0000-000000000000
+S6: Randomize filesystem UUID
+S7: Restore original filesystem UUID
+UUID = babababa-baba-baba-baba-babababababa
diff --git a/tests/xfs/773 b/tests/xfs/773
new file mode 100755
index 00000000..f7a340f6
--- /dev/null
+++ b/tests/xfs/773
@@ -0,0 +1,114 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 773
+#
+# Functional testing for xfs_admin to ensure that it parses arguments correctly
+# with regards to data devices that are files, external logs, and realtime
+# devices.
+#
+# Because this test synthesizes log and rt devices (by modifying the test run
+# configuration), it does /not/ require the ability to mount the scratch
+# filesystem.  This increases test coverage while isolating the weird bits to a
+# single test.
+#
+# This is partially a regression test for "xfs_admin: pick up log arguments
+# correctly", insofar as the issue fixed by that patch was discovered with an
+# earlier revision of this test.
+
+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.* $fake_logfile $fake_rtfile $fake_datafile
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_test
+_require_scratch_nocheck
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+# Create some fake sparse files for testing external devices and whatnot
+fake_datafile=$TEST_DIR/$seq.scratch.data
+rm -f $fake_datafile
+truncate -s 500m $fake_datafile
+
+fake_logfile=$TEST_DIR/$seq.scratch.log
+rm -f $fake_logfile
+truncate -s 500m $fake_logfile
+
+fake_rtfile=$TEST_DIR/$seq.scratch.rt
+rm -f $fake_rtfile
+truncate -s 500m $fake_rtfile
+
+# Save the original variables
+orig_ddev=$SCRATCH_DEV
+orig_external=$USE_EXTERNAL
+orig_logdev=$SCRATCH_LOGDEV
+orig_rtdev=$SCRATCH_RTDEV
+
+scenario() {
+	echo "$@" | tee -a $seqres.full
+
+	SCRATCH_DEV=$orig_ddev
+	USE_EXTERNAL=$orig_external
+	SCRATCH_LOGDEV=$orig_logdev
+	SCRATCH_RTDEV=$orig_rtdev
+}
+
+check_label() {
+	_scratch_mkfs -L oldlabel >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+}
+
+scenario "S1: Check that label setting with file image"
+SCRATCH_DEV=$fake_datafile
+check_label -f
+
+scenario "S2: Check that setting with logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+check_label
+
+scenario "S3: Check that setting with rtdev works"
+USE_EXTERNAL=yes
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S4: Check that setting with rtdev + logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S5: Check that setting with nortdev + nologdev works"
+USE_EXTERNAL=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+check_label
+
+scenario "S6: Check that setting with bdev incorrectly flagged as file works"
+check_label -f
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/773.out b/tests/xfs/773.out
new file mode 100644
index 00000000..954bfb85
--- /dev/null
+++ b/tests/xfs/773.out
@@ -0,0 +1,19 @@
+QA output created by 773
+S1: Check that label setting with file image
+label = "oldlabel"
+label = "newlabel"
+S2: Check that setting with logdev works
+label = "oldlabel"
+label = "newlabel"
+S3: Check that setting with rtdev works
+label = "oldlabel"
+label = "newlabel"
+S4: Check that setting with rtdev + logdev works
+label = "oldlabel"
+label = "newlabel"
+S5: Check that setting with nortdev + nologdev works
+label = "oldlabel"
+label = "newlabel"
+S6: Check that setting with bdev incorrectly flagged as file works
+label = "oldlabel"
+label = "newlabel"
diff --git a/tests/xfs/group b/tests/xfs/group
index 461ae2b2..4231d1d5 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -522,5 +522,7 @@
 537 auto quick
 538 auto stress
 539 auto quick mount
+764 auto quick admin
 768 auto quick repair
 770 auto repair
+773 auto quick admin

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2.1 2/2] xfs: test inobtcount upgrade
  2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
                     ` (2 preceding siblings ...)
  2021-04-22  0:29   ` Allison Henderson
@ 2021-04-22  0:53   ` Darrick J. Wong
  3 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-22  0:53 UTC (permalink / raw)
  To: guaneryu; +Cc: linux-xfs, fstests, guan, bfoster, allison.henderson, amir73il

From: Darrick J. Wong <djwong@kernel.org>

Make sure we can actually upgrade filesystems to support inode btree
counters.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
---
v2.1: fix helper bogosity, broken regexps.
---
 common/xfs        |   13 +++++++
 tests/xfs/910     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/910.out |   23 ++++++++++++
 tests/xfs/group   |    1 +
 4 files changed, 135 insertions(+)
 create mode 100755 tests/xfs/910
 create mode 100644 tests/xfs/910.out

diff --git a/common/xfs b/common/xfs
index 4f1a4dba..848311b4 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1138,3 +1138,16 @@ _require_xfs_repair_upgrade()
 		grep -q 'unknown option' && \
 		_notrun "xfs_repair does not support upgrading fs with $type"
 }
+
+# Require that the scratch device exists, that mkfs can format with inobtcount
+# enabled, and that the kernel can mount such a filesystem.
+_require_scratch_xfs_inobtcount()
+{
+	_require_scratch
+
+	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
+		_notrun "mkfs.xfs doesn't support inobtcount feature"
+	_try_scratch_mount || \
+		_notrun "kernel doesn't support xfs inobtcount feature"
+	_scratch_unmount
+}
diff --git a/tests/xfs/910 b/tests/xfs/910
new file mode 100755
index 00000000..0ed2dc4f
--- /dev/null
+++ b/tests/xfs/910
@@ -0,0 +1,98 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  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
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch_xfs_inobtcount
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+_require_xfs_repair_upgrade 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 V4 filesystem
+_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full
+_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
+_check_scratch_xfs_features INOBTCNT
+
+# 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=1 2>> $seqres.full
+_check_scratch_xfs_features INOBTCNT
+
+# Format V5 filesystem without inode btree counter support and populate it.
+_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full
+_scratch_mount
+
+mkdir $SCRATCH_MNT/stress
+$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
+echo moo > $SCRATCH_MNT/urk
+
+_scratch_unmount
+
+# Upgrade filesystem to have the counters and inject failure into repair and
+# make sure that the only path forward is to re-run repair on the filesystem.
+echo "Fail partway through upgrading"
+XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full
+test $? -eq 137 || echo "repair should have been killed??"
+_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
+_try_scratch_mount &> $tmp.mount
+res=$?
+_filter_scratch < $tmp.mount
+if [ $res -eq 0 ]; then
+	echo "needsrepair should have prevented mount"
+	_scratch_unmount
+fi
+
+echo "Re-run repair to finish upgrade"
+_scratch_xfs_repair 2>> $seqres.full
+_check_scratch_xfs_features NEEDSREPAIR INOBTCNT
+
+echo "Filesystem should be usable again"
+_scratch_mount
+$FSSTRESS_PROG -d $SCRATCH_MNT/stress -n 1000 >> $seqres.full
+_scratch_unmount
+_check_scratch_fs
+_check_scratch_xfs_features INOBTCNT
+
+echo "Make sure we have nonzero counters"
+_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \
+	sed -e 's/= 0$/= ZERO/g' -e 's/= [0-9]*/= NONZERO/g'
+
+echo "Make sure we can't re-add inobtcount"
+_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full
+
+echo "Mount again, look at our files"
+_scratch_mount >> $seqres.full
+cat $SCRATCH_MNT/urk
+
+status=0
+exit
diff --git a/tests/xfs/910.out b/tests/xfs/910.out
new file mode 100644
index 00000000..1bf040d5
--- /dev/null
+++ b/tests/xfs/910.out
@@ -0,0 +1,23 @@
+QA output created by 910
+Running xfs_repair to upgrade filesystem.
+Inode btree count feature only supported on V5 filesystems.
+FEATURES: INOBTCNT:NO
+Running xfs_repair to upgrade filesystem.
+Inode btree count feature requires free inode btree.
+FEATURES: INOBTCNT:NO
+Fail partway through upgrading
+Adding inode btree counts to filesystem.
+FEATURES: NEEDSREPAIR:YES INOBTCNT:YES
+mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning.
+Re-run repair to finish upgrade
+FEATURES: NEEDSREPAIR:NO INOBTCNT:YES
+Filesystem should be usable again
+FEATURES: INOBTCNT:YES
+Make sure we have nonzero counters
+ino_blocks = NONZERO
+fino_blocks = NONZERO
+Make sure we can't re-add inobtcount
+Running xfs_repair to upgrade filesystem.
+Filesystem already has inode btree counts.
+Mount again, look at our files
+moo
diff --git a/tests/xfs/group b/tests/xfs/group
index 4231d1d5..4c70cff1 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -526,3 +526,4 @@
 768 auto quick repair
 770 auto repair
 773 auto quick admin
+910 auto quick inobtcount

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-05 14:47       ` Brian Foster
@ 2021-04-07 23:13         ` Darrick J. Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-07 23:13 UTC (permalink / raw)
  To: Brian Foster; +Cc: guaneryu, linux-xfs, fstests, guan

On Mon, Apr 05, 2021 at 10:47:43AM -0400, Brian Foster wrote:
> On Thu, Apr 01, 2021 at 05:58:14PM -0700, Darrick J. Wong wrote:
> > On Wed, Mar 31, 2021 at 01:36:21PM -0400, Brian Foster wrote:
> > > On Tue, Mar 30, 2021 at 06:08:28PM -0700, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong <djwong@kernel.org>
> > > > 
> > > > Currently, the only functional testing for xfs_admin is xfs/287, which
> > > > checks that one can add 32-bit project ids to a V4 filesystem.  This
> > > > obviously isn't an exhaustive test of all the CLI arguments, and
> > > > historically there have been xfs configurations that don't even work.
> > > > 
> > > > Therefore, introduce a couple of new tests -- one that will test the
> > > > simple options with the default configuration, and a second test that
> > > > steps a bit outside of the test run configuration to make sure that we
> > > > do the right thing for external devices.  The second test already caught
> > > > a nasty bug in xfsprogs 5.11.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > > ---
> > > >  common/xfs        |   21 ++++++++++
> > > >  tests/xfs/764     |   91 ++++++++++++++++++++++++++++++++++++++++++
> > > >  tests/xfs/764.out |   17 ++++++++
> > > >  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >  tests/xfs/773.out |   19 +++++++++
> > > >  tests/xfs/group   |    2 +
> > > >  6 files changed, 264 insertions(+)
> > > >  create mode 100755 tests/xfs/764
> > > >  create mode 100644 tests/xfs/764.out
> > > >  create mode 100755 tests/xfs/773
> > > >  create mode 100644 tests/xfs/773.out
> > > > 
> > > > 
> > > ...
> > > > diff --git a/tests/xfs/764 b/tests/xfs/764
> > > > new file mode 100755
> > > > index 00000000..c710ad4e
> > > > --- /dev/null
> > > > +++ b/tests/xfs/764
> > > > @@ -0,0 +1,91 @@
> > > > +#! /bin/bash
> > > > +# SPDX-License-Identifier: GPL-2.0-or-later
> > > > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > > > +#
> > > > +# FS QA Test No. 764
> > > > +#
> > > > +# Functional testing for xfs_admin to make sure that it handles option parsing
> > > > +# correctly, at least for functionality that's relevant to V5 filesystems.
> > > 
> > > This test doesn't seem to depend on v5..?
> > 
> > Why would it?  You can set labels and uuids for V4 filesystems.
> > 
> > "..relevant to V5 filesystems" means this test doesn't bother with the
> > the upgrade options that don't apply to V5, like lazycount, 32bit
> > project ids, and v2 logs.
> > 
> 
> The wording of the test description was unclear to me because I ran it
> on v4 and it seemed to work fine. FWIW, something that just says the
> test intentionally doesn't cover v4 only options might be a bit more
> clear.

Changed to:

# Functional testing for xfs_admin to make sure that it handles option
# parsing correctly for functionality that's relevant to V5 filesystems.
# It doesn't test the options that apply only to V4 filesystems because
# that disk format is deprecated.

> > > > +
> > > > +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
> > > > +_supported_fs xfs
> > > > +_require_scratch
> > > > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > > > +
> > > > +rm -f $seqres.full
> > > > +
> > > > +note() {
> > > > +	echo "$@" | tee -a $seqres.full
> > > > +}
> > > > +
> > > > +note "S0: Initialize filesystem"
> > > > +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
> > > > +_scratch_xfs_db -c label -c uuid
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S1: Set a filesystem label"
> > > > +_scratch_xfs_admin -L newlabel >> $seqres.full
> > > > +_scratch_xfs_db -c label
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S2: Clear filesystem label"
> > > > +_scratch_xfs_admin -L -- >> $seqres.full
> > > > +_scratch_xfs_db -c label
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S3: Try to set oversized label"
> > > > +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
> > > > +_scratch_xfs_db -c label
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S4: Set filesystem UUID"
> > > > +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
> > > > +_scratch_xfs_db -c uuid
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S5: Zero out filesystem UUID"
> > > > +_scratch_xfs_admin -U nil >> $seqres.full
> > > > +_scratch_xfs_db -c uuid
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > > +note "S6: Randomize filesystem UUID"
> > > > +old_uuid="$(_scratch_xfs_db -c uuid)"
> > > > +_scratch_xfs_admin -U generate >> $seqres.full
> > > > +new_uuid="$(_scratch_xfs_db -c uuid)"
> > > > +if [ "$new_uuid" = "$old_uuid" ]; then
> > > > +	echo "UUID randomization failed? $old_uuid == $new_uuid"
> > > > +fi
> > > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +
> > > 
> > > Can we drop all these intermediate repair invocations and just rely on
> > > the post-test device check? Otherwise the rest LGTM.
> > 
> > I was trying to be thorough, checking at each step that we haven't
> > accidentally broken the filesystem.  They could go away, but what's the
> > harm in checking an empty filesystem?
> > 
> 
> It's not harmful (and I don't care that much whether it stays or goes).
> I just didn't see the point and it made the test incrementally harder to
> grok at a glance.

<nod>

--D

> 
> Brian
> 
> > --D
> > 
> > > Brian
> > > 
> > > > +note "S7: Restore original filesystem UUID"
> > > > +if _check_scratch_xfs_features V5 >/dev/null; then
> > > > +	# Only V5 supports the metauuid feature that enables us to restore the
> > > > +	# original UUID after a change.
> > > > +	_scratch_xfs_admin -U restore >> $seqres.full
> > > > +	_scratch_xfs_db -c uuid
> > > > +else
> > > > +	echo "UUID = babababa-baba-baba-baba-babababababa"
> > > > +fi
> > > > +
> > > > +# success, all done
> > > > +status=0
> > > > +exit
> > > > diff --git a/tests/xfs/764.out b/tests/xfs/764.out
> > > > new file mode 100644
> > > > index 00000000..8da929ec
> > > > --- /dev/null
> > > > +++ b/tests/xfs/764.out
> > > > @@ -0,0 +1,17 @@
> > > > +QA output created by 764
> > > > +S0: Initialize filesystem
> > > > +label = "origlabel"
> > > > +UUID = babababa-baba-baba-baba-babababababa
> > > > +S1: Set a filesystem label
> > > > +label = "newlabel"
> > > > +S2: Clear filesystem label
> > > > +label = ""
> > > > +S3: Try to set oversized label
> > > > +label = "thisismuchto"
> > > > +S4: Set filesystem UUID
> > > > +UUID = deaddead-dead-dead-dead-deaddeaddead
> > > > +S5: Zero out filesystem UUID
> > > > +UUID = 00000000-0000-0000-0000-000000000000
> > > > +S6: Randomize filesystem UUID
> > > > +S7: Restore original filesystem UUID
> > > > +UUID = babababa-baba-baba-baba-babababababa
> > > > diff --git a/tests/xfs/773 b/tests/xfs/773
> > > > new file mode 100755
> > > > index 00000000..f184962a
> > > > --- /dev/null
> > > > +++ b/tests/xfs/773
> > > > @@ -0,0 +1,114 @@
> > > > +#! /bin/bash
> > > > +# SPDX-License-Identifier: GPL-2.0-or-later
> > > > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > > > +#
> > > > +# FS QA Test No. 773
> > > > +#
> > > > +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> > > > +# with regards to data devices that are files, external logs, and realtime
> > > > +# devices.
> > > > +#
> > > > +# Because this test synthesizes log and rt devices (by modifying the test run
> > > > +# configuration), it does /not/ require the ability to mount the scratch
> > > > +# filesystem.  This increases test coverage while isolating the weird bits to a
> > > > +# single test.
> > > > +#
> > > > +# This is partially a regression test for "xfs_admin: pick up log arguments
> > > > +# correctly", insofar as the issue fixed by that patch was discovered with an
> > > > +# earlier revision of this test.
> > > > +
> > > > +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.* $fake_logfile $fake_rtfile $fake_datafile
> > > > +}
> > > > +
> > > > +# get standard environment, filters and checks
> > > > +. ./common/rc
> > > > +. ./common/filter
> > > > +
> > > > +# real QA test starts here
> > > > +_supported_fs xfs
> > > > +_require_test
> > > > +_require_scratch_nocheck
> > > > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > > > +
> > > > +rm -f $seqres.full
> > > > +
> > > > +# Create some fake sparse files for testing external devices and whatnot
> > > > +fake_datafile=$TEST_DIR/scratch.data
> > > > +rm -f $fake_datafile
> > > > +truncate -s 500m $fake_datafile
> > > > +
> > > > +fake_logfile=$TEST_DIR/scratch.log
> > > > +rm -f $fake_logfile
> > > > +truncate -s 500m $fake_logfile
> > > > +
> > > > +fake_rtfile=$TEST_DIR/scratch.rt
> > > > +rm -f $fake_rtfile
> > > > +truncate -s 500m $fake_rtfile
> > > > +
> > > > +# Save the original variables
> > > > +orig_ddev=$SCRATCH_DEV
> > > > +orig_external=$USE_EXTERNAL
> > > > +orig_logdev=$SCRATCH_LOGDEV
> > > > +orig_rtdev=$SCRATCH_RTDEV
> > > > +
> > > > +scenario() {
> > > > +	echo "$@" | tee -a $seqres.full
> > > > +
> > > > +	SCRATCH_DEV=$orig_ddev
> > > > +	USE_EXTERNAL=$orig_external
> > > > +	SCRATCH_LOGDEV=$orig_logdev
> > > > +	SCRATCH_RTDEV=$orig_rtdev
> > > > +}
> > > > +
> > > > +check_label() {
> > > > +	_scratch_mkfs -L oldlabel >> $seqres.full
> > > > +	_scratch_xfs_db -c label
> > > > +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> > > > +	_scratch_xfs_db -c label
> > > > +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > > +}
> > > > +
> > > > +scenario "S1: Check that label setting with file image"
> > > > +SCRATCH_DEV=$fake_datafile
> > > > +check_label -f
> > > > +
> > > > +scenario "S2: Check that setting with logdev works"
> > > > +USE_EXTERNAL=yes
> > > > +SCRATCH_LOGDEV=$fake_logfile
> > > > +check_label
> > > > +
> > > > +scenario "S3: Check that setting with rtdev works"
> > > > +USE_EXTERNAL=yes
> > > > +SCRATCH_RTDEV=$fake_rtfile
> > > > +check_label
> > > > +
> > > > +scenario "S4: Check that setting with rtdev + logdev works"
> > > > +USE_EXTERNAL=yes
> > > > +SCRATCH_LOGDEV=$fake_logfile
> > > > +SCRATCH_RTDEV=$fake_rtfile
> > > > +check_label
> > > > +
> > > > +scenario "S5: Check that setting with nortdev + nologdev works"
> > > > +USE_EXTERNAL=
> > > > +SCRATCH_LOGDEV=
> > > > +SCRATCH_RTDEV=
> > > > +check_label
> > > > +
> > > > +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> > > > +check_label -f
> > > > +
> > > > +# success, all done
> > > > +status=0
> > > > +exit
> > > > diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> > > > new file mode 100644
> > > > index 00000000..954bfb85
> > > > --- /dev/null
> > > > +++ b/tests/xfs/773.out
> > > > @@ -0,0 +1,19 @@
> > > > +QA output created by 773
> > > > +S1: Check that label setting with file image
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > +S2: Check that setting with logdev works
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > +S3: Check that setting with rtdev works
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > +S4: Check that setting with rtdev + logdev works
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > +S5: Check that setting with nortdev + nologdev works
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > +S6: Check that setting with bdev incorrectly flagged as file works
> > > > +label = "oldlabel"
> > > > +label = "newlabel"
> > > > diff --git a/tests/xfs/group b/tests/xfs/group
> > > > index 09fddb5a..5801471b 100644
> > > > --- a/tests/xfs/group
> > > > +++ b/tests/xfs/group
> > > > @@ -520,5 +520,7 @@
> > > >  537 auto quick
> > > >  538 auto stress
> > > >  539 auto quick mount
> > > > +764 auto quick repair
> > > >  768 auto quick repair
> > > >  770 auto repair
> > > > +773 auto quick repair
> > > > 
> > > 
> > 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-04-02  0:58     ` Darrick J. Wong
@ 2021-04-05 14:47       ` Brian Foster
  2021-04-07 23:13         ` Darrick J. Wong
  0 siblings, 1 reply; 17+ messages in thread
From: Brian Foster @ 2021-04-05 14:47 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On Thu, Apr 01, 2021 at 05:58:14PM -0700, Darrick J. Wong wrote:
> On Wed, Mar 31, 2021 at 01:36:21PM -0400, Brian Foster wrote:
> > On Tue, Mar 30, 2021 at 06:08:28PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <djwong@kernel.org>
> > > 
> > > Currently, the only functional testing for xfs_admin is xfs/287, which
> > > checks that one can add 32-bit project ids to a V4 filesystem.  This
> > > obviously isn't an exhaustive test of all the CLI arguments, and
> > > historically there have been xfs configurations that don't even work.
> > > 
> > > Therefore, introduce a couple of new tests -- one that will test the
> > > simple options with the default configuration, and a second test that
> > > steps a bit outside of the test run configuration to make sure that we
> > > do the right thing for external devices.  The second test already caught
> > > a nasty bug in xfsprogs 5.11.
> > > 
> > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > ---
> > >  common/xfs        |   21 ++++++++++
> > >  tests/xfs/764     |   91 ++++++++++++++++++++++++++++++++++++++++++
> > >  tests/xfs/764.out |   17 ++++++++
> > >  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  tests/xfs/773.out |   19 +++++++++
> > >  tests/xfs/group   |    2 +
> > >  6 files changed, 264 insertions(+)
> > >  create mode 100755 tests/xfs/764
> > >  create mode 100644 tests/xfs/764.out
> > >  create mode 100755 tests/xfs/773
> > >  create mode 100644 tests/xfs/773.out
> > > 
> > > 
> > ...
> > > diff --git a/tests/xfs/764 b/tests/xfs/764
> > > new file mode 100755
> > > index 00000000..c710ad4e
> > > --- /dev/null
> > > +++ b/tests/xfs/764
> > > @@ -0,0 +1,91 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0-or-later
> > > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > > +#
> > > +# FS QA Test No. 764
> > > +#
> > > +# Functional testing for xfs_admin to make sure that it handles option parsing
> > > +# correctly, at least for functionality that's relevant to V5 filesystems.
> > 
> > This test doesn't seem to depend on v5..?
> 
> Why would it?  You can set labels and uuids for V4 filesystems.
> 
> "..relevant to V5 filesystems" means this test doesn't bother with the
> the upgrade options that don't apply to V5, like lazycount, 32bit
> project ids, and v2 logs.
> 

The wording of the test description was unclear to me because I ran it
on v4 and it seemed to work fine. FWIW, something that just says the
test intentionally doesn't cover v4 only options might be a bit more
clear.

> > > +
> > > +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
> > > +_supported_fs xfs
> > > +_require_scratch
> > > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > > +
> > > +rm -f $seqres.full
> > > +
> > > +note() {
> > > +	echo "$@" | tee -a $seqres.full
> > > +}
> > > +
> > > +note "S0: Initialize filesystem"
> > > +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
> > > +_scratch_xfs_db -c label -c uuid
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S1: Set a filesystem label"
> > > +_scratch_xfs_admin -L newlabel >> $seqres.full
> > > +_scratch_xfs_db -c label
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S2: Clear filesystem label"
> > > +_scratch_xfs_admin -L -- >> $seqres.full
> > > +_scratch_xfs_db -c label
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S3: Try to set oversized label"
> > > +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
> > > +_scratch_xfs_db -c label
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S4: Set filesystem UUID"
> > > +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
> > > +_scratch_xfs_db -c uuid
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S5: Zero out filesystem UUID"
> > > +_scratch_xfs_admin -U nil >> $seqres.full
> > > +_scratch_xfs_db -c uuid
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > > +note "S6: Randomize filesystem UUID"
> > > +old_uuid="$(_scratch_xfs_db -c uuid)"
> > > +_scratch_xfs_admin -U generate >> $seqres.full
> > > +new_uuid="$(_scratch_xfs_db -c uuid)"
> > > +if [ "$new_uuid" = "$old_uuid" ]; then
> > > +	echo "UUID randomization failed? $old_uuid == $new_uuid"
> > > +fi
> > > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +
> > 
> > Can we drop all these intermediate repair invocations and just rely on
> > the post-test device check? Otherwise the rest LGTM.
> 
> I was trying to be thorough, checking at each step that we haven't
> accidentally broken the filesystem.  They could go away, but what's the
> harm in checking an empty filesystem?
> 

It's not harmful (and I don't care that much whether it stays or goes).
I just didn't see the point and it made the test incrementally harder to
grok at a glance.

Brian

> --D
> 
> > Brian
> > 
> > > +note "S7: Restore original filesystem UUID"
> > > +if _check_scratch_xfs_features V5 >/dev/null; then
> > > +	# Only V5 supports the metauuid feature that enables us to restore the
> > > +	# original UUID after a change.
> > > +	_scratch_xfs_admin -U restore >> $seqres.full
> > > +	_scratch_xfs_db -c uuid
> > > +else
> > > +	echo "UUID = babababa-baba-baba-baba-babababababa"
> > > +fi
> > > +
> > > +# success, all done
> > > +status=0
> > > +exit
> > > diff --git a/tests/xfs/764.out b/tests/xfs/764.out
> > > new file mode 100644
> > > index 00000000..8da929ec
> > > --- /dev/null
> > > +++ b/tests/xfs/764.out
> > > @@ -0,0 +1,17 @@
> > > +QA output created by 764
> > > +S0: Initialize filesystem
> > > +label = "origlabel"
> > > +UUID = babababa-baba-baba-baba-babababababa
> > > +S1: Set a filesystem label
> > > +label = "newlabel"
> > > +S2: Clear filesystem label
> > > +label = ""
> > > +S3: Try to set oversized label
> > > +label = "thisismuchto"
> > > +S4: Set filesystem UUID
> > > +UUID = deaddead-dead-dead-dead-deaddeaddead
> > > +S5: Zero out filesystem UUID
> > > +UUID = 00000000-0000-0000-0000-000000000000
> > > +S6: Randomize filesystem UUID
> > > +S7: Restore original filesystem UUID
> > > +UUID = babababa-baba-baba-baba-babababababa
> > > diff --git a/tests/xfs/773 b/tests/xfs/773
> > > new file mode 100755
> > > index 00000000..f184962a
> > > --- /dev/null
> > > +++ b/tests/xfs/773
> > > @@ -0,0 +1,114 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0-or-later
> > > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > > +#
> > > +# FS QA Test No. 773
> > > +#
> > > +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> > > +# with regards to data devices that are files, external logs, and realtime
> > > +# devices.
> > > +#
> > > +# Because this test synthesizes log and rt devices (by modifying the test run
> > > +# configuration), it does /not/ require the ability to mount the scratch
> > > +# filesystem.  This increases test coverage while isolating the weird bits to a
> > > +# single test.
> > > +#
> > > +# This is partially a regression test for "xfs_admin: pick up log arguments
> > > +# correctly", insofar as the issue fixed by that patch was discovered with an
> > > +# earlier revision of this test.
> > > +
> > > +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.* $fake_logfile $fake_rtfile $fake_datafile
> > > +}
> > > +
> > > +# get standard environment, filters and checks
> > > +. ./common/rc
> > > +. ./common/filter
> > > +
> > > +# real QA test starts here
> > > +_supported_fs xfs
> > > +_require_test
> > > +_require_scratch_nocheck
> > > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > > +
> > > +rm -f $seqres.full
> > > +
> > > +# Create some fake sparse files for testing external devices and whatnot
> > > +fake_datafile=$TEST_DIR/scratch.data
> > > +rm -f $fake_datafile
> > > +truncate -s 500m $fake_datafile
> > > +
> > > +fake_logfile=$TEST_DIR/scratch.log
> > > +rm -f $fake_logfile
> > > +truncate -s 500m $fake_logfile
> > > +
> > > +fake_rtfile=$TEST_DIR/scratch.rt
> > > +rm -f $fake_rtfile
> > > +truncate -s 500m $fake_rtfile
> > > +
> > > +# Save the original variables
> > > +orig_ddev=$SCRATCH_DEV
> > > +orig_external=$USE_EXTERNAL
> > > +orig_logdev=$SCRATCH_LOGDEV
> > > +orig_rtdev=$SCRATCH_RTDEV
> > > +
> > > +scenario() {
> > > +	echo "$@" | tee -a $seqres.full
> > > +
> > > +	SCRATCH_DEV=$orig_ddev
> > > +	USE_EXTERNAL=$orig_external
> > > +	SCRATCH_LOGDEV=$orig_logdev
> > > +	SCRATCH_RTDEV=$orig_rtdev
> > > +}
> > > +
> > > +check_label() {
> > > +	_scratch_mkfs -L oldlabel >> $seqres.full
> > > +	_scratch_xfs_db -c label
> > > +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> > > +	_scratch_xfs_db -c label
> > > +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > > +}
> > > +
> > > +scenario "S1: Check that label setting with file image"
> > > +SCRATCH_DEV=$fake_datafile
> > > +check_label -f
> > > +
> > > +scenario "S2: Check that setting with logdev works"
> > > +USE_EXTERNAL=yes
> > > +SCRATCH_LOGDEV=$fake_logfile
> > > +check_label
> > > +
> > > +scenario "S3: Check that setting with rtdev works"
> > > +USE_EXTERNAL=yes
> > > +SCRATCH_RTDEV=$fake_rtfile
> > > +check_label
> > > +
> > > +scenario "S4: Check that setting with rtdev + logdev works"
> > > +USE_EXTERNAL=yes
> > > +SCRATCH_LOGDEV=$fake_logfile
> > > +SCRATCH_RTDEV=$fake_rtfile
> > > +check_label
> > > +
> > > +scenario "S5: Check that setting with nortdev + nologdev works"
> > > +USE_EXTERNAL=
> > > +SCRATCH_LOGDEV=
> > > +SCRATCH_RTDEV=
> > > +check_label
> > > +
> > > +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> > > +check_label -f
> > > +
> > > +# success, all done
> > > +status=0
> > > +exit
> > > diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> > > new file mode 100644
> > > index 00000000..954bfb85
> > > --- /dev/null
> > > +++ b/tests/xfs/773.out
> > > @@ -0,0 +1,19 @@
> > > +QA output created by 773
> > > +S1: Check that label setting with file image
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > +S2: Check that setting with logdev works
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > +S3: Check that setting with rtdev works
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > +S4: Check that setting with rtdev + logdev works
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > +S5: Check that setting with nortdev + nologdev works
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > +S6: Check that setting with bdev incorrectly flagged as file works
> > > +label = "oldlabel"
> > > +label = "newlabel"
> > > diff --git a/tests/xfs/group b/tests/xfs/group
> > > index 09fddb5a..5801471b 100644
> > > --- a/tests/xfs/group
> > > +++ b/tests/xfs/group
> > > @@ -520,5 +520,7 @@
> > >  537 auto quick
> > >  538 auto stress
> > >  539 auto quick mount
> > > +764 auto quick repair
> > >  768 auto quick repair
> > >  770 auto repair
> > > +773 auto quick repair
> > > 
> > 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-03-31 17:36   ` Brian Foster
@ 2021-04-02  0:58     ` Darrick J. Wong
  2021-04-05 14:47       ` Brian Foster
  0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2021-04-02  0:58 UTC (permalink / raw)
  To: Brian Foster; +Cc: guaneryu, linux-xfs, fstests, guan

On Wed, Mar 31, 2021 at 01:36:21PM -0400, Brian Foster wrote:
> On Tue, Mar 30, 2021 at 06:08:28PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Currently, the only functional testing for xfs_admin is xfs/287, which
> > checks that one can add 32-bit project ids to a V4 filesystem.  This
> > obviously isn't an exhaustive test of all the CLI arguments, and
> > historically there have been xfs configurations that don't even work.
> > 
> > Therefore, introduce a couple of new tests -- one that will test the
> > simple options with the default configuration, and a second test that
> > steps a bit outside of the test run configuration to make sure that we
> > do the right thing for external devices.  The second test already caught
> > a nasty bug in xfsprogs 5.11.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  common/xfs        |   21 ++++++++++
> >  tests/xfs/764     |   91 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/764.out |   17 ++++++++
> >  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/773.out |   19 +++++++++
> >  tests/xfs/group   |    2 +
> >  6 files changed, 264 insertions(+)
> >  create mode 100755 tests/xfs/764
> >  create mode 100644 tests/xfs/764.out
> >  create mode 100755 tests/xfs/773
> >  create mode 100644 tests/xfs/773.out
> > 
> > 
> ...
> > diff --git a/tests/xfs/764 b/tests/xfs/764
> > new file mode 100755
> > index 00000000..c710ad4e
> > --- /dev/null
> > +++ b/tests/xfs/764
> > @@ -0,0 +1,91 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 764
> > +#
> > +# Functional testing for xfs_admin to make sure that it handles option parsing
> > +# correctly, at least for functionality that's relevant to V5 filesystems.
> 
> This test doesn't seem to depend on v5..?

Why would it?  You can set labels and uuids for V4 filesystems.

"..relevant to V5 filesystems" means this test doesn't bother with the
the upgrade options that don't apply to V5, like lazycount, 32bit
project ids, and v2 logs.

> > +
> > +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
> > +_supported_fs xfs
> > +_require_scratch
> > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > +
> > +rm -f $seqres.full
> > +
> > +note() {
> > +	echo "$@" | tee -a $seqres.full
> > +}
> > +
> > +note "S0: Initialize filesystem"
> > +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
> > +_scratch_xfs_db -c label -c uuid
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S1: Set a filesystem label"
> > +_scratch_xfs_admin -L newlabel >> $seqres.full
> > +_scratch_xfs_db -c label
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S2: Clear filesystem label"
> > +_scratch_xfs_admin -L -- >> $seqres.full
> > +_scratch_xfs_db -c label
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S3: Try to set oversized label"
> > +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
> > +_scratch_xfs_db -c label
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S4: Set filesystem UUID"
> > +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
> > +_scratch_xfs_db -c uuid
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S5: Zero out filesystem UUID"
> > +_scratch_xfs_admin -U nil >> $seqres.full
> > +_scratch_xfs_db -c uuid
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> > +note "S6: Randomize filesystem UUID"
> > +old_uuid="$(_scratch_xfs_db -c uuid)"
> > +_scratch_xfs_admin -U generate >> $seqres.full
> > +new_uuid="$(_scratch_xfs_db -c uuid)"
> > +if [ "$new_uuid" = "$old_uuid" ]; then
> > +	echo "UUID randomization failed? $old_uuid == $new_uuid"
> > +fi
> > +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +
> 
> Can we drop all these intermediate repair invocations and just rely on
> the post-test device check? Otherwise the rest LGTM.

I was trying to be thorough, checking at each step that we haven't
accidentally broken the filesystem.  They could go away, but what's the
harm in checking an empty filesystem?

--D

> Brian
> 
> > +note "S7: Restore original filesystem UUID"
> > +if _check_scratch_xfs_features V5 >/dev/null; then
> > +	# Only V5 supports the metauuid feature that enables us to restore the
> > +	# original UUID after a change.
> > +	_scratch_xfs_admin -U restore >> $seqres.full
> > +	_scratch_xfs_db -c uuid
> > +else
> > +	echo "UUID = babababa-baba-baba-baba-babababababa"
> > +fi
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/764.out b/tests/xfs/764.out
> > new file mode 100644
> > index 00000000..8da929ec
> > --- /dev/null
> > +++ b/tests/xfs/764.out
> > @@ -0,0 +1,17 @@
> > +QA output created by 764
> > +S0: Initialize filesystem
> > +label = "origlabel"
> > +UUID = babababa-baba-baba-baba-babababababa
> > +S1: Set a filesystem label
> > +label = "newlabel"
> > +S2: Clear filesystem label
> > +label = ""
> > +S3: Try to set oversized label
> > +label = "thisismuchto"
> > +S4: Set filesystem UUID
> > +UUID = deaddead-dead-dead-dead-deaddeaddead
> > +S5: Zero out filesystem UUID
> > +UUID = 00000000-0000-0000-0000-000000000000
> > +S6: Randomize filesystem UUID
> > +S7: Restore original filesystem UUID
> > +UUID = babababa-baba-baba-baba-babababababa
> > diff --git a/tests/xfs/773 b/tests/xfs/773
> > new file mode 100755
> > index 00000000..f184962a
> > --- /dev/null
> > +++ b/tests/xfs/773
> > @@ -0,0 +1,114 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 773
> > +#
> > +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> > +# with regards to data devices that are files, external logs, and realtime
> > +# devices.
> > +#
> > +# Because this test synthesizes log and rt devices (by modifying the test run
> > +# configuration), it does /not/ require the ability to mount the scratch
> > +# filesystem.  This increases test coverage while isolating the weird bits to a
> > +# single test.
> > +#
> > +# This is partially a regression test for "xfs_admin: pick up log arguments
> > +# correctly", insofar as the issue fixed by that patch was discovered with an
> > +# earlier revision of this test.
> > +
> > +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.* $fake_logfile $fake_rtfile $fake_datafile
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_test
> > +_require_scratch_nocheck
> > +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> > +
> > +rm -f $seqres.full
> > +
> > +# Create some fake sparse files for testing external devices and whatnot
> > +fake_datafile=$TEST_DIR/scratch.data
> > +rm -f $fake_datafile
> > +truncate -s 500m $fake_datafile
> > +
> > +fake_logfile=$TEST_DIR/scratch.log
> > +rm -f $fake_logfile
> > +truncate -s 500m $fake_logfile
> > +
> > +fake_rtfile=$TEST_DIR/scratch.rt
> > +rm -f $fake_rtfile
> > +truncate -s 500m $fake_rtfile
> > +
> > +# Save the original variables
> > +orig_ddev=$SCRATCH_DEV
> > +orig_external=$USE_EXTERNAL
> > +orig_logdev=$SCRATCH_LOGDEV
> > +orig_rtdev=$SCRATCH_RTDEV
> > +
> > +scenario() {
> > +	echo "$@" | tee -a $seqres.full
> > +
> > +	SCRATCH_DEV=$orig_ddev
> > +	USE_EXTERNAL=$orig_external
> > +	SCRATCH_LOGDEV=$orig_logdev
> > +	SCRATCH_RTDEV=$orig_rtdev
> > +}
> > +
> > +check_label() {
> > +	_scratch_mkfs -L oldlabel >> $seqres.full
> > +	_scratch_xfs_db -c label
> > +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> > +	_scratch_xfs_db -c label
> > +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> > +}
> > +
> > +scenario "S1: Check that label setting with file image"
> > +SCRATCH_DEV=$fake_datafile
> > +check_label -f
> > +
> > +scenario "S2: Check that setting with logdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_LOGDEV=$fake_logfile
> > +check_label
> > +
> > +scenario "S3: Check that setting with rtdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_RTDEV=$fake_rtfile
> > +check_label
> > +
> > +scenario "S4: Check that setting with rtdev + logdev works"
> > +USE_EXTERNAL=yes
> > +SCRATCH_LOGDEV=$fake_logfile
> > +SCRATCH_RTDEV=$fake_rtfile
> > +check_label
> > +
> > +scenario "S5: Check that setting with nortdev + nologdev works"
> > +USE_EXTERNAL=
> > +SCRATCH_LOGDEV=
> > +SCRATCH_RTDEV=
> > +check_label
> > +
> > +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> > +check_label -f
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> > new file mode 100644
> > index 00000000..954bfb85
> > --- /dev/null
> > +++ b/tests/xfs/773.out
> > @@ -0,0 +1,19 @@
> > +QA output created by 773
> > +S1: Check that label setting with file image
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S2: Check that setting with logdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S3: Check that setting with rtdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S4: Check that setting with rtdev + logdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S5: Check that setting with nortdev + nologdev works
> > +label = "oldlabel"
> > +label = "newlabel"
> > +S6: Check that setting with bdev incorrectly flagged as file works
> > +label = "oldlabel"
> > +label = "newlabel"
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index 09fddb5a..5801471b 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -520,5 +520,7 @@
> >  537 auto quick
> >  538 auto stress
> >  539 auto quick mount
> > +764 auto quick repair
> >  768 auto quick repair
> >  770 auto repair
> > +773 auto quick repair
> > 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-03-31  1:08 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
@ 2021-03-31 17:36   ` Brian Foster
  2021-04-02  0:58     ` Darrick J. Wong
  0 siblings, 1 reply; 17+ messages in thread
From: Brian Foster @ 2021-03-31 17:36 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On Tue, Mar 30, 2021 at 06:08:28PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Currently, the only functional testing for xfs_admin is xfs/287, which
> checks that one can add 32-bit project ids to a V4 filesystem.  This
> obviously isn't an exhaustive test of all the CLI arguments, and
> historically there have been xfs configurations that don't even work.
> 
> Therefore, introduce a couple of new tests -- one that will test the
> simple options with the default configuration, and a second test that
> steps a bit outside of the test run configuration to make sure that we
> do the right thing for external devices.  The second test already caught
> a nasty bug in xfsprogs 5.11.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  common/xfs        |   21 ++++++++++
>  tests/xfs/764     |   91 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/764.out |   17 ++++++++
>  tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/773.out |   19 +++++++++
>  tests/xfs/group   |    2 +
>  6 files changed, 264 insertions(+)
>  create mode 100755 tests/xfs/764
>  create mode 100644 tests/xfs/764.out
>  create mode 100755 tests/xfs/773
>  create mode 100644 tests/xfs/773.out
> 
> 
...
> diff --git a/tests/xfs/764 b/tests/xfs/764
> new file mode 100755
> index 00000000..c710ad4e
> --- /dev/null
> +++ b/tests/xfs/764
> @@ -0,0 +1,91 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 764
> +#
> +# Functional testing for xfs_admin to make sure that it handles option parsing
> +# correctly, at least for functionality that's relevant to V5 filesystems.

This test doesn't seem to depend on v5..?

> +
> +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
> +_supported_fs xfs
> +_require_scratch
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +
> +rm -f $seqres.full
> +
> +note() {
> +	echo "$@" | tee -a $seqres.full
> +}
> +
> +note "S0: Initialize filesystem"
> +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
> +_scratch_xfs_db -c label -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S1: Set a filesystem label"
> +_scratch_xfs_admin -L newlabel >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S2: Clear filesystem label"
> +_scratch_xfs_admin -L -- >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S3: Try to set oversized label"
> +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
> +_scratch_xfs_db -c label
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S4: Set filesystem UUID"
> +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
> +_scratch_xfs_db -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S5: Zero out filesystem UUID"
> +_scratch_xfs_admin -U nil >> $seqres.full
> +_scratch_xfs_db -c uuid
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +
> +note "S6: Randomize filesystem UUID"
> +old_uuid="$(_scratch_xfs_db -c uuid)"
> +_scratch_xfs_admin -U generate >> $seqres.full
> +new_uuid="$(_scratch_xfs_db -c uuid)"
> +if [ "$new_uuid" = "$old_uuid" ]; then
> +	echo "UUID randomization failed? $old_uuid == $new_uuid"
> +fi
> +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +

Can we drop all these intermediate repair invocations and just rely on
the post-test device check? Otherwise the rest LGTM.

Brian

> +note "S7: Restore original filesystem UUID"
> +if _check_scratch_xfs_features V5 >/dev/null; then
> +	# Only V5 supports the metauuid feature that enables us to restore the
> +	# original UUID after a change.
> +	_scratch_xfs_admin -U restore >> $seqres.full
> +	_scratch_xfs_db -c uuid
> +else
> +	echo "UUID = babababa-baba-baba-baba-babababababa"
> +fi
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/764.out b/tests/xfs/764.out
> new file mode 100644
> index 00000000..8da929ec
> --- /dev/null
> +++ b/tests/xfs/764.out
> @@ -0,0 +1,17 @@
> +QA output created by 764
> +S0: Initialize filesystem
> +label = "origlabel"
> +UUID = babababa-baba-baba-baba-babababababa
> +S1: Set a filesystem label
> +label = "newlabel"
> +S2: Clear filesystem label
> +label = ""
> +S3: Try to set oversized label
> +label = "thisismuchto"
> +S4: Set filesystem UUID
> +UUID = deaddead-dead-dead-dead-deaddeaddead
> +S5: Zero out filesystem UUID
> +UUID = 00000000-0000-0000-0000-000000000000
> +S6: Randomize filesystem UUID
> +S7: Restore original filesystem UUID
> +UUID = babababa-baba-baba-baba-babababababa
> diff --git a/tests/xfs/773 b/tests/xfs/773
> new file mode 100755
> index 00000000..f184962a
> --- /dev/null
> +++ b/tests/xfs/773
> @@ -0,0 +1,114 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 773
> +#
> +# Functional testing for xfs_admin to ensure that it parses arguments correctly
> +# with regards to data devices that are files, external logs, and realtime
> +# devices.
> +#
> +# Because this test synthesizes log and rt devices (by modifying the test run
> +# configuration), it does /not/ require the ability to mount the scratch
> +# filesystem.  This increases test coverage while isolating the weird bits to a
> +# single test.
> +#
> +# This is partially a regression test for "xfs_admin: pick up log arguments
> +# correctly", insofar as the issue fixed by that patch was discovered with an
> +# earlier revision of this test.
> +
> +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.* $fake_logfile $fake_rtfile $fake_datafile
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_test
> +_require_scratch_nocheck
> +_require_command "$XFS_ADMIN_PROG" "xfs_admin"
> +
> +rm -f $seqres.full
> +
> +# Create some fake sparse files for testing external devices and whatnot
> +fake_datafile=$TEST_DIR/scratch.data
> +rm -f $fake_datafile
> +truncate -s 500m $fake_datafile
> +
> +fake_logfile=$TEST_DIR/scratch.log
> +rm -f $fake_logfile
> +truncate -s 500m $fake_logfile
> +
> +fake_rtfile=$TEST_DIR/scratch.rt
> +rm -f $fake_rtfile
> +truncate -s 500m $fake_rtfile
> +
> +# Save the original variables
> +orig_ddev=$SCRATCH_DEV
> +orig_external=$USE_EXTERNAL
> +orig_logdev=$SCRATCH_LOGDEV
> +orig_rtdev=$SCRATCH_RTDEV
> +
> +scenario() {
> +	echo "$@" | tee -a $seqres.full
> +
> +	SCRATCH_DEV=$orig_ddev
> +	USE_EXTERNAL=$orig_external
> +	SCRATCH_LOGDEV=$orig_logdev
> +	SCRATCH_RTDEV=$orig_rtdev
> +}
> +
> +check_label() {
> +	_scratch_mkfs -L oldlabel >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> +	_scratch_xfs_db -c label
> +	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +}
> +
> +scenario "S1: Check that label setting with file image"
> +SCRATCH_DEV=$fake_datafile
> +check_label -f
> +
> +scenario "S2: Check that setting with logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +check_label
> +
> +scenario "S3: Check that setting with rtdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S4: Check that setting with rtdev + logdev works"
> +USE_EXTERNAL=yes
> +SCRATCH_LOGDEV=$fake_logfile
> +SCRATCH_RTDEV=$fake_rtfile
> +check_label
> +
> +scenario "S5: Check that setting with nortdev + nologdev works"
> +USE_EXTERNAL=
> +SCRATCH_LOGDEV=
> +SCRATCH_RTDEV=
> +check_label
> +
> +scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> +check_label -f
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/773.out b/tests/xfs/773.out
> new file mode 100644
> index 00000000..954bfb85
> --- /dev/null
> +++ b/tests/xfs/773.out
> @@ -0,0 +1,19 @@
> +QA output created by 773
> +S1: Check that label setting with file image
> +label = "oldlabel"
> +label = "newlabel"
> +S2: Check that setting with logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S3: Check that setting with rtdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S4: Check that setting with rtdev + logdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S5: Check that setting with nortdev + nologdev works
> +label = "oldlabel"
> +label = "newlabel"
> +S6: Check that setting with bdev incorrectly flagged as file works
> +label = "oldlabel"
> +label = "newlabel"
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 09fddb5a..5801471b 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -520,5 +520,7 @@
>  537 auto quick
>  538 auto stress
>  539 auto quick mount
> +764 auto quick repair
>  768 auto quick repair
>  770 auto repair
> +773 auto quick repair
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/2] xfs: functional testing of V5-relevant options
  2021-03-31  1:08 [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header Darrick J. Wong
@ 2021-03-31  1:08 ` Darrick J. Wong
  2021-03-31 17:36   ` Brian Foster
  0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2021-03-31  1:08 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

From: Darrick J. Wong <djwong@kernel.org>

Currently, the only functional testing for xfs_admin is xfs/287, which
checks that one can add 32-bit project ids to a V4 filesystem.  This
obviously isn't an exhaustive test of all the CLI arguments, and
historically there have been xfs configurations that don't even work.

Therefore, introduce a couple of new tests -- one that will test the
simple options with the default configuration, and a second test that
steps a bit outside of the test run configuration to make sure that we
do the right thing for external devices.  The second test already caught
a nasty bug in xfsprogs 5.11.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/xfs        |   21 ++++++++++
 tests/xfs/764     |   91 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/764.out |   17 ++++++++
 tests/xfs/773     |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/773.out |   19 +++++++++
 tests/xfs/group   |    2 +
 6 files changed, 264 insertions(+)
 create mode 100755 tests/xfs/764
 create mode 100644 tests/xfs/764.out
 create mode 100755 tests/xfs/773
 create mode 100644 tests/xfs/773.out


diff --git a/common/xfs b/common/xfs
index 051e5652..a65eeb58 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1112,3 +1112,24 @@ _check_scratch_xfs_features()
 	echo "${output[@]}"
 	test "${found}" -eq "$#"
 }
+
+# Decide if xfs_repair knows how to set (or clear) a filesystem feature.
+_require_xfs_repair_upgrade()
+{
+	local type="$1"
+
+	$XFS_REPAIR_PROG -c "$type=garbagevalue" 2>&1 | \
+		grep -q 'unknown option' && \
+		_notrun "xfs_repair does not support upgrading fs with $type"
+}
+
+_require_xfs_scratch_inobtcount()
+{
+	_require_scratch
+
+	_scratch_mkfs -m inobtcount=1 &> /dev/null || \
+		_notrun "mkfs.xfs doesn't have inobtcount feature"
+	_try_scratch_mount || \
+		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
+	_scratch_unmount
+}
diff --git a/tests/xfs/764 b/tests/xfs/764
new file mode 100755
index 00000000..c710ad4e
--- /dev/null
+++ b/tests/xfs/764
@@ -0,0 +1,91 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 764
+#
+# Functional testing for xfs_admin to make sure that it handles option parsing
+# correctly, at least for functionality that's relevant to V5 filesystems.
+
+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
+_supported_fs xfs
+_require_scratch
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+note() {
+	echo "$@" | tee -a $seqres.full
+}
+
+note "S0: Initialize filesystem"
+_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full
+_scratch_xfs_db -c label -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S1: Set a filesystem label"
+_scratch_xfs_admin -L newlabel >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S2: Clear filesystem label"
+_scratch_xfs_admin -L -- >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S3: Try to set oversized label"
+_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full
+_scratch_xfs_db -c label
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S4: Set filesystem UUID"
+_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S5: Zero out filesystem UUID"
+_scratch_xfs_admin -U nil >> $seqres.full
+_scratch_xfs_db -c uuid
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S6: Randomize filesystem UUID"
+old_uuid="$(_scratch_xfs_db -c uuid)"
+_scratch_xfs_admin -U generate >> $seqres.full
+new_uuid="$(_scratch_xfs_db -c uuid)"
+if [ "$new_uuid" = "$old_uuid" ]; then
+	echo "UUID randomization failed? $old_uuid == $new_uuid"
+fi
+_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+
+note "S7: Restore original filesystem UUID"
+if _check_scratch_xfs_features V5 >/dev/null; then
+	# Only V5 supports the metauuid feature that enables us to restore the
+	# original UUID after a change.
+	_scratch_xfs_admin -U restore >> $seqres.full
+	_scratch_xfs_db -c uuid
+else
+	echo "UUID = babababa-baba-baba-baba-babababababa"
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/764.out b/tests/xfs/764.out
new file mode 100644
index 00000000..8da929ec
--- /dev/null
+++ b/tests/xfs/764.out
@@ -0,0 +1,17 @@
+QA output created by 764
+S0: Initialize filesystem
+label = "origlabel"
+UUID = babababa-baba-baba-baba-babababababa
+S1: Set a filesystem label
+label = "newlabel"
+S2: Clear filesystem label
+label = ""
+S3: Try to set oversized label
+label = "thisismuchto"
+S4: Set filesystem UUID
+UUID = deaddead-dead-dead-dead-deaddeaddead
+S5: Zero out filesystem UUID
+UUID = 00000000-0000-0000-0000-000000000000
+S6: Randomize filesystem UUID
+S7: Restore original filesystem UUID
+UUID = babababa-baba-baba-baba-babababababa
diff --git a/tests/xfs/773 b/tests/xfs/773
new file mode 100755
index 00000000..f184962a
--- /dev/null
+++ b/tests/xfs/773
@@ -0,0 +1,114 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 773
+#
+# Functional testing for xfs_admin to ensure that it parses arguments correctly
+# with regards to data devices that are files, external logs, and realtime
+# devices.
+#
+# Because this test synthesizes log and rt devices (by modifying the test run
+# configuration), it does /not/ require the ability to mount the scratch
+# filesystem.  This increases test coverage while isolating the weird bits to a
+# single test.
+#
+# This is partially a regression test for "xfs_admin: pick up log arguments
+# correctly", insofar as the issue fixed by that patch was discovered with an
+# earlier revision of this test.
+
+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.* $fake_logfile $fake_rtfile $fake_datafile
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_test
+_require_scratch_nocheck
+_require_command "$XFS_ADMIN_PROG" "xfs_admin"
+
+rm -f $seqres.full
+
+# Create some fake sparse files for testing external devices and whatnot
+fake_datafile=$TEST_DIR/scratch.data
+rm -f $fake_datafile
+truncate -s 500m $fake_datafile
+
+fake_logfile=$TEST_DIR/scratch.log
+rm -f $fake_logfile
+truncate -s 500m $fake_logfile
+
+fake_rtfile=$TEST_DIR/scratch.rt
+rm -f $fake_rtfile
+truncate -s 500m $fake_rtfile
+
+# Save the original variables
+orig_ddev=$SCRATCH_DEV
+orig_external=$USE_EXTERNAL
+orig_logdev=$SCRATCH_LOGDEV
+orig_rtdev=$SCRATCH_RTDEV
+
+scenario() {
+	echo "$@" | tee -a $seqres.full
+
+	SCRATCH_DEV=$orig_ddev
+	USE_EXTERNAL=$orig_external
+	SCRATCH_LOGDEV=$orig_logdev
+	SCRATCH_RTDEV=$orig_rtdev
+}
+
+check_label() {
+	_scratch_mkfs -L oldlabel >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
+	_scratch_xfs_db -c label
+	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+}
+
+scenario "S1: Check that label setting with file image"
+SCRATCH_DEV=$fake_datafile
+check_label -f
+
+scenario "S2: Check that setting with logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+check_label
+
+scenario "S3: Check that setting with rtdev works"
+USE_EXTERNAL=yes
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S4: Check that setting with rtdev + logdev works"
+USE_EXTERNAL=yes
+SCRATCH_LOGDEV=$fake_logfile
+SCRATCH_RTDEV=$fake_rtfile
+check_label
+
+scenario "S5: Check that setting with nortdev + nologdev works"
+USE_EXTERNAL=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+check_label
+
+scenario "S6: Check that setting with bdev incorrectly flagged as file works"
+check_label -f
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/773.out b/tests/xfs/773.out
new file mode 100644
index 00000000..954bfb85
--- /dev/null
+++ b/tests/xfs/773.out
@@ -0,0 +1,19 @@
+QA output created by 773
+S1: Check that label setting with file image
+label = "oldlabel"
+label = "newlabel"
+S2: Check that setting with logdev works
+label = "oldlabel"
+label = "newlabel"
+S3: Check that setting with rtdev works
+label = "oldlabel"
+label = "newlabel"
+S4: Check that setting with rtdev + logdev works
+label = "oldlabel"
+label = "newlabel"
+S5: Check that setting with nortdev + nologdev works
+label = "oldlabel"
+label = "newlabel"
+S6: Check that setting with bdev incorrectly flagged as file works
+label = "oldlabel"
+label = "newlabel"
diff --git a/tests/xfs/group b/tests/xfs/group
index 09fddb5a..5801471b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -520,5 +520,7 @@
 537 auto quick
 538 auto stress
 539 auto quick mount
+764 auto quick repair
 768 auto quick repair
 770 auto repair
+773 auto quick repair


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-04-22  1:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  0:22 [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header Darrick J. Wong
2021-04-21  0:22 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
2021-04-21 18:00   ` Brian Foster
2021-04-21 20:39     ` Darrick J. Wong
2021-04-22  0:29   ` Allison Henderson
2021-04-22  0:51   ` [PATCH v2.1 " Darrick J. Wong
2021-04-21  0:22 ` [PATCH 2/2] xfs: test inobtcount upgrade Darrick J. Wong
2021-04-21  5:52   ` Amir Goldstein
2021-04-22  0:50     ` Darrick J. Wong
2021-04-21 18:00   ` Brian Foster
2021-04-22  0:29   ` Allison Henderson
2021-04-22  0:53   ` [PATCH v2.1 " Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2021-03-31  1:08 [PATCHSET v2 0/2] fstests: add inode btree blocks counters to the AGI header Darrick J. Wong
2021-03-31  1:08 ` [PATCH 1/2] xfs: functional testing of V5-relevant options Darrick J. Wong
2021-03-31 17:36   ` Brian Foster
2021-04-02  0:58     ` Darrick J. Wong
2021-04-05 14:47       ` Brian Foster
2021-04-07 23:13         ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.