All of lore.kernel.org
 help / color / mirror / Atom feed
* fstests: new tests and various fixes
@ 2022-06-02  0:31 Dave Chinner
  2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

Hi folks,

This is the current set of test modifications I've been running at
the end of the 5.19 merge cycle. This series:

- adds a LARP test
- adds better _begin_fstests documentation
- fixes problematic use of DM devices on DAX capable bdevs
- fixes test interruption issues
- works around a new systemd/mount malfeature
- converts a long running test to use TIME_FACTOR
- fixes a TIME_FACTOR scaling bug

With these, my test machines running the current 5.19-rc0+XFS for-next
tree with default and rmapbt=1 configs pass the autogroup with zero
test failures.

Cheers,

Dave.


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

* [PATCH 1/8] xfstests: Add Log Attribute Replay test
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  1:05   ` Darrick J. Wong
  2022-06-03  1:41   ` [PATCH 1/8 v2] fstests: " Dave Chinner
  2022-06-02  0:31 ` [PATCH 2/8] README: document _begin_fstests better Dave Chinner
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Allison Henderson <allison.henderson@oracle.com>

This patch adds tests to exercise the log attribute error
inject and log replay. These tests aim to cover cases where attributes
are added, removed, and overwritten in each format (shortform, leaf,
node). Error inject is used to replay these operations from the log.

dchinner: sanitise md5sum input to just attr values.
dchinner: correct md5sums.
dchinner: ensure replace tests use different values so recovery can
          determine the replace was replayed correctly.
dchinner: don't remove corpse in _cleanup - scratch devices don't
	  require cleanup, and if the test fails we want to leave
	  the broken state for post-mortem analysis.
dchinner: only run on v5 filesystems.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/600     | 179 +++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/600.out | 188 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 367 insertions(+)
 create mode 100755 tests/xfs/600
 create mode 100644 tests/xfs/600.out

diff --git a/tests/xfs/600 b/tests/xfs/600
new file mode 100755
index 00000000..0ff41e13
--- /dev/null
+++ b/tests/xfs/600
@@ -0,0 +1,179 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test 600
+#
+# Log attribute replay test
+#
+. ./common/preamble
+_begin_fstest auto quick attr
+
+# get standard environment, filters and checks
+. ./common/filter
+. ./common/attr
+. ./common/inject
+
+_cleanup()
+{
+	rm -rf $tmp.*
+	test -w /sys/fs/xfs/debug/larp && \
+		echo 0 > /sys/fs/xfs/debug/larp
+}
+
+test_attr_replay()
+{
+	testfile=$testdir/$1
+	attr_name=$2
+	attr_value=$3
+	flag=$4
+	error_tag=$5
+
+	# Inject error
+	_scratch_inject_error $error_tag
+
+	# Set attribute
+	echo "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
+			    _filter_scratch
+
+	# FS should be shut down, touch will fail
+	touch $testfile 2>&1 | _filter_scratch
+
+	# Remount to replay log
+	_scratch_remount_dump_log >> $seqres.full
+
+	# FS should be online, touch should succeed
+	touch $testfile
+
+	# Verify attr recovery
+	$ATTR_PROG -l $testfile | _filter_scratch
+	echo -n "$attr_name: "
+	$ATTR_PROG -q -g $attr_name $testfile | md5sum;
+
+	echo ""
+}
+
+create_test_file()
+{
+	filename=$testdir/$1
+	count=$2
+	attr_value=$3
+
+	touch $filename
+
+	for i in `seq $count`
+	do
+		$ATTR_PROG -s "attr_name$i" -V $attr_value $filename >> \
+			$seqres.full
+	done
+}
+
+# real QA test starts here
+_supported_fs xfs
+
+_require_scratch
+_require_scratch_xfs_crc
+_require_attrs
+_require_xfs_io_error_injection "larp"
+_require_xfs_io_error_injection "da_leaf_split"
+_require_xfs_io_error_injection "attr_leaf_to_node"
+_require_xfs_sysfs debug/larp
+test -w /sys/fs/xfs/debug/larp || _notrun "larp knob not writable"
+
+# turn on log attributes
+echo 1 > /sys/fs/xfs/debug/larp
+
+attr16="0123456789ABCDEF"
+attr64="$attr16$attr16$attr16$attr16"
+attr256="$attr64$attr64$attr64$attr64"
+attr1k="$attr256$attr256$attr256$attr256"
+attr4k="$attr1k$attr1k$attr1k$attr1k"
+attr8k="$attr4k$attr4k"
+attr16k="$attr8k$attr8k"
+attr32k="$attr16k$attr16k"
+attr64k="$attr32k$attr32k"
+
+echo "*** mkfs"
+_scratch_mkfs >/dev/null
+
+echo "*** mount FS"
+_scratch_mount
+
+testdir=$SCRATCH_MNT/testdir
+mkdir $testdir
+
+# empty, inline
+create_test_file empty_file1 0
+test_attr_replay empty_file1 "attr_name" $attr64 "s" "larp"
+test_attr_replay empty_file1 "attr_name" $attr64 "r" "larp"
+
+# empty, internal
+create_test_file empty_file2 0
+test_attr_replay empty_file2 "attr_name" $attr1k "s" "larp"
+test_attr_replay empty_file2 "attr_name" $attr1k "r" "larp"
+
+# empty, remote
+create_test_file empty_file3 0
+test_attr_replay empty_file3 "attr_name" $attr64k "s" "larp"
+test_attr_replay empty_file3 "attr_name" $attr64k "r" "larp"
+
+# inline, inline
+create_test_file inline_file1 1 $attr16
+test_attr_replay inline_file1 "attr_name2" $attr64 "s" "larp"
+test_attr_replay inline_file1 "attr_name2" $attr64 "r" "larp"
+
+# inline, internal
+create_test_file inline_file2 1 $attr16
+test_attr_replay inline_file2 "attr_name2" $attr1k "s" "larp"
+test_attr_replay inline_file2 "attr_name2" $attr1k "r" "larp"
+
+# inline, remote
+create_test_file inline_file3 1 $attr16
+test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
+test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
+
+# extent, internal
+create_test_file extent_file1 1 $attr1k
+test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
+test_attr_replay extent_file1 "attr_name2" $attr1k "r" "larp"
+
+# extent, inject error on split
+create_test_file extent_file2 3 $attr1k
+test_attr_replay extent_file2 "attr_name4" $attr1k "s" "da_leaf_split"
+
+# extent, inject error on fork transition
+create_test_file extent_file3 3 $attr1k
+test_attr_replay extent_file3 "attr_name4" $attr1k "s" "attr_leaf_to_node"
+
+# extent, remote
+create_test_file extent_file4 1 $attr1k
+test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
+test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
+
+# remote, internal
+create_test_file remote_file1 1 $attr64k
+test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
+test_attr_replay remote_file1 "attr_name2" $attr1k "r" "larp"
+
+# remote, remote
+create_test_file remote_file2 1 $attr64k
+test_attr_replay remote_file2 "attr_name2" $attr64k "s" "larp"
+test_attr_replay remote_file2 "attr_name2" $attr64k "r" "larp"
+
+# replace shortform with different value
+create_test_file sf_file 2 $attr64
+test_attr_replay sf_file "attr_name2" $attr16 "s" "larp"
+
+# replace leaf with different value
+create_test_file leaf_file 3 $attr1k
+test_attr_replay leaf_file "attr_name2" $attr256 "s" "larp"
+
+# replace node with a different value
+create_test_file node_file 1 $attr64k
+$ATTR_PROG -s "attr_name2" -V $attr1k $testdir/node_file \
+		>> $seqres.full
+test_attr_replay node_file "attr_name2" $attr256 "s" "larp"
+
+echo "*** done"
+status=0
+exit
diff --git a/tests/xfs/600.out b/tests/xfs/600.out
new file mode 100644
index 00000000..fe25ea3e
--- /dev/null
+++ b/tests/xfs/600.out
@@ -0,0 +1,188 @@
+QA output created by 600
+*** mkfs
+*** mount FS
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
+Attribute "attr_name" has a 65 byte value for SCRATCH_MNT/testdir/empty_file1
+attr_name: cfbe2a33be4601d2b655d099a18378fc  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
+attr_name: attr_get: No data available
+Could not get "attr_name" for /mnt/scratch/testdir/empty_file1
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
+Attribute "attr_name" has a 1025 byte value for SCRATCH_MNT/testdir/empty_file2
+attr_name: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
+attr_name: attr_get: No data available
+Could not get "attr_name" for /mnt/scratch/testdir/empty_file2
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
+Attribute "attr_name" has a 65536 byte value for SCRATCH_MNT/testdir/empty_file3
+attr_name: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
+attr_name: attr_get: No data available
+Could not get "attr_name" for /mnt/scratch/testdir/empty_file3
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
+Attribute "attr_name2" has a 65 byte value for SCRATCH_MNT/testdir/inline_file1
+attr_name2: cfbe2a33be4601d2b655d099a18378fc  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/inline_file1
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/inline_file2
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/inline_file2
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/inline_file3
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/inline_file3
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file1
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/extent_file1
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file2': Input/output error
+Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_set: Input/output error
+Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file3': Input/output error
+Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file4
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/extent_file4
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/extent_file4
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/remote_file1
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/remote_file1
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+attr_name2: attr_get: No data available
+Could not get "attr_name2" for /mnt/scratch/testdir/remote_file2
+d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/sf_file
+touch: cannot touch 'SCRATCH_MNT/testdir/sf_file': Input/output error
+Attribute "attr_name1" has a 64 byte value for SCRATCH_MNT/testdir/sf_file
+Attribute "attr_name2" has a 17 byte value for SCRATCH_MNT/testdir/sf_file
+attr_name2: 9a6eb1bc9da3c66a9b495dfe2fe8a756  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/leaf_file
+touch: cannot touch 'SCRATCH_MNT/testdir/leaf_file': Input/output error
+Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/leaf_file
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
+attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/node_file
+touch: cannot touch 'SCRATCH_MNT/testdir/node_file': Input/output error
+Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/node_file
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/node_file
+attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
+
+*** done
-- 
2.35.1


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

* [PATCH 2/8] README: document _begin_fstests better
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
  2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  0:51   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 3/8] generic/081: don't run on DAX capable devices Dave Chinner
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Because how it actually gets used by the fstests infrastructure
has been undocumented and that has impact on how it should be set
up.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 README | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/README b/README
index 7da66cb6..80d148be 100644
--- a/README
+++ b/README
@@ -368,19 +368,41 @@ Test script environment:
 
      6. Test group membership: Each test can be associated with any number
 	of groups for convenient selection of subsets of tests.  Group names
-	can be any sequence of non-whitespace characters.  Test authors
-	associate a test with groups by passing the names of those groups as
-	arguments to the _begin_fstest function.  For example, the code:
+	must  be human readable using only characters in the set [:alnum:_-].
 
-	_begin_fstest auto quick subvol snapshot
+	Test authors associate a test with groups by passing the names of those
+	groups as arguments to the _begin_fstest function. While _begin_fstests
+	is a shell function that must be called at the start of a test to
+	initialise the test environment correctly, the the build infrastructure
+	also scans the test files for _begin_fstests invocations. It does this
+	to compile the group lists that are used to determine which tests to run
+	when `check` is executed. In other words, test files files must call
+	_begin_fstest with their intended groups or they will not be run.
+
+	However, because the build infrastructure also uses _begin_fstests as
+	a defined keyword, addition restrictions are placed on how it must be
+	formatted:
+
+	(a) It must be a single line with no multi-line continuations.
+
+	(b) group names should be separated by spaces and not other whitespace
+
+	(c) A '#' placed anywhere in the list, even in the middle of a group
+	    name, will cause everything from the # to the end of the line to be
+	    ignored.
+
+	For example, the code:
+
+	_begin_fstest auto quick subvol snapshot # metadata
 
 	associates the current test with the "auto", "quick", "subvol", and
-	"snapshot" groups.  It is not necessary to specify the "all" group
-	in the list because that group is computed at run time.
+	"snapshot" groups. Because "metadata" is after the "#" comment
+	delimiter, it is ignored by the build infrastructure and so it will not
+	be associated with that group.
+
+	It is not necessary to specify the "all" group in the list because that
+	group is always computed at run time from the group lists.
 
-	The build process scans test files for _begin_fstest invocations and
-	compiles the group list from that information.  In other words, test
-	files must call _begin_fstest or they will not be run.
 
 Verified output:
 
-- 
2.35.1


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

* [PATCH 3/8] generic/081: don't run on DAX capable devices
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
  2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
  2022-06-02  0:31 ` [PATCH 2/8] README: document _begin_fstests better Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  2:03   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 4/8] generic/038: kill background threads on interrupt Dave Chinner
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

LVM/DM has conniptions when you try to use snapshots on a device
that has DAX capability. It first sets up the underlying device as a
DAX capable mapping (type 3 or DM_TYPE_DAX_BIO_BASED) but because
snapshots require COW and shared mappings, it isn't supported on DAX
capable devices. Hence creating the snapshot device fails because it
requires a type 1 (DM_TYPE_BIO_BASED) device and DM can't change
types on a loaded mapping.

Hence we get this obscure error message in the log:

device-mapper: ioctl: can't change device type (old=3 vs new=1) after initial table load.

and these obscure, unhelpful error messages from the LVM command
outputs:

  device-mapper: reload ioctl on  (251:0) failed: Invalid argument
  Failed to suspend logical volume vg_081/base_081.
  Device vg_081-base_081-real (251:1) is used by another device.
  Failed to revert logical volume vg_081/base_081.
  Aborting. Manual intervention required.
Failed to create snapshot

How to turn off DAX capability is not documented in dmsetup or LVM
man pages, nor is dax mentioned anywhere in
Documentation/admin/device-mapper/ so I have no idea how to tell
LVM/DM "don't try to enable DAX support!".

As such, if the uderlying block device is dax capable, skip this
test.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/rc | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/common/rc b/common/rc
index 2f31ca46..c334cfbf 100644
--- a/common/rc
+++ b/common/rc
@@ -2116,21 +2116,33 @@ _require_sane_bdev_flush()
 # Decide if the scratch filesystem is likely to be mounted in fsdax mode.
 # It goes 3 ways based on mount options::
 #	1. "dax" or "dax=always" means always test using DAX
-#	2. "dax=never" means we'll never use DAX
+#	2. "dax=never" means we'll never use DAX.
 #	3. "dax=inode" or nothing means "use scratch dev capability" to
 #	    determine whether DAX is going to be used.
 #
-# Returns 0 if DAX will be used, 1 if DAX is not going to be used.
+# Case 2 and 3 basically mean the same thing for the purpose of
+# _require_dm_target(). If the fs is not forcing the use of DAX, then DAX
+# can only be enabled if the underlying block device supports it.
+#
+# Returns 0 if the filesytem will use DAX, 1 if it won't.
 __scratch_uses_fsdax()
 {
 	local ops=$(_normalize_mount_options "$MOUNT_OPTIONS")
 
 	echo $ops | egrep -qw "dax(=always| |$)" && return 0
-	echo $ops | grep -qw "dax=never" && return 1
+	return 1
+}
 
+# Determine if the scratch device is DAX capable. Even if the fs is not
+# using DAX, we still can't use certain device mapper targets if the block
+# device is DAX capable. Hence the check needs to be separat from the FS
+# capability.
+__scratch_dev_has_dax()
+{
 	local sysfs="/sys/block/$(_short_dev $SCRATCH_DEV)"
 	test -e "${sysfs}/dax" && return 0
 	test "$(cat "${sysfs}/queue/dax" 2>/dev/null)" = "1" && return 0
+
 	return 1
 }
 
@@ -2147,15 +2159,18 @@ _require_dm_target()
 	_require_sane_bdev_flush $SCRATCH_DEV
 	_require_command "$DMSETUP_PROG" dmsetup
 
-	if __scratch_uses_fsdax; then
-		case $target in
-		stripe|linear|log-writes)
-			;;
-		*)
-			_notrun "Cannot run tests with DAX on $target devices."
-			;;
-		esac
-	fi
+	case $target in
+	stripe|linear|log-writes)
+		;;
+	*)
+		if __scratch_uses_fsdax; then
+			_notrun "Cannot run tests with fsdax on $target devices."
+		fi
+		if __scratch_dev_has_dax; then
+			_notrun "Cannot use $target devices on DAX capable block devices."
+		fi
+		;;
+	esac
 
 	modprobe dm-$target >/dev/null 2>&1
 
-- 
2.35.1


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

* [PATCH 4/8] generic/038: kill background threads on interrupt
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
                   ` (2 preceding siblings ...)
  2022-06-02  0:31 ` [PATCH 3/8] generic/081: don't run on DAX capable devices Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  0:51   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 5/8] xfs/538: fix fsstress scaling Dave Chinner
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

When I ctrl-c g/038, it either does nothing or it leaves processes
running in the background. It is not cleaning up it's background
processes correctly, so add kill vectors into the cleanup. Make sure
we only kill in the cleanup trap if the background processes are
running.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/generic/038 | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tests/generic/038 b/tests/generic/038
index c6cea94e..e9b49967 100755
--- a/tests/generic/038
+++ b/tests/generic/038
@@ -36,6 +36,10 @@ _begin_fstest auto stress trim
 # Override the default cleanup function.
 _cleanup()
 {
+	[ -n "${create_pids}" ] && kill ${create_pids[@]}
+	[ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
+	[ -n "${trim_pids}" ] && kill ${trim_pids[@]}
+	wait
 	rm -fr $tmp
 }
 
@@ -47,6 +51,8 @@ _supported_fs generic
 _require_scratch
 _require_xfs_io_command "falloc"
 
+echo "Silence is golden"
+
 # Keep allocating and deallocating 1G of data space with the goal of creating
 # and deleting 1 block group constantly. The intention is to race with the
 # fstrim loop below.
@@ -113,7 +119,7 @@ create_files()
 	done
 
 	wait ${create_pids[@]}
-
+	unset create_pids
 }
 
 _scratch_mkfs >>$seqres.full 2>&1
@@ -136,12 +142,8 @@ create_files "foobar"
 kill ${fallocate_pids[@]}
 kill ${trim_pids[@]}
 wait
+unset fallocate_pids
+unset trim_pids
 
-# The fstests framework will now check for fs consistency with fsck.
-# The trimming was racy and caused some btree nodes to get full of zeroes on
-# disk, which obviously caused fs metadata corruption. The race often lead
-# to missing free space entries in a block group's free space cache too.
-
-echo "Silence is golden"
 status=0
 exit
-- 
2.35.1


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

* [PATCH 5/8] xfs/538: fix fsstress scaling
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
                   ` (3 preceding siblings ...)
  2022-06-02  0:31 ` [PATCH 4/8] generic/038: kill background threads on interrupt Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  0:52   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 6/8] xfs/070: filter the bad sb magic number error Dave Chinner
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

_scale_fsstress_args() does time/load scaling of parameters. Doing
it also in the test causes exponential scaling instead of linear
scaling as the time/load parameters are meant to do.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/538     | 36 +++++++++++++++++-------------------
 tests/xfs/538.out |  3 +--
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/tests/xfs/538 b/tests/xfs/538
index e0102f48..2b5e97e5 100755
--- a/tests/xfs/538
+++ b/tests/xfs/538
@@ -47,25 +47,23 @@ done
 echo "Inject bmap_alloc_minlen_extent error tag"
 _scratch_inject_error bmap_alloc_minlen_extent 1
 
-echo "Scale fsstress args"
-args=$(_scale_fsstress_args -p $((LOAD_FACTOR * 75)) -n $((TIME_FACTOR * 1000)))
-
-echo "Execute fsstress in background"
-$FSSTRESS_PROG -d $SCRATCH_MNT $args \
-		 -f bulkstat=0 \
-		 -f bulkstat1=0 \
-		 -f fiemap=0 \
-		 -f getattr=0 \
-		 -f getdents=0 \
-		 -f getfattr=0 \
-		 -f listfattr=0 \
-		 -f mread=0 \
-		 -f read=0 \
-		 -f readlink=0 \
-		 -f readv=0 \
-		 -f stat=0 \
-		 -f aread=0 \
-		 -f dread=0 > /dev/null 2>&1
+echo "Execute fsstress"
+$FSSTRESS_PROG -d $SCRATCH_MNT \
+		$(_scale_fsstress_args -p 75 -n 1000) \
+		-f bulkstat=0 \
+		-f bulkstat1=0 \
+		-f fiemap=0 \
+		-f getattr=0 \
+		-f getdents=0 \
+		-f getfattr=0 \
+		-f listfattr=0 \
+		-f mread=0 \
+		-f read=0 \
+		-f readlink=0 \
+		-f readv=0 \
+		-f stat=0 \
+		-f aread=0 \
+		-f dread=0 > /dev/null 2>&1
 
 # success, all done
 status=0
diff --git a/tests/xfs/538.out b/tests/xfs/538.out
index 85932c82..97ebc314 100644
--- a/tests/xfs/538.out
+++ b/tests/xfs/538.out
@@ -3,5 +3,4 @@ Format and mount fs
 Consume free space
 Create fragmented filesystem
 Inject bmap_alloc_minlen_extent error tag
-Scale fsstress args
-Execute fsstress in background
+Execute fsstress
-- 
2.35.1


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

* [PATCH 6/8] xfs/070: filter the bad sb magic number error
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
                   ` (4 preceding siblings ...)
  2022-06-02  0:31 ` [PATCH 5/8] xfs/538: fix fsstress scaling Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  0:52   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR Dave Chinner
  2022-06-02  0:31 ` [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks Dave Chinner
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

Lastest XFS kernel makes the superblock bad magic number error
message more meaningful, and that's being picked up by xfsprogs in
very short order. And, of course, the error is output by xfs_repair,
too, and it's been captured in the golden output of a test. Fix it
by filtering the output back down to the old message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/repair | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/repair b/common/repair
index 5a957f4e..463ef9db 100644
--- a/common/repair
+++ b/common/repair
@@ -90,6 +90,7 @@ s/(superblock) (\d+)/\1 AGNO/;
 s/(AG \#)(\d+)/\1AGNO/;
 s/(reset bad sb for ag) (\d+)/\1 AGNO/;
 s/(unknown block state, ag )(\d+)(, blocks? )(\d+)/\1AGNO\3AGBNO/;
+s/^Superblock has (bad magic number) 0x.*/\1/;
 /^Note - quota info will be regenerated on next quota mount.$/ && next;
 	print;'
 }
-- 
2.35.1


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

* [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
                   ` (5 preceding siblings ...)
  2022-06-02  0:31 ` [PATCH 6/8] xfs/070: filter the bad sb magic number error Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  0:53   ` Darrick J. Wong
  2022-06-02  0:31 ` [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks Dave Chinner
  7 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

xfs/167 takes between 6 and 10 minutes to run on my SSD based test
machines. It's running 50 loops of a unwritten extent conversion
test program whilst running a heavy fsstress workload in the
background. This does not need to run for 10 minutes on every auto
group regression test run. Shorten it to loop 5 * TIME_FACTOR
so that normal runtime drops to something sane but can still be
easily ramped up if soak/stress testing is being run.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/167 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tests/xfs/167 b/tests/xfs/167
index 5f985010..15bb1854 100755
--- a/tests/xfs/167
+++ b/tests/xfs/167
@@ -47,13 +47,11 @@ _require_fs_space $SCRATCH_MNT 10485760
 
 TEST_FILE=$SCRATCH_MNT/test_file
 TEST_PROG=$here/src/unwritten_sync
-LOOPS=50
+LOOPS=$((5 * $TIME_FACTOR))
 
 echo "*** test unwritten extent conversion under heavy I/O"
-
-workout
-
 rm -f $TEST_FILE
+workout
 $TEST_PROG $LOOPS $TEST_FILE
 
 echo "     *** test done"
-- 
2.35.1


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

* [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks
  2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
                   ` (6 preceding siblings ...)
  2022-06-02  0:31 ` [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR Dave Chinner
@ 2022-06-02  0:31 ` Dave Chinner
  2022-06-02  1:04   ` Darrick J. Wong
  2022-06-03  1:54   ` [PATCH 8/8 v2] " Dave Chinner
  7 siblings, 2 replies; 23+ messages in thread
From: Dave Chinner @ 2022-06-02  0:31 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

On a recently upgraded system, xfs/189 still works just fine, but
every test run after it now gets spammed from mount/systemd
like so:

xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 1s
xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 2s
xfs/193 2s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 2s
xfs/194 1s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

This is because xfs/189 modifies /etc/fstab during the test, then
restores it to it's original condition so there's nothing to update.
However, systemd is sees that the mtime of /etc/fstab has changed,
and assumes they sky has fallen and so everything must be reloaded
from scratch to silence the unnecessary "hint".

We can avoid this clumsiness by capturing the mtime of /etc/fstab
before we modify it, and restore it afterwards and that means
systemd doesn't even notice that we've being playing around with
/etc/fstab.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/189 | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/tests/xfs/189 b/tests/xfs/189
index e601881a..6287a733 100755
--- a/tests/xfs/189
+++ b/tests/xfs/189
@@ -32,6 +32,27 @@
 #
 # <---- Normal programming is resumed ---->
 #
+# <---- Bbbzzzzzzztttt ---->
+#
+# < systemd enters the chat >
+#
+# xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
+# xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
+#        the old version; use 'systemctl daemon-reload' to reload.
+#  1s
+#  xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
+#        the old version; use 'systemctl daemon-reload' to reload.
+#
+# So now mount/systemd sees that /etc/fstab has changed (because mtime changed)
+# and so it now whines that it needs updating on every mount from this point
+# onwards. Yes, that's totally obnoxious behaviour from mount/systemd but we
+# have to work around it.
+#
+# Hence we save/restore the mtime of /etc/fstab around every modification we
+# make so that any time /etc/fstab is checked in future it won't appear to have
+# changed.
+#
+# < systemd leaves the chat >
 #
 . ./common/preamble
 _begin_fstest mount auto quick
@@ -190,31 +211,46 @@ ENDL
 # Example fstab entry
 # /dev/sdb2            /mnt/scratch1        xfs       defaults 0 0
 #
+# Note that to avoid systemd whinging about /etc/fstab being modified, we
+# need to ensure the mtime of /etc/fstab does not change across all these
+# modifications.
+#
 _add_scratch_fstab()
 {
+	local mtime="$(stat -c %y /etc/fstab)"
+
 	# comment out any existing SCRATCH_DEV
 	$SED_PROG -i "s;$SCRATCH_DEV;#$SCRATCH_DEV;" /etc/fstab
 
 	# add our fstab entry
 	echo "$SCRATCH_DEV $SCRATCH_MNT xfs defaults 0 0 # $tag" >> /etc/fstab
+
+	touch -m --date="$mtime" /etc/fstab
 }
 
 _modify_scratch_fstab()
 {
-	opts=$1
+	local opts=$1
+	local mtime="$(stat -c %y /etc/fstab)"
 
 	# modify our fstab entry that we added
 	# modify opts by looking for last word which has non-space chars
 	$SED_PROG -i "s; [^ ]* 0 0 # $tag; $opts 0 0 # $tag;" /etc/fstab
+
+	touch -m --date="$mtime" /etc/fstab
 }
 
 _putback_scratch_fstab()
 {
+	local mtime="$(stat -c %y /etc/fstab)"
+
 	# uncomment out any existing SCRATCH_DEV
 	$SED_PROG -i "s;#$SCRATCH_DEV;$SCRATCH_DEV;" /etc/fstab
 
 	# remove the one we added at the end
 	$SED_PROG -i "/# $tag/d" /etc/fstab
+
+	touch -m --date="$mtime" /etc/fstab
 }
 
 # Import common functions.
-- 
2.35.1


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

* Re: [PATCH 2/8] README: document _begin_fstests better
  2022-06-02  0:31 ` [PATCH 2/8] README: document _begin_fstests better Dave Chinner
@ 2022-06-02  0:51   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  0:51 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:20AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Because how it actually gets used by the fstests infrastructure
> has been undocumented and that has impact on how it should be set
> up.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  README | 40 +++++++++++++++++++++++++++++++---------
>  1 file changed, 31 insertions(+), 9 deletions(-)
> 
> diff --git a/README b/README
> index 7da66cb6..80d148be 100644
> --- a/README
> +++ b/README
> @@ -368,19 +368,41 @@ Test script environment:
>  
>       6. Test group membership: Each test can be associated with any number
>  	of groups for convenient selection of subsets of tests.  Group names
> -	can be any sequence of non-whitespace characters.  Test authors
> -	associate a test with groups by passing the names of those groups as
> -	arguments to the _begin_fstest function.  For example, the code:
> +	must  be human readable using only characters in the set [:alnum:_-].
>  
> -	_begin_fstest auto quick subvol snapshot
> +	Test authors associate a test with groups by passing the names of those
> +	groups as arguments to the _begin_fstest function. While _begin_fstests
> +	is a shell function that must be called at the start of a test to
> +	initialise the test environment correctly, the the build infrastructure
> +	also scans the test files for _begin_fstests invocations. It does this
> +	to compile the group lists that are used to determine which tests to run
> +	when `check` is executed. In other words, test files files must call
> +	_begin_fstest with their intended groups or they will not be run.
> +
> +	However, because the build infrastructure also uses _begin_fstests as
> +	a defined keyword, addition restrictions are placed on how it must be
> +	formatted:
> +
> +	(a) It must be a single line with no multi-line continuations.
> +
> +	(b) group names should be separated by spaces and not other whitespace
> +
> +	(c) A '#' placed anywhere in the list, even in the middle of a group
> +	    name, will cause everything from the # to the end of the line to be
> +	    ignored.
> +
> +	For example, the code:
> +
> +	_begin_fstest auto quick subvol snapshot # metadata
>  
>  	associates the current test with the "auto", "quick", "subvol", and
> -	"snapshot" groups.  It is not necessary to specify the "all" group
> -	in the list because that group is computed at run time.
> +	"snapshot" groups. Because "metadata" is after the "#" comment
> +	delimiter, it is ignored by the build infrastructure and so it will not
> +	be associated with that group.
> +
> +	It is not necessary to specify the "all" group in the list because that
> +	group is always computed at run time from the group lists.
>  
> -	The build process scans test files for _begin_fstest invocations and
> -	compiles the group list from that information.  In other words, test
> -	files must call _begin_fstest or they will not be run.
>  
>  Verified output:
>  
> -- 
> 2.35.1
> 

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

* Re: [PATCH 4/8] generic/038: kill background threads on interrupt
  2022-06-02  0:31 ` [PATCH 4/8] generic/038: kill background threads on interrupt Dave Chinner
@ 2022-06-02  0:51   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  0:51 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:22AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When I ctrl-c g/038, it either does nothing or it leaves processes
> running in the background. It is not cleaning up it's background
> processes correctly, so add kill vectors into the cleanup. Make sure
> we only kill in the cleanup trap if the background processes are
> running.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/generic/038 | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/generic/038 b/tests/generic/038
> index c6cea94e..e9b49967 100755
> --- a/tests/generic/038
> +++ b/tests/generic/038
> @@ -36,6 +36,10 @@ _begin_fstest auto stress trim
>  # Override the default cleanup function.
>  _cleanup()
>  {
> +	[ -n "${create_pids}" ] && kill ${create_pids[@]}
> +	[ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
> +	[ -n "${trim_pids}" ] && kill ${trim_pids[@]}
> +	wait
>  	rm -fr $tmp
>  }
>  
> @@ -47,6 +51,8 @@ _supported_fs generic
>  _require_scratch
>  _require_xfs_io_command "falloc"
>  
> +echo "Silence is golden"
> +
>  # Keep allocating and deallocating 1G of data space with the goal of creating
>  # and deleting 1 block group constantly. The intention is to race with the
>  # fstrim loop below.
> @@ -113,7 +119,7 @@ create_files()
>  	done
>  
>  	wait ${create_pids[@]}
> -
> +	unset create_pids
>  }
>  
>  _scratch_mkfs >>$seqres.full 2>&1
> @@ -136,12 +142,8 @@ create_files "foobar"
>  kill ${fallocate_pids[@]}
>  kill ${trim_pids[@]}
>  wait
> +unset fallocate_pids
> +unset trim_pids
>  
> -# The fstests framework will now check for fs consistency with fsck.
> -# The trimming was racy and caused some btree nodes to get full of zeroes on
> -# disk, which obviously caused fs metadata corruption. The race often lead
> -# to missing free space entries in a block group's free space cache too.
> -
> -echo "Silence is golden"
>  status=0
>  exit
> -- 
> 2.35.1
> 

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

* Re: [PATCH 5/8] xfs/538: fix fsstress scaling
  2022-06-02  0:31 ` [PATCH 5/8] xfs/538: fix fsstress scaling Dave Chinner
@ 2022-06-02  0:52   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  0:52 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:23AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> _scale_fsstress_args() does time/load scaling of parameters. Doing
> it also in the test causes exponential scaling instead of linear
> scaling as the time/load parameters are meant to do.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Yep.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/xfs/538     | 36 +++++++++++++++++-------------------
>  tests/xfs/538.out |  3 +--
>  2 files changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/tests/xfs/538 b/tests/xfs/538
> index e0102f48..2b5e97e5 100755
> --- a/tests/xfs/538
> +++ b/tests/xfs/538
> @@ -47,25 +47,23 @@ done
>  echo "Inject bmap_alloc_minlen_extent error tag"
>  _scratch_inject_error bmap_alloc_minlen_extent 1
>  
> -echo "Scale fsstress args"
> -args=$(_scale_fsstress_args -p $((LOAD_FACTOR * 75)) -n $((TIME_FACTOR * 1000)))
> -
> -echo "Execute fsstress in background"
> -$FSSTRESS_PROG -d $SCRATCH_MNT $args \
> -		 -f bulkstat=0 \
> -		 -f bulkstat1=0 \
> -		 -f fiemap=0 \
> -		 -f getattr=0 \
> -		 -f getdents=0 \
> -		 -f getfattr=0 \
> -		 -f listfattr=0 \
> -		 -f mread=0 \
> -		 -f read=0 \
> -		 -f readlink=0 \
> -		 -f readv=0 \
> -		 -f stat=0 \
> -		 -f aread=0 \
> -		 -f dread=0 > /dev/null 2>&1
> +echo "Execute fsstress"
> +$FSSTRESS_PROG -d $SCRATCH_MNT \
> +		$(_scale_fsstress_args -p 75 -n 1000) \
> +		-f bulkstat=0 \
> +		-f bulkstat1=0 \
> +		-f fiemap=0 \
> +		-f getattr=0 \
> +		-f getdents=0 \
> +		-f getfattr=0 \
> +		-f listfattr=0 \
> +		-f mread=0 \
> +		-f read=0 \
> +		-f readlink=0 \
> +		-f readv=0 \
> +		-f stat=0 \
> +		-f aread=0 \
> +		-f dread=0 > /dev/null 2>&1
>  
>  # success, all done
>  status=0
> diff --git a/tests/xfs/538.out b/tests/xfs/538.out
> index 85932c82..97ebc314 100644
> --- a/tests/xfs/538.out
> +++ b/tests/xfs/538.out
> @@ -3,5 +3,4 @@ Format and mount fs
>  Consume free space
>  Create fragmented filesystem
>  Inject bmap_alloc_minlen_extent error tag
> -Scale fsstress args
> -Execute fsstress in background
> +Execute fsstress
> -- 
> 2.35.1
> 

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

* Re: [PATCH 6/8] xfs/070: filter the bad sb magic number error
  2022-06-02  0:31 ` [PATCH 6/8] xfs/070: filter the bad sb magic number error Dave Chinner
@ 2022-06-02  0:52   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  0:52 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:24AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Lastest XFS kernel makes the superblock bad magic number error
> message more meaningful, and that's being picked up by xfsprogs in
> very short order. And, of course, the error is output by xfs_repair,
> too, and it's been captured in the golden output of a test. Fix it
> by filtering the output back down to the old message.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Heh, I had a patch just like this one!
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  common/repair | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/common/repair b/common/repair
> index 5a957f4e..463ef9db 100644
> --- a/common/repair
> +++ b/common/repair
> @@ -90,6 +90,7 @@ s/(superblock) (\d+)/\1 AGNO/;
>  s/(AG \#)(\d+)/\1AGNO/;
>  s/(reset bad sb for ag) (\d+)/\1 AGNO/;
>  s/(unknown block state, ag )(\d+)(, blocks? )(\d+)/\1AGNO\3AGBNO/;
> +s/^Superblock has (bad magic number) 0x.*/\1/;
>  /^Note - quota info will be regenerated on next quota mount.$/ && next;
>  	print;'
>  }
> -- 
> 2.35.1
> 

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

* Re: [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR
  2022-06-02  0:31 ` [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR Dave Chinner
@ 2022-06-02  0:53   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  0:53 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:25AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> xfs/167 takes between 6 and 10 minutes to run on my SSD based test
> machines. It's running 50 loops of a unwritten extent conversion
> test program whilst running a heavy fsstress workload in the
> background. This does not need to run for 10 minutes on every auto
> group regression test run. Shorten it to loop 5 * TIME_FACTOR
> so that normal runtime drops to something sane but can still be
> easily ramped up if soak/stress testing is being run.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/xfs/167 | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/xfs/167 b/tests/xfs/167
> index 5f985010..15bb1854 100755
> --- a/tests/xfs/167
> +++ b/tests/xfs/167
> @@ -47,13 +47,11 @@ _require_fs_space $SCRATCH_MNT 10485760
>  
>  TEST_FILE=$SCRATCH_MNT/test_file
>  TEST_PROG=$here/src/unwritten_sync
> -LOOPS=50
> +LOOPS=$((5 * $TIME_FACTOR))
>  
>  echo "*** test unwritten extent conversion under heavy I/O"
> -
> -workout
> -
>  rm -f $TEST_FILE
> +workout
>  $TEST_PROG $LOOPS $TEST_FILE
>  
>  echo "     *** test done"
> -- 
> 2.35.1
> 

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

* Re: [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks
  2022-06-02  0:31 ` [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks Dave Chinner
@ 2022-06-02  1:04   ` Darrick J. Wong
  2022-06-03  1:54   ` [PATCH 8/8 v2] " Dave Chinner
  1 sibling, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  1:04 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:26AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> On a recently upgraded system, xfs/189 still works just fine, but
> every test run after it now gets spammed from mount/systemd
> like so:
> 
> xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
> xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  1s
> xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  2s
> xfs/193 2s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  2s
> xfs/194 1s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
> 
> This is because xfs/189 modifies /etc/fstab during the test, then
> restores it to it's original condition so there's nothing to update.
> However, systemd is sees that the mtime of /etc/fstab has changed,
> and assumes they sky has fallen and so everything must be reloaded
> from scratch to silence the unnecessary "hint".
> 
> We can avoid this clumsiness by capturing the mtime of /etc/fstab
> before we modify it, and restore it afterwards and that means
> systemd doesn't even notice that we've being playing around with
> /etc/fstab.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  tests/xfs/189 | 38 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/xfs/189 b/tests/xfs/189
> index e601881a..6287a733 100755
> --- a/tests/xfs/189
> +++ b/tests/xfs/189
> @@ -32,6 +32,27 @@
>  #
>  # <---- Normal programming is resumed ---->
>  #
> +# <---- Bbbzzzzzzztttt ---->
> +#
> +# < systemd enters the chat >
> +#
> +# xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
> +# xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
> +#        the old version; use 'systemctl daemon-reload' to reload.
> +#  1s
> +#  xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
> +#        the old version; use 'systemctl daemon-reload' to reload.
> +#
> +# So now mount/systemd sees that /etc/fstab has changed (because mtime changed)
> +# and so it now whines that it needs updating on every mount from this point
> +# onwards. Yes, that's totally obnoxious behaviour from mount/systemd but we
> +# have to work around it.
> +#
> +# Hence we save/restore the mtime of /etc/fstab around every modification we
> +# make so that any time /etc/fstab is checked in future it won't appear to have
> +# changed.
> +#
> +# < systemd leaves the chat >
>  #
>  . ./common/preamble
>  _begin_fstest mount auto quick
> @@ -190,31 +211,46 @@ ENDL
>  # Example fstab entry
>  # /dev/sdb2            /mnt/scratch1        xfs       defaults 0 0
>  #
> +# Note that to avoid systemd whinging about /etc/fstab being modified, we
> +# need to ensure the mtime of /etc/fstab does not change across all these
> +# modifications.

systemd chose to create .mount units to represent filesystems that
should be mounted.  These units are owned by system packages, and
systemd *is* supposed to notice when changes are made to these files:

$ ls /lib/systemd/system/*.mount
/lib/systemd/system/dev-hugepages.mount
/lib/systemd/system/dev-mqueue.mount
/lib/systemd/system/proc-sys-fs-binfmt_misc.mount
/lib/systemd/system/sys-fs-fuse-connections.mount
/lib/systemd/system/sys-kernel-config.mount
/lib/systemd/system/sys-kernel-debug.mount
/lib/systemd/system/sys-kernel-tracing.mount
<etc>

For compatibility reasons, it synthesizes .mount units from /etc/fstab
at boot time (since the whole world still uses fstab):

$ cat /etc/fstab
/dev/mapper/flax-root /               xfs     defaults        0       0
/dev/mapper/flax.boot /boot           xfs     defaults        0       0
UUID=6C22-4885  /boot/efi       vfat    umask=0077      0       1

$ ls /run/systemd/generator/*.mount
/run/systemd/generator/boot-efi.mount
/run/systemd/generator/boot.mount
/run/systemd/generator/-.mount

systemd doesn't claim ownership of fstab (since you /could/ edit the
generated files), which means that it won't rewrite the generated .mount
files when fstab changes for fear of erasing something the sysadmin
actually changed in /run/systemd.

The annoying message you get from mount is, as you say, because the
mtime of /etc/fstab is newer than the generated files.  (This is also
why systemd had that godawful misbehavior where you'd update fstab for
an unmounted fs, mount it, and systemd would immediately unmount it,
because the device name doesn't match the un-updated .mount file).

That said, I think the proper solution here is to tell systemd to
regenerate its .mount files:

	command -v systemctl 2>/dev/null && systemctl daemon-reload

Not hack around it by futzing with the mtime.

--D

> +#
>  _add_scratch_fstab()
>  {
> +	local mtime="$(stat -c %y /etc/fstab)"
> +
>  	# comment out any existing SCRATCH_DEV
>  	$SED_PROG -i "s;$SCRATCH_DEV;#$SCRATCH_DEV;" /etc/fstab
>  
>  	# add our fstab entry
>  	echo "$SCRATCH_DEV $SCRATCH_MNT xfs defaults 0 0 # $tag" >> /etc/fstab
> +
> +	touch -m --date="$mtime" /etc/fstab
>  }
>  
>  _modify_scratch_fstab()
>  {
> -	opts=$1
> +	local opts=$1
> +	local mtime="$(stat -c %y /etc/fstab)"
>  
>  	# modify our fstab entry that we added
>  	# modify opts by looking for last word which has non-space chars
>  	$SED_PROG -i "s; [^ ]* 0 0 # $tag; $opts 0 0 # $tag;" /etc/fstab
> +
> +	touch -m --date="$mtime" /etc/fstab
>  }
>  
>  _putback_scratch_fstab()
>  {
> +	local mtime="$(stat -c %y /etc/fstab)"
> +
>  	# uncomment out any existing SCRATCH_DEV
>  	$SED_PROG -i "s;#$SCRATCH_DEV;$SCRATCH_DEV;" /etc/fstab
>  
>  	# remove the one we added at the end
>  	$SED_PROG -i "/# $tag/d" /etc/fstab
> +
> +	touch -m --date="$mtime" /etc/fstab
>  }
>  
>  # Import common functions.
> -- 
> 2.35.1
> 

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

* Re: [PATCH 1/8] xfstests: Add Log Attribute Replay test
  2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
@ 2022-06-02  1:05   ` Darrick J. Wong
  2022-06-03  1:41   ` [PATCH 1/8 v2] fstests: " Dave Chinner
  1 sibling, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  1:05 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:19AM +1000, Dave Chinner wrote:
> From: Allison Henderson <allison.henderson@oracle.com>
> 
> This patch adds tests to exercise the log attribute error
> inject and log replay. These tests aim to cover cases where attributes
> are added, removed, and overwritten in each format (shortform, leaf,
> node). Error inject is used to replay these operations from the log.
> 
> dchinner: sanitise md5sum input to just attr values.
> dchinner: correct md5sums.
> dchinner: ensure replace tests use different values so recovery can
>           determine the replace was replayed correctly.
> dchinner: don't remove corpse in _cleanup - scratch devices don't
> 	  require cleanup, and if the test fails we want to leave
> 	  the broken state for post-mortem analysis.
> dchinner: only run on v5 filesystems.
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  tests/xfs/600     | 179 +++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/600.out | 188 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 367 insertions(+)
>  create mode 100755 tests/xfs/600
>  create mode 100644 tests/xfs/600.out
> 
> diff --git a/tests/xfs/600 b/tests/xfs/600
> new file mode 100755
> index 00000000..0ff41e13
> --- /dev/null
> +++ b/tests/xfs/600
> @@ -0,0 +1,179 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# FS QA Test 600
> +#
> +# Log attribute replay test
> +#
> +. ./common/preamble
> +_begin_fstest auto quick attr
> +
> +# get standard environment, filters and checks
> +. ./common/filter
> +. ./common/attr
> +. ./common/inject
> +
> +_cleanup()
> +{
> +	rm -rf $tmp.*
> +	test -w /sys/fs/xfs/debug/larp && \
> +		echo 0 > /sys/fs/xfs/debug/larp
> +}
> +
> +test_attr_replay()
> +{
> +	testfile=$testdir/$1
> +	attr_name=$2
> +	attr_value=$3
> +	flag=$4
> +	error_tag=$5
> +
> +	# Inject error
> +	_scratch_inject_error $error_tag
> +
> +	# Set attribute
> +	echo "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
> +			    _filter_scratch
> +
> +	# FS should be shut down, touch will fail
> +	touch $testfile 2>&1 | _filter_scratch
> +
> +	# Remount to replay log
> +	_scratch_remount_dump_log >> $seqres.full
> +
> +	# FS should be online, touch should succeed
> +	touch $testfile
> +
> +	# Verify attr recovery
> +	$ATTR_PROG -l $testfile | _filter_scratch
> +	echo -n "$attr_name: "
> +	$ATTR_PROG -q -g $attr_name $testfile | md5sum;
> +
> +	echo ""
> +}
> +
> +create_test_file()
> +{
> +	filename=$testdir/$1
> +	count=$2
> +	attr_value=$3
> +
> +	touch $filename
> +
> +	for i in `seq $count`
> +	do
> +		$ATTR_PROG -s "attr_name$i" -V $attr_value $filename >> \
> +			$seqres.full
> +	done
> +}
> +
> +# real QA test starts here
> +_supported_fs xfs
> +
> +_require_scratch
> +_require_scratch_xfs_crc
> +_require_attrs
> +_require_xfs_io_error_injection "larp"
> +_require_xfs_io_error_injection "da_leaf_split"
> +_require_xfs_io_error_injection "attr_leaf_to_node"
> +_require_xfs_sysfs debug/larp
> +test -w /sys/fs/xfs/debug/larp || _notrun "larp knob not writable"
> +
> +# turn on log attributes
> +echo 1 > /sys/fs/xfs/debug/larp
> +
> +attr16="0123456789ABCDEF"
> +attr64="$attr16$attr16$attr16$attr16"
> +attr256="$attr64$attr64$attr64$attr64"
> +attr1k="$attr256$attr256$attr256$attr256"
> +attr4k="$attr1k$attr1k$attr1k$attr1k"
> +attr8k="$attr4k$attr4k"
> +attr16k="$attr8k$attr8k"
> +attr32k="$attr16k$attr16k"
> +attr64k="$attr32k$attr32k"
> +
> +echo "*** mkfs"
> +_scratch_mkfs >/dev/null
> +
> +echo "*** mount FS"
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT/testdir
> +mkdir $testdir
> +
> +# empty, inline
> +create_test_file empty_file1 0
> +test_attr_replay empty_file1 "attr_name" $attr64 "s" "larp"
> +test_attr_replay empty_file1 "attr_name" $attr64 "r" "larp"
> +
> +# empty, internal
> +create_test_file empty_file2 0
> +test_attr_replay empty_file2 "attr_name" $attr1k "s" "larp"
> +test_attr_replay empty_file2 "attr_name" $attr1k "r" "larp"
> +
> +# empty, remote
> +create_test_file empty_file3 0
> +test_attr_replay empty_file3 "attr_name" $attr64k "s" "larp"
> +test_attr_replay empty_file3 "attr_name" $attr64k "r" "larp"
> +
> +# inline, inline
> +create_test_file inline_file1 1 $attr16
> +test_attr_replay inline_file1 "attr_name2" $attr64 "s" "larp"
> +test_attr_replay inline_file1 "attr_name2" $attr64 "r" "larp"
> +
> +# inline, internal
> +create_test_file inline_file2 1 $attr16
> +test_attr_replay inline_file2 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay inline_file2 "attr_name2" $attr1k "r" "larp"
> +
> +# inline, remote
> +create_test_file inline_file3 1 $attr16
> +test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
> +
> +# extent, internal
> +create_test_file extent_file1 1 $attr1k
> +test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay extent_file1 "attr_name2" $attr1k "r" "larp"
> +
> +# extent, inject error on split
> +create_test_file extent_file2 3 $attr1k
> +test_attr_replay extent_file2 "attr_name4" $attr1k "s" "da_leaf_split"
> +
> +# extent, inject error on fork transition
> +create_test_file extent_file3 3 $attr1k
> +test_attr_replay extent_file3 "attr_name4" $attr1k "s" "attr_leaf_to_node"
> +
> +# extent, remote
> +create_test_file extent_file4 1 $attr1k
> +test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
> +
> +# remote, internal
> +create_test_file remote_file1 1 $attr64k
> +test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay remote_file1 "attr_name2" $attr1k "r" "larp"
> +
> +# remote, remote
> +create_test_file remote_file2 1 $attr64k
> +test_attr_replay remote_file2 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay remote_file2 "attr_name2" $attr64k "r" "larp"
> +
> +# replace shortform with different value
> +create_test_file sf_file 2 $attr64
> +test_attr_replay sf_file "attr_name2" $attr16 "s" "larp"
> +
> +# replace leaf with different value
> +create_test_file leaf_file 3 $attr1k
> +test_attr_replay leaf_file "attr_name2" $attr256 "s" "larp"
> +
> +# replace node with a different value
> +create_test_file node_file 1 $attr64k
> +$ATTR_PROG -s "attr_name2" -V $attr1k $testdir/node_file \
> +		>> $seqres.full
> +test_attr_replay node_file "attr_name2" $attr256 "s" "larp"
> +
> +echo "*** done"
> +status=0
> +exit
> diff --git a/tests/xfs/600.out b/tests/xfs/600.out
> new file mode 100644
> index 00000000..fe25ea3e
> --- /dev/null
> +++ b/tests/xfs/600.out
> @@ -0,0 +1,188 @@
> +QA output created by 600
> +*** mkfs
> +*** mount FS
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> +Attribute "attr_name" has a 65 byte value for SCRATCH_MNT/testdir/empty_file1
> +attr_name: cfbe2a33be4601d2b655d099a18378fc  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> +attr_name: attr_get: No data available
> +Could not get "attr_name" for /mnt/scratch/testdir/empty_file1

SCRATCH_MNT, not /mnt/scratch?

--D

> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> +Attribute "attr_name" has a 1025 byte value for SCRATCH_MNT/testdir/empty_file2
> +attr_name: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> +attr_name: attr_get: No data available
> +Could not get "attr_name" for /mnt/scratch/testdir/empty_file2
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> +Attribute "attr_name" has a 65536 byte value for SCRATCH_MNT/testdir/empty_file3
> +attr_name: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> +attr_name: attr_get: No data available
> +Could not get "attr_name" for /mnt/scratch/testdir/empty_file3
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> +Attribute "attr_name2" has a 65 byte value for SCRATCH_MNT/testdir/inline_file1
> +attr_name2: cfbe2a33be4601d2b655d099a18378fc  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/inline_file1
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/inline_file2
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/inline_file2
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/inline_file3
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/inline_file3
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file1
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/extent_file1
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file2': Input/output error
> +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file3': Input/output error
> +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/extent_file4
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/extent_file4
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/remote_file1
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/remote_file1
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +attr_name2: attr_get: No data available
> +Could not get "attr_name2" for /mnt/scratch/testdir/remote_file2
> +d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/sf_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/sf_file': Input/output error
> +Attribute "attr_name1" has a 64 byte value for SCRATCH_MNT/testdir/sf_file
> +Attribute "attr_name2" has a 17 byte value for SCRATCH_MNT/testdir/sf_file
> +attr_name2: 9a6eb1bc9da3c66a9b495dfe2fe8a756  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/leaf_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/leaf_file': Input/output error
> +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/leaf_file
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/node_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/node_file': Input/output error
> +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/node_file
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/node_file
> +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> +
> +*** done
> -- 
> 2.35.1
> 

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

* Re: [PATCH 3/8] generic/081: don't run on DAX capable devices
  2022-06-02  0:31 ` [PATCH 3/8] generic/081: don't run on DAX capable devices Dave Chinner
@ 2022-06-02  2:03   ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-02  2:03 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Thu, Jun 02, 2022 at 10:31:21AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> LVM/DM has conniptions when you try to use snapshots on a device
> that has DAX capability. It first sets up the underlying device as a
> DAX capable mapping (type 3 or DM_TYPE_DAX_BIO_BASED) but because
> snapshots require COW and shared mappings, it isn't supported on DAX
> capable devices. Hence creating the snapshot device fails because it
> requires a type 1 (DM_TYPE_BIO_BASED) device and DM can't change
> types on a loaded mapping.
> 
> Hence we get this obscure error message in the log:
> 
> device-mapper: ioctl: can't change device type (old=3 vs new=1) after initial table load.
> 
> and these obscure, unhelpful error messages from the LVM command
> outputs:
> 
>   device-mapper: reload ioctl on  (251:0) failed: Invalid argument
>   Failed to suspend logical volume vg_081/base_081.
>   Device vg_081-base_081-real (251:1) is used by another device.
>   Failed to revert logical volume vg_081/base_081.
>   Aborting. Manual intervention required.
> Failed to create snapshot
> 
> How to turn off DAX capability is not documented in dmsetup or LVM
> man pages, nor is dax mentioned anywhere in
> Documentation/admin/device-mapper/ so I have no idea how to tell
> LVM/DM "don't try to enable DAX support!".
> 
> As such, if the uderlying block device is dax capable, skip this
> test.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Seems reasonable to me, who also sees weird problems on the dax vms...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  common/rc | 39 +++++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 2f31ca46..c334cfbf 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2116,21 +2116,33 @@ _require_sane_bdev_flush()
>  # Decide if the scratch filesystem is likely to be mounted in fsdax mode.
>  # It goes 3 ways based on mount options::
>  #	1. "dax" or "dax=always" means always test using DAX
> -#	2. "dax=never" means we'll never use DAX
> +#	2. "dax=never" means we'll never use DAX.
>  #	3. "dax=inode" or nothing means "use scratch dev capability" to
>  #	    determine whether DAX is going to be used.
>  #
> -# Returns 0 if DAX will be used, 1 if DAX is not going to be used.
> +# Case 2 and 3 basically mean the same thing for the purpose of
> +# _require_dm_target(). If the fs is not forcing the use of DAX, then DAX
> +# can only be enabled if the underlying block device supports it.
> +#
> +# Returns 0 if the filesytem will use DAX, 1 if it won't.
>  __scratch_uses_fsdax()
>  {
>  	local ops=$(_normalize_mount_options "$MOUNT_OPTIONS")
>  
>  	echo $ops | egrep -qw "dax(=always| |$)" && return 0
> -	echo $ops | grep -qw "dax=never" && return 1
> +	return 1
> +}
>  
> +# Determine if the scratch device is DAX capable. Even if the fs is not
> +# using DAX, we still can't use certain device mapper targets if the block
> +# device is DAX capable. Hence the check needs to be separat from the FS
> +# capability.
> +__scratch_dev_has_dax()
> +{
>  	local sysfs="/sys/block/$(_short_dev $SCRATCH_DEV)"
>  	test -e "${sysfs}/dax" && return 0
>  	test "$(cat "${sysfs}/queue/dax" 2>/dev/null)" = "1" && return 0
> +
>  	return 1
>  }
>  
> @@ -2147,15 +2159,18 @@ _require_dm_target()
>  	_require_sane_bdev_flush $SCRATCH_DEV
>  	_require_command "$DMSETUP_PROG" dmsetup
>  
> -	if __scratch_uses_fsdax; then
> -		case $target in
> -		stripe|linear|log-writes)
> -			;;
> -		*)
> -			_notrun "Cannot run tests with DAX on $target devices."
> -			;;
> -		esac
> -	fi
> +	case $target in
> +	stripe|linear|log-writes)
> +		;;
> +	*)
> +		if __scratch_uses_fsdax; then
> +			_notrun "Cannot run tests with fsdax on $target devices."
> +		fi
> +		if __scratch_dev_has_dax; then
> +			_notrun "Cannot use $target devices on DAX capable block devices."
> +		fi
> +		;;
> +	esac
>  
>  	modprobe dm-$target >/dev/null 2>&1
>  
> -- 
> 2.35.1
> 

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

* [PATCH 1/8 v2] fstests: Add Log Attribute Replay test
  2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
  2022-06-02  1:05   ` Darrick J. Wong
@ 2022-06-03  1:41   ` Dave Chinner
  2022-06-03  2:43     ` Darrick J. Wong
  1 sibling, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-03  1:41 UTC (permalink / raw)
  To: fstests

From: Allison Henderson <allison.henderson@oracle.com>

This patch adds tests to exercise the log attribute error
inject and log replay. These tests aim to cover cases where attributes
are added, removed, and overwritten in each format (shortform, leaf,
node). Error inject is used to replay these operations from the log.

dchinner: sanitise md5sum input to just attr values.
dchinner: correct md5sums.
dchinner: ensure replace tests use different values so recovery can
          determine the replace was replayed correctly.
dchinner: don't remove corpse in _cleanup - scratch devices don't
	  require cleanup, and if the test fails we want to leave
	  the broken state for post-mortem analysis.
dchinner: only run on v5 filesystems.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
V2:
- redirected attr get failure messages to /dev/null rather than
  have to filter them. The md5sum tells us that the attr didn't
  exist.

 tests/xfs/600     | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/600.out | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 347 insertions(+)

diff --git a/tests/xfs/600 b/tests/xfs/600
new file mode 100755
index 00000000..bc9415ec
--- /dev/null
+++ b/tests/xfs/600
@@ -0,0 +1,179 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test 600
+#
+# Log attribute replay test
+#
+. ./common/preamble
+_begin_fstest auto quick attr
+
+# get standard environment, filters and checks
+. ./common/filter
+. ./common/attr
+. ./common/inject
+
+_cleanup()
+{
+	rm -rf $tmp.*
+	test -w /sys/fs/xfs/debug/larp && \
+		echo 0 > /sys/fs/xfs/debug/larp
+}
+
+test_attr_replay()
+{
+	testfile=$testdir/$1
+	attr_name=$2
+	attr_value=$3
+	flag=$4
+	error_tag=$5
+
+	# Inject error
+	_scratch_inject_error $error_tag
+
+	# Set attribute
+	echo "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
+			    _filter_scratch
+
+	# FS should be shut down, touch will fail
+	touch $testfile 2>&1 | _filter_scratch
+
+	# Remount to replay log
+	_scratch_remount_dump_log >> $seqres.full
+
+	# FS should be online, touch should succeed
+	touch $testfile
+
+	# Verify attr recovery
+	$ATTR_PROG -l $testfile | _filter_scratch
+	echo -n "$attr_name: "
+	$ATTR_PROG -q -g $attr_name $testfile 2> /dev/null | md5sum;
+
+	echo ""
+}
+
+create_test_file()
+{
+	filename=$testdir/$1
+	count=$2
+	attr_value=$3
+
+	touch $filename
+
+	for i in `seq $count`
+	do
+		$ATTR_PROG -s "attr_name$i" -V $attr_value $filename >> \
+			$seqres.full
+	done
+}
+
+# real QA test starts here
+_supported_fs xfs
+
+_require_scratch
+_require_scratch_xfs_crc
+_require_attrs
+_require_xfs_io_error_injection "larp"
+_require_xfs_io_error_injection "da_leaf_split"
+_require_xfs_io_error_injection "attr_leaf_to_node"
+_require_xfs_sysfs debug/larp
+test -w /sys/fs/xfs/debug/larp || _notrun "larp knob not writable"
+
+# turn on log attributes
+echo 1 > /sys/fs/xfs/debug/larp
+
+attr16="0123456789ABCDEF"
+attr64="$attr16$attr16$attr16$attr16"
+attr256="$attr64$attr64$attr64$attr64"
+attr1k="$attr256$attr256$attr256$attr256"
+attr4k="$attr1k$attr1k$attr1k$attr1k"
+attr8k="$attr4k$attr4k"
+attr16k="$attr8k$attr8k"
+attr32k="$attr16k$attr16k"
+attr64k="$attr32k$attr32k"
+
+echo "*** mkfs"
+_scratch_mkfs >/dev/null
+
+echo "*** mount FS"
+_scratch_mount
+
+testdir=$SCRATCH_MNT/testdir
+mkdir $testdir
+
+# empty, inline
+create_test_file empty_file1 0
+test_attr_replay empty_file1 "attr_name" $attr64 "s" "larp"
+test_attr_replay empty_file1 "attr_name" $attr64 "r" "larp"
+
+# empty, internal
+create_test_file empty_file2 0
+test_attr_replay empty_file2 "attr_name" $attr1k "s" "larp"
+test_attr_replay empty_file2 "attr_name" $attr1k "r" "larp"
+
+# empty, remote
+create_test_file empty_file3 0
+test_attr_replay empty_file3 "attr_name" $attr64k "s" "larp"
+test_attr_replay empty_file3 "attr_name" $attr64k "r" "larp"
+
+# inline, inline
+create_test_file inline_file1 1 $attr16
+test_attr_replay inline_file1 "attr_name2" $attr64 "s" "larp"
+test_attr_replay inline_file1 "attr_name2" $attr64 "r" "larp"
+
+# inline, internal
+create_test_file inline_file2 1 $attr16
+test_attr_replay inline_file2 "attr_name2" $attr1k "s" "larp"
+test_attr_replay inline_file2 "attr_name2" $attr1k "r" "larp"
+
+# inline, remote
+create_test_file inline_file3 1 $attr16
+test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
+test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
+
+# extent, internal
+create_test_file extent_file1 1 $attr1k
+test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
+test_attr_replay extent_file1 "attr_name2" $attr1k "r" "larp"
+
+# extent, inject error on split
+create_test_file extent_file2 3 $attr1k
+test_attr_replay extent_file2 "attr_name4" $attr1k "s" "da_leaf_split"
+
+# extent, inject error on fork transition
+create_test_file extent_file3 3 $attr1k
+test_attr_replay extent_file3 "attr_name4" $attr1k "s" "attr_leaf_to_node"
+
+# extent, remote
+create_test_file extent_file4 1 $attr1k
+test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
+test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
+
+# remote, internal
+create_test_file remote_file1 1 $attr64k
+test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
+test_attr_replay remote_file1 "attr_name2" $attr1k "r" "larp"
+
+# remote, remote
+create_test_file remote_file2 1 $attr64k
+test_attr_replay remote_file2 "attr_name2" $attr64k "s" "larp"
+test_attr_replay remote_file2 "attr_name2" $attr64k "r" "larp"
+
+# replace shortform with different value
+create_test_file sf_file 2 $attr64
+test_attr_replay sf_file "attr_name2" $attr16 "s" "larp"
+
+# replace leaf with different value
+create_test_file leaf_file 3 $attr1k
+test_attr_replay leaf_file "attr_name2" $attr256 "s" "larp"
+
+# replace node with a different value
+create_test_file node_file 1 $attr64k
+$ATTR_PROG -s "attr_name2" -V $attr1k $testdir/node_file \
+		>> $seqres.full
+test_attr_replay node_file "attr_name2" $attr256 "s" "larp"
+
+echo "*** done"
+status=0
+exit
diff --git a/tests/xfs/600.out b/tests/xfs/600.out
new file mode 100644
index 00000000..259b05ee
--- /dev/null
+++ b/tests/xfs/600.out
@@ -0,0 +1,168 @@
+QA output created by 600
+*** mkfs
+*** mount FS
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
+Attribute "attr_name" has a 65 byte value for SCRATCH_MNT/testdir/empty_file1
+attr_name: cfbe2a33be4601d2b655d099a18378fc  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
+attr_name: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
+Attribute "attr_name" has a 1025 byte value for SCRATCH_MNT/testdir/empty_file2
+attr_name: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
+attr_name: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
+Attribute "attr_name" has a 65536 byte value for SCRATCH_MNT/testdir/empty_file3
+attr_name: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
+attr_name: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
+Attribute "attr_name2" has a 65 byte value for SCRATCH_MNT/testdir/inline_file1
+attr_name2: cfbe2a33be4601d2b655d099a18378fc  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/inline_file2
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/inline_file3
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
+Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file1
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file2': Input/output error
+Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
+attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_set: Input/output error
+Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file3
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file3': Input/output error
+Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
+attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file4
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/extent_file4
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
+touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
+Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/remote_file1
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
+attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file1
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
+Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
+
+attr_remove: Input/output error
+Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file2
+touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
+attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/sf_file
+touch: cannot touch 'SCRATCH_MNT/testdir/sf_file': Input/output error
+Attribute "attr_name1" has a 64 byte value for SCRATCH_MNT/testdir/sf_file
+Attribute "attr_name2" has a 17 byte value for SCRATCH_MNT/testdir/sf_file
+attr_name2: 9a6eb1bc9da3c66a9b495dfe2fe8a756  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/leaf_file
+touch: cannot touch 'SCRATCH_MNT/testdir/leaf_file': Input/output error
+Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/leaf_file
+Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
+Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
+attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
+
+attr_set: Input/output error
+Could not set "attr_name2" for SCRATCH_MNT/testdir/node_file
+touch: cannot touch 'SCRATCH_MNT/testdir/node_file': Input/output error
+Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/node_file
+Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/node_file
+attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
+
+*** done
-- 
Dave Chinner
david@fromorbit.com

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

* [PATCH 8/8 v2] xfs/189: systemd monitoring of /etc/fstab sucks
  2022-06-02  0:31 ` [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks Dave Chinner
  2022-06-02  1:04   ` Darrick J. Wong
@ 2022-06-03  1:54   ` Dave Chinner
  2022-06-03  2:41     ` Darrick J. Wong
  1 sibling, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2022-06-03  1:54 UTC (permalink / raw)
  To: fstests

From: Dave Chinner <dchinner@redhat.com>

On a recently upgraded system, xfs/189 still works just fine, but
every test run after it now gets spammed from mount/systemd
like so:

xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 1s
xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 2s
xfs/193 2s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
 2s
xfs/194 1s ... mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

This is because xfs/189 modifies /etc/fstab during the test, then
restores it to it's original condition so there's nothing to update.
However, systemd is sees that the mtime of /etc/fstab has changed,
and assumes they sky has fallen and so everything must be reloaded
from scratch to silence the unnecessary "hint".

We can avoid this clumsiness by capturing the mtime of /etc/fstab
before we modify it, and restore it afterwards and that means
systemd doesn't even notice that we've being playing around with
/etc/fstab.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
V2:
- use systemctl daemon-reload instead of mtime futzing as Darrick
  suggested.

 tests/xfs/189 | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/tests/xfs/189 b/tests/xfs/189
index e601881a..bc7ccca5 100755
--- a/tests/xfs/189
+++ b/tests/xfs/189
@@ -32,6 +32,23 @@
 #
 # <---- Normal programming is resumed ---->
 #
+# <---- Bbbzzzzzzztttt ---->
+#
+# < systemd enters the chat >
+#
+# xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
+# xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
+#        the old version; use 'systemctl daemon-reload' to reload.
+#  1s
+#  xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
+#        the old version; use 'systemctl daemon-reload' to reload.
+#
+# mount/systemd sees that /etc/fstab has changed (because mtime changed)
+# and so it whines that systemd needs updating on every mount from this point
+# onwards. Yes, that's totally obnoxious behaviour from mount/systemd but we
+# have to work around it.
+#
+# < systemd leaves the chat >
 #
 . ./common/preamble
 _begin_fstest mount auto quick
@@ -190,6 +207,10 @@ ENDL
 # Example fstab entry
 # /dev/sdb2            /mnt/scratch1        xfs       defaults 0 0
 #
+# Note that to avoid mnt/systemd whining about /etc/fstab being modified, we
+# need to ensure that it reloads it's state once we restore the fstab to
+# original.
+#
 _add_scratch_fstab()
 {
 	# comment out any existing SCRATCH_DEV
@@ -201,7 +222,7 @@ _add_scratch_fstab()
 
 _modify_scratch_fstab()
 {
-	opts=$1
+	local opts=$1
 
 	# modify our fstab entry that we added
 	# modify opts by looking for last word which has non-space chars
@@ -215,6 +236,9 @@ _putback_scratch_fstab()
 
 	# remove the one we added at the end
 	$SED_PROG -i "/# $tag/d" /etc/fstab
+
+	# stop mount/systemd whining that /etcfstab was changed.
+	command -v systemctl > /dev/null 2>&1 && systemctl daemon-reload
 }
 
 # Import common functions.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 8/8 v2] xfs/189: systemd monitoring of /etc/fstab sucks
  2022-06-03  1:54   ` [PATCH 8/8 v2] " Dave Chinner
@ 2022-06-03  2:41     ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-03  2:41 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Fri, Jun 03, 2022 at 11:54:13AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> On a recently upgraded system, xfs/189 still works just fine, but
> every test run after it now gets spammed from mount/systemd
> like so:
> 
> xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
> xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  1s
> xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  2s
> xfs/193 2s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
>  2s
> xfs/194 1s ... mount: (hint) your fstab has been modified, but systemd still uses
>        the old version; use 'systemctl daemon-reload' to reload.
> 
> This is because xfs/189 modifies /etc/fstab during the test, then
> restores it to it's original condition so there's nothing to update.
> However, systemd is sees that the mtime of /etc/fstab has changed,
> and assumes they sky has fallen and so everything must be reloaded
> from scratch to silence the unnecessary "hint".
> 
> We can avoid this clumsiness by capturing the mtime of /etc/fstab
> before we modify it, and restore it afterwards and that means
> systemd doesn't even notice that we've being playing around with
> /etc/fstab.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> V2:
> - use systemctl daemon-reload instead of mtime futzing as Darrick
>   suggested.

Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> 
>  tests/xfs/189 | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/xfs/189 b/tests/xfs/189
> index e601881a..bc7ccca5 100755
> --- a/tests/xfs/189
> +++ b/tests/xfs/189
> @@ -32,6 +32,23 @@
>  #
>  # <---- Normal programming is resumed ---->
>  #
> +# <---- Bbbzzzzzzztttt ---->
> +#
> +# < systemd enters the chat >
> +#
> +# xfs/189 [not run] noattr2 mount option not supported on /dev/vdc
> +# xfs/190 1s ... mount: (hint) your fstab has been modified, but systemd still uses
> +#        the old version; use 'systemctl daemon-reload' to reload.
> +#  1s
> +#  xfs/192 3s ... mount: (hint) your fstab has been modified, but systemd still uses
> +#        the old version; use 'systemctl daemon-reload' to reload.
> +#
> +# mount/systemd sees that /etc/fstab has changed (because mtime changed)
> +# and so it whines that systemd needs updating on every mount from this point
> +# onwards. Yes, that's totally obnoxious behaviour from mount/systemd but we
> +# have to work around it.
> +#
> +# < systemd leaves the chat >
>  #
>  . ./common/preamble
>  _begin_fstest mount auto quick
> @@ -190,6 +207,10 @@ ENDL
>  # Example fstab entry
>  # /dev/sdb2            /mnt/scratch1        xfs       defaults 0 0
>  #
> +# Note that to avoid mnt/systemd whining about /etc/fstab being modified, we
> +# need to ensure that it reloads it's state once we restore the fstab to
> +# original.
> +#
>  _add_scratch_fstab()
>  {
>  	# comment out any existing SCRATCH_DEV
> @@ -201,7 +222,7 @@ _add_scratch_fstab()
>  
>  _modify_scratch_fstab()
>  {
> -	opts=$1
> +	local opts=$1
>  
>  	# modify our fstab entry that we added
>  	# modify opts by looking for last word which has non-space chars
> @@ -215,6 +236,9 @@ _putback_scratch_fstab()
>  
>  	# remove the one we added at the end
>  	$SED_PROG -i "/# $tag/d" /etc/fstab
> +
> +	# stop mount/systemd whining that /etcfstab was changed.
> +	command -v systemctl > /dev/null 2>&1 && systemctl daemon-reload
>  }
>  
>  # Import common functions.
> -- 
> Dave Chinner
> david@fromorbit.com

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

* Re: [PATCH 1/8 v2] fstests: Add Log Attribute Replay test
  2022-06-03  1:41   ` [PATCH 1/8 v2] fstests: " Dave Chinner
@ 2022-06-03  2:43     ` Darrick J. Wong
  2022-06-03  4:55       ` Zorro Lang
  0 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2022-06-03  2:43 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests

On Fri, Jun 03, 2022 at 11:41:12AM +1000, Dave Chinner wrote:
> From: Allison Henderson <allison.henderson@oracle.com>
> 
> This patch adds tests to exercise the log attribute error
> inject and log replay. These tests aim to cover cases where attributes
> are added, removed, and overwritten in each format (shortform, leaf,
> node). Error inject is used to replay these operations from the log.
> 
> dchinner: sanitise md5sum input to just attr values.
> dchinner: correct md5sums.
> dchinner: ensure replace tests use different values so recovery can
>           determine the replace was replayed correctly.
> dchinner: don't remove corpse in _cleanup - scratch devices don't
> 	  require cleanup, and if the test fails we want to leave
> 	  the broken state for post-mortem analysis.
> dchinner: only run on v5 filesystems.
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> V2:
> - redirected attr get failure messages to /dev/null rather than
>   have to filter them. The md5sum tells us that the attr didn't
>   exist.
> 
>  tests/xfs/600     | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/600.out | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 347 insertions(+)
> 
> diff --git a/tests/xfs/600 b/tests/xfs/600
> new file mode 100755
> index 00000000..bc9415ec
> --- /dev/null
> +++ b/tests/xfs/600
> @@ -0,0 +1,179 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# FS QA Test 600
> +#
> +# Log attribute replay test
> +#
> +. ./common/preamble
> +_begin_fstest auto quick attr
> +
> +# get standard environment, filters and checks
> +. ./common/filter
> +. ./common/attr
> +. ./common/inject
> +
> +_cleanup()
> +{
> +	rm -rf $tmp.*
> +	test -w /sys/fs/xfs/debug/larp && \
> +		echo 0 > /sys/fs/xfs/debug/larp

Probably ought to restore the old value, but otherwise the logic in here
looks solid enough.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +}
> +
> +test_attr_replay()
> +{
> +	testfile=$testdir/$1
> +	attr_name=$2
> +	attr_value=$3
> +	flag=$4
> +	error_tag=$5
> +
> +	# Inject error
> +	_scratch_inject_error $error_tag
> +
> +	# Set attribute
> +	echo "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
> +			    _filter_scratch
> +
> +	# FS should be shut down, touch will fail
> +	touch $testfile 2>&1 | _filter_scratch
> +
> +	# Remount to replay log
> +	_scratch_remount_dump_log >> $seqres.full
> +
> +	# FS should be online, touch should succeed
> +	touch $testfile
> +
> +	# Verify attr recovery
> +	$ATTR_PROG -l $testfile | _filter_scratch
> +	echo -n "$attr_name: "
> +	$ATTR_PROG -q -g $attr_name $testfile 2> /dev/null | md5sum;
> +
> +	echo ""
> +}
> +
> +create_test_file()
> +{
> +	filename=$testdir/$1
> +	count=$2
> +	attr_value=$3
> +
> +	touch $filename
> +
> +	for i in `seq $count`
> +	do
> +		$ATTR_PROG -s "attr_name$i" -V $attr_value $filename >> \
> +			$seqres.full
> +	done
> +}
> +
> +# real QA test starts here
> +_supported_fs xfs
> +
> +_require_scratch
> +_require_scratch_xfs_crc
> +_require_attrs
> +_require_xfs_io_error_injection "larp"
> +_require_xfs_io_error_injection "da_leaf_split"
> +_require_xfs_io_error_injection "attr_leaf_to_node"
> +_require_xfs_sysfs debug/larp
> +test -w /sys/fs/xfs/debug/larp || _notrun "larp knob not writable"
> +
> +# turn on log attributes
> +echo 1 > /sys/fs/xfs/debug/larp
> +
> +attr16="0123456789ABCDEF"
> +attr64="$attr16$attr16$attr16$attr16"
> +attr256="$attr64$attr64$attr64$attr64"
> +attr1k="$attr256$attr256$attr256$attr256"
> +attr4k="$attr1k$attr1k$attr1k$attr1k"
> +attr8k="$attr4k$attr4k"
> +attr16k="$attr8k$attr8k"
> +attr32k="$attr16k$attr16k"
> +attr64k="$attr32k$attr32k"
> +
> +echo "*** mkfs"
> +_scratch_mkfs >/dev/null
> +
> +echo "*** mount FS"
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT/testdir
> +mkdir $testdir
> +
> +# empty, inline
> +create_test_file empty_file1 0
> +test_attr_replay empty_file1 "attr_name" $attr64 "s" "larp"
> +test_attr_replay empty_file1 "attr_name" $attr64 "r" "larp"
> +
> +# empty, internal
> +create_test_file empty_file2 0
> +test_attr_replay empty_file2 "attr_name" $attr1k "s" "larp"
> +test_attr_replay empty_file2 "attr_name" $attr1k "r" "larp"
> +
> +# empty, remote
> +create_test_file empty_file3 0
> +test_attr_replay empty_file3 "attr_name" $attr64k "s" "larp"
> +test_attr_replay empty_file3 "attr_name" $attr64k "r" "larp"
> +
> +# inline, inline
> +create_test_file inline_file1 1 $attr16
> +test_attr_replay inline_file1 "attr_name2" $attr64 "s" "larp"
> +test_attr_replay inline_file1 "attr_name2" $attr64 "r" "larp"
> +
> +# inline, internal
> +create_test_file inline_file2 1 $attr16
> +test_attr_replay inline_file2 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay inline_file2 "attr_name2" $attr1k "r" "larp"
> +
> +# inline, remote
> +create_test_file inline_file3 1 $attr16
> +test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
> +
> +# extent, internal
> +create_test_file extent_file1 1 $attr1k
> +test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay extent_file1 "attr_name2" $attr1k "r" "larp"
> +
> +# extent, inject error on split
> +create_test_file extent_file2 3 $attr1k
> +test_attr_replay extent_file2 "attr_name4" $attr1k "s" "da_leaf_split"
> +
> +# extent, inject error on fork transition
> +create_test_file extent_file3 3 $attr1k
> +test_attr_replay extent_file3 "attr_name4" $attr1k "s" "attr_leaf_to_node"
> +
> +# extent, remote
> +create_test_file extent_file4 1 $attr1k
> +test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
> +
> +# remote, internal
> +create_test_file remote_file1 1 $attr64k
> +test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
> +test_attr_replay remote_file1 "attr_name2" $attr1k "r" "larp"
> +
> +# remote, remote
> +create_test_file remote_file2 1 $attr64k
> +test_attr_replay remote_file2 "attr_name2" $attr64k "s" "larp"
> +test_attr_replay remote_file2 "attr_name2" $attr64k "r" "larp"
> +
> +# replace shortform with different value
> +create_test_file sf_file 2 $attr64
> +test_attr_replay sf_file "attr_name2" $attr16 "s" "larp"
> +
> +# replace leaf with different value
> +create_test_file leaf_file 3 $attr1k
> +test_attr_replay leaf_file "attr_name2" $attr256 "s" "larp"
> +
> +# replace node with a different value
> +create_test_file node_file 1 $attr64k
> +$ATTR_PROG -s "attr_name2" -V $attr1k $testdir/node_file \
> +		>> $seqres.full
> +test_attr_replay node_file "attr_name2" $attr256 "s" "larp"
> +
> +echo "*** done"
> +status=0
> +exit
> diff --git a/tests/xfs/600.out b/tests/xfs/600.out
> new file mode 100644
> index 00000000..259b05ee
> --- /dev/null
> +++ b/tests/xfs/600.out
> @@ -0,0 +1,168 @@
> +QA output created by 600
> +*** mkfs
> +*** mount FS
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> +Attribute "attr_name" has a 65 byte value for SCRATCH_MNT/testdir/empty_file1
> +attr_name: cfbe2a33be4601d2b655d099a18378fc  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> +Attribute "attr_name" has a 1025 byte value for SCRATCH_MNT/testdir/empty_file2
> +attr_name: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> +Attribute "attr_name" has a 65536 byte value for SCRATCH_MNT/testdir/empty_file3
> +attr_name: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> +Attribute "attr_name2" has a 65 byte value for SCRATCH_MNT/testdir/inline_file1
> +attr_name2: cfbe2a33be4601d2b655d099a18378fc  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/inline_file2
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/inline_file3
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file1
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file2': Input/output error
> +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file3
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file3': Input/output error
> +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/extent_file4
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/remote_file1
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> +
> +attr_remove: Input/output error
> +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/sf_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/sf_file': Input/output error
> +Attribute "attr_name1" has a 64 byte value for SCRATCH_MNT/testdir/sf_file
> +Attribute "attr_name2" has a 17 byte value for SCRATCH_MNT/testdir/sf_file
> +attr_name2: 9a6eb1bc9da3c66a9b495dfe2fe8a756  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/leaf_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/leaf_file': Input/output error
> +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/leaf_file
> +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> +
> +attr_set: Input/output error
> +Could not set "attr_name2" for SCRATCH_MNT/testdir/node_file
> +touch: cannot touch 'SCRATCH_MNT/testdir/node_file': Input/output error
> +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/node_file
> +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/node_file
> +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> +
> +*** done
> -- 
> Dave Chinner
> david@fromorbit.com

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

* Re: [PATCH 1/8 v2] fstests: Add Log Attribute Replay test
  2022-06-03  2:43     ` Darrick J. Wong
@ 2022-06-03  4:55       ` Zorro Lang
  2022-06-03  5:29         ` Dave Chinner
  0 siblings, 1 reply; 23+ messages in thread
From: Zorro Lang @ 2022-06-03  4:55 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Dave Chinner, fstests

On Thu, Jun 02, 2022 at 07:43:21PM -0700, Darrick J. Wong wrote:
> On Fri, Jun 03, 2022 at 11:41:12AM +1000, Dave Chinner wrote:
> > From: Allison Henderson <allison.henderson@oracle.com>
> > 
> > This patch adds tests to exercise the log attribute error
> > inject and log replay. These tests aim to cover cases where attributes
> > are added, removed, and overwritten in each format (shortform, leaf,
> > node). Error inject is used to replay these operations from the log.
> > 
> > dchinner: sanitise md5sum input to just attr values.
> > dchinner: correct md5sums.
> > dchinner: ensure replace tests use different values so recovery can
> >           determine the replace was replayed correctly.
> > dchinner: don't remove corpse in _cleanup - scratch devices don't
> > 	  require cleanup, and if the test fails we want to leave
> > 	  the broken state for post-mortem analysis.
> > dchinner: only run on v5 filesystems.
> > 
> > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> > V2:
> > - redirected attr get failure messages to /dev/null rather than
> >   have to filter them. The md5sum tells us that the attr didn't
> >   exist.
> > 
> >  tests/xfs/600     | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/600.out | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 347 insertions(+)
> > 
> > diff --git a/tests/xfs/600 b/tests/xfs/600
> > new file mode 100755
> > index 00000000..bc9415ec
> > --- /dev/null
> > +++ b/tests/xfs/600
> > @@ -0,0 +1,179 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> > +#
> > +# FS QA Test 600
> > +#
> > +# Log attribute replay test
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto quick attr
> > +
> > +# get standard environment, filters and checks
> > +. ./common/filter
> > +. ./common/attr
> > +. ./common/inject
> > +
> > +_cleanup()
> > +{
> > +	rm -rf $tmp.*
> > +	test -w /sys/fs/xfs/debug/larp && \
> > +		echo 0 > /sys/fs/xfs/debug/larp
> 
> Probably ought to restore the old value, but otherwise the logic in here
> looks solid enough.

I can help that when I merge it this week.

BTW, I saw the "[PATCH 00/15] xfs: Log Attribute Replay" patchset has been
merged by mainline linux. So I suspose it's time to merge this patch. Please
tell me if it's still not the time. As I know there's not only one patchset
is related with this.

And I'll really appreciate that, if any of you would like to list all related
patchset titles (from kernel and userspace) to help this case test pass :)

Thanks,
Zorro

> 
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
> > +}
> > +
> > +test_attr_replay()
> > +{
> > +	testfile=$testdir/$1
> > +	attr_name=$2
> > +	attr_value=$3
> > +	flag=$4
> > +	error_tag=$5
> > +
> > +	# Inject error
> > +	_scratch_inject_error $error_tag
> > +
> > +	# Set attribute
> > +	echo "$attr_value" | ${ATTR_PROG} -$flag "$attr_name" $testfile 2>&1 | \
> > +			    _filter_scratch
> > +
> > +	# FS should be shut down, touch will fail
> > +	touch $testfile 2>&1 | _filter_scratch
> > +
> > +	# Remount to replay log
> > +	_scratch_remount_dump_log >> $seqres.full
> > +
> > +	# FS should be online, touch should succeed
> > +	touch $testfile
> > +
> > +	# Verify attr recovery
> > +	$ATTR_PROG -l $testfile | _filter_scratch
> > +	echo -n "$attr_name: "
> > +	$ATTR_PROG -q -g $attr_name $testfile 2> /dev/null | md5sum;
> > +
> > +	echo ""
> > +}
> > +
> > +create_test_file()
> > +{
> > +	filename=$testdir/$1
> > +	count=$2
> > +	attr_value=$3
> > +
> > +	touch $filename
> > +
> > +	for i in `seq $count`
> > +	do
> > +		$ATTR_PROG -s "attr_name$i" -V $attr_value $filename >> \
> > +			$seqres.full
> > +	done
> > +}
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +
> > +_require_scratch
> > +_require_scratch_xfs_crc
> > +_require_attrs
> > +_require_xfs_io_error_injection "larp"
> > +_require_xfs_io_error_injection "da_leaf_split"
> > +_require_xfs_io_error_injection "attr_leaf_to_node"
> > +_require_xfs_sysfs debug/larp
> > +test -w /sys/fs/xfs/debug/larp || _notrun "larp knob not writable"
> > +
> > +# turn on log attributes
> > +echo 1 > /sys/fs/xfs/debug/larp
> > +
> > +attr16="0123456789ABCDEF"
> > +attr64="$attr16$attr16$attr16$attr16"
> > +attr256="$attr64$attr64$attr64$attr64"
> > +attr1k="$attr256$attr256$attr256$attr256"
> > +attr4k="$attr1k$attr1k$attr1k$attr1k"
> > +attr8k="$attr4k$attr4k"
> > +attr16k="$attr8k$attr8k"
> > +attr32k="$attr16k$attr16k"
> > +attr64k="$attr32k$attr32k"
> > +
> > +echo "*** mkfs"
> > +_scratch_mkfs >/dev/null
> > +
> > +echo "*** mount FS"
> > +_scratch_mount
> > +
> > +testdir=$SCRATCH_MNT/testdir
> > +mkdir $testdir
> > +
> > +# empty, inline
> > +create_test_file empty_file1 0
> > +test_attr_replay empty_file1 "attr_name" $attr64 "s" "larp"
> > +test_attr_replay empty_file1 "attr_name" $attr64 "r" "larp"
> > +
> > +# empty, internal
> > +create_test_file empty_file2 0
> > +test_attr_replay empty_file2 "attr_name" $attr1k "s" "larp"
> > +test_attr_replay empty_file2 "attr_name" $attr1k "r" "larp"
> > +
> > +# empty, remote
> > +create_test_file empty_file3 0
> > +test_attr_replay empty_file3 "attr_name" $attr64k "s" "larp"
> > +test_attr_replay empty_file3 "attr_name" $attr64k "r" "larp"
> > +
> > +# inline, inline
> > +create_test_file inline_file1 1 $attr16
> > +test_attr_replay inline_file1 "attr_name2" $attr64 "s" "larp"
> > +test_attr_replay inline_file1 "attr_name2" $attr64 "r" "larp"
> > +
> > +# inline, internal
> > +create_test_file inline_file2 1 $attr16
> > +test_attr_replay inline_file2 "attr_name2" $attr1k "s" "larp"
> > +test_attr_replay inline_file2 "attr_name2" $attr1k "r" "larp"
> > +
> > +# inline, remote
> > +create_test_file inline_file3 1 $attr16
> > +test_attr_replay inline_file3 "attr_name2" $attr64k "s" "larp"
> > +test_attr_replay inline_file3 "attr_name2" $attr64k "r" "larp"
> > +
> > +# extent, internal
> > +create_test_file extent_file1 1 $attr1k
> > +test_attr_replay extent_file1 "attr_name2" $attr1k "s" "larp"
> > +test_attr_replay extent_file1 "attr_name2" $attr1k "r" "larp"
> > +
> > +# extent, inject error on split
> > +create_test_file extent_file2 3 $attr1k
> > +test_attr_replay extent_file2 "attr_name4" $attr1k "s" "da_leaf_split"
> > +
> > +# extent, inject error on fork transition
> > +create_test_file extent_file3 3 $attr1k
> > +test_attr_replay extent_file3 "attr_name4" $attr1k "s" "attr_leaf_to_node"
> > +
> > +# extent, remote
> > +create_test_file extent_file4 1 $attr1k
> > +test_attr_replay extent_file4 "attr_name2" $attr64k "s" "larp"
> > +test_attr_replay extent_file4 "attr_name2" $attr64k "r" "larp"
> > +
> > +# remote, internal
> > +create_test_file remote_file1 1 $attr64k
> > +test_attr_replay remote_file1 "attr_name2" $attr1k "s" "larp"
> > +test_attr_replay remote_file1 "attr_name2" $attr1k "r" "larp"
> > +
> > +# remote, remote
> > +create_test_file remote_file2 1 $attr64k
> > +test_attr_replay remote_file2 "attr_name2" $attr64k "s" "larp"
> > +test_attr_replay remote_file2 "attr_name2" $attr64k "r" "larp"
> > +
> > +# replace shortform with different value
> > +create_test_file sf_file 2 $attr64
> > +test_attr_replay sf_file "attr_name2" $attr16 "s" "larp"
> > +
> > +# replace leaf with different value
> > +create_test_file leaf_file 3 $attr1k
> > +test_attr_replay leaf_file "attr_name2" $attr256 "s" "larp"
> > +
> > +# replace node with a different value
> > +create_test_file node_file 1 $attr64k
> > +$ATTR_PROG -s "attr_name2" -V $attr1k $testdir/node_file \
> > +		>> $seqres.full
> > +test_attr_replay node_file "attr_name2" $attr256 "s" "larp"
> > +
> > +echo "*** done"
> > +status=0
> > +exit
> > diff --git a/tests/xfs/600.out b/tests/xfs/600.out
> > new file mode 100644
> > index 00000000..259b05ee
> > --- /dev/null
> > +++ b/tests/xfs/600.out
> > @@ -0,0 +1,168 @@
> > +QA output created by 600
> > +*** mkfs
> > +*** mount FS
> > +attr_set: Input/output error
> > +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> > +Attribute "attr_name" has a 65 byte value for SCRATCH_MNT/testdir/empty_file1
> > +attr_name: cfbe2a33be4601d2b655d099a18378fc  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file1': Input/output error
> > +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> > +Attribute "attr_name" has a 1025 byte value for SCRATCH_MNT/testdir/empty_file2
> > +attr_name: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file2': Input/output error
> > +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name" for SCRATCH_MNT/testdir/empty_file3
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> > +Attribute "attr_name" has a 65536 byte value for SCRATCH_MNT/testdir/empty_file3
> > +attr_name: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name" for SCRATCH_MNT/testdir/empty_file3
> > +touch: cannot touch 'SCRATCH_MNT/testdir/empty_file3': Input/output error
> > +attr_name: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> > +Attribute "attr_name2" has a 65 byte value for SCRATCH_MNT/testdir/inline_file1
> > +attr_name2: cfbe2a33be4601d2b655d099a18378fc  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file1': Input/output error
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file1
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> > +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/inline_file2
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> > +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file2': Input/output error
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file2
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> > +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/inline_file3
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> > +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/inline_file3
> > +touch: cannot touch 'SCRATCH_MNT/testdir/inline_file3': Input/output error
> > +Attribute "attr_name1" has a 16 byte value for SCRATCH_MNT/testdir/inline_file3
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> > +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file1
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> > +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file1': Input/output error
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file1
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file2': Input/output error
> > +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file2
> > +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> > +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file2
> > +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name4" for SCRATCH_MNT/testdir/extent_file3
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file3': Input/output error
> > +Attribute "attr_name4" has a 1025 byte value for SCRATCH_MNT/testdir/extent_file3
> > +Attribute "attr_name2" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> > +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file3
> > +attr_name4: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> > +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/extent_file4
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> > +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/extent_file4
> > +touch: cannot touch 'SCRATCH_MNT/testdir/extent_file4': Input/output error
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/extent_file4
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> > +Attribute "attr_name2" has a 1025 byte value for SCRATCH_MNT/testdir/remote_file1
> > +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> > +attr_name2: 9fd415c49d67afc4b78fad4055a3a376  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file1
> > +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file1': Input/output error
> > +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file1
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> > +Attribute "attr_name2" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> > +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> > +attr_name2: 7f6fd1b6d872108bd44bd143cbcdfa19  -
> > +
> > +attr_remove: Input/output error
> > +Could not remove "attr_name2" for SCRATCH_MNT/testdir/remote_file2
> > +touch: cannot touch 'SCRATCH_MNT/testdir/remote_file2': Input/output error
> > +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/remote_file2
> > +attr_name2: d41d8cd98f00b204e9800998ecf8427e  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/sf_file
> > +touch: cannot touch 'SCRATCH_MNT/testdir/sf_file': Input/output error
> > +Attribute "attr_name1" has a 64 byte value for SCRATCH_MNT/testdir/sf_file
> > +Attribute "attr_name2" has a 17 byte value for SCRATCH_MNT/testdir/sf_file
> > +attr_name2: 9a6eb1bc9da3c66a9b495dfe2fe8a756  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/leaf_file
> > +touch: cannot touch 'SCRATCH_MNT/testdir/leaf_file': Input/output error
> > +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/leaf_file
> > +Attribute "attr_name3" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> > +Attribute "attr_name1" has a 1024 byte value for SCRATCH_MNT/testdir/leaf_file
> > +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> > +
> > +attr_set: Input/output error
> > +Could not set "attr_name2" for SCRATCH_MNT/testdir/node_file
> > +touch: cannot touch 'SCRATCH_MNT/testdir/node_file': Input/output error
> > +Attribute "attr_name2" has a 257 byte value for SCRATCH_MNT/testdir/node_file
> > +Attribute "attr_name1" has a 65536 byte value for SCRATCH_MNT/testdir/node_file
> > +attr_name2: f4ea5799d72a0a9bf2d56a685c9cba7a  -
> > +
> > +*** done
> > -- 
> > Dave Chinner
> > david@fromorbit.com
> 


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

* Re: [PATCH 1/8 v2] fstests: Add Log Attribute Replay test
  2022-06-03  4:55       ` Zorro Lang
@ 2022-06-03  5:29         ` Dave Chinner
  0 siblings, 0 replies; 23+ messages in thread
From: Dave Chinner @ 2022-06-03  5:29 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, fstests

On Fri, Jun 03, 2022 at 12:55:04PM +0800, Zorro Lang wrote:
> On Thu, Jun 02, 2022 at 07:43:21PM -0700, Darrick J. Wong wrote:
> > On Fri, Jun 03, 2022 at 11:41:12AM +1000, Dave Chinner wrote:
> > > From: Allison Henderson <allison.henderson@oracle.com>
> > > 
> > > This patch adds tests to exercise the log attribute error
> > > inject and log replay. These tests aim to cover cases where attributes
> > > are added, removed, and overwritten in each format (shortform, leaf,
> > > node). Error inject is used to replay these operations from the log.
> > > 
> > > dchinner: sanitise md5sum input to just attr values.
> > > dchinner: correct md5sums.
> > > dchinner: ensure replace tests use different values so recovery can
> > >           determine the replace was replayed correctly.
> > > dchinner: don't remove corpse in _cleanup - scratch devices don't
> > > 	  require cleanup, and if the test fails we want to leave
> > > 	  the broken state for post-mortem analysis.
> > > dchinner: only run on v5 filesystems.
> > > 
> > > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > > ---
> > > V2:
> > > - redirected attr get failure messages to /dev/null rather than
> > >   have to filter them. The md5sum tells us that the attr didn't
> > >   exist.
> > > 
> > >  tests/xfs/600     | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  tests/xfs/600.out | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  2 files changed, 347 insertions(+)
> > > 
> > > diff --git a/tests/xfs/600 b/tests/xfs/600
> > > new file mode 100755
> > > index 00000000..bc9415ec
> > > --- /dev/null
> > > +++ b/tests/xfs/600
> > > @@ -0,0 +1,179 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> > > +#
> > > +# FS QA Test 600
> > > +#
> > > +# Log attribute replay test
> > > +#
> > > +. ./common/preamble
> > > +_begin_fstest auto quick attr
> > > +
> > > +# get standard environment, filters and checks
> > > +. ./common/filter
> > > +. ./common/attr
> > > +. ./common/inject
> > > +
> > > +_cleanup()
> > > +{
> > > +	rm -rf $tmp.*
> > > +	test -w /sys/fs/xfs/debug/larp && \
> > > +		echo 0 > /sys/fs/xfs/debug/larp
> > 
> > Probably ought to restore the old value, but otherwise the logic in here
> > looks solid enough.
> 
> I can help that when I merge it this week.
> 
> BTW, I saw the "[PATCH 00/15] xfs: Log Attribute Replay" patchset has been
> merged by mainline linux. So I suspose it's time to merge this patch. Please
> tell me if it's still not the time. As I know there's not only one patchset
> is related with this.

I wanted it merged two weeks ago because we merged LARP into the XFS
for-next tree a month ago. We need tests merged when the changes go
into the for-next tree, not when the for-next tree gets merged into
Linus's tree weeks later....

> And I'll really appreciate that, if any of you would like to list all related
> patchset titles (from kernel and userspace) to help this case test pass :)

I'm not going to attempt to find the 6 or 7 patchset and list them.
They are all merged into 5.19, so use that kernel. For userspace,
use the libxfs-5.19-sync branch I pushed out earlier in the week:

https://lore.kernel.org/linux-xfs/20220601010636.GC227878@dread.disaster.area/T/#u

That contains all the 5.19 kernel changes and the userspace support
for large extent counters and LARP, including all the error
injection stuff that the various tests use.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

end of thread, other threads:[~2022-06-03  5:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  0:31 fstests: new tests and various fixes Dave Chinner
2022-06-02  0:31 ` [PATCH 1/8] xfstests: Add Log Attribute Replay test Dave Chinner
2022-06-02  1:05   ` Darrick J. Wong
2022-06-03  1:41   ` [PATCH 1/8 v2] fstests: " Dave Chinner
2022-06-03  2:43     ` Darrick J. Wong
2022-06-03  4:55       ` Zorro Lang
2022-06-03  5:29         ` Dave Chinner
2022-06-02  0:31 ` [PATCH 2/8] README: document _begin_fstests better Dave Chinner
2022-06-02  0:51   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 3/8] generic/081: don't run on DAX capable devices Dave Chinner
2022-06-02  2:03   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 4/8] generic/038: kill background threads on interrupt Dave Chinner
2022-06-02  0:51   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 5/8] xfs/538: fix fsstress scaling Dave Chinner
2022-06-02  0:52   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 6/8] xfs/070: filter the bad sb magic number error Dave Chinner
2022-06-02  0:52   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 7/8] xfs/167: adjust runtime with TIME_FACTOR Dave Chinner
2022-06-02  0:53   ` Darrick J. Wong
2022-06-02  0:31 ` [PATCH 8/8] xfs/189: systemd monitoring of /etc/fstab sucks Dave Chinner
2022-06-02  1:04   ` Darrick J. Wong
2022-06-03  1:54   ` [PATCH 8/8 v2] " Dave Chinner
2022-06-03  2:41     ` 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.