Skip to contentSkip to conversation

xfstests: some small fixes and mkfs validation test

PATCH In review Jan Tulak 3 participants 22 messages Jul 14, 2016 – Jul 22, 2016

lore
Share & tools
lore

Jan Tulak

author
#0 lore raw

v3 cover xfstests: some small fixes and mkfs validation test

This set is a merge of all my recent patches. The reason for the merge is that the patches are sequentially dependent and making a set is the safest way of ensuring their correct order after a merge.

One patch, "filename handling - fix early wildcard expansion", was dropped for now. Patch "add _require_xfs_mkfs_validation to common/rc" is new, and update of xfs/096 and input validation tests were changed.

Jan Tulak (6):
xfstests: Fix installation for extended names
fstests: filename handling for extended names in ./check was on a
wrong place
xfstests: remove unused variable
xfstests: add _require_xfs_mkfs_validation to common/rc
xfstests: update xfs/096 for new behaviour
xfstests: Add mkfs input validation tests

 check                              |  26 +--
 common/rc                          |  29 ++++
 include/buildrules                 |  31 ++++
 tests/btrfs/Makefile               |   4 +-
 tests/cifs/Makefile                |   4 +-
 tests/ext4/Makefile                |   4 +-
 tests/f2fs/Makefile                |   4 +-
 tests/generic/Makefile             |   4 +-
 tests/overlay/Makefile             |   4 +-
 tests/shared/Makefile              |   4 +-
 tests/udf/Makefile                 |   4 +-
 tests/xfs/096                      |   1 +
 tests/xfs/400-input-validation     | 338 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/Makefile                 |   4 +-
 tests/xfs/group                    |   1 +
 16 files changed, 433 insertions(+), 31 deletions(-)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out
Signature · 1 line
2.5.5
author
#3 lore raw

PATCH v3 3/6 xfstests: remove unused variable

After the previous patch moved few lines of code, one seqnum assignment is now immediately overwritten by another. Remove the useless one.

---
 check | 1 -
 1 file changed, 1 deletion(-)
check +0 -1
index ef6bd47..58d8869 100755
@@ -554,7 +554,6 @@ for section in $HOST_OPTIONS_SECTIONS; do
 	        if [ -f $full_seq ] \
 	            && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
 	            seq=$full_seq
-	            seqnum=${full_seq#*/}
 	        fi
 	    fi
 
Signature · 1 line
2.5.5
author
#4 lore raw

PATCH v3 4/6 xfstests: add _require_xfs_mkfs_validation to common/rc

In reply to Jan Tulak

Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs.

---
 common/rc | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
common/rc +29 -0
index 0c68e4f..72f9901 100644
@@ -3843,6 +3843,35 @@ _get_fs_sysfs_attr()
 	cat /sys/fs/${FSTYP}/${dname}/${attr}
 }
 
+# Skip if we are running an older binary without the stricter input checks.
+# Make multiple checks to be sure that there is no regression on the one
+# selected feature check, which would skew the result.
+_require_xfs_mkfs_validation()
+{
+	_require_scratch
+	$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+	sum=$?
+	$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+	sum=`expr $sum + $?`
+
+	if [ "$sum" -eq 0 ]; then
+		_notrun "Requires newer mkfs with stricter input checks."
+	fi
+}
+
+# The oposite of _require_xfs_mkfs_validation.
+_require_xfs_mkfs_without_validation()
+{
+	_require_scratch
+	$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+	sum=$?
+	$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+	sum=`expr $sum + $?`
+
+	if [ "$sum" -eq 2 ]; then
+		_notrun "Requires older mkfs without stricter input checks."
+	fi
+}
 init_rc
 
 ################################################################################
Signature · 1 line
2.5.5
author
#8 lore raw

PATCH v3 5/6 xfstests: update xfs/096 for new behaviour

In reply to Jan Tulak

Because we recently changed how mkfs behaves when it gets incorrect/invalid values, add a feature check to run this test only on older binaries, which accepts invalid sunit values.

---
UPDATE:
Throw away all changes and replace them with a single _require_xfs_mkfs_without_validation from common/rc.

---
 tests/xfs/096 | 1 +
 1 file changed, 1 insertion(+)
tests/xfs/096 +1 -0
index f949e83..64754b2 100755
@@ -105,6 +105,7 @@ _supported_fs xfs
 _supported_os IRIX Linux
 _require_scratch
 _require_v2log
+_require_xfs_mkfs_without_validation
 
 # choose .out file based on internal/external log
 rm -f $seqfull.out
Signature · 1 line
2.5.5
author
#1 lore raw

PATCH v3 1/6 xfstests: Fix installation for extended names

In reply to Jan Tulak

xfstests supports extended test names like 314-foo-bar, but installation of these tests was skipped (not matching a regexp). So this patch fixes the makefiles in tests/*/

The include/buildrules change was written by Dave Chinner.

---
 include/buildrules     | 31 +++++++++++++++++++++++++++++++
 tests/btrfs/Makefile   |  4 ++--
 tests/cifs/Makefile    |  4 ++--
 tests/ext4/Makefile    |  4 ++--
 tests/f2fs/Makefile    |  4 ++--
 tests/generic/Makefile |  4 ++--
 tests/overlay/Makefile |  4 ++--
 tests/shared/Makefile  |  4 ++--
 tests/udf/Makefile     |  4 ++--
 tests/xfs/Makefile     |  4 ++--
 10 files changed, 49 insertions(+), 18 deletions(-)
include/buildrules +31 -0
index c8a7c47..1269c8c 100644
@@ -100,3 +100,34 @@ MAKEDEP := $(MAKEDEPEND) $(CFLAGS)
 	    cp /dev/null .dep; \
 	fi
 
+# Gather files for installing into two lists:
+# TESTS with executable scripts and OUTFILES with all the test outputs.
+# Makefile has a very small matching, so we have to go this long way.
+
+# Start with all test related files:
+ALLFILES = $(wildcard [0-9]??*)
+
+# Now build a list of known output files.  Unfortunately, the
+# multiple output test files are poorly handled as makefiles don't
+# handle wildcarded multi-suffix matching. Hence we separate the
+# processing of these right now.
+EXTENDED_OUTFILES = $(wildcard [0-9]??*.out.*)
+BASIC_OUTFILES = $(wildcard [0-9]??*.out)
+OUTFILES = $(EXTENDED_OUTFILES) $(BASIC_OUTFILES)
+
+# Strip suffix to get matching tests. We want to strip from the
+# first "." to the end, but makefiles don't have a built in
+# operative for that. So:
+#
+# Hack: strip the multiple segments after .out with repeated basename calls.
+EXTFILTER1 = $(basename $(EXTENDED_OUTFILES))
+EXTFILTER2 = $(basename $(EXTFILTER1))
+EXTFILTER3 = $(basename $(EXTFILTER2))
+EXTFILTER4 = $(basename $(EXTFILTER3))
+
+# final filter list
+FILTER = $(basename $(EXTFILTER4) $(BASIC_OUTFILES))
+
+# finally, select the test files by filtering against against the
+# stripped output files and sort them to remove duplicates.
+TESTS = $(sort $(filter $(ALLFILES), $(FILTER)))
tests/btrfs/Makefile +2 -2
index e1a5be1..2d93642 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/cifs/Makefile +2 -2
index 9176e5c..0c5cf3b 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/ext4/Makefile +2 -2
index 7a3c8e1..beb1541 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/f2fs/Makefile +2 -2
index 4d00e9e..d13bca3 100644
@@ -13,9 +13,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/generic/Makefile +2 -2
index 9529fb8..3878d05 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/overlay/Makefile +2 -2
index 63c9878..b07f892 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/shared/Makefile +2 -2
index cbd87f9..8a83278 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/udf/Makefile +2 -2
index 1d96658..c9c9f1b 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/xfs/Makefile +2 -2
index db94be0..d64800e 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
Signature · 1 line
2.5.5
author
#9 lore raw

PATCH v3 6/6 xfstests: Add mkfs input validation tests

In reply to Jan Tulak

mkfs.xfs does not do a very good job of input validation. This test is designed to exercise the input validation and test good/bad combinations of options being set. It will not pass on an old mkfs.xfs binary - it is designed to be the test case for an input validation cleanup (merged in spring/summer 2016).

---
CHANGES:
Use common/rc feature check for mkfs version testing.

Cheers,
Jan

---
 tests/xfs/400-input-validation     | 338 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/group                    |   1 +
 3 files changed, 341 insertions(+)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out
tests/xfs/400-input-validation new file +338 -0
new file mode 100755
index 0000000..83a4ff9
@@ -0,0 +1,338 @@
+#! /bin/bash
+# FS QA Test No. xfs/400
+#
+# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
+# filter garbage input or invalid option combinations correctly.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+_require_xfs_mkfs_validation
+
+
+
+rm -f $seqres.full
+echo silence is golden
+
+# clear out any options to mkfs first. We want to test realtime and external log
+# devices if we can, but we also want to control them ourselves.
+logdev=$SCRATCH_LOGDEV
+rtdev=$SCRATCH_RTDEV
+
+MKFS_OPTIONS=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+
+# limit the image size of the filesystem being created to something small
+fssize=$((4 * 1024 * 1024 * 1024))
+logsize=$((4 * 1024 * 1024 * 100))
+fsimg=$TEST_DIR/$seq.img
+
+do_mkfs_pass()
+{
+	echo >> $seqres.full
+	echo "pass expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -ne 0 ] && echo "fail $*"
+}
+
+do_mkfs_fail()
+{
+	echo >> $seqres.full
+	echo "fail expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -eq 0 ] && echo "pass $*"
+}
+
+reset_fsimg()
+{
+	rm -f $fsimg
+	$XFS_IO_PROG -f -c "truncate $fssize" $fsimg
+}
+
+reset_fsimg
+
+do_mkfs_pass $SCRATCH_DEV
+
+# basic "should fail" options
+
+# specifying sector sizes in sectors or blocks or garbage
+do_mkfs_fail -s size=2s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -s size=2b $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2b $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2b $SCRATCH_DEV
+
+do_mkfs_fail -s size=grot $SCRATCH_DEV
+do_mkfs_fail -s size=2yerk $SCRATCH_DEV
+do_mkfs_fail -d sectsize=blah $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2foo $SCRATCH_DEV
+do_mkfs_fail -l sectsize=nggh $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2nggh $SCRATCH_DEV
+
+# conflicting sector/block sizes
+do_mkfs_fail -s size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -s size=512 -l sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2048 -l sectsize=1024 $SCRATCH_DEV
+
+do_mkfs_fail -b size=512 -s size=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -l sectsize=1024 $SCRATCH_DEV
+
+# specifying block sizes in sectors without specifying sector size
+# or in blocks or garbage
+do_mkfs_fail -b size=2s $SCRATCH_DEV
+do_mkfs_fail -b size=2b $SCRATCH_DEV
+do_mkfs_fail -b size=nfi $SCRATCH_DEV
+do_mkfs_fail -b size=4096nfi $SCRATCH_DEV
+do_mkfs_fail -n size=2s $SCRATCH_DEV
+do_mkfs_fail -n size=2b $SCRATCH_DEV
+do_mkfs_fail -n size=nfi $SCRATCH_DEV
+do_mkfs_fail -n size=4096nfi $SCRATCH_DEV
+
+# bad label length
+do_mkfs_fail -L thisiswaytoolong $SCRATCH_DEV
+
+# basic "should pass" data section tests
+do_mkfs_pass $SCRATCH_DEV
+do_mkfs_pass -d name=$SCRATCH_DEV
+do_mkfs_pass -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -d agcount=32 $SCRATCH_DEV
+do_mkfs_pass -d agsize=32m $SCRATCH_DEV
+do_mkfs_pass -d agsize=32M $SCRATCH_DEV
+do_mkfs_pass -d agsize=1g $SCRATCH_DEV
+do_mkfs_pass -d agsize=$((32 * 1024 * 1024)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d agsize=8192b $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -d noalign $SCRATCH_DEV
+do_mkfs_pass -d sunit=0,swidth=0 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=64 $SCRATCH_DEV
+do_mkfs_pass -d su=0,sw=0 $SCRATCH_DEV
+do_mkfs_pass -d su=4096,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4k,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4K,sw=8 $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d su=1b,sw=8 $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,su=8s,sw=8 $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d su=8s,sw=8 $SCRATCH_DEV
+
+# invalid data section tests
+do_mkfs_fail -d size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -d agsize=8192b $SCRATCH_DEV
+do_mkfs_fail -d agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d agsize=32Mbsdfsdo $SCRATCH_DEV
+do_mkfs_fail -d agsize=1GB $SCRATCH_DEV
+do_mkfs_fail -d agcount=1k $SCRATCH_DEV
+do_mkfs_fail -d agcount=6b $SCRATCH_DEV
+do_mkfs_fail -d agcount=32,agsize=32m $SCRATCH_DEV
+do_mkfs_fail -d sunit=0,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=0 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d sunit=64k,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64m $SCRATCH_DEV
+do_mkfs_fail -d su=0,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=0 $SCRATCH_DEV
+do_mkfs_fail -d su=4097,sw=1 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64s $SCRATCH_DEV
+do_mkfs_fail -d su=4096s,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096b,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096garabge,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,sunit=64,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=512s,agsize=65536s $SCRATCH_DEV
+
+reset_fsimg
+
+# file section, should pass
+do_mkfs_pass $fsimg
+do_mkfs_pass -d file=0 $SCRATCH_DEV
+do_mkfs_pass -d size=$fssize,file=1,name=$fsimg
+do_mkfs_pass -d size=$fssize,file $fsimg
+do_mkfs_pass -d size=$fssize $fsimg
+do_mkfs_pass -d size=$fssize,name=$fsimg
+do_mkfs_pass -d size=$((fssize/2)) $fsimg
+# again this one, to check that we didn't truncated the file
+do_mkfs_pass -d size=$fssize $fsimg
+rm -f $fsimg
+do_mkfs_pass -d file,size=$fssize $fsimg
+
+reset_fsimg
+
+# file section, should fail
+do_mkfs_fail -d file=1 $SCRATCH_DEV
+do_mkfs_fail -d file $fsimg # no size given
+rm -f $fsimg
+do_mkfs_fail $fsimg
+do_mkfs_fail -d size=$fssize $fsimg
+
+reset_fsimg
+
+# log section, should pass
+do_mkfs_pass -l size=$logsize -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -l agnum=2 $SCRATCH_DEV
+do_mkfs_pass -l size=4096b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -l sunit=8 $SCRATCH_DEV
+do_mkfs_pass -l su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -l su=10b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512,su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -l internal $SCRATCH_DEV
+$XFS_IO_PROG -f -c "truncate $logsize" $fsimg
+do_mkfs_pass -l logdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l name=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 $SCRATCH_DEV
+
+# log section, should fail
+do_mkfs_fail -l size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -l agnum=1k $SCRATCH_DEV
+do_mkfs_fail -l agnum=6b $SCRATCH_DEV
+do_mkfs_fail -l agnum=32 $SCRATCH_DEV
+do_mkfs_fail -l sunit=0  $SCRATCH_DEV
+do_mkfs_fail -l sunit=63 $SCRATCH_DEV
+do_mkfs_fail -l su=1 $SCRATCH_DEV
+do_mkfs_fail -l su=10b $SCRATCH_DEV
+do_mkfs_fail -l su=10s $SCRATCH_DEV
+do_mkfs_fail -l su=$((4096*10+1)) $SCRATCH_DEV
+do_mkfs_fail -l sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=512s,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l internal=0 $SCRATCH_DEV
+reset_fsimg
+do_mkfs_fail -l internal=1,logdev=$fsimg $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=0  $SCRATCH_DEV
+
+
+
+# naming section, should pass
+do_mkfs_pass -n size=65536 $SCRATCH_DEV
+do_mkfs_pass -n log=15 $SCRATCH_DEV
+do_mkfs_pass -n version=2 $SCRATCH_DEV
+do_mkfs_pass -n version=ci $SCRATCH_DEV
+do_mkfs_pass -n ftype=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -n ftype=1 $SCRATCH_DEV
+
+# naming section, should fail
+do_mkfs_fail -n version=1 $SCRATCH_DEV
+do_mkfs_fail -n version=cid $SCRATCH_DEV
+do_mkfs_fail -n ftype=4 $SCRATCH_DEV
+do_mkfs_fail -n ftype=0 $SCRATCH_DEV
+
+reset_fsimg
+
+# metadata section, should pass
+do_mkfs_pass -m crc=1,finobt=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=1,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=0,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=1 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=0 $SCRATCH_DEV
+
+# metadata section, should fail
+do_mkfs_fail -m crc=0,finobt=1 $SCRATCH_DEV
+do_mkfs_fail -m crc=1 -n ftype=0 $SCRATCH_DEV
+
+
+# realtime section, should pass
+do_mkfs_pass -r rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r extsize=4k $SCRATCH_DEV
+do_mkfs_pass -r extsize=1G $SCRATCH_DEV
+do_mkfs_pass -r size=65536,rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r noalign $SCRATCH_DEV
+
+
+# realtime section, should fail
+do_mkfs_fail -r rtdev=$SCRATCH_DEV
+do_mkfs_fail -r extsize=256 $SCRATCH_DEV
+do_mkfs_fail -r extsize=2G $SCRATCH_DEV
+do_mkfs_fail -r size=65536 $SCRATCH_DEV
+
+
+
+# inode section, should pass
+do_mkfs_pass -i size=256 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i size=512 $SCRATCH_DEV
+do_mkfs_pass -i size=2048 $SCRATCH_DEV
+do_mkfs_pass -i log=10 $SCRATCH_DEV
+do_mkfs_pass -i perblock=2 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=10 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=100 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=0 $SCRATCH_DEV
+do_mkfs_pass -i align=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i align=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_pass -i attr=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i attr=2 $SCRATCH_DEV
+do_mkfs_pass -i projid32bit $SCRATCH_DEV
+do_mkfs_pass -i sparse=0 $SCRATCH_DEV
+do_mkfs_pass -i sparse -m crc $SCRATCH_DEV
+
+
+# inode section, should fail
+do_mkfs_fail -i size=256 -m crc $SCRATCH_DEV
+do_mkfs_fail -i size=128 $SCRATCH_DEV
+do_mkfs_fail -i size=513 $SCRATCH_DEV
+do_mkfs_fail -i size=4096 $SCRATCH_DEV
+do_mkfs_fail -i maxpct=110 $SCRATCH_DEV
+do_mkfs_fail -i align=2 $SCRATCH_DEV
+do_mkfs_fail -i sparse -m crc=0 $SCRATCH_DEV
+do_mkfs_fail -i align=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -i attr=1 -m crc=1 $SCRATCH_DEV
+
+status=0
+exit
tests/xfs/400-input-validation.out new file +2 -0
new file mode 100644
index 0000000..7080553
@@ -0,0 +1,2 @@
+QA output created by 400-input-validation
+silence is golden
tests/xfs/group +1 -0
index 9f8ca0f..dd2aa5b 100644
@@ -308,3 +308,4 @@
 325 auto quick clone
 326 auto quick clone
 327 auto quick clone
+400-input-validation auto quick mkfs
Signature · 1 line
2.5.5
author
#2 lore raw

PATCH v3 2/6 fstests: filename handling for extended names in ./check was on a wrong place

In reply to Jan Tulak

The code handling "./check foo/123", when the real test is "foo/123-bar-baz" was moved to the earliest position, so everything working with the test name or path will know the full name. Thus, no "123" and "123-bar-baz" mix is possible.

An example of this issue is $testname.notrun file. When _notrun "foo" was run during ./check foo/$name command, it created $name.notrun. But few lines later, it wanted $fullname.notrun. So if you did ./check foo/999, but the file was 999-bar-baz, then you got comparing outputs (and most likely a fail) instead of a skip.

Another example of this mix is in xfstests output:
./check xfs/999
[...]
xfs/999 0s ... 0s
Ran: xfs/999-test-case

---
UPDATE:
Just more explanation in the commit message.

 check | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
check +14 -13
index 5be183f..ef6bd47 100755
@@ -543,6 +543,20 @@ for section in $HOST_OPTIONS_SECTIONS; do
 	for seq in $list
 	do
 	    err=false
+	    if [ ! -f $seq ]; then
+	        # Try to get full name in case the user supplied only seq id
+	        # and the test has a name. A bit of hassle to find really
+	        # the test and not its sample output or helping files.
+	        bname=$(basename $seq)
+	        full_seq=$(find $(dirname $seq) -name $bname* -executable |
+	            awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
+	            	END { print shortest }')
+	        if [ -f $full_seq ] \
+	            && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
+	            seq=$full_seq
+	            seqnum=${full_seq#*/}
+	        fi
+	    fi
 
 	    # the filename for the test and the name output are different.
 	    # we don't include the tests/ directory in the name output.
@@ -566,19 +580,6 @@ for section in $HOST_OPTIONS_SECTIONS; do
 		if $showme; then
 			echo
 			continue
-		elif [ ! -f $seq ]; then
-			# Try to get full name in case the user supplied only seq id
-			# and the test has a name. A bit of hassle to find really
-			# the test and not its sample output or helping files.
-			bname=$(basename $seq)
-			full_seq=$(find $(dirname $seq) -name $bname* -executable |
-				awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
-					END { print shortest }')
-			if [ -f $full_seq ] \
-				&& [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
-				seq=$full_seq
-				seqnum=${full_seq#*/}
-			fi
 		fi
 
 		if [ ! -f $seq ]; then
Signature · 1 line
2.5.5
#5 lore raw

Re: [PATCH 4/6] xfstests: add _require_xfs_mkfs_validation to common/rc

In reply to Jan Tulak
Quoted 13 lines · Jan Tulak

Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs.

---
 common/rc | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
common/rc +0 -0
index 0c68e4f..72f9901 100644

common/rc _get_fs_sysfs_attr() · line 3851

Quoted 9 lines
common/rc +6 -0
@@ -3843,6 +3843,35 @@ _get_fs_sysfs_attr()
 	cat /sys/fs/${FSTYP}/${dname}/${attr}
 }
 
+# Skip if we are running an older binary without the stricter input checks.
+# Make multiple checks to be sure that there is no regression on the one
+# selected feature check, which would skew the result.
+_require_xfs_mkfs_validation()
+{
+	_require_scratch

I don't think you need $SCRATCH_DEV and _require_scratch in this helper, a test file just does the work, e.g. creating an empty file somewhere and using the "-d name=<filename>,size=<size>" option of mkfs.xfs to do the test.

common/rc _get_fs_sysfs_attr() · line 3858

Quoted 7 lines
common/rc +7 -0
+	$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+	sum=$?
+	$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+	sum=`expr $sum + $?`
+
+	if [ "$sum" -eq 0 ]; then
+		_notrun "Requires newer mkfs with stricter input checks."

"newer mkfs" is not specific, it's not clear which version of xfsprogs one should use to run this test. It'd be good to see specific version info in this message if possible. (Sorry I didn't make my point clear in previous reviews.)

Thanks,
Eryu

Quoted 26 lines
common/rc +16 -0
+	fi
+}
+
+# The oposite of _require_xfs_mkfs_validation.
+_require_xfs_mkfs_without_validation()
+{
+	_require_scratch
+	$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+	sum=$?
+	$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+	sum=`expr $sum + $?`
+
+	if [ "$sum" -eq 2 ]; then
+		_notrun "Requires older mkfs without stricter input checks."
+	fi
+}
 init_rc
 
 ################################################################################
Signature · 6 lines
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#6 lore raw

Re: [PATCH 4/6] xfstests: add _require_xfs_mkfs_validation to common/rc

Quoted 17 lines · Eryu Guan
Quoted 16 lines · Jan Tulak

Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs.

---
 common/rc | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
common/rc +0 -0
index 0c68e4f..72f9901 100644
@@ -3843,6 +3843,35 @@ _get_fs_sysfs_attr()
      cat /sys/fs/${FSTYP}/${dname}/${attr}
 }
 
Quoted 12 lines

common/rc _get_fs_sysfs_attr() · line 3851

Quoted 6 lines
common/rc +6 -0
+# Skip if we are running an older binary without the stricter input checks.
+# Make multiple checks to be sure that there is no regression on the one
+# selected feature check, which would skew the result.
+_require_xfs_mkfs_validation()
+{
+     _require_scratch

I don't think you need $SCRATCH_DEV and _require_scratch in this helper, a test file just does the work, e.g. creating an empty file somewhere and using the "-d name=<filename>,size=<size>" option of mkfs.xfs to do the test.

True, that works too. I'm doing some further small tinkering around this patch, but I will send a new version soon.

Quoted 8 lines

common/rc _get_fs_sysfs_attr() · line 3858

Quoted 7 lines
common/rc +7 -0
+     $MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+     sum=$?
+     $MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+     sum=`expr $sum + $?`
+
+     if [ "$sum" -eq 0 ]; then
+             _notrun "Requires newer mkfs with stricter input checks."
Quoted 5 lines

"newer mkfs" is not specific, it's not clear which version of xfsprogs one should use to run this test. It'd be good to see specific version info in this message if possible. (Sorry I didn't make my point clear in previous reviews.)

All right. :-) How about these?
Requires older mkfs without strict input checks: the last supported version of xfsprogs is 4.5.
Requires newer mkfs with stricter input checks: the oldest supported version of xfsprogs is 4.7.

Thanks,
Jan

Quoted 29 lines

Thanks,
Eryu

Quoted 26 lines
common/rc +16 -1
+     fi
+}
+
+# The oposite of _require_xfs_mkfs_validation.
+_require_xfs_mkfs_without_validation()
+{
+     _require_scratch
+     $MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+     sum=$?
+     $MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+     sum=`expr $sum + $?`
+
+     if [ "$sum" -eq 2 ]; then
+             _notrun "Requires older mkfs without stricter input checks."
+     fi
+}
 init_rc
 
 ################################################################################
--

2.5.5

--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
author
#7 lore raw

PATCH v2 1/1 xfstests: add _require_xfs_mkfs_validation to common/rc

In reply to Jan Tulak

Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs.

---
UPDATE:
* Use tmp file instead of scratch - we are using -N flag, so it doesn't really matter.
* Make both _requires to use the same function for testing, so if it is ever changed, the change will be reflected in both.

---
 common/rc | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
common/rc +33 -0
index 0c68e4f..c66d31d 100644
@@ -3843,6 +3843,39 @@ _get_fs_sysfs_attr()
 	cat /sys/fs/${FSTYP}/${dname}/${attr}
 }
 
+# Skip if we are running an older binary without the stricter input checks.
+# Make multiple checks to be sure that there is no regression on the one
+# selected feature check, which would skew the result.
+#
+# At first, make a common function that runs the tests and returns
+# number of failed cases.
+mkfs_validation_check()
+{
+	local cmd="$MKFS_XFS_PROG -f -N -d file,name=/tmp/foo,size=$((1024 * 1024 * 1024))"
+	$cmd -s size=2s >/dev/null 2>&1
+	local sum=$?
+	$cmd -l version=2,su=$((256 * 1024 + 4096))  >/dev/null 2>&1
+	sum=`expr $sum + $?`
+	return $sum
+}
+# Skip the test if all calls passed - mkfs accepts invalid input
+_require_xfs_mkfs_validation()
+{
+	mkfs_validation_check
+	if [ "$?" -eq 0 ]; then
+		_notrun "Requires newer mkfs with stricter input checks: the oldest supported version of xfsprogs is 4.7."
+	fi
+}
+
+# The oposite of _require_xfs_mkfs_validation.
+_require_xfs_mkfs_without_validation()
+{
+	mkfs_validation_check
+	if [ "$?" -ne 0 ]; then
+		_notrun "Requires older mkfs without strict input checks: the last supported version of xfsprogs is 4.5."
+	fi
+}
+
 init_rc
 
 ################################################################################
Signature · 1 line
2.5.5
#10 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

In reply to Jan Tulak
Quoted 59 lines · Jan Tulak

mkfs.xfs does not do a very good job of input validation. This test is designed to exercise the input validation and test good/bad combinations of options being set. It will not pass on an old mkfs.xfs binary - it is designed to be the test case for an input validation cleanup (merged in spring/summer 2016).

---
CHANGES:
Use common/rc feature check for mkfs version testing.

Cheers,
Jan

---
 tests/xfs/400-input-validation     | 338 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/group                    |   1 +
 3 files changed, 341 insertions(+)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out
tests/xfs/400-input-validation new file +28 -0
new file mode 100755
index 0000000..83a4ff9
@@ -0,0 +1,338 @@
+#! /bin/bash
+# FS QA Test No. xfs/400
+#
+# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
+# filter garbage input or invalid option combinations correctly.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"

[snip]

tests/xfs/400-input-validation line 258

Quoted 5 lines
tests/xfs/400-input-validation new file +5 -0
+do_mkfs_fail -l internal=1,logdev=$fsimg $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Is it a mkfs.xfs bug or the test case should handle the special case?

Thanks,
Eryu

#20 lore raw
In reply to Jan Tulak
Quoted 9 lines · Jan Tulak

This set is a merge of all my recent patches. The reason for the merge is that the patches are sequentially dependent and making a set is the safest way of ensuring their correct order after a merge.

One patch, "filename handling - fix early wildcard expansion", was dropped for now. Patch "add _require_xfs_mkfs_validation to common/rc" is new, and update of xfs/096 and input validation tests were changed.

Quoted 8 lines

Jan Tulak (6):
xfstests: Fix installation for extended names
fstests: filename handling for extended names in ./check was on a
wrong place
xfstests: remove unused variable
xfstests: add _require_xfs_mkfs_validation to common/rc
xfstests: update xfs/096 for new behaviour
xfstests: Add mkfs input validation tests

I took patch 4 and 5 in this pull-request and left other extended name related patches for now, due to the .cfg file installation issue.

Thanks,
Eryu

#11 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

In reply to Eryu Guan
Quoted 22 lines · Eryu Guan

tests/xfs/400-input-validation line 258

Quoted 4 lines · Jan Tulak
tests/xfs/400-input-validation new file +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#21 lore raw

PATCH v2 1/1 xfstests: Fix installation for extended names

In reply to Jan Tulak

xfstests supports extended test names like 314-foo-bar, but installation of these tests was skipped (not matching a regexp). So this patch fixes the makefiles in tests/*/

The include/buildrules change was written by Dave Chinner.

---
UPDATE:
Add .cfg support

---
 include/buildrules     | 32 ++++++++++++++++++++++++++++++++
 tests/btrfs/Makefile   |  4 ++--
 tests/cifs/Makefile    |  4 ++--
 tests/ext4/Makefile    |  4 ++--
 tests/f2fs/Makefile    |  4 ++--
 tests/generic/Makefile |  4 ++--
 tests/overlay/Makefile |  4 ++--
 tests/shared/Makefile  |  4 ++--
 tests/udf/Makefile     |  4 ++--
 tests/xfs/Makefile     |  4 ++--
 10 files changed, 50 insertions(+), 18 deletions(-)
include/buildrules +32 -0
index c8a7c47..76b755e 100644
@@ -100,3 +100,35 @@ MAKEDEP := $(MAKEDEPEND) $(CFLAGS)
 	    cp /dev/null .dep; \
 	fi
 
+# Gather files for installing into two lists:
+# TESTS with executable scripts and OUTFILES with all the test outputs.
+# Makefile has a very small matching, so we have to go this long way.
+
+# Start with all test related files:
+ALLFILES = $(wildcard [0-9]??*)
+
+# Now build a list of known output files.  Unfortunately, the
+# multiple output test files are poorly handled as makefiles don't
+# handle wildcarded multi-suffix matching. Hence we separate the
+# processing of these right now.
+EXTENDED_OUTFILES = $(wildcard [0-9]??*.out.*)
+EXTENDED_OUTFILE_CFGS = $(wildcard [0-9]??.cfg)
+BASIC_OUTFILES = $(wildcard [0-9]??*.out)
+OUTFILES = $(EXTENDED_OUTFILES) $(EXTENDED_OUTFILE_CFGS) $(BASIC_OUTFILES)
+
+# Strip suffix to get matching tests. We want to strip from the
+# first "." to the end, but makefiles don't have a built in
+# operative for that. So:
+#
+# Hack: strip the multiple segments after .out with repeated basename calls.
+EXTFILTER1 = $(basename $(EXTENDED_OUTFILES))
+EXTFILTER2 = $(basename $(EXTFILTER1))
+EXTFILTER3 = $(basename $(EXTFILTER2))
+EXTFILTER4 = $(basename $(EXTFILTER3))
+
+# final filter list
+FILTER = $(basename $(EXTFILTER4) $(BASIC_OUTFILES))
+
+# finally, select the test files by filtering against against the
+# stripped output files and sort them to remove duplicates.
+TESTS = $(sort $(filter $(ALLFILES), $(FILTER)))
tests/btrfs/Makefile +2 -2
index e1a5be1..2d93642 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/cifs/Makefile +2 -2
index 9176e5c..0c5cf3b 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/ext4/Makefile +2 -2
index 7a3c8e1..beb1541 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/f2fs/Makefile +2 -2
index 4d00e9e..d13bca3 100644
@@ -13,9 +13,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/generic/Makefile +2 -2
index 9529fb8..3878d05 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/overlay/Makefile +2 -2
index 63c9878..b07f892 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/shared/Makefile +2 -2
index cbd87f9..8a83278 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/udf/Makefile +2 -2
index 1d96658..c9c9f1b 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
tests/xfs/Makefile +2 -2
index db94be0..d64800e 100644
@@ -12,9 +12,9 @@ include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
-	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
 	$(INSTALL) -m 644 group $(TARGET_DIR)
-	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
 install-dev install-lib:
Signature · 1 line
2.5.5
author
#12 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

In reply to Dave Chinner
Quoted 23 lines · Dave Chinner
Quoted 22 lines · Eryu Guan

tests/xfs/400-input-validation line 258

Quoted 4 lines · Jan Tulak
tests/xfs/400-input-validation new file +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 8 lines
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

I tried to duplicate this, but in my config it didn't failed - how did you create the ramdisk?

# modprobe brd rd_nr=1 rd_size=$((200*1024))
# blockdev --getbsz /dev/ram0
4096
# blockdev --getpbsz /dev/ram0
512
# blockdev --getss /dev/ram0
512
# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0
V2 logs always enabled for CRC enabled filesytems
Usage: mkfs.xfs
[snip]

Thanks, Jan

PS: cc-ing XFS list - if it is mkfs bug, it is better there than in fstests.

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
#13 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 33 lines · Jan Tulak
Quoted 23 lines · Dave Chinner
Quoted 22 lines · Eryu Guan

tests/xfs/400-input-validation line 258

Quoted 4 lines · Jan Tulak
tests/xfs/400-input-validation new file +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 8 lines
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

Quoted 2 lines

I tried to duplicate this, but in my config it didn't failed - how did you create the ramdisk?

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

meta-data=/dev/sdc               isize=512    agcount=4, agsize=8192 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=32768, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

If you remove the "physblk_exp=3" at modprobe time, mkfs failed as expected.

Thanks,
Eryu

Quoted 21 lines
# modprobe brd rd_nr=1 rd_size=$((200*1024))
# blockdev --getbsz /dev/ram0
4096
# blockdev --getpbsz /dev/ram0
512
# blockdev --getss /dev/ram0
512
# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0
V2 logs always enabled for CRC enabled filesytems
Usage: mkfs.xfs
[snip]

Thanks, Jan

PS: cc-ing XFS list - if it is mkfs bug, it is better there than in fstests.

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
author
#14 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 57 lines · Eryu Guan
Quoted 33 lines · Jan Tulak
Quoted 23 lines · Dave Chinner
Quoted 22 lines · Eryu Guan

tests/xfs/400-input-validation line 258

Quoted 4 lines · Jan Tulak
tests/xfs/400-input-validation new file +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 8 lines
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

Quoted 2 lines

I tried to duplicate this, but in my config it didn't failed - how did you create the ramdisk?

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

meta-data=/dev/sdc               isize=512    agcount=4, agsize=8192 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=32768, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 3 lines

If you remove the "physblk_exp=3" at modprobe time, mkfs failed as expected.

Ah, thanks. :-) Now I can reproduce it and see what happens.

Thanks.
Jan

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
author
#15 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 58 lines · Jan Tulak
Quoted 57 lines · Eryu Guan
Quoted 33 lines · Jan Tulak
Quoted 23 lines · Dave Chinner
Quoted 22 lines · Eryu Guan

tests/xfs/400-input-validation line 258

Quoted 4 lines · Jan Tulak
tests/xfs/400-input-validation new file +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 8 lines
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

Quoted 2 lines

I tried to duplicate this, but in my config it didn't failed - how did you create the ramdisk?

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

meta-data=/dev/sdc               isize=512    agcount=4, agsize=8192 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=32768, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 5 lines
Quoted 3 lines

If you remove the "physblk_exp=3" at modprobe time, mkfs failed as expected.

Ah, thanks. :-) Now I can reproduce it and see what happens.

And the culprit is in mkfs, some forty lines before the crc & log version check:

2026 ⇥       } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
2027 ⇥       ⇥       lsu = blocksize;
2028 ⇥       ⇥       sb_feat.log_version = 2;
2029 ⇥       }

The possible solutions I can think of are:

1) Make a more complicated check.
This would change just a line or two, but most likely, we would test the same thing multiple times and added unnecessary complexity.

2) Move the crc checks into an earlier place.
The only value that can be changed in crc checks from default is finobt, and finobt is not read nor modified between argument parsing and the crc check. This looks like a simple and safe thing, but it will move some ~60 lines. I tested moving the crc testing block right behind this:
1968 ⇥ memset(&ft, 0, sizeof(ft));
1969 ⇥ get_topology(&xi, &ft, force_overwrite);
And it works. I didn't run full test suite yet, though.

3) Change the silent autoupdating of log version. The default is 2 and if user explicitly states v1, then we should either warn or fail entirely if it is not possible to make such fs.

4) Do nothing with mkfs and instead, update the test to check the sector size and expect pass/fail...

But this issue boils down to the question "what is the correct order of doing things"? Should we try to autosolve what we can at first, and check for remaining issues after that? Or should we check for issues with the input ASAP, even if it can be solved by updating the input to match the physical device? Right now, it looks like "someone wrote it that way a long time ago" mix of both.

Your ideas, guys?

Thanks,
Jan

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
#16 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 42 lines · Jan Tulak
Quoted 41 lines · Jan Tulak
Quoted 40 lines · Eryu Guan
Quoted 33 lines · Jan Tulak
Quoted 23 lines · Dave Chinner
Quoted 22 lines · Eryu Guan

Review

Quoted 4 lines · Jan Tulak
(quoted diff) +4 -0
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV

This test fails in my DAX testing, where SCRATCH_DEV is ramdisk. The mkfs itself should fail, but it passed. Log version 2 was used automatically, instead of prompting "V2 logs always enabled for CRC enabled filesytems"

[root@dhcp-66-86-11 xfstests]# mkfs -t xfs -f -l version=1 -m crc=1 /dev/ram0

meta-data=/dev/ram0              isize=512    agcount=1, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=4096, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1605, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Quoted 8 lines
Quoted 1 line

Is it a mkfs.xfs bug or the test case should handle the special case?

Looks like it might be a side effect of using a 4k sector size. v1 logs only supported 512 byte sectors, so it's entirely possible that the sector size is silently overriding the log version specification. Probably should be fixed in mkfs.

Quoted 2 lines

I tried to duplicate this, but in my config it didn't failed - how did you create the ramdisk?

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

So this is an invalid filesystem configuration. It should be detected as such during command line parsing and rejected before we get anywhere near checking topology constraints. In mkfs terms, it's a conflicting option set.

Quoted 8 lines

And the culprit is in mkfs, some forty lines before the crc & log version check:

2026 ⇥       } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
2027 ⇥       ⇥       lsu = blocksize;
2028 ⇥       ⇥       sb_feat.log_version = 2;
2029 ⇥       }

The possible solutions I can think of are:

None of which really appeal because, IMO, they are trying to solve the wrong problem.

The whole point of moving to table based command line option parsing is that we can encode these sorts of conflicts into the option table. The conflict resolution in the option table is currently not complete - it can only encode and detect conflicts within a suboption type, but not across suboption types (e.g. within -d suboptions, but not between -d and -l suboptions).

This is simply because I never got as far as implementing this level of conflict encoding/resolution. In essence, the conflict array needs to define the sub option type, the suboption that is in conflict and the value that it conflicts against. Hence the conflicts table can then encode such things as "version 1 logs are invalid for CRC enabled filesystems" and vice versa.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#17 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 35 lines · Dave Chinner
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

So this is an invalid filesystem configuration. It should be detected as such during command line parsing and rejected before we get anywhere near checking topology constraints. In mkfs terms, it's a conflicting option set.

Quoted 8 lines

And the culprit is in mkfs, some forty lines before the crc & log version check:

2026 ⇥       } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
2027 ⇥       ⇥       lsu = blocksize;
2028 ⇥       ⇥       sb_feat.log_version = 2;
2029 ⇥       }

The possible solutions I can think of are:

None of which really appeal because, IMO, they are trying to solve the wrong problem.

The whole point of moving to table based command line option parsing is that we can encode these sorts of conflicts into the option table. The conflict resolution in the option table is currently not complete - it can only encode and detect conflicts within a suboption type, but not across suboption types (e.g. within -d suboptions, but not between -d and -l suboptions).

Quoted 7 lines

This is simply because I never got as far as implementing this level of conflict encoding/resolution. In essence, the conflict array needs to define the sub option type, the suboption that is in conflict and the value that it conflicts against. Hence the conflicts table can then encode such things as "version 1 logs are invalid for CRC enabled filesystems" and vice versa.

Ok, in long term, the correct way is to extend the conflicts table. But what in the meantime? Are we going to let it be now until it is fixed by the enhanced table?
And regarding my question at the end of the mail, I interpret your answer as "if the arguments are wrong, fail ASAP and don't try to fix it."

Thanks,
Jan

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]
#18 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 44 lines · Jan Tulak
Quoted 35 lines · Dave Chinner
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

So this is an invalid filesystem configuration. It should be detected as such during command line parsing and rejected before we get anywhere near checking topology constraints. In mkfs terms, it's a conflicting option set.

Quoted 8 lines

And the culprit is in mkfs, some forty lines before the crc & log version check:

2026 ⇥       } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
2027 ⇥       ⇥       lsu = blocksize;
2028 ⇥       ⇥       sb_feat.log_version = 2;
2029 ⇥       }

The possible solutions I can think of are:

None of which really appeal because, IMO, they are trying to solve the wrong problem.

The whole point of moving to table based command line option parsing is that we can encode these sorts of conflicts into the option table. The conflict resolution in the option table is currently not complete - it can only encode and detect conflicts within a suboption type, but not across suboption types (e.g. within -d suboptions, but not between -d and -l suboptions).

Quoted 7 lines

This is simply because I never got as far as implementing this level of conflict encoding/resolution. In essence, the conflict array needs to define the sub option type, the suboption that is in conflict and the value that it conflicts against. Hence the conflicts table can then encode such things as "version 1 logs are invalid for CRC enabled filesystems" and vice versa.

Quoted 1 line

Ok, in long term, the correct way is to extend the conflicts table.

Not long term. It's fairly simple to do.

1. Convert all the individual subopt parameter tables to an array of tables with a defined index for each set of subopts,
2. add a value field to the parameter, and store the CLI value in it when it is set
3. make the conflicts array in each subopts a structure like:

struct conflicts {
        int     subopt;
        int     index;
        int     invalid_value;
};

and convert all the existing conflicts to this format

4. Define cross-subopt conflicts like this:

       .subopt_params = {
                { .index = M_CRC,
-                 .conflicts = { LAST_CONFLICT },
+		  .conflicts = { { LOG, L_VERSION, 1 },
+				 { LAST_CONFLICT, 0, 0 }, },
                  .minval = 0,
                  .maxval = 1,
                  .defaultval = 1,
                },

And the L_VERSION subopt parameter will have a conflict like

+ .conflicts = { { META, M_CRC, 1 },
+ { LAST_CONFLICT, 0, 0 }, },

5. update the conflict lookup to do cross option lookups via checking the relevant option conflict table. e.g by checking the conflict[i].value against subopt[LOG].subopt_params[L_VERSION].value...

Quoted 2 lines

But what in the meantime? Are we going to let it be now until it is fixed by the enhanced table?

IMO: fix it once, fix it properly.

Quoted 3 lines

And regarding my question at the end of the mail, I interpret your answer as "if the arguments are wrong, fail ASAP and don't try to fix it."

The first step in any program shoul dbe to validate user supplied inputs. Once they are validated and known good, you don't have to add random code to handle invalid combinations - you can just assume the inputs are valid to begin with and those corner cases don't need to be handled.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#19 lore raw

Re: [PATCH 6/6] xfstests: Add mkfs input validation tests

Quoted 93 lines · Dave Chinner
Quoted 44 lines · Jan Tulak
Quoted 35 lines · Dave Chinner
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

I think you need to test on a 4k sector size disk. I use scsi_debug to simulate physical 4k sector disk to reproduce this:

[root@dhcp-66-86-11 xfsprogs-dev]# modprobe -r scsi_debug [root@dhcp-66-86-11 xfsprogs-dev]# modprobe scsi_debug dev_size_mb=128 physblk_exp=3 [root@dhcp-66-86-11 xfsprogs-dev]# blockdev --getbsz --getpbsz --getss /dev/sdc 4096
4096
512
[root@dhcp-66-86-11 xfsprogs-dev]# mkfs -t xfs -l version=1 -m crc=1 /dev/sdc

So this is an invalid filesystem configuration. It should be detected as such during command line parsing and rejected before we get anywhere near checking topology constraints. In mkfs terms, it's a conflicting option set.

Quoted 8 lines

And the culprit is in mkfs, some forty lines before the crc & log version check:

2026 ⇥       } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
2027 ⇥       ⇥       lsu = blocksize;
2028 ⇥       ⇥       sb_feat.log_version = 2;
2029 ⇥       }

The possible solutions I can think of are:

None of which really appeal because, IMO, they are trying to solve the wrong problem.

The whole point of moving to table based command line option parsing is that we can encode these sorts of conflicts into the option table. The conflict resolution in the option table is currently not complete - it can only encode and detect conflicts within a suboption type, but not across suboption types (e.g. within -d suboptions, but not between -d and -l suboptions).

Quoted 7 lines

This is simply because I never got as far as implementing this level of conflict encoding/resolution. In essence, the conflict array needs to define the sub option type, the suboption that is in conflict and the value that it conflicts against. Hence the conflicts table can then encode such things as "version 1 logs are invalid for CRC enabled filesystems" and vice versa.

Quoted 1 line

Ok, in long term, the correct way is to extend the conflicts table.

Not long term. It's fairly simple to do.

1. Convert all the individual subopt parameter tables to an array of tables with a defined index for each set of subopts,
2. add a value field to the parameter, and store the CLI value in it when it is set
3. make the conflicts array in each subopts a structure like:

struct conflicts {
        int     subopt;
        int     index;
        int     invalid_value;
};

and convert all the existing conflicts to this format

4. Define cross-subopt conflicts like this:

       .subopt_params = {
                { .index = M_CRC,
(quoted diff) +2 -1
-                 .conflicts = { LAST_CONFLICT },
+                 .conflicts = { { LOG, L_VERSION, 1 },
+                                { LAST_CONFLICT, 0, 0 }, },
                  .minval = 0,
                  .maxval = 1,
                  .defaultval = 1,
                },

And the L_VERSION subopt parameter will have a conflict like

(quoted diff) +2 -0
+                 .conflicts = { { META, M_CRC, 1 },
+                                { LAST_CONFLICT, 0, 0 }, },

5. update the conflict lookup to do cross option lookups via checking the relevant option conflict table. e.g by checking the conflict[i].value against subopt[LOG].subopt_params[L_VERSION].value...

Quoted 2 lines

But what in the meantime? Are we going to let it be now until it is fixed by the enhanced table?

IMO: fix it once, fix it properly.

Quoted 3 lines

And regarding my question at the end of the mail, I interpret your answer as "if the arguments are wrong, fail ASAP and don't try to fix it."

Quoted 6 lines

The first step in any program shoul dbe to validate user supplied inputs. Once they are validated and known good, you don't have to add random code to handle invalid combinations - you can just assume the inputs are valid to begin with and those corner cases don't need to be handled.

OK, thanks for showing the way, I will work on the changes.

In any case, to return to the beginning, the new test added by this patch is all right.

Thanks,
Jan

Signature · 2 lines
Jan Tulak
[email protected] / [email protected]