All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] fstests: fix various problems
@ 2018-12-18 20:35 Darrick J. Wong
  2018-12-18 20:35 ` [PATCH 1/5] xfs/111: fix golden output Darrick J. Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:35 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

Hi all,

Here are some fixes for various fstests failures.

Patch 1 fixes a weird porting problem in xfs/111 when it was converted
to use xfs_fsr.

Patch 2 fixes xfs/123 to eliminate a corruption error in the golden
output on 1k v5 filesystems.

Patch 3 is a revised version of a previous patch that works around the
fact that mounting xfs with quotas requires a writable block device even
for a ro mount, which leads to a slightly different error message from
the mount call.

Patch 4 adds a new test to look for forgotten TRACE_DEFINE_ENUM wrappers
for xfs enums that are used as part of __print_symbolic() calls in the
trace points.

Patch 5 is the same old patch that filters v5 mount options out of
MOUNT_OPTIONS when the test formats a v4 filesystem, rather than letting
the test fail due to bad mount options.

--D

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

* [PATCH 1/5] xfs/111: fix golden output
  2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
@ 2018-12-18 20:35 ` Darrick J. Wong
  2018-12-18 20:35 ` [PATCH 2/5] xfs/123: fix remote symlink block size calculation Darrick J. Wong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:35 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

In commit f4eee5126, this test was changed to run xfs_fsr to bulkstat
its way through the filesystem until it finds the corrupt inode.  The
golden output was changed to capture xfs_fsr's output, but neglects the
fact that when fsr's output is not a tty, all the status and error
messages are sent to syslog, not stdout.  Therefore, this test
consistently fails because it expects output of "$SCRATCH_MNT start
inode=0" but this never appears.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/111     |    2 +-
 tests/xfs/111.out |    1 -
 2 files changed, 1 insertion(+), 2 deletions(-)


diff --git a/tests/xfs/111 b/tests/xfs/111
index 2ef69f07..965eb625 100755
--- a/tests/xfs/111
+++ b/tests/xfs/111
@@ -58,7 +58,7 @@ _try_scratch_mount || _fail "Couldn't mount after itrash"
 
 echo Attempting bulkstat
 #src/bstat -q $SCRATCH_MNT
-$XFS_FSR_PROG $SCRATCH_MNT | _filter_scratch
+$XFS_FSR_PROG -g $SCRATCH_MNT | _filter_scratch
 
 # Fix up intentional corruption so test can pass
 _scratch_unmount
diff --git a/tests/xfs/111.out b/tests/xfs/111.out
index fd56c3c8..41fa48f8 100644
--- a/tests/xfs/111.out
+++ b/tests/xfs/111.out
@@ -10,4 +10,3 @@ Blat inode clusters
 Starting overwrite
 Overwrite complete
 Attempting bulkstat
-SCRATCH_MNT start inode=0

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

* [PATCH 2/5] xfs/123: fix remote symlink block size calculation
  2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
  2018-12-18 20:35 ` [PATCH 1/5] xfs/111: fix golden output Darrick J. Wong
@ 2018-12-18 20:35 ` Darrick J. Wong
  2018-12-18 20:36 ` [PATCH 3/5] generic/050: fix ro blockdev mount of xfs with quota Darrick J. Wong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:35 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

In this test we try to create a remote symlink block by creating a
symlink target buffer large enough to exceed the size of an inode.
Unfortunately we don't use the correct block size or symlink header
size, which on a 1k block filesystem causes there to be two remote
blocks.  This causes crc verification errors in xfs_db (because it's too
dumb to load both blocks as one like the kernel does) which we don't
care about because we're about to corrupt the block anyway.

So, fix the block size calculation so that we end up with one block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/123 |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


diff --git a/tests/xfs/123 b/tests/xfs/123
index 8a494ef9..f45e94bf 100755
--- a/tests/xfs/123
+++ b/tests/xfs/123
@@ -46,11 +46,12 @@ _scratch_mkfs_xfs > /dev/null
 
 echo "+ mount fs image"
 _scratch_mount
-blksz=1000
+blksz=1024
 
 echo "+ make some files"
 echo "file contents: moo" > "${SCRATCH_MNT}/x"
-str="$(perl -e "print './' x $(( (blksz / 2) - 16));")x"
+reps=$(( (blksz - (56 + 1)) / 2 ))
+str="$(perl -e "print './' x $reps;")x"
 (cd $SCRATCH_MNT; ln -s "${str}" "long_symlink")
 cat "${SCRATCH_MNT}/long_symlink"
 inode="$(stat -c '%i' "${SCRATCH_MNT}/long_symlink")"
@@ -60,7 +61,7 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 4)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 if _try_scratch_mount >> $seqres.full 2>&1; then

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

* [PATCH 3/5] generic/050: fix ro blockdev mount of xfs with quota
  2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
  2018-12-18 20:35 ` [PATCH 1/5] xfs/111: fix golden output Darrick J. Wong
  2018-12-18 20:35 ` [PATCH 2/5] xfs/123: fix remote symlink block size calculation Darrick J. Wong
@ 2018-12-18 20:36 ` Darrick J. Wong
  2018-12-18 20:36 ` [PATCH 4/5] xfs: look for stringified constants in ftrace formats Darrick J. Wong
  2018-12-18 20:36 ` [PATCH 5/5] xfs: filter out mount options that don't work on v4 filesystems Darrick J. Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:36 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

In XFS, mounting with quota always require a writable device.  If the
block device is read only, the mount fails, which fails this test.
Since this is expected, work around this by simulating the golden output
when we expect a mount failure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/050 |   62 +++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 46 insertions(+), 16 deletions(-)


diff --git a/tests/generic/050 b/tests/generic/050
index 90e924db..9a327165 100755
--- a/tests/generic/050
+++ b/tests/generic/050
@@ -36,6 +36,22 @@ _require_norecovery
 
 _scratch_mkfs >/dev/null 2>&1
 
+filter_ro_mount() {
+	local arg=""
+
+	if [ -n "$expect_mount_failure" ]; then
+		arg="s|mount: $SCRATCH_MNT: permission denied|mount: device write-protected, mounting read-only|g"
+	fi
+	sed -e "$arg" | _filter_ro_mount
+}
+
+# Mounting with quota on XFS requires a writable fs, which means
+# we expect to fail the ro blockdev test with with EPERM.
+expect_mount_failure=
+if [ "$FSTYP" = "xfs" ] && echo "$MOUNT_OPTIONS" | grep -q quota ; then
+	expect_mount_failure=1
+fi
+
 #
 # Mark the device read-only
 #
@@ -46,17 +62,25 @@ blockdev --setro $SCRATCH_DEV
 # Mount it, and make sure we can't write to it, and we can unmount it again
 #
 echo "mounting read-only block device:"
-_try_scratch_mount 2>&1 | _filter_ro_mount
-
-echo "touching file on read-only filesystem (should fail)"
-touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
-
-#
-# Apparently this used to be broken at some point:
-#	http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
-#
-echo "unmounting read-only filesystem"
-_scratch_unmount 2>&1 | _filter_scratch
+_try_scratch_mount 2>&1 | filter_ro_mount
+if [ "${PIPESTATUS[0]}" -eq 0 ]; then
+	echo "touching file on read-only filesystem (should fail)"
+	touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+
+	#
+	# Apparently this used to be broken at some point:
+	#	http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
+	#
+	echo "unmounting read-only filesystem"
+	_scratch_unmount 2>&1 | _filter_scratch
+elif [ -n "${expect_mount_failure}" ]; then
+	# Mount failed, so simulate EROFS instead of scribbling on root fs
+	echo "touching file on read-only filesystem (should fail)"
+	echo "touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system"
+	echo "unmounting read-only filesystem"
+else
+	echo "Mount failed, though it wasn't supposed to!"
+fi
 
 echo "setting device read-write"
 blockdev --setrw $SCRATCH_DEV
@@ -88,14 +112,20 @@ _scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 
 #
 # This is the way out if the underlying device really is read-only.
-# Doesn't mean it's a good idea in practive, more a last resort
+# Doesn't mean it's a good idea in practice, more a last resort
 # data recovery hack.
 #
 echo "mounting filesystem with -o norecovery on a read-only device:"
-_try_scratch_mount -o norecovery 2>&1 | _filter_ro_mount
-
-echo "unmounting read-only filesystem"
-_scratch_unmount 2>&1 | _filter_scratch
+_try_scratch_mount -o norecovery 2>&1 | filter_ro_mount
+if [ "${PIPESTATUS[0]}" -eq 0 ]; then
+	echo "unmounting read-only filesystem"
+	_scratch_unmount 2>&1 | _filter_scratch
+elif [ -n "${expect_mount_failure}" ]; then
+	# Mount failed, simulate correct output
+	echo "unmounting read-only filesystem"
+else
+	echo "Mount failed, though it wasn't supposed to!"
+fi
 
 echo "setting device read-write"
 blockdev --setrw $SCRATCH_DEV

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

* [PATCH 4/5] xfs: look for stringified constants in ftrace formats
  2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
                   ` (2 preceding siblings ...)
  2018-12-18 20:36 ` [PATCH 3/5] generic/050: fix ro blockdev mount of xfs with quota Darrick J. Wong
@ 2018-12-18 20:36 ` Darrick J. Wong
  2018-12-18 20:36 ` [PATCH 5/5] xfs: filter out mount options that don't work on v4 filesystems Darrick J. Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:36 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

Look for uninterpretable stringified constants in the ftrace format
description for xfs tracepoints.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/735     |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/735.out |    3 ++
 tests/xfs/group   |    1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/xfs/735
 create mode 100644 tests/xfs/735.out


diff --git a/tests/xfs/735 b/tests/xfs/735
new file mode 100755
index 00000000..d5f4eba0
--- /dev/null
+++ b/tests/xfs/735
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 735
+#
+# Look for stringified constants in the __print_symbolic format strings,
+# which suggest that we forgot to TRACE_DEFINE_ENUM somewhere, which causes
+# incomplete ftrace reporting.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+
+cprog=$tmp.ftrace.c
+oprog=$tmp.ftrace
+sedprog=$tmp.ftrace.sed
+
+ftrace_dir=/sys/kernel/debug/tracing/events/xfs
+
+test -d $ftrace_dir || _notrun "ftrace not enabled"
+
+# The second argument to __print_symbolic is stringified in the tracepoint's
+# fmt file, so we look for "{ NUM, STRING }" and try to separate each of them
+# into single lines so that we can build a C structure.  This will (we hope)
+# catch non-constant numbers that the compiler won't know about.
+cat > $sedprog << ENDL
+s/}, /},\n/g
+s/}),/},\n/g
+s/})/},\n/g
+s/, {/\n{/g
+ENDL
+
+cat > $cprog << ENDL
+struct ftrace_chk {
+	unsigned long long	num;
+	char			*str;
+} syms[] = {
+ENDL
+egrep '(__print_flags|__print_symbolic)' $ftrace_dir*/*/format | \
+	sed -f $sedprog | grep '^{' | sort | uniq >> $cprog
+cat >> $cprog << ENDL
+};
+
+int main(int argc, char *argv[]) { return 0; }
+ENDL
+
+cat $cprog >> $seqres.full
+echo Compiler errors imply missing TRACE_DEFINE_ENUM.
+cc -o $oprog $cprog
+
+# success, all done
+echo Silence is golden
+status=0
+exit
diff --git a/tests/xfs/735.out b/tests/xfs/735.out
new file mode 100644
index 00000000..844cea1d
--- /dev/null
+++ b/tests/xfs/735.out
@@ -0,0 +1,3 @@
+QA output created by 735
+Compiler errors imply missing TRACE_DEFINE_ENUM.
+Silence is golden
diff --git a/tests/xfs/group b/tests/xfs/group
index dfaae2bc..4a986af3 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -496,3 +496,4 @@
 496 dangerous_fuzzers dangerous_scrub dangerous_repair
 497 dangerous_fuzzers dangerous_scrub dangerous_online_repair
 498 dangerous_fuzzers dangerous_norepair
+735 auto quick

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

* [PATCH 5/5] xfs: filter out mount options that don't work on v4 filesystems
  2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
                   ` (3 preceding siblings ...)
  2018-12-18 20:36 ` [PATCH 4/5] xfs: look for stringified constants in ftrace formats Darrick J. Wong
@ 2018-12-18 20:36 ` Darrick J. Wong
  4 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2018-12-18 20:36 UTC (permalink / raw)
  To: guaneryu, darrick.wong; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

A few tests require v4 filesystems and enforce this by disabling crc's
in the _scratch_mkfs call.  However, if the user specified MOUNT_OPTIONS
that only work with v5 filesystems, these tests fail.  If we detect a
test creating a v4 scratch filesystem, filter out incompatible mount
options that don't work on v4, such as simultaneous group/project quota.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)


diff --git a/common/xfs b/common/xfs
index 80340b0d..484e6ab6 100644
--- a/common/xfs
+++ b/common/xfs
@@ -89,6 +89,7 @@ _scratch_mkfs_xfs()
 	_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
 	mkfs_status=$?
 
+	grep -q crc=0 $tmp.mkfsstd && _force_xfsv4_mount_options
 
 	if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
 		# manually parse the mkfs output to get the fs size in bytes
@@ -779,3 +780,26 @@ _scratch_get_bmx_prefix() {
 	_scratch_xfs_db -c "inode ${ino}" -c 'p' >> $seqres.full
 	return 1
 }
+
+#
+# Ensures that we don't pass any mount options incompatible with XFS v4
+#
+_force_xfsv4_mount_options()
+{
+	local gquota=0
+	local pquota=0
+
+	# Can't have group and project quotas in XFS v4
+	echo "$MOUNT_OPTIONS" | egrep -q "(gquota|grpquota|grpjquota=|gqnoenforce)" && gquota=1
+	echo "$MOUNT_OPTIONS" | egrep -q "(\bpquota|prjquota|pqnoenforce)" && pquota=1
+
+	if [ $gquota -gt 0 ] && [ $pquota -gt 0 ]; then
+		export MOUNT_OPTIONS=$(echo $MOUNT_OPTIONS \
+			| sed   -e 's/gquota/QUOTA/g'      \
+				-e 's/grpquota/QUOTA/g'    \
+				-e 's/grpjquota=[^, ]/QUOTA/g' \
+				-e 's/gqnoenforce/QUOTA/g' \
+				-e "s/QUOTA/defaults/g")
+	fi
+	echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$seqres.full
+}

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

end of thread, other threads:[~2018-12-18 20:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 20:35 [PATCH 0/5] fstests: fix various problems Darrick J. Wong
2018-12-18 20:35 ` [PATCH 1/5] xfs/111: fix golden output Darrick J. Wong
2018-12-18 20:35 ` [PATCH 2/5] xfs/123: fix remote symlink block size calculation Darrick J. Wong
2018-12-18 20:36 ` [PATCH 3/5] generic/050: fix ro blockdev mount of xfs with quota Darrick J. Wong
2018-12-18 20:36 ` [PATCH 4/5] xfs: look for stringified constants in ftrace formats Darrick J. Wong
2018-12-18 20:36 ` [PATCH 5/5] xfs: filter out mount options that don't work on v4 filesystems 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.