All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] xfstests: misc reflink test fixes
@ 2017-01-05  1:04 Darrick J. Wong
  2017-01-05  1:04 ` [PATCH 1/7] ocfs2: test reflinking to inline data files Darrick J. Wong
                   ` (6 more replies)
  0 siblings, 7 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:04 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Hi all,

The following patchset enable the use of xfstests to test reflink
functionality under ocfs2.  The first patch tests the ability to reflink
into and out of inline-data files on ocfs2.  Patches 2-6 fix various
problems with the tests that came up when qualifying ocfs2.

The last patch maliciously corrupts ext4 and xfs filesystems to
exploit nonexistent checking of i_size in order to coerce Linux into
loading a file with negative size.  It then exploits integer overflows
in the VFS writeback code to hard lock the kernel.  Don't run the tests
in this patch ({shared,xfs}/40[01]) unless you have a fixed kernel (4.10)

Comments and questions are, as always, welcome.

--D

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

* [PATCH 1/7] ocfs2: test reflinking to inline data files
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
@ 2017-01-05  1:04 ` Darrick J. Wong
  2017-01-05  1:04 ` [PATCH 2/7] common: add leading underscore to get_block_size Darrick J. Wong
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:04 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Make sure that we can handle reflinking from and to inline-data files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink       |    2 +
 tests/ocfs2/001      |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/ocfs2/001.out  |   14 ++++++++
 tests/ocfs2/Makefile |   20 +++++++++++
 tests/ocfs2/group    |    1 +
 5 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100755 tests/ocfs2/001
 create mode 100644 tests/ocfs2/001.out
 create mode 100644 tests/ocfs2/Makefile
 create mode 100644 tests/ocfs2/group


diff --git a/common/reflink b/common/reflink
index 64ee04f..55d82ac 100644
--- a/common/reflink
+++ b/common/reflink
@@ -206,7 +206,7 @@ _cp_reflink() {
 	file1="$1"
 	file2="$2"
 
-	cp --reflink=always -p "$file1" "$file2"
+	cp --reflink=always -p -f "$file1" "$file2"
 }
 
 # Reflink some file1 into file2
diff --git a/tests/ocfs2/001 b/tests/ocfs2/001
new file mode 100755
index 0000000..1cd9dc5
--- /dev/null
+++ b/tests/ocfs2/001
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 001
+#
+# Ensure that reflink works correctly with inline-data files.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017, Oracle and/or its affiliates.  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 -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ocfs2
+_require_scratch_reflink
+_require_cp_reflink
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs --fs-features=local,unwritten,refcount,inline-data > $seqres.full 2>&1
+tunefs.ocfs2 --query '%H' $SCRATCH_DEV | grep -q 'inline-data' || \
+	_notrun "Inline data is not supported."
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+sz=65536
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
+echo x > $testdir/file2
+echo x > $testdir/file3
+echo y > $testdir/file4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file5 >> $seqres.full
+echo a > $testdir/file6
+_scratch_cycle_mount
+
+echo "reflink into the start of file2"
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+
+echo "reflink past the stuff in file3"
+_reflink_range $testdir/file1 0 $testdir/file3 $sz $sz >> $seqres.full
+
+echo "reflink an inline-data file to a regular one"
+_cp_reflink $testdir/file4 $testdir/file5 >> $seqres.full
+
+echo "reflink an inline-data file to another inline-data file"
+_cp_reflink $testdir/file4 $testdir/file6 >> $seqres.full
+
+echo "Verify the whole mess"
+_scratch_cycle_mount
+md5sum $testdir/file* | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/ocfs2/001.out b/tests/ocfs2/001.out
new file mode 100644
index 0000000..99fa43a
--- /dev/null
+++ b/tests/ocfs2/001.out
@@ -0,0 +1,14 @@
+QA output created by 001
+Format and mount
+Create the original files
+reflink into the start of file2
+reflink past the stuff in file3
+reflink an inline-data file to a regular one
+reflink an inline-data file to another inline-data file
+Verify the whole mess
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file1
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file2
+4e68a2e24b6b0f386ab39d01d902293d  SCRATCH_MNT/test-001/file3
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file4
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file5
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file6
diff --git a/tests/ocfs2/Makefile b/tests/ocfs2/Makefile
new file mode 100644
index 0000000..e133790
--- /dev/null
+++ b/tests/ocfs2/Makefile
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2017 Oracle.  All Rights Reserved.
+#
+
+TOPDIR = ../..
+include $(TOPDIR)/include/builddefs
+
+OCFS2_DIR = ocfs2
+TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(OCFS2_DIR)
+
+include $(BUILDRULES)
+
+install:
+	$(INSTALL) -m 755 -d $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
+	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
+
+# Nothing.
+install-dev install-lib:
diff --git a/tests/ocfs2/group b/tests/ocfs2/group
new file mode 100644
index 0000000..28e6807
--- /dev/null
+++ b/tests/ocfs2/group
@@ -0,0 +1 @@
+001 auto quick clone


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

* [PATCH 2/7] common: add leading underscore to get_block_size
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
  2017-01-05  1:04 ` [PATCH 1/7] ocfs2: test reflinking to inline data files Darrick J. Wong
@ 2017-01-05  1:04 ` Darrick J. Wong
  2017-01-09 10:20   ` Eryu Guan
  2017-01-05  1:04 ` [PATCH 3/7] ocfs2/reflink: fix file block size reporting Darrick J. Wong
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:04 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Add a leading underscore to the get_block_size helper since it's a
common function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/attr       |    4 ++--
 common/defrag     |    2 +-
 common/filter     |    4 ++--
 common/punch      |    2 +-
 common/rc         |    4 ++--
 tests/btrfs/017   |    2 +-
 tests/btrfs/052   |    2 +-
 tests/btrfs/055   |    2 +-
 tests/btrfs/056   |    2 +-
 tests/btrfs/094   |    2 +-
 tests/btrfs/095   |    2 +-
 tests/btrfs/096   |    2 +-
 tests/btrfs/097   |    2 +-
 tests/btrfs/098   |    2 +-
 tests/btrfs/103   |    2 +-
 tests/generic/017 |    2 +-
 tests/generic/064 |    2 +-
 tests/generic/150 |    2 +-
 tests/generic/151 |    2 +-
 tests/generic/152 |    2 +-
 tests/generic/153 |    2 +-
 tests/generic/154 |    2 +-
 tests/generic/155 |    2 +-
 tests/generic/156 |    2 +-
 tests/generic/157 |    2 +-
 tests/generic/158 |    2 +-
 tests/generic/159 |    2 +-
 tests/generic/160 |    2 +-
 tests/generic/171 |    2 +-
 tests/generic/172 |    2 +-
 tests/generic/173 |    2 +-
 tests/generic/174 |    2 +-
 tests/generic/175 |    2 +-
 tests/generic/176 |    2 +-
 tests/generic/205 |    2 +-
 tests/generic/206 |    2 +-
 tests/generic/216 |    2 +-
 tests/generic/217 |    2 +-
 tests/generic/218 |    2 +-
 tests/generic/220 |    2 +-
 tests/generic/222 |    2 +-
 tests/generic/227 |    2 +-
 tests/generic/229 |    2 +-
 tests/generic/238 |    2 +-
 tests/generic/240 |    2 +-
 tests/generic/242 |    2 +-
 tests/generic/243 |    2 +-
 tests/generic/256 |    2 +-
 tests/generic/273 |    2 +-
 tests/generic/296 |    2 +-
 tests/generic/297 |    2 +-
 tests/generic/298 |    2 +-
 tests/generic/301 |    2 +-
 tests/generic/302 |    2 +-
 tests/generic/308 |    2 +-
 tests/generic/391 |    2 +-
 tests/shared/298  |    2 +-
 tests/xfs/127     |    2 +-
 tests/xfs/128     |    2 +-
 tests/xfs/129     |    2 +-
 tests/xfs/132     |    2 +-
 tests/xfs/139     |    2 +-
 tests/xfs/140     |    2 +-
 tests/xfs/169     |    2 +-
 tests/xfs/180     |    2 +-
 tests/xfs/182     |    2 +-
 tests/xfs/184     |    2 +-
 tests/xfs/192     |    2 +-
 tests/xfs/193     |    2 +-
 tests/xfs/198     |    2 +-
 tests/xfs/200     |    2 +-
 tests/xfs/204     |    2 +-
 tests/xfs/208     |    2 +-
 tests/xfs/211     |    2 +-
 tests/xfs/215     |    2 +-
 tests/xfs/218     |    2 +-
 tests/xfs/219     |    2 +-
 tests/xfs/221     |    2 +-
 tests/xfs/223     |    2 +-
 tests/xfs/224     |    2 +-
 tests/xfs/225     |    2 +-
 tests/xfs/226     |    2 +-
 tests/xfs/228     |    2 +-
 tests/xfs/230     |    2 +-
 tests/xfs/231     |    2 +-
 tests/xfs/232     |    2 +-
 tests/xfs/233     |    2 +-
 tests/xfs/234     |    2 +-
 tests/xfs/236     |    2 +-
 tests/xfs/265     |    2 +-
 tests/xfs/309     |    2 +-
 tests/xfs/310     |    4 ++--
 tests/xfs/328     |    2 +-
 tests/xfs/331     |    2 +-
 tests/xfs/335     |    2 +-
 tests/xfs/336     |    2 +-
 tests/xfs/337     |    2 +-
 tests/xfs/341     |    2 +-
 tests/xfs/342     |    2 +-
 tests/xfs/344     |    2 +-
 tests/xfs/345     |    2 +-
 tests/xfs/346     |    2 +-
 tests/xfs/347     |    2 +-
 103 files changed, 107 insertions(+), 107 deletions(-)


diff --git a/common/attr b/common/attr
index ce2d76a..08643e6 100644
--- a/common/attr
+++ b/common/attr
@@ -257,7 +257,7 @@ _sort_getfattr_output()
 if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" ]; then
 	MAX_ATTRS=1000
 else # Assume max ~1 block of attrs
-	BLOCK_SIZE=`get_block_size $TEST_DIR`
+	BLOCK_SIZE=`_get_block_size $TEST_DIR`
 	# user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead
 	let MAX_ATTRS=$BLOCK_SIZE/40
 fi
@@ -268,7 +268,7 @@ export MAX_ATTRS
 if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" -o "$FSTYP" == "btrfs" ]; then
 	MAX_ATTRVAL_SIZE=64
 else # Assume max ~1 block of attrs
-	BLOCK_SIZE=`get_block_size $TEST_DIR`
+	BLOCK_SIZE=`_get_block_size $TEST_DIR`
 	# leave a little overhead
 	let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256
 fi
diff --git a/common/defrag b/common/defrag
index 986b4bf..d279382 100644
--- a/common/defrag
+++ b/common/defrag
@@ -29,7 +29,7 @@ _require_defrag()
     ext4|ext4dev)
 	testfile="$TEST_DIR/$$-test.defrag"
 	donorfile="$TEST_DIR/$$-donor.defrag"
-	bsize=`get_block_size $TEST_DIR`
+	bsize=`_get_block_size $TEST_DIR`
 	$XFS_IO_PROG -f -c "pwrite -b $bsize 0 $bsize" $testfile > /dev/null
 	cp $testfile $donorfile
 	echo $testfile | $here/src/e4compact -v -f $donorfile | \
diff --git a/common/filter b/common/filter
index 397b456..3666a68 100644
--- a/common/filter
+++ b/common/filter
@@ -265,7 +265,7 @@ _filter_xfs_io_units_modified()
 
 _filter_xfs_io_blocks_modified()
 {
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 	_filter_xfs_io_units_modified "Block" $BLOCK_SIZE
 }
@@ -383,7 +383,7 @@ _filter_ro_mount() {
 
 _filter_od()
 {
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 	$AWK_PROG -v block_size=$BLOCK_SIZE '
 		/^[0-9]+/ {
 			offset = strtonum("0"$1);
diff --git a/common/punch b/common/punch
index 44c6e1c..c4ed261 100644
--- a/common/punch
+++ b/common/punch
@@ -584,7 +584,7 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	block_size=`get_block_size $TEST_DIR`
+	block_size=`_get_block_size $TEST_DIR`
 	$XFS_IO_PROG -f -c "truncate $block_size" \
 		-c "pwrite 0 $block_size" $sync_cmd \
 		-c "$zero_cmd 128 128" \
diff --git a/common/rc b/common/rc
index c3ab658..7b62a18 100644
--- a/common/rc
+++ b/common/rc
@@ -3077,10 +3077,10 @@ _sysfs_dev()
 	echo /sys/dev/block/$_maj:$_min
 }
 
-get_block_size()
+_get_block_size()
 {
 	if [ -z $1 ] || [ ! -d $1 ]; then
-		echo "Missing mount point argument for get_block_size"
+		echo "Missing mount point argument for _get_block_size"
 		exit 1
 	fi
 	echo `stat -f -c %S $1`
diff --git a/tests/btrfs/017 b/tests/btrfs/017
index 3f409d3..1041957 100755
--- a/tests/btrfs/017
+++ b/tests/btrfs/017
@@ -62,7 +62,7 @@ rm -f $seqres.full
 _scratch_mkfs "--nodesize 65536" >>$seqres.full 2>&1
 _scratch_mount
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 EXTENT_SIZE=$((2 * $BLOCK_SIZE))
 
 $XFS_IO_PROG -f -d -c "pwrite 0 $EXTENT_SIZE" $SCRATCH_MNT/foo \
diff --git a/tests/btrfs/052 b/tests/btrfs/052
index 599d261..c76d245 100755
--- a/tests/btrfs/052
+++ b/tests/btrfs/052
@@ -58,7 +58,7 @@ test_btrfs_clone_same_file()
 	_scratch_mkfs >/dev/null 2>&1
 	_scratch_mount $MOUNT_OPTIONS
 
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 	EXTENT_SIZE=$((2 * $BLOCK_SIZE))
 
diff --git a/tests/btrfs/055 b/tests/btrfs/055
index 29afdba..481d5c8 100755
--- a/tests/btrfs/055
+++ b/tests/btrfs/055
@@ -59,7 +59,7 @@ test_btrfs_clone_with_holes()
 	_scratch_mkfs "$1" >/dev/null 2>&1
 	_scratch_mount
 
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 	EXTENT_SIZE=$((2 * $BLOCK_SIZE))
 
diff --git a/tests/btrfs/056 b/tests/btrfs/056
index ef515a1..d9b6fd7 100755
--- a/tests/btrfs/056
+++ b/tests/btrfs/056
@@ -67,7 +67,7 @@ test_btrfs_clone_fsync_log_recover()
 	MOUNT_OPTIONS="$MOUNT_OPTIONS $2"
 	_mount_flakey
 
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 	EXTENT_SIZE=$((2 * $BLOCK_SIZE))
 
diff --git a/tests/btrfs/094 b/tests/btrfs/094
index 52b7ed2..452c008 100755
--- a/tests/btrfs/094
+++ b/tests/btrfs/094
@@ -66,7 +66,7 @@ mkdir $send_files_dir
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount "-o compress"
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 # Create the file with a single extent of 32 blocks. This creates a metadata
 # file extent item with a data start offset of 0 and a logical length of
diff --git a/tests/btrfs/095 b/tests/btrfs/095
index b477b57..f256e88 100755
--- a/tests/btrfs/095
+++ b/tests/btrfs/095
@@ -62,7 +62,7 @@ _scratch_mkfs >>$seqres.full 2>&1
 _init_flakey
 _mount_flakey
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 # Create prealloc extent covering file block range [40, 155[
 $XFS_IO_PROG -f -c "falloc $((40 * $BLOCK_SIZE)) $((115 * $BLOCK_SIZE))" \
diff --git a/tests/btrfs/096 b/tests/btrfs/096
index 039e09d..fd13cf7 100755
--- a/tests/btrfs/096
+++ b/tests/btrfs/096
@@ -50,7 +50,7 @@ rm -f $seqres.full
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 # Create our test files. File foo has the same 2k of data at offset $BLOCK_SIZE
 # as file bar has at its offset 0.
diff --git a/tests/btrfs/097 b/tests/btrfs/097
index 4b4dd18..d83cc46 100755
--- a/tests/btrfs/097
+++ b/tests/btrfs/097
@@ -56,7 +56,7 @@ mkdir $send_files_dir
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 # Create our test file with a single extent of 16 blocks starting at a file
 # offset mapped by 32nd block.
diff --git a/tests/btrfs/098 b/tests/btrfs/098
index f916c37..ba95fd3 100755
--- a/tests/btrfs/098
+++ b/tests/btrfs/098
@@ -57,7 +57,7 @@ _scratch_mkfs >>$seqres.full 2>&1
 _init_flakey
 _mount_flakey
 
-BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 # Create our test file with a single 25 block extent starting at file offset
 # mapped by 200th block We fsync the file here to make the fsync log tree get a
diff --git a/tests/btrfs/103 b/tests/btrfs/103
index caa979a..b672d62 100755
--- a/tests/btrfs/103
+++ b/tests/btrfs/103
@@ -55,7 +55,7 @@ test_clone_and_read_compressed_extent()
 	_scratch_mkfs >>$seqres.full 2>&1
 	_scratch_mount $mount_opts
 
-	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
 	# Create a test file with a single extent that is compressed (the
 	# data we write into it is highly compressible no matter which
diff --git a/tests/generic/017 b/tests/generic/017
index 5fe4628..419e762 100755
--- a/tests/generic/017
+++ b/tests/generic/017
@@ -53,7 +53,7 @@ _scratch_mount
 testfile=$SCRATCH_MNT/$seq.$$
 BLOCKS=10240
 
-BSIZE=`get_block_size $SCRATCH_MNT`
+BSIZE=`_get_block_size $SCRATCH_MNT`
 
 length=$(($BLOCKS * $BSIZE))
 
diff --git a/tests/generic/064 b/tests/generic/064
index d384a9a..8cd31b3 100755
--- a/tests/generic/064
+++ b/tests/generic/064
@@ -49,7 +49,7 @@ _require_xfs_io_command "fcollapse"
 src=$SCRATCH_MNT/testfile
 dest=$SCRATCH_MNT/testfile.dest
 BLOCKS=100
-BSIZE=`get_block_size $SCRATCH_MNT`
+BSIZE=`_get_block_size $SCRATCH_MNT`
 rm -f $seqres.full
 
 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
diff --git a/tests/generic/150 b/tests/generic/150
index fadbb42..b57db51 100755
--- a/tests/generic/150
+++ b/tests/generic/150
@@ -55,7 +55,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/151 b/tests/generic/151
index b0f0521..efb93ed 100755
--- a/tests/generic/151
+++ b/tests/generic/151
@@ -59,7 +59,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/152 b/tests/generic/152
index aa10bcf..ee009ea 100755
--- a/tests/generic/152
+++ b/tests/generic/152
@@ -60,7 +60,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/153 b/tests/generic/153
index 2ddb48d..fb5d552 100755
--- a/tests/generic/153
+++ b/tests/generic/153
@@ -60,7 +60,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/154 b/tests/generic/154
index f270ccb..9daee70 100755
--- a/tests/generic/154
+++ b/tests/generic/154
@@ -59,7 +59,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 free_blocks0=$(stat -f $testdir -c '%f')
diff --git a/tests/generic/155 b/tests/generic/155
index 23057c0..9eead24 100755
--- a/tests/generic/155
+++ b/tests/generic/155
@@ -64,7 +64,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/156 b/tests/generic/156
index e062b56..a81b91a 100755
--- a/tests/generic/156
+++ b/tests/generic/156
@@ -67,7 +67,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/157 b/tests/generic/157
index 9284c55..722dc22 100755
--- a/tests/generic/157
+++ b/tests/generic/157
@@ -60,7 +60,7 @@ testdir2=$SCRATCH_MNT/test-$seq
 mkdir $testdir2
 
 echo "Create the original files"
-blksz="$(get_block_size $testdir1)"
+blksz="$(_get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/158 b/tests/generic/158
index 086c522..1e16f5d 100755
--- a/tests/generic/158
+++ b/tests/generic/158
@@ -60,7 +60,7 @@ testdir2=$SCRATCH_MNT/test-$seq
 mkdir $testdir2
 
 echo "Create the original files"
-blksz="$(get_block_size $testdir1)"
+blksz="$(_get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/159 b/tests/generic/159
index 6f75b73..7e52d5c 100755
--- a/tests/generic/159
+++ b/tests/generic/159
@@ -54,7 +54,7 @@ rm -rf $testdir1
 mkdir $testdir1
 
 echo "Create the original files"
-blksz="$(get_block_size $testdir1)"
+blksz="$(_get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/160 b/tests/generic/160
index 066bf5e..409b15e 100755
--- a/tests/generic/160
+++ b/tests/generic/160
@@ -54,7 +54,7 @@ rm -rf $testdir1
 mkdir $testdir1
 
 echo "Create the original files"
-blksz="$(get_block_size $testdir1)"
+blksz="$(_get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/171 b/tests/generic/171
index 916d663..0942ac3 100755
--- a/tests/generic/171
+++ b/tests/generic/171
@@ -58,7 +58,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/172 b/tests/generic/172
index 2727836..d8ab882 100755
--- a/tests/generic/172
+++ b/tests/generic/172
@@ -58,7 +58,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 umount $SCRATCH_MNT
 
 file_size=$((168 * 1024 * 1024))
diff --git a/tests/generic/173 b/tests/generic/173
index a414c8e..ad4e5da 100755
--- a/tests/generic/173
+++ b/tests/generic/173
@@ -58,7 +58,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/174 b/tests/generic/174
index 1eeff69..d230577 100755
--- a/tests/generic/174
+++ b/tests/generic/174
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/175 b/tests/generic/175
index f4f19f8..df25f0a 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -56,7 +56,7 @@ testdir="$SCRATCH_MNT/test-$seq"
 mkdir "$testdir"
 
 echo "Create a one block file"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
 fnr=19
diff --git a/tests/generic/176 b/tests/generic/176
index 76e923a..3e61b68 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -60,7 +60,7 @@ mkdir "$testdir"
 # 2^17 blocks... that should be plenty for anyone.
 fnr=20
 free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(get_block_size "$testdir")
+blksz=$(_get_block_size "$testdir")
 space_avail=$((free_blocks * blksz))
 calc_space() {
 	blocks_needed=$(( 2 ** (fnr + 1) ))
diff --git a/tests/generic/205 b/tests/generic/205
index cfda8c3..65e345a 100755
--- a/tests/generic/205
+++ b/tests/generic/205
@@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/206 b/tests/generic/206
index 909956f..1816502 100755
--- a/tests/generic/206
+++ b/tests/generic/206
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/216 b/tests/generic/216
index d9b868a..d85c1e6 100755
--- a/tests/generic/216
+++ b/tests/generic/216
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/217 b/tests/generic/217
index 65113d9..19d6f00 100755
--- a/tests/generic/217
+++ b/tests/generic/217
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/218 b/tests/generic/218
index 21029ef..f69c02a 100755
--- a/tests/generic/218
+++ b/tests/generic/218
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/220 b/tests/generic/220
index c54bf06..0678b5f 100755
--- a/tests/generic/220
+++ b/tests/generic/220
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/222 b/tests/generic/222
index d7ee57e..24c54bb 100755
--- a/tests/generic/222
+++ b/tests/generic/222
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/227 b/tests/generic/227
index fa6a33e..eb79bac 100755
--- a/tests/generic/227
+++ b/tests/generic/227
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/229 b/tests/generic/229
index 3e2c6f4..332e69c 100755
--- a/tests/generic/229
+++ b/tests/generic/229
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
diff --git a/tests/generic/238 b/tests/generic/238
index a2f44e8..df13c63 100755
--- a/tests/generic/238
+++ b/tests/generic/238
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
diff --git a/tests/generic/240 b/tests/generic/240
index e32f15a..7fbd4b3 100755
--- a/tests/generic/240
+++ b/tests/generic/240
@@ -62,7 +62,7 @@ rm -f $seqres.full
 rm -f $TEST_DIR/aiodio_sparse
 
 logical_block_size=`_min_dio_alignment $TEST_DEV`
-fs_block_size=`get_block_size $TEST_DIR`
+fs_block_size=`_get_block_size $TEST_DIR`
 file_size=$((8 * $fs_block_size))
 
 if [ $fs_block_size -le $logical_block_size ]; then
diff --git a/tests/generic/242 b/tests/generic/242
index 2b07067..1bfeb77 100755
--- a/tests/generic/242
+++ b/tests/generic/242
@@ -65,7 +65,7 @@ bufnr=1280
 bufsize=$((blksz * bufnr))
 
 free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 space_needed=$(((filesize * 3) * 5 / 4))
 space_avail=$((free_blocks * real_blksz))
 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
diff --git a/tests/generic/243 b/tests/generic/243
index 1ba3e8a..59ae6e8 100755
--- a/tests/generic/243
+++ b/tests/generic/243
@@ -66,7 +66,7 @@ bufnr=1280
 bufsize=$((blksz * bufnr))
 
 free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 space_needed=$(((filesize * 3) * 5 / 4))
 space_avail=$((free_blocks * real_blksz))
 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
diff --git a/tests/generic/256 b/tests/generic/256
index 63f2d4f..3b00d56 100755
--- a/tests/generic/256
+++ b/tests/generic/256
@@ -117,7 +117,7 @@ _scratch_mount
 # Test must be able to write files with non-root permissions
 chmod 777 $SCRATCH_MNT
 
-block_size=`get_block_size $SCRATCH_MNT`
+block_size=`_get_block_size $SCRATCH_MNT`
 _test_full_fs_punch $(( $block_size * 2 )) $block_size 500 $SCRATCH_MNT/252.$$ $block_size
 
 status=0 ; exit
diff --git a/tests/generic/273 b/tests/generic/273
index d90212e..578b1da 100755
--- a/tests/generic/273
+++ b/tests/generic/273
@@ -106,7 +106,7 @@ _do_workload()
 {
 	_pids=""
 	_pid=1
-	block_size=$(get_block_size $SCRATCH_MNT)
+	block_size=$(_get_block_size $SCRATCH_MNT)
 	
 	_threads_set
 	_file_create $block_size
diff --git a/tests/generic/296 b/tests/generic/296
index 9199006..31c8e89 100755
--- a/tests/generic/296
+++ b/tests/generic/296
@@ -61,7 +61,7 @@ filesize=$((blksz * nr))
 bufnr=16
 bufsize=$((blksz * bufnr))
 
-real_blksz=$(get_block_size "$testdir")
+real_blksz=$(_get_block_size "$testdir")
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
 
 echo "Create the original files"
diff --git a/tests/generic/297 b/tests/generic/297
index 8dfc342..f7eb37b 100755
--- a/tests/generic/297
+++ b/tests/generic/297
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create a one block file"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
diff --git a/tests/generic/298 b/tests/generic/298
index 3f6446c..b518da1 100755
--- a/tests/generic/298
+++ b/tests/generic/298
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create a one block file"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
diff --git a/tests/generic/301 b/tests/generic/301
index a196cd4..67b1a0c 100755
--- a/tests/generic/301
+++ b/tests/generic/301
@@ -65,7 +65,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/generic/302 b/tests/generic/302
index b2298cb..3834f98 100755
--- a/tests/generic/302
+++ b/tests/generic/302
@@ -66,7 +66,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/generic/308 b/tests/generic/308
index e639da1..afc9bf5 100755
--- a/tests/generic/308
+++ b/tests/generic/308
@@ -49,7 +49,7 @@ _require_test
 rm -f $seqres.full
 echo "Silence is golden"
 
-block_size=`get_block_size $TEST_DIR`
+block_size=`_get_block_size $TEST_DIR`
 
 # On unpatched ext4, if an extent exists which includes the block right
 # before the maximum file offset, and the block for the maximum file offset
diff --git a/tests/generic/391 b/tests/generic/391
index 5db8587..6da1781 100755
--- a/tests/generic/391
+++ b/tests/generic/391
@@ -54,7 +54,7 @@ _require_test
 _require_xfs_io_command "falloc"
 _require_test_program "dio-interleaved"
 
-extent_size="$(($(get_block_size "$TEST_DIR") * 2))"
+extent_size="$(($(_get_block_size "$TEST_DIR") * 2))"
 num_extents=1024
 testfile="$TEST_DIR/$$-testfile"
 
diff --git a/tests/shared/298 b/tests/shared/298
index 2ed7eab..0a11300 100755
--- a/tests/shared/298
+++ b/tests/shared/298
@@ -165,7 +165,7 @@ echo "done."
 
 echo -n "Comparing holes to the reported space from FS..."
 # Get block size
-block_size=$(get_block_size $loop_mnt/)
+block_size=$(_get_block_size $loop_mnt/)
 sectors_per_block=`expr $block_size / 512`
 
 # Obtain free space from filesystem
diff --git a/tests/xfs/127 b/tests/xfs/127
index 8212ec3..9df9990 100755
--- a/tests/xfs/127
+++ b/tests/xfs/127
@@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file and reflink to copy1, copy2"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 _pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
 _cp_reflink $testdir/original $testdir/copy1
 _cp_reflink $testdir/copy1 $testdir/copy2
diff --git a/tests/xfs/128 b/tests/xfs/128
index 6bb6282..8e29b8d 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -60,7 +60,7 @@ echo "Create the original file and reflink to file2, file3"
 blks=2000
 margin=160
 blksz=65536
-real_blksz="$(get_block_size $testdir)"
+real_blksz="$(_get_block_size $testdir)"
 blksz_factor=$((blksz / real_blksz))
 _pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file2
diff --git a/tests/xfs/129 b/tests/xfs/129
index 10880e5..687d627 100755
--- a/tests/xfs/129
+++ b/tests/xfs/129
@@ -59,7 +59,7 @@ mkdir $testdir
 metadump_file=$TEST_DIR/${seq}_metadump
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((4 * blksz / 12))
 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
 
diff --git a/tests/xfs/132 b/tests/xfs/132
index ac8dc25..178e268 100755
--- a/tests/xfs/132
+++ b/tests/xfs/132
@@ -72,7 +72,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 blks=2000
 margin=100
 sz=$((blksz * blks))
diff --git a/tests/xfs/139 b/tests/xfs/139
index b62ef1b..4ee7ea2 100755
--- a/tests/xfs/139
+++ b/tests/xfs/139
@@ -54,7 +54,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 
 echo "Create the original files"
 sz=$((48 * 1048576))
diff --git a/tests/xfs/140 b/tests/xfs/140
index a87357b..74d8f12 100755
--- a/tests/xfs/140
+++ b/tests/xfs/140
@@ -54,7 +54,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-blksz=$(get_block_size $testdir)
+blksz=$(_get_block_size $testdir)
 
 echo "Create the original files"
 sz=$((48 * 1048576))
diff --git a/tests/xfs/169 b/tests/xfs/169
index acd4b89..96f7c5e 100755
--- a/tests/xfs/169
+++ b/tests/xfs/169
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((8 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/180 b/tests/xfs/180
index e2d3369..ce2ac26 100755
--- a/tests/xfs/180
+++ b/tests/xfs/180
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/182 b/tests/xfs/182
index f48a8c7..4413c7d 100755
--- a/tests/xfs/182
+++ b/tests/xfs/182
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/184 b/tests/xfs/184
index 0860701..54eb115 100755
--- a/tests/xfs/184
+++ b/tests/xfs/184
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/192 b/tests/xfs/192
index e56c860..d8bdb25 100755
--- a/tests/xfs/192
+++ b/tests/xfs/192
@@ -70,7 +70,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/193 b/tests/xfs/193
index 2cd8880..76cb143 100755
--- a/tests/xfs/193
+++ b/tests/xfs/193
@@ -67,7 +67,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/198 b/tests/xfs/198
index f55ed23..d185ca2 100755
--- a/tests/xfs/198
+++ b/tests/xfs/198
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/200 b/tests/xfs/200
index d4363a4..e70fda3 100755
--- a/tests/xfs/200
+++ b/tests/xfs/200
@@ -71,7 +71,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/204 b/tests/xfs/204
index 3dbaf95..c0b69cf 100755
--- a/tests/xfs/204
+++ b/tests/xfs/204
@@ -72,7 +72,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/208 b/tests/xfs/208
index e64106a..62192cb 100755
--- a/tests/xfs/208
+++ b/tests/xfs/208
@@ -71,7 +71,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/211 b/tests/xfs/211
index 68abaf7..0d150f1 100755
--- a/tests/xfs/211
+++ b/tests/xfs/211
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 2 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/215 b/tests/xfs/215
index c4bb322..c2b9c0e 100755
--- a/tests/xfs/215
+++ b/tests/xfs/215
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/218 b/tests/xfs/218
index 7fcca82..31cac44 100755
--- a/tests/xfs/218
+++ b/tests/xfs/218
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/219 b/tests/xfs/219
index f02cc2d..2a8d966 100755
--- a/tests/xfs/219
+++ b/tests/xfs/219
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/221 b/tests/xfs/221
index 1dfcd96..405d2d5 100755
--- a/tests/xfs/221
+++ b/tests/xfs/221
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/223 b/tests/xfs/223
index d93b311..6654872 100755
--- a/tests/xfs/223
+++ b/tests/xfs/223
@@ -67,7 +67,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/224 b/tests/xfs/224
index 7a59dba..376abe1 100755
--- a/tests/xfs/224
+++ b/tests/xfs/224
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/225 b/tests/xfs/225
index 596cdb8..5864677 100755
--- a/tests/xfs/225
+++ b/tests/xfs/225
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/226 b/tests/xfs/226
index d3a0dc0..44605b1 100755
--- a/tests/xfs/226
+++ b/tests/xfs/226
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/228 b/tests/xfs/228
index 994f501..9d8e9a9 100755
--- a/tests/xfs/228
+++ b/tests/xfs/228
@@ -72,7 +72,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/230 b/tests/xfs/230
index f4b9f15..e42013f 100755
--- a/tests/xfs/230
+++ b/tests/xfs/230
@@ -72,7 +72,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/231 b/tests/xfs/231
index 54fc46d..f0b64c0 100755
--- a/tests/xfs/231
+++ b/tests/xfs/231
@@ -72,7 +72,7 @@ bufnr=2
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/232 b/tests/xfs/232
index 0ffa198..6b74997 100755
--- a/tests/xfs/232
+++ b/tests/xfs/232
@@ -73,7 +73,7 @@ bufnr=2
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/233 b/tests/xfs/233
index a0c1612..e61c444 100755
--- a/tests/xfs/233
+++ b/tests/xfs/233
@@ -53,7 +53,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original files"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 _pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
 cp -p $testdir/original $testdir/copy1
 cp -p $testdir/copy1 $testdir/copy2
diff --git a/tests/xfs/234 b/tests/xfs/234
index 9a60ec6..3480758 100755
--- a/tests/xfs/234
+++ b/tests/xfs/234
@@ -59,7 +59,7 @@ mkdir $testdir
 metadump_file=$TEST_DIR/${seq}_metadump
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((4 * blksz / 12))
 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
 sync
diff --git a/tests/xfs/236 b/tests/xfs/236
index e5840cb..3ce4de8 100755
--- a/tests/xfs/236
+++ b/tests/xfs/236
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((8 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/265 b/tests/xfs/265
index c8fb527..3dfeb70 100755
--- a/tests/xfs/265
+++ b/tests/xfs/265
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((2 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/309 b/tests/xfs/309
index 38c0452..0dd2dcf 100755
--- a/tests/xfs/309
+++ b/tests/xfs/309
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 nr_blks=$((2 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/310 b/tests/xfs/310
index cce21be..c78f6f1 100755
--- a/tests/xfs/310
+++ b/tests/xfs/310
@@ -58,7 +58,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount >> $seqres.full
 
 testdir=$SCRATCH_MNT/test-$seq
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 umount $SCRATCH_MNT
 
@@ -72,7 +72,7 @@ xfs_info $SCRATCH_MNT >> $seqres.full
 
 echo "Create the original file blocks"
 mkdir $testdir
-blksz="$(get_block_size $testdir)"
+blksz="$(_get_block_size $testdir)"
 $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
 
 echo "Check extent count"
diff --git a/tests/xfs/328 b/tests/xfs/328
index 8518456..90c5f2b 100755
--- a/tests/xfs/328
+++ b/tests/xfs/328
@@ -62,7 +62,7 @@ mkdir "$testdir"
 # 2^10 blocks... that should be plenty for anyone.
 fnr=$((12 + LOAD_FACTOR))
 free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(get_block_size $testdir)
+blksz=$(_get_block_size $testdir)
 space_avail=$((free_blocks * blksz))
 calc_space()
 {
diff --git a/tests/xfs/331 b/tests/xfs/331
index 8a7692d..8a1367c 100755
--- a/tests/xfs/331
+++ b/tests/xfs/331
@@ -55,7 +55,7 @@ _scratch_mkfs > "$seqres.full" 2>&1
 
 echo "+ mount fs image"
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # btree header is 56 bytes; an rmapbt record is 24 bytes; and
 # a rmapbt key/pointer pair is 44 bytes.
diff --git a/tests/xfs/335 b/tests/xfs/335
index 5e48f59..5afeaa8 100755
--- a/tests/xfs/335
+++ b/tests/xfs/335
@@ -54,7 +54,7 @@ _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
 . $tmp.mkfs
 cat $tmp.mkfs > "$seqres.full" 2>&1
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 echo "Create a three-level rtrmapbt"
 # inode core size is at least 176 bytes; btree header is 56 bytes;
diff --git a/tests/xfs/336 b/tests/xfs/336
index b3b703d..39838e9 100755
--- a/tests/xfs/336
+++ b/tests/xfs/336
@@ -54,7 +54,7 @@ _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
 . $tmp.mkfs
 cat $tmp.mkfs > "$seqres.full" 2>&1
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 metadump_file=$TEST_DIR/${seq}_metadump
 rm -rf $metadump_file
diff --git a/tests/xfs/337 b/tests/xfs/337
index 96a7be0..b61e722 100755
--- a/tests/xfs/337
+++ b/tests/xfs/337
@@ -57,7 +57,7 @@ cat $tmp.mkfs > "$seqres.full" 2>&1
 
 echo "+ mount fs image"
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
diff --git a/tests/xfs/341 b/tests/xfs/341
index 8a47b77..058e98e 100755
--- a/tests/xfs/341
+++ b/tests/xfs/341
@@ -54,7 +54,7 @@ _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
 . $tmp.mkfs
 cat $tmp.mkfs > "$seqres.full" 2>&1
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
diff --git a/tests/xfs/342 b/tests/xfs/342
index e0d2f33..a95b49d 100755
--- a/tests/xfs/342
+++ b/tests/xfs/342
@@ -53,7 +53,7 @@ _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
 . $tmp.mkfs
 cat $tmp.mkfs > "$seqres.full" 2>&1
 _scratch_mount
-blksz="$(get_block_size $SCRATCH_MNT)"
+blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
diff --git a/tests/xfs/344 b/tests/xfs/344
index 229e22a..806f7ab 100755
--- a/tests/xfs/344
+++ b/tests/xfs/344
@@ -70,7 +70,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/345 b/tests/xfs/345
index 4e31324..1684297 100755
--- a/tests/xfs/345
+++ b/tests/xfs/345
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/346 b/tests/xfs/346
index 7d7075a..90fe5eb 100755
--- a/tests/xfs/346
+++ b/tests/xfs/346
@@ -70,7 +70,7 @@ bufnr=8
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/347 b/tests/xfs/347
index e4f9635..2a13977 100755
--- a/tests/xfs/347
+++ b/tests/xfs/347
@@ -69,7 +69,7 @@ bufnr=8
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(get_block_size $testdir)
+real_blksz=$(_get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"


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

* [PATCH 3/7] ocfs2/reflink: fix file block size reporting
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
  2017-01-05  1:04 ` [PATCH 1/7] ocfs2: test reflinking to inline data files Darrick J. Wong
  2017-01-05  1:04 ` [PATCH 2/7] common: add leading underscore to get_block_size Darrick J. Wong
@ 2017-01-05  1:04 ` Darrick J. Wong
  2017-01-05  1:05 ` [PATCH 4/7] reflink: fix quota tests to work properly Darrick J. Wong
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:04 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Some of the reflink tests try to require a specific filesystem block
size so that they can test file block manipulation functions.  That's
straightforward for most filesystems but ocfs2 throws in the additional
twist that data fork block mappings are stored in units of clusters, not
blocks, which causes these reflink tests to fail.

Therefore, introduce a new helper that retrieves the file minimum block
size and adapt the reflink tests to use that instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: Add a leading underscore to the helper name.
---
 common/rc         |   21 +++++++++++++++++++--
 tests/generic/205 |    2 +-
 tests/generic/206 |    2 +-
 tests/generic/216 |    2 +-
 tests/generic/217 |    2 +-
 tests/generic/218 |    2 +-
 tests/generic/220 |    2 +-
 tests/generic/222 |    2 +-
 tests/generic/227 |    2 +-
 tests/generic/229 |    2 +-
 tests/generic/238 |    2 +-
 11 files changed, 29 insertions(+), 12 deletions(-)


diff --git a/common/rc b/common/rc
index 7b62a18..46bfb68 100644
--- a/common/rc
+++ b/common/rc
@@ -973,7 +973,7 @@ _scratch_mkfs_blocksized()
 	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
 	;;
     ocfs2)
-	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV
 	;;
     *)
 	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
@@ -3077,13 +3077,30 @@ _sysfs_dev()
 	echo /sys/dev/block/$_maj:$_min
 }
 
+# Get the minimum block size of a file.  Usually this is the
+# minimum fs block size, but some filesystems (ocfs2) do block
+# mappings in larger units.
+_get_file_block_size()
+{
+	if [ -z $1 ] || [ ! -d $1 ]; then
+		echo "Missing mount point argument for _get_file_block_size"
+		exit 1
+	fi
+	if [ "$FSTYP" = "ocfs2" ]; then
+		stat -c '%o' $1
+	else
+		_get_block_size $1
+	fi
+}
+
+# Get the minimum block size of an fs.
 _get_block_size()
 {
 	if [ -z $1 ] || [ ! -d $1 ]; then
 		echo "Missing mount point argument for _get_block_size"
 		exit 1
 	fi
-	echo `stat -f -c %S $1`
+	stat -f -c %S $1
 }
 
 get_page_size()
diff --git a/tests/generic/205 b/tests/generic/205
index 65e345a..564afc0 100755
--- a/tests/generic/205
+++ b/tests/generic/205
@@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/206 b/tests/generic/206
index 1816502..3fdbec2 100755
--- a/tests/generic/206
+++ b/tests/generic/206
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/216 b/tests/generic/216
index d85c1e6..93b0106 100755
--- a/tests/generic/216
+++ b/tests/generic/216
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/217 b/tests/generic/217
index 19d6f00..509f2c4 100755
--- a/tests/generic/217
+++ b/tests/generic/217
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/218 b/tests/generic/218
index f69c02a..92bc521 100755
--- a/tests/generic/218
+++ b/tests/generic/218
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/220 b/tests/generic/220
index 0678b5f..2bd0e99 100755
--- a/tests/generic/220
+++ b/tests/generic/220
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/222 b/tests/generic/222
index 24c54bb..eb2169c 100755
--- a/tests/generic/222
+++ b/tests/generic/222
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/227 b/tests/generic/227
index eb79bac..3fe2490 100755
--- a/tests/generic/227
+++ b/tests/generic/227
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/229 b/tests/generic/229
index 332e69c..55f875d 100755
--- a/tests/generic/229
+++ b/tests/generic/229
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
diff --git a/tests/generic/238 b/tests/generic/238
index df13c63..c60799d 100755
--- a/tests/generic/238
+++ b/tests/generic/238
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {


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

* [PATCH 4/7] reflink: fix quota tests to work properly
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
                   ` (2 preceding siblings ...)
  2017-01-05  1:04 ` [PATCH 3/7] ocfs2/reflink: fix file block size reporting Darrick J. Wong
@ 2017-01-05  1:05 ` Darrick J. Wong
  2017-01-09  8:55   ` Eryu Guan
  2017-01-09 20:53   ` [PATCH v2 " Darrick J. Wong
  2017-01-05  1:05 ` [PATCH 5/7] reflink: make error reporting consistent when simulating EIO Darrick J. Wong
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:05 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Fix the reflink quota tests to su to the fsgqa user so that we actually
test enforcement of quotas.  Seems that XFS enforces user quotas even
if root is writing to a user file, whereas everything else lets root
writes through.  Also clean up some of the variable usage and
_require_user.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: Refactor the quota block reporting into a helper function and
port all the existing tests.  Fix "fsgqa"/$qa_user usage too.
---
 common/quota          |   10 ++++++++++
 tests/generic/305     |   22 ++++++++++------------
 tests/generic/305.out |   30 +++++++++++++++---------------
 tests/generic/326     |   22 ++++++++++------------
 tests/generic/326.out |   30 +++++++++++++++---------------
 tests/generic/327     |   19 +++++++++----------
 tests/generic/327.out |   12 ++++++------
 tests/generic/328     |   29 ++++++++++++++---------------
 tests/generic/328.out |   28 ++++++++++++++--------------
 tests/xfs/213         |   22 ++++++++++------------
 tests/xfs/213.out     |   30 +++++++++++++++---------------
 tests/xfs/214         |   22 ++++++++++------------
 tests/xfs/214.out     |   30 +++++++++++++++---------------
 13 files changed, 153 insertions(+), 153 deletions(-)


diff --git a/common/quota b/common/quota
index d4ae861..5c6e680 100644
--- a/common/quota
+++ b/common/quota
@@ -302,5 +302,15 @@ _check_quota_usage()
 	}
 }
 
+# Report the block usage of root, $qa_user, and nobody
+_report_quota_blocks() {
+	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $3, $4, $5}'
+}
+
+# Report the inode usage of root, $qa_user, and nobody
+_report_quota_inodes() {
+	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}'
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/generic/305 b/tests/generic/305
index d73d87f..f0799eb 100755
--- a/tests/generic/305
+++ b/tests/generic/305
@@ -49,10 +49,8 @@ _require_cp_reflink
 _require_fiemap
 _require_quota
 _require_nobody
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -73,27 +71,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks
 
 echo "CoW one of the files"
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/generic/305.out b/tests/generic/305.out
index 0bfd620..fbd4e24 100644
--- a/tests/generic/305.out
+++ b/tests/generic/305.out
@@ -1,22 +1,22 @@
 QA output created by 305
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/generic/326 b/tests/generic/326
index 8afc6a2..a41e0cf 100755
--- a/tests/generic/326
+++ b/tests/generic/326
@@ -50,10 +50,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -74,27 +72,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks
 
 echo "CoW one of the files"
 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/generic/326.out b/tests/generic/326.out
index e771eb7..de7f20b 100644
--- a/tests/generic/326.out
+++ b/tests/generic/326.out
@@ -1,22 +1,22 @@
 QA output created by 326
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/generic/327 b/tests/generic/327
index c165ad5..2f132fe 100755
--- a/tests/generic/327
+++ b/tests/generic/327
@@ -48,10 +48,8 @@ _require_cp_reflink
 _require_fiemap
 _require_quota
 _require_nobody
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -67,20 +65,21 @@ mkdir $testdir
 sz=1048576
 echo "Create the original files"
 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
-chown fsgqa $testdir/file1
+chown $qa_user $testdir/file1
 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks
 _scratch_cycle_mount
+quotaon $SCRATCH_MNT 2> /dev/null
 
 echo "Set hard quota to prevent third reflink"
-setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
+_report_quota_blocks
 
 echo "Try to reflink again"
 touch $testdir/file3
-chown fsgqa $testdir/file3
-_cp_reflink $testdir/file1 $testdir/file3 2>&1 | _filter_scratch
-_repquota
+chown $qa_user $testdir/file3
+su $qa_user -c "cp --reflink=always -f $testdir/file1 $testdir/file3" 2>&1 | _filter_scratch
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/generic/327.out b/tests/generic/327.out
index 7160ff2..f4e145a 100644
--- a/tests/generic/327.out
+++ b/tests/generic/327.out
@@ -1,12 +1,12 @@
 QA output created by 327
 Format and mount
 Create the original files
-root      --       0       0       0              4     0     0       
-fsgqa     --    2048       0       0              2     0     0       
+root 0 0 0
+fsgqa 2048 0 0
 Set hard quota to prevent third reflink
-root      --       0       0       0              4     0     0       
-fsgqa     +-    2048       0    1024              2     0     0       
+root 0 0 0
+fsgqa 2048 0 1024
 Try to reflink again
 cp: failed to clone 'SCRATCH_MNT/test-327/file3' from 'SCRATCH_MNT/test-327/file1': Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    2048       0    1024              3     0     0       
+root 0 0 0
+fsgqa 2048 0 1024
diff --git a/tests/generic/328 b/tests/generic/328
index 705368e..dbf094f 100755
--- a/tests/generic/328
+++ b/tests/generic/328
@@ -49,10 +49,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -68,39 +66,40 @@ mkdir $testdir
 sz=1048576
 echo "Create the original files"
 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
-chown fsgqa $testdir/file1
+chown $qa_user $testdir/file1
 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
-_repquota
+_report_quota_blocks
 _scratch_cycle_mount
+quotaon $SCRATCH_MNT 2> /dev/null
 
 echo "Set hard quota to prevent rewrite"
-setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
+_report_quota_blocks
 
 echo "Try to dio write the whole file"
-_pwrite_byte 0x62 0 $sz $testdir/file1 -d 2>&1 >> $seqres.full | \
+su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
 	_filter_xfs_io_error
-_repquota
+_report_quota_blocks
 
 echo "Try to write the whole file"
-_pwrite_byte 0x62 0 $sz $testdir/file1 2>&1 >> $seqres.full | \
+su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
 	_filter_xfs_io_error
-_repquota
+_report_quota_blocks
 
 echo "Set hard quota to allow rewrite"
-setquota -u fsgqa 0 8192 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 8192 0 0 $SCRATCH_MNT
+_report_quota_blocks
 
 echo "Try to dio write the whole file"
 _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full
 sync
-_repquota
+_report_quota_blocks
 
 echo "Try to write the whole file"
 _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full
 sync
-_repquota
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/generic/328.out b/tests/generic/328.out
index 4630151..b7fe9f8 100644
--- a/tests/generic/328.out
+++ b/tests/generic/328.out
@@ -1,25 +1,25 @@
 QA output created by 328
 Format and mount
 Create the original files
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0       0              3     0     0       
+root 0 0 0
+fsgqa 3072 0 0
 Set hard quota to prevent rewrite
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Try to dio write the whole file
 pwrite: Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Try to write the whole file
 pwrite: Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Set hard quota to allow rewrite
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
 Try to dio write the whole file
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
 Try to write the whole file
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
diff --git a/tests/xfs/213 b/tests/xfs/213
index d5cc129..8e3565e 100755
--- a/tests/xfs/213
+++ b/tests/xfs/213
@@ -52,10 +52,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_xfs_io_command "cowextsize"
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -78,27 +76,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks
 
 echo "CoW one of the files"
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/xfs/213.out b/tests/xfs/213.out
index be8d56c..7dd30dd 100644
--- a/tests/xfs/213.out
+++ b/tests/xfs/213.out
@@ -1,22 +1,22 @@
 QA output created by 213
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3520       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3520 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/xfs/214 b/tests/xfs/214
index 35972c6..f5234fd 100755
--- a/tests/xfs/214
+++ b/tests/xfs/214
@@ -53,10 +53,8 @@ _require_quota
 _require_nobody
 _require_xfs_io_command "cowextsize"
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -79,27 +77,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks
 
 echo "CoW one of the files"
 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks
 
 # success, all done
 status=0
diff --git a/tests/xfs/214.out b/tests/xfs/214.out
index 496a503..2c7e358 100644
--- a/tests/xfs/214.out
+++ b/tests/xfs/214.out
@@ -1,22 +1,22 @@
 QA output created by 214
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3520       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3520 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0


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

* [PATCH 5/7] reflink: make error reporting consistent when simulating EIO
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
                   ` (3 preceding siblings ...)
  2017-01-05  1:05 ` [PATCH 4/7] reflink: fix quota tests to work properly Darrick J. Wong
@ 2017-01-05  1:05 ` Darrick J. Wong
  2017-01-05  1:05 ` [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests Darrick J. Wong
  2017-01-05  1:05 ` [PATCH 7/7] xfs/ext4: check negative inode size Darrick J. Wong
  6 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:05 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

When we're using dm-error to simulate failed devices, we don't really
know if the write or the fdatasync is going to receive the EIO.  For
tests that make a single (failed) write attempt and never retry, it's
sufficient to check that the file md5 doesn't change after recovery.
For tests that /do/ retry the write, we should capture the entire output
and just look for the word error instead of enshrining the exact perror
message (filename/function call and everything) in the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/265     |    6 +++++-
 tests/generic/265.out |    1 -
 tests/generic/266     |    5 ++++-
 tests/generic/266.out |    1 -
 tests/generic/267     |    2 +-
 tests/generic/268     |    5 ++++-
 tests/generic/268.out |    1 -
 tests/generic/271     |    5 +++--
 tests/generic/271.out |    1 -
 tests/generic/272     |    5 +++--
 tests/generic/272.out |    1 -
 tests/generic/276     |    2 +-
 tests/generic/276.out |    1 -
 tests/generic/278     |    5 +++--
 tests/generic/278.out |    1 -
 tests/generic/279     |    4 ++--
 tests/generic/279.out |    1 -
 tests/generic/281     |    4 ++--
 tests/generic/281.out |    1 -
 tests/generic/282     |    3 +--
 tests/generic/283     |    6 ++++--
 tests/generic/283.out |    1 -
 22 files changed, 33 insertions(+), 29 deletions(-)


diff --git a/tests/generic/265 b/tests/generic/265
index 8e9d5bc..ceddfbe 100755
--- a/tests/generic/265
+++ b/tests/generic/265
@@ -80,7 +80,11 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
+urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
+	-c "fdatasync" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
+
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
diff --git a/tests/generic/265.out b/tests/generic/265.out
index 1b67114..31eb4e9 100644
--- a/tests/generic/265.out
+++ b/tests/generic/265.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file2
 CoW and unmount
-fdatasync: Input/output error
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
 Check for damage
diff --git a/tests/generic/266 b/tests/generic/266
index 4f9816a..09541c8 100755
--- a/tests/generic/266
+++ b/tests/generic/266
@@ -80,7 +80,10 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
+urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
+	-c "fdatasync" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
 
 echo "Clean up the mess"
 _dmerror_unmount
diff --git a/tests/generic/266.out b/tests/generic/266.out
index dd34ad3..1641654 100644
--- a/tests/generic/266.out
+++ b/tests/generic/266.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file2
 CoW and unmount
-fdatasync: Input/output error
 Clean up the mess
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
diff --git a/tests/generic/267 b/tests/generic/267
index e3a6b0c..2ec6ad9 100755
--- a/tests/generic/267
+++ b/tests/generic/267
@@ -80,7 +80,7 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
 _dmerror_load_working_table
 rm -rf $testdir/file2 >> $seqres.full 2>&1
 _dmerror_unmount
diff --git a/tests/generic/268 b/tests/generic/268
index c7dcd57..b7d16ab 100755
--- a/tests/generic/268
+++ b/tests/generic/268
@@ -81,7 +81,10 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
+urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
+	-c "fdatasync" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
 _dmerror_load_working_table
 
 echo "Rewrite"
diff --git a/tests/generic/268.out b/tests/generic/268.out
index 234e8be..1a3b39a 100644
--- a/tests/generic/268.out
+++ b/tests/generic/268.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file2
 CoW and unmount
-fdatasync: Input/output error
 Rewrite
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
diff --git a/tests/generic/271 b/tests/generic/271
index ded8854..9439327 100755
--- a/tests/generic/271
+++ b/tests/generic/271
@@ -81,8 +81,9 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \
-	2>&1 >> $seqres.full | _filter_xfs_io_error
+urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
diff --git a/tests/generic/271.out b/tests/generic/271.out
index 54d5b0d..9b44ee7 100644
--- a/tests/generic/271.out
+++ b/tests/generic/271.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file2
 CoW and unmount
-pwrite: Input/output error
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
 Check for damage
diff --git a/tests/generic/272 b/tests/generic/272
index 5bc5b39..243adf5 100755
--- a/tests/generic/272
+++ b/tests/generic/272
@@ -81,8 +81,9 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \
-	2>&1 >> $seqres.full | _filter_xfs_io_error
+urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail"
 
 echo "Clean up the mess"
 _dmerror_unmount
diff --git a/tests/generic/272.out b/tests/generic/272.out
index 0b8bdca..10ecda9 100644
--- a/tests/generic/272.out
+++ b/tests/generic/272.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file2
 CoW and unmount
-pwrite: Input/output error
 Clean up the mess
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
diff --git a/tests/generic/276 b/tests/generic/276
index 83b902e..34b0029 100755
--- a/tests/generic/276
+++ b/tests/generic/276
@@ -82,7 +82,7 @@ echo "CoW and unmount"
 sync
 _dmerror_load_error_table
 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \
-	2>&1 >> $seqres.full | _filter_xfs_io_error
+	>> $seqres.full 2>&1
 _dmerror_load_working_table
 rm -rf $testdir/file2 >> $seqres.full 2>&1
 _dmerror_unmount
diff --git a/tests/generic/276.out b/tests/generic/276.out
index 88a0162..a080dd0 100644
--- a/tests/generic/276.out
+++ b/tests/generic/276.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file2
 CoW and unmount
-pwrite: Input/output error
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
 Check for damage
diff --git a/tests/generic/278 b/tests/generic/278
index 415742a..d751f01 100755
--- a/tests/generic/278
+++ b/tests/generic/278
@@ -82,8 +82,9 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \
-	2>&1 >> $seqres.full | _filter_xfs_io_error
+urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail"
 _dmerror_load_working_table
 
 echo "Rewrite"
diff --git a/tests/generic/278.out b/tests/generic/278.out
index 9ead4ac..cd22fcd 100644
--- a/tests/generic/278.out
+++ b/tests/generic/278.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file2
 CoW and unmount
-pwrite: Input/output error
 Rewrite
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
diff --git a/tests/generic/279 b/tests/generic/279
index 2f1ec4f..4541de3 100755
--- a/tests/generic/279
+++ b/tests/generic/279
@@ -80,8 +80,8 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1)
-cat $TEST_DIR/mwrite.out | tee -a $seqres.full
+$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
+	-c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
diff --git a/tests/generic/279.out b/tests/generic/279.out
index f34c2b2..009f05e 100644
--- a/tests/generic/279.out
+++ b/tests/generic/279.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file2
 CoW and unmount
-msync: Input/output error
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
 Check for damage
diff --git a/tests/generic/281 b/tests/generic/281
index c95acf2..e8e1661 100755
--- a/tests/generic/281
+++ b/tests/generic/281
@@ -80,8 +80,8 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1)
-cat $TEST_DIR/mwrite.out | tee -a $seqres.full
+$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
+	-c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
 
 echo "Clean up the mess"
 _dmerror_unmount
diff --git a/tests/generic/281.out b/tests/generic/281.out
index a2d8e3f..1bae187 100644
--- a/tests/generic/281.out
+++ b/tests/generic/281.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file2
 CoW and unmount
-msync: Input/output error
 Clean up the mess
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
diff --git a/tests/generic/282 b/tests/generic/282
index 6452025..8a30811 100755
--- a/tests/generic/282
+++ b/tests/generic/282
@@ -80,8 +80,7 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1)
-cat $TEST_DIR/mwrite.out | tee -a $seqres.full
+$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 >> $seqres.full 2>&1
 _dmerror_load_working_table
 rm -rf $testdir/file2 >> $seqres.full 2>&1
 _dmerror_unmount
diff --git a/tests/generic/283 b/tests/generic/283
index 8d56ac3..7bfdb4d 100755
--- a/tests/generic/283
+++ b/tests/generic/283
@@ -81,8 +81,10 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 sync
 _dmerror_load_error_table
-urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1)
-cat $TEST_DIR/mwrite.out | tee -a $seqres.full
+urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \
+	-c "msync -s 0 $filesize" $testdir/file2 2>&1)
+echo $urk >> $seqres.full
+echo "$urk" | grep -q "error" || _fail "mwrite did not fail"
 _dmerror_load_working_table
 
 echo "Rewrite"
diff --git a/tests/generic/283.out b/tests/generic/283.out
index f9fd5c8..b475054 100644
--- a/tests/generic/283.out
+++ b/tests/generic/283.out
@@ -5,7 +5,6 @@ Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file2
 CoW and unmount
-msync: Input/output error
 Rewrite
 Compare files
 1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1


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

* [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
                   ` (4 preceding siblings ...)
  2017-01-05  1:05 ` [PATCH 5/7] reflink: make error reporting consistent when simulating EIO Darrick J. Wong
@ 2017-01-05  1:05 ` Darrick J. Wong
  2017-01-09  9:26   ` Eryu Guan
  2017-01-09 20:54   ` [PATCH v2 " Darrick J. Wong
  2017-01-05  1:05 ` [PATCH 7/7] xfs/ext4: check negative inode size Darrick J. Wong
  6 siblings, 2 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:05 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Since we're fixing the xfs_io dedupe command to consistently
print the dedupe ioctl name on error, fix the tests too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/122.out |    2 +-
 tests/generic/136.out |    2 +-
 tests/generic/158.out |   16 ++++++++--------
 tests/generic/304.out |   12 ++++++------
 tests/generic/374.out |    2 +-
 5 files changed, 17 insertions(+), 17 deletions(-)


diff --git a/tests/generic/122.out b/tests/generic/122.out
index 7925e90..4459985 100644
--- a/tests/generic/122.out
+++ b/tests/generic/122.out
@@ -4,7 +4,7 @@ Create the original files
 5e3501f97fd2669babfcbd3e1972e833  TEST_DIR/test-122/file2
 Files 1-2 do not match (intentional)
 (Fail to) dedupe the middle blocks together
-dedupe: Extents did not match.
+XFS_IOC_FILE_EXTENT_SAME: Extents did not match.
 Compare sections
 35ac8d7917305c385c30f3d82c30a8f6  TEST_DIR/test-122/file1
 5e3501f97fd2669babfcbd3e1972e833  TEST_DIR/test-122/file2
diff --git a/tests/generic/136.out b/tests/generic/136.out
index f76f40a..508953f 100644
--- a/tests/generic/136.out
+++ b/tests/generic/136.out
@@ -7,7 +7,7 @@ c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file2
 Dedupe the last blocks together
 1->2
 1->3
-dedupe: Extents did not match.
+XFS_IOC_FILE_EXTENT_SAME: Extents did not match.
 c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file1
 c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file2
 07ac67bf7f271195442509e79cde4cee  TEST_DIR/test-136/file3
diff --git a/tests/generic/158.out b/tests/generic/158.out
index 9b82ddf..8df9d9a 100644
--- a/tests/generic/158.out
+++ b/tests/generic/158.out
@@ -2,17 +2,17 @@ QA output created by 158
 Format and mount
 Create the original files
 Try cross-device dedupe
-dedupe: Invalid cross-device link
+XFS_IOC_FILE_EXTENT_SAME: Invalid cross-device link
 Try unaligned dedupe
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try overlapping dedupe
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try dedupe from past EOF
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try dedupe to past EOF, destination offset beyond EOF
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try dedupe to past EOF, destination offset behind EOF
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try to dedupe a dir
 XFS_IOC_FILE_EXTENT_SAME: Is a directory
 Try to dedupe a device
@@ -20,8 +20,8 @@ XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try to dedupe to a dir
 TEST_DIR/test-158/dir1: Is a directory
 Try to dedupe to a device
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try to dedupe to a fifo
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Try to dedupe an append-only file
 Dedupe two files
diff --git a/tests/generic/304.out b/tests/generic/304.out
index 7b5ff0e..a979099 100644
--- a/tests/generic/304.out
+++ b/tests/generic/304.out
@@ -2,17 +2,17 @@ QA output created by 304
 Format and mount
 Create the original files
 Dedupe large single byte file
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe large empty file
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe past maximum file size in dest file (should fail)
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe high offset to low offset
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe past source file EOF (should fail)
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe max size at nonzero offset (should fail)
-dedupe: Invalid argument
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Dedupe with huge off/len (should fail)
 XFS_IOC_FILE_EXTENT_SAME: Invalid argument
 Check file creation
diff --git a/tests/generic/374.out b/tests/generic/374.out
index b9a2073..3243ad3 100644
--- a/tests/generic/374.out
+++ b/tests/generic/374.out
@@ -3,7 +3,7 @@ Format and mount
 Mount otherdir
 Create file
 Dedupe one file to another
-dedupe: Invalid cross-device link
+XFS_IOC_FILE_EXTENT_SAME: Invalid cross-device link
 Check output
 2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-374/file
 2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-374/otherfile


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

* [PATCH 7/7] xfs/ext4: check negative inode size
  2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
                   ` (5 preceding siblings ...)
  2017-01-05  1:05 ` [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests Darrick J. Wong
@ 2017-01-05  1:05 ` Darrick J. Wong
  2017-01-09  9:36   ` Eryu Guan
  2017-01-09 20:55   ` [PATCH v2 " Darrick J. Wong
  6 siblings, 2 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-05  1:05 UTC (permalink / raw)
  To: eguan, darrick.wong; +Cc: linux-xfs, fstests

Craft a malicious filesystem image with a negative inode size,
then try to trigger a kernel DoS by appending data to the file.
Ideally this should trigger verifier errors instead of hanging.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/shared/400     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/400.out |    5 +++
 tests/shared/401     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/401.out |    5 +++
 tests/shared/group   |    2 +
 tests/xfs/400        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/400.out    |    5 +++
 tests/xfs/401        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/401.out    |    5 +++
 tests/xfs/group      |    2 +
 10 files changed, 310 insertions(+)
 create mode 100755 tests/shared/400
 create mode 100644 tests/shared/400.out
 create mode 100755 tests/shared/401
 create mode 100644 tests/shared/401.out
 create mode 100755 tests/xfs/400
 create mode 100644 tests/xfs/400.out
 create mode 100755 tests/xfs/401
 create mode 100644 tests/xfs/401.out


diff --git a/tests/shared/400 b/tests/shared/400
new file mode 100755
index 0000000..ba7bcda
--- /dev/null
+++ b/tests/shared/400
@@ -0,0 +1,71 @@
+#! /bin/bash
+# FSQA Test No. 400
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ext2 ext3 ext4
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+
+echo "Corrupt filesystem"
+_scratch_unmount
+debugfs -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/shared/400.out b/tests/shared/400.out
new file mode 100644
index 0000000..ddf8a28
--- /dev/null
+++ b/tests/shared/400.out
@@ -0,0 +1,5 @@
+QA output created by 400
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/shared/401 b/tests/shared/401
new file mode 100755
index 0000000..d790381
--- /dev/null
+++ b/tests/shared/401
@@ -0,0 +1,71 @@
+#! /bin/bash
+# FSQA Test No. 401
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ext2 ext3 ext4
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+
+echo "Corrupt filesystem"
+_scratch_unmount
+debugfs -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/shared/401.out b/tests/shared/401.out
new file mode 100644
index 0000000..0d45add
--- /dev/null
+++ b/tests/shared/401.out
@@ -0,0 +1,5 @@
+QA output created by 401
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/shared/group b/tests/shared/group
index 55bb594..64d2d2f 100644
--- a/tests/shared/group
+++ b/tests/shared/group
@@ -13,3 +13,5 @@
 272 auto enospc rw
 289 auto quick
 298 auto trim
+400 dangerous_fuzzers
+401 dangerous_fuzzers
diff --git a/tests/xfs/400 b/tests/xfs/400
new file mode 100755
index 0000000..eed8fdf
--- /dev/null
+++ b/tests/xfs/400
@@ -0,0 +1,72 @@
+#! /bin/bash
+# FSQA Test No. 400
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+inum=$(stat -c "%i" $testdir/a)
+
+echo "Corrupt filesystem"
+_scratch_unmount
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/400.out b/tests/xfs/400.out
new file mode 100644
index 0000000..ddf8a28
--- /dev/null
+++ b/tests/xfs/400.out
@@ -0,0 +1,5 @@
+QA output created by 400
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/xfs/401 b/tests/xfs/401
new file mode 100755
index 0000000..2be684a
--- /dev/null
+++ b/tests/xfs/401
@@ -0,0 +1,72 @@
+#! /bin/bash
+# FSQA Test No. 401
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+inum=$(stat -c "%i" $testdir/a)
+
+echo "Corrupt filesystem"
+_scratch_unmount
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/401.out b/tests/xfs/401.out
new file mode 100644
index 0000000..0d45add
--- /dev/null
+++ b/tests/xfs/401.out
@@ -0,0 +1,5 @@
+QA output created by 401
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/xfs/group b/tests/xfs/group
index c237b50..10ba27b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -334,3 +334,5 @@
 345 auto quick clone
 346 auto quick clone
 347 auto quick clone
+400 dangerous_fuzzers
+401 dangerous_fuzzers


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

* Re: [PATCH 4/7] reflink: fix quota tests to work properly
  2017-01-05  1:05 ` [PATCH 4/7] reflink: fix quota tests to work properly Darrick J. Wong
@ 2017-01-09  8:55   ` Eryu Guan
  2017-01-09 19:30     ` Darrick J. Wong
  2017-01-09 20:53   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 1 reply; 21+ messages in thread
From: Eryu Guan @ 2017-01-09  8:55 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, fstests

On Wed, Jan 04, 2017 at 05:05:01PM -0800, Darrick J. Wong wrote:
> Fix the reflink quota tests to su to the fsgqa user so that we actually
> test enforcement of quotas.  Seems that XFS enforces user quotas even
> if root is writing to a user file, whereas everything else lets root
> writes through.  Also clean up some of the variable usage and
> _require_user.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: Refactor the quota block reporting into a helper function and
> port all the existing tests.  Fix "fsgqa"/$qa_user usage too.
> ---
>  common/quota          |   10 ++++++++++
>  tests/generic/305     |   22 ++++++++++------------
>  tests/generic/305.out |   30 +++++++++++++++---------------
>  tests/generic/326     |   22 ++++++++++------------
>  tests/generic/326.out |   30 +++++++++++++++---------------
>  tests/generic/327     |   19 +++++++++----------
>  tests/generic/327.out |   12 ++++++------
>  tests/generic/328     |   29 ++++++++++++++---------------
>  tests/generic/328.out |   28 ++++++++++++++--------------
>  tests/xfs/213         |   22 ++++++++++------------
>  tests/xfs/213.out     |   30 +++++++++++++++---------------
>  tests/xfs/214         |   22 ++++++++++------------
>  tests/xfs/214.out     |   30 +++++++++++++++---------------
>  13 files changed, 153 insertions(+), 153 deletions(-)
> 
> 
> diff --git a/common/quota b/common/quota
> index d4ae861..5c6e680 100644
> --- a/common/quota
> +++ b/common/quota
> @@ -302,5 +302,15 @@ _check_quota_usage()
>  	}
>  }
>  
> +# Report the block usage of root, $qa_user, and nobody
> +_report_quota_blocks() {
> +	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $3, $4, $5}'
> +}
> +
> +# Report the inode usage of root, $qa_user, and nobody
> +_report_quota_inodes() {
> +	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}'
> +}
> +

Name them as _scratch_report_quota_blocks|inodes ? Since they're
assuming mount point is SCRATCH_MNT. Or take the mount point as the
first argument?

Thanks,
Eryu

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

* Re: [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests
  2017-01-05  1:05 ` [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests Darrick J. Wong
@ 2017-01-09  9:26   ` Eryu Guan
  2017-01-09 20:36     ` Darrick J. Wong
  2017-01-09 20:54   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 1 reply; 21+ messages in thread
From: Eryu Guan @ 2017-01-09  9:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, fstests

On Wed, Jan 04, 2017 at 05:05:14PM -0800, Darrick J. Wong wrote:
> Since we're fixing the xfs_io dedupe command to consistently
> print the dedupe ioctl name on error, fix the tests too.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Seems you need to rebase against current master, I just pushed my patch
out on Sunday with your Reviewed-by :)

1300cbc generic/158,304: filter dedupe error message

And take use the new _filter_dedupe_error()? So both old and new version
of xfs_io pass the tests.

Thanks,
Eryu

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

* Re: [PATCH 7/7] xfs/ext4: check negative inode size
  2017-01-05  1:05 ` [PATCH 7/7] xfs/ext4: check negative inode size Darrick J. Wong
@ 2017-01-09  9:36   ` Eryu Guan
  2017-01-09 20:36     ` Darrick J. Wong
  2017-01-09 20:55   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 1 reply; 21+ messages in thread
From: Eryu Guan @ 2017-01-09  9:36 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, fstests

On Wed, Jan 04, 2017 at 05:05:20PM -0800, Darrick J. Wong wrote:
> Craft a malicious filesystem image with a negative inode size,
> then try to trigger a kernel DoS by appending data to the file.
> Ideally this should trigger verifier errors instead of hanging.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/shared/400     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/shared/400.out |    5 +++
>  tests/shared/401     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/shared/401.out |    5 +++
>  tests/shared/group   |    2 +
>  tests/xfs/400        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/400.out    |    5 +++
>  tests/xfs/401        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/401.out    |    5 +++
>  tests/xfs/group      |    2 +
>  10 files changed, 310 insertions(+)
>  create mode 100755 tests/shared/400
>  create mode 100644 tests/shared/400.out
>  create mode 100755 tests/shared/401
>  create mode 100644 tests/shared/401.out
>  create mode 100755 tests/xfs/400
>  create mode 100644 tests/xfs/400.out
>  create mode 100755 tests/xfs/401
>  create mode 100644 tests/xfs/401.out
> 
> 
> diff --git a/tests/shared/400 b/tests/shared/400
> new file mode 100755
> index 0000000..ba7bcda
> --- /dev/null
> +++ b/tests/shared/400
> @@ -0,0 +1,71 @@
> +#! /bin/bash
> +# FSQA Test No. 400
> +#
> +# Since loff_t is a signed type, it is invalid for a filesystem to load
> +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> +# which means that we can trivially DoS the VFS by creating such a file
> +# and appending to it.  This causes an integer overflow in the routines
> +# underlying writeback, which results in the kernel locking up.

How about adding some more descriptions here? Stating that this test is
testing buffered I/O, and adding some comments about testing direct I/O
to shared/401? The same to xfs/400 and xfs/401. Otherwise they look the
same just from the test description.

> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017 Oracle, 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"
> +
> +PIDS=""
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs ext2 ext3 ext4
> +_require_scratch_nocheck
> +_disable_dmesg_check

_require_command "$DEBUGFS_PROG" debugfs  and..

> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs  >> $seqres.full 2>&1
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT
> +echo m > $testdir/a
> +
> +echo "Corrupt filesystem"
> +_scratch_unmount
> +debugfs -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1

$DEBUGFS_PROG here

> +
> +echo "Remount, try to append"
> +_scratch_mount
> +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> +sync
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/shared/400.out b/tests/shared/400.out
> new file mode 100644
> index 0000000..ddf8a28
> --- /dev/null
> +++ b/tests/shared/400.out
> @@ -0,0 +1,5 @@
> +QA output created by 400
> +Format and mount
> +Corrupt filesystem
> +Remount, try to append
> +Write did not succeed (ok).
> diff --git a/tests/shared/401 b/tests/shared/401
> new file mode 100755
> index 0000000..d790381
> --- /dev/null
> +++ b/tests/shared/401
> @@ -0,0 +1,71 @@
> +#! /bin/bash
> +# FSQA Test No. 401
> +#
> +# Since loff_t is a signed type, it is invalid for a filesystem to load
> +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> +# which means that we can trivially DoS the VFS by creating such a file
> +# and appending to it.  This causes an integer overflow in the routines
> +# underlying writeback, which results in the kernel locking up.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017 Oracle, 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"
> +
> +PIDS=""
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs ext2 ext3 ext4
> +_require_scratch_nocheck
> +_disable_dmesg_check
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs  >> $seqres.full 2>&1
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT
> +echo m > $testdir/a
> +
> +echo "Corrupt filesystem"
> +_scratch_unmount
> +debugfs -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1

Better to have your explanation to 0XFFFFFFFFFFFFFE00 as comments. (Same
to xfs/400 and xfs/401.)

"The 0xFFFFFFFFFFFFFE00 rounds the file size down to a multiple of 512
so that we can do the directio"

Thanks,
Eryu

> +
> +echo "Remount, try to append"
> +_scratch_mount
> +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> +sync
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/shared/401.out b/tests/shared/401.out
> new file mode 100644
> index 0000000..0d45add
> --- /dev/null
> +++ b/tests/shared/401.out
> @@ -0,0 +1,5 @@
> +QA output created by 401
> +Format and mount
> +Corrupt filesystem
> +Remount, try to append
> +Write did not succeed (ok).
> diff --git a/tests/shared/group b/tests/shared/group
> index 55bb594..64d2d2f 100644
> --- a/tests/shared/group
> +++ b/tests/shared/group
> @@ -13,3 +13,5 @@
>  272 auto enospc rw
>  289 auto quick
>  298 auto trim
> +400 dangerous_fuzzers
> +401 dangerous_fuzzers
> diff --git a/tests/xfs/400 b/tests/xfs/400
> new file mode 100755
> index 0000000..eed8fdf
> --- /dev/null
> +++ b/tests/xfs/400
> @@ -0,0 +1,72 @@
> +#! /bin/bash
> +# FSQA Test No. 400
> +#
> +# Since loff_t is a signed type, it is invalid for a filesystem to load
> +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> +# which means that we can trivially DoS the VFS by creating such a file
> +# and appending to it.  This causes an integer overflow in the routines
> +# underlying writeback, which results in the kernel locking up.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017 Oracle, 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"
> +
> +PIDS=""
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_nocheck
> +_disable_dmesg_check
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs  >> $seqres.full 2>&1
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT
> +echo m > $testdir/a
> +inum=$(stat -c "%i" $testdir/a)
> +
> +echo "Corrupt filesystem"
> +_scratch_unmount
> +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
> +
> +echo "Remount, try to append"
> +_scratch_mount
> +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> +sync
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/400.out b/tests/xfs/400.out
> new file mode 100644
> index 0000000..ddf8a28
> --- /dev/null
> +++ b/tests/xfs/400.out
> @@ -0,0 +1,5 @@
> +QA output created by 400
> +Format and mount
> +Corrupt filesystem
> +Remount, try to append
> +Write did not succeed (ok).
> diff --git a/tests/xfs/401 b/tests/xfs/401
> new file mode 100755
> index 0000000..2be684a
> --- /dev/null
> +++ b/tests/xfs/401
> @@ -0,0 +1,72 @@
> +#! /bin/bash
> +# FSQA Test No. 401
> +#
> +# Since loff_t is a signed type, it is invalid for a filesystem to load
> +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> +# which means that we can trivially DoS the VFS by creating such a file
> +# and appending to it.  This causes an integer overflow in the routines
> +# underlying writeback, which results in the kernel locking up.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017 Oracle, 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"
> +
> +PIDS=""
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_nocheck
> +_disable_dmesg_check
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs  >> $seqres.full 2>&1
> +_scratch_mount
> +
> +testdir=$SCRATCH_MNT
> +echo m > $testdir/a
> +inum=$(stat -c "%i" $testdir/a)
> +
> +echo "Corrupt filesystem"
> +_scratch_unmount
> +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
> +
> +echo "Remount, try to append"
> +_scratch_mount
> +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> +sync
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/401.out b/tests/xfs/401.out
> new file mode 100644
> index 0000000..0d45add
> --- /dev/null
> +++ b/tests/xfs/401.out
> @@ -0,0 +1,5 @@
> +QA output created by 401
> +Format and mount
> +Corrupt filesystem
> +Remount, try to append
> +Write did not succeed (ok).
> diff --git a/tests/xfs/group b/tests/xfs/group
> index c237b50..10ba27b 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -334,3 +334,5 @@
>  345 auto quick clone
>  346 auto quick clone
>  347 auto quick clone
> +400 dangerous_fuzzers
> +401 dangerous_fuzzers
> 

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

* Re: [PATCH 2/7] common: add leading underscore to get_block_size
  2017-01-05  1:04 ` [PATCH 2/7] common: add leading underscore to get_block_size Darrick J. Wong
@ 2017-01-09 10:20   ` Eryu Guan
  2017-01-09 21:32     ` Darrick J. Wong
  0 siblings, 1 reply; 21+ messages in thread
From: Eryu Guan @ 2017-01-09 10:20 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, fstests

On Wed, Jan 04, 2017 at 05:04:48PM -0800, Darrick J. Wong wrote:
> Add a leading underscore to the get_block_size helper since it's a
> common function.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

There's a new user of get_block_size, after latest fstests update,
btrfs/012. I can fold the btrfs/012 update to this patch.

Thanks for doing this!

Eryu

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

* Re: [PATCH 4/7] reflink: fix quota tests to work properly
  2017-01-09  8:55   ` Eryu Guan
@ 2017-01-09 19:30     ` Darrick J. Wong
  0 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 19:30 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-xfs, fstests

On Mon, Jan 09, 2017 at 04:55:14PM +0800, Eryu Guan wrote:
> On Wed, Jan 04, 2017 at 05:05:01PM -0800, Darrick J. Wong wrote:
> > Fix the reflink quota tests to su to the fsgqa user so that we actually
> > test enforcement of quotas.  Seems that XFS enforces user quotas even
> > if root is writing to a user file, whereas everything else lets root
> > writes through.  Also clean up some of the variable usage and
> > _require_user.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > v2: Refactor the quota block reporting into a helper function and
> > port all the existing tests.  Fix "fsgqa"/$qa_user usage too.
> > ---
> >  common/quota          |   10 ++++++++++
> >  tests/generic/305     |   22 ++++++++++------------
> >  tests/generic/305.out |   30 +++++++++++++++---------------
> >  tests/generic/326     |   22 ++++++++++------------
> >  tests/generic/326.out |   30 +++++++++++++++---------------
> >  tests/generic/327     |   19 +++++++++----------
> >  tests/generic/327.out |   12 ++++++------
> >  tests/generic/328     |   29 ++++++++++++++---------------
> >  tests/generic/328.out |   28 ++++++++++++++--------------
> >  tests/xfs/213         |   22 ++++++++++------------
> >  tests/xfs/213.out     |   30 +++++++++++++++---------------
> >  tests/xfs/214         |   22 ++++++++++------------
> >  tests/xfs/214.out     |   30 +++++++++++++++---------------
> >  13 files changed, 153 insertions(+), 153 deletions(-)
> > 
> > 
> > diff --git a/common/quota b/common/quota
> > index d4ae861..5c6e680 100644
> > --- a/common/quota
> > +++ b/common/quota
> > @@ -302,5 +302,15 @@ _check_quota_usage()
> >  	}
> >  }
> >  
> > +# Report the block usage of root, $qa_user, and nobody
> > +_report_quota_blocks() {
> > +	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $3, $4, $5}'
> > +}
> > +
> > +# Report the inode usage of root, $qa_user, and nobody
> > +_report_quota_inodes() {
> > +	repquota $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}'
> > +}
> > +
> 
> Name them as _scratch_report_quota_blocks|inodes ? Since they're
> assuming mount point is SCRATCH_MNT. Or take the mount point as the
> first argument?

Ok, changed to require a mountpoint as a first arg.

--D

> 
> Thanks,
> Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 7/7] xfs/ext4: check negative inode size
  2017-01-09  9:36   ` Eryu Guan
@ 2017-01-09 20:36     ` Darrick J. Wong
  0 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 20:36 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-xfs, fstests

On Mon, Jan 09, 2017 at 05:36:35PM +0800, Eryu Guan wrote:
> On Wed, Jan 04, 2017 at 05:05:20PM -0800, Darrick J. Wong wrote:
> > Craft a malicious filesystem image with a negative inode size,
> > then try to trigger a kernel DoS by appending data to the file.
> > Ideally this should trigger verifier errors instead of hanging.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  tests/shared/400     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/shared/400.out |    5 +++
> >  tests/shared/401     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/shared/401.out |    5 +++
> >  tests/shared/group   |    2 +
> >  tests/xfs/400        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/400.out    |    5 +++
> >  tests/xfs/401        |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/401.out    |    5 +++
> >  tests/xfs/group      |    2 +
> >  10 files changed, 310 insertions(+)
> >  create mode 100755 tests/shared/400
> >  create mode 100644 tests/shared/400.out
> >  create mode 100755 tests/shared/401
> >  create mode 100644 tests/shared/401.out
> >  create mode 100755 tests/xfs/400
> >  create mode 100644 tests/xfs/400.out
> >  create mode 100755 tests/xfs/401
> >  create mode 100644 tests/xfs/401.out
> > 
> > 
> > diff --git a/tests/shared/400 b/tests/shared/400
> > new file mode 100755
> > index 0000000..ba7bcda
> > --- /dev/null
> > +++ b/tests/shared/400
> > @@ -0,0 +1,71 @@
> > +#! /bin/bash
> > +# FSQA Test No. 400
> > +#
> > +# Since loff_t is a signed type, it is invalid for a filesystem to load
> > +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> > +# which means that we can trivially DoS the VFS by creating such a file
> > +# and appending to it.  This causes an integer overflow in the routines
> > +# underlying writeback, which results in the kernel locking up.
> 
> How about adding some more descriptions here? Stating that this test is
> testing buffered I/O, and adding some comments about testing direct I/O
> to shared/401? The same to xfs/400 and xfs/401. Otherwise they look the
> same just from the test description.

Ok.

> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2017 Oracle, 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"
> > +
> > +PIDS=""
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +	rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs ext2 ext3 ext4
> > +_require_scratch_nocheck
> > +_disable_dmesg_check
> 
> _require_command "$DEBUGFS_PROG" debugfs  and..

<nod>

> 
> > +
> > +rm -f $seqres.full
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs  >> $seqres.full 2>&1
> > +_scratch_mount
> > +
> > +testdir=$SCRATCH_MNT
> > +echo m > $testdir/a
> > +
> > +echo "Corrupt filesystem"
> > +_scratch_unmount
> > +debugfs -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1
> 
> $DEBUGFS_PROG here

<nod>
> 
> > +
> > +echo "Remount, try to append"
> > +_scratch_mount
> > +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> > +sync
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/shared/400.out b/tests/shared/400.out
> > new file mode 100644
> > index 0000000..ddf8a28
> > --- /dev/null
> > +++ b/tests/shared/400.out
> > @@ -0,0 +1,5 @@
> > +QA output created by 400
> > +Format and mount
> > +Corrupt filesystem
> > +Remount, try to append
> > +Write did not succeed (ok).
> > diff --git a/tests/shared/401 b/tests/shared/401
> > new file mode 100755
> > index 0000000..d790381
> > --- /dev/null
> > +++ b/tests/shared/401
> > @@ -0,0 +1,71 @@
> > +#! /bin/bash
> > +# FSQA Test No. 401
> > +#
> > +# Since loff_t is a signed type, it is invalid for a filesystem to load
> > +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> > +# which means that we can trivially DoS the VFS by creating such a file
> > +# and appending to it.  This causes an integer overflow in the routines
> > +# underlying writeback, which results in the kernel locking up.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2017 Oracle, 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"
> > +
> > +PIDS=""
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +	rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs ext2 ext3 ext4
> > +_require_scratch_nocheck
> > +_disable_dmesg_check
> > +
> > +rm -f $seqres.full
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs  >> $seqres.full 2>&1
> > +_scratch_mount
> > +
> > +testdir=$SCRATCH_MNT
> > +echo m > $testdir/a
> > +
> > +echo "Corrupt filesystem"
> > +_scratch_unmount
> > +debugfs -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
> 
> Better to have your explanation to 0XFFFFFFFFFFFFFE00 as comments. (Same
> to xfs/400 and xfs/401.)
> 
> "The 0xFFFFFFFFFFFFFE00 rounds the file size down to a multiple of 512
> so that we can do the directio"

Ok, fixed.

--D

> 
> Thanks,
> Eryu
> 
> > +
> > +echo "Remount, try to append"
> > +_scratch_mount
> > +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> > +sync
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/shared/401.out b/tests/shared/401.out
> > new file mode 100644
> > index 0000000..0d45add
> > --- /dev/null
> > +++ b/tests/shared/401.out
> > @@ -0,0 +1,5 @@
> > +QA output created by 401
> > +Format and mount
> > +Corrupt filesystem
> > +Remount, try to append
> > +Write did not succeed (ok).
> > diff --git a/tests/shared/group b/tests/shared/group
> > index 55bb594..64d2d2f 100644
> > --- a/tests/shared/group
> > +++ b/tests/shared/group
> > @@ -13,3 +13,5 @@
> >  272 auto enospc rw
> >  289 auto quick
> >  298 auto trim
> > +400 dangerous_fuzzers
> > +401 dangerous_fuzzers
> > diff --git a/tests/xfs/400 b/tests/xfs/400
> > new file mode 100755
> > index 0000000..eed8fdf
> > --- /dev/null
> > +++ b/tests/xfs/400
> > @@ -0,0 +1,72 @@
> > +#! /bin/bash
> > +# FSQA Test No. 400
> > +#
> > +# Since loff_t is a signed type, it is invalid for a filesystem to load
> > +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> > +# which means that we can trivially DoS the VFS by creating such a file
> > +# and appending to it.  This causes an integer overflow in the routines
> > +# underlying writeback, which results in the kernel locking up.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2017 Oracle, 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"
> > +
> > +PIDS=""
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +	rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_scratch_nocheck
> > +_disable_dmesg_check
> > +
> > +rm -f $seqres.full
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs  >> $seqres.full 2>&1
> > +_scratch_mount
> > +
> > +testdir=$SCRATCH_MNT
> > +echo m > $testdir/a
> > +inum=$(stat -c "%i" $testdir/a)
> > +
> > +echo "Corrupt filesystem"
> > +_scratch_unmount
> > +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
> > +
> > +echo "Remount, try to append"
> > +_scratch_mount
> > +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> > +sync
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/400.out b/tests/xfs/400.out
> > new file mode 100644
> > index 0000000..ddf8a28
> > --- /dev/null
> > +++ b/tests/xfs/400.out
> > @@ -0,0 +1,5 @@
> > +QA output created by 400
> > +Format and mount
> > +Corrupt filesystem
> > +Remount, try to append
> > +Write did not succeed (ok).
> > diff --git a/tests/xfs/401 b/tests/xfs/401
> > new file mode 100755
> > index 0000000..2be684a
> > --- /dev/null
> > +++ b/tests/xfs/401
> > @@ -0,0 +1,72 @@
> > +#! /bin/bash
> > +# FSQA Test No. 401
> > +#
> > +# Since loff_t is a signed type, it is invalid for a filesystem to load
> > +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> > +# which means that we can trivially DoS the VFS by creating such a file
> > +# and appending to it.  This causes an integer overflow in the routines
> > +# underlying writeback, which results in the kernel locking up.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2017 Oracle, 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"
> > +
> > +PIDS=""
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +	rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_scratch_nocheck
> > +_disable_dmesg_check
> > +
> > +rm -f $seqres.full
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs  >> $seqres.full 2>&1
> > +_scratch_mount
> > +
> > +testdir=$SCRATCH_MNT
> > +echo m > $testdir/a
> > +inum=$(stat -c "%i" $testdir/a)
> > +
> > +echo "Corrupt filesystem"
> > +_scratch_unmount
> > +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
> > +
> > +echo "Remount, try to append"
> > +_scratch_mount
> > +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
> > +sync
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/401.out b/tests/xfs/401.out
> > new file mode 100644
> > index 0000000..0d45add
> > --- /dev/null
> > +++ b/tests/xfs/401.out
> > @@ -0,0 +1,5 @@
> > +QA output created by 401
> > +Format and mount
> > +Corrupt filesystem
> > +Remount, try to append
> > +Write did not succeed (ok).
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index c237b50..10ba27b 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -334,3 +334,5 @@
> >  345 auto quick clone
> >  346 auto quick clone
> >  347 auto quick clone
> > +400 dangerous_fuzzers
> > +401 dangerous_fuzzers
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests
  2017-01-09  9:26   ` Eryu Guan
@ 2017-01-09 20:36     ` Darrick J. Wong
  0 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 20:36 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-xfs, fstests

On Mon, Jan 09, 2017 at 05:26:00PM +0800, Eryu Guan wrote:
> On Wed, Jan 04, 2017 at 05:05:14PM -0800, Darrick J. Wong wrote:
> > Since we're fixing the xfs_io dedupe command to consistently
> > print the dedupe ioctl name on error, fix the tests too.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Seems you need to rebase against current master, I just pushed my patch
> out on Sunday with your Reviewed-by :)
> 
> 1300cbc generic/158,304: filter dedupe error message
> 
> And take use the new _filter_dedupe_error()? So both old and new version
> of xfs_io pass the tests.

Ok, will do.

--D

> 
> Thanks,
> Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 4/7] reflink: fix quota tests to work properly
  2017-01-05  1:05 ` [PATCH 4/7] reflink: fix quota tests to work properly Darrick J. Wong
  2017-01-09  8:55   ` Eryu Guan
@ 2017-01-09 20:53   ` Darrick J. Wong
  1 sibling, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 20:53 UTC (permalink / raw)
  To: eguan; +Cc: linux-xfs, fstests

Fix the reflink quota tests to su to the fsgqa user so that we actually
test enforcement of quotas.  Seems that XFS enforces user quotas even
if root is writing to a user file, whereas everything else lets root
writes through.  Also clean up some of the variable usage and
_require_user.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: Refactor the quota block reporting into a helper function and
port all the existing tests.  Fix "fsgqa"/$qa_user usage too.
v3: _report_quota_* should take a mountpoint as an argument.
---
 common/quota          |   10 ++++++++++
 tests/generic/305     |   22 ++++++++++------------
 tests/generic/305.out |   30 +++++++++++++++---------------
 tests/generic/326     |   22 ++++++++++------------
 tests/generic/326.out |   30 +++++++++++++++---------------
 tests/generic/327     |   19 +++++++++----------
 tests/generic/327.out |   12 ++++++------
 tests/generic/328     |   29 ++++++++++++++---------------
 tests/generic/328.out |   28 ++++++++++++++--------------
 tests/xfs/213         |   22 ++++++++++------------
 tests/xfs/213.out     |   30 +++++++++++++++---------------
 tests/xfs/214         |   22 ++++++++++------------
 tests/xfs/214.out     |   30 +++++++++++++++---------------
 13 files changed, 153 insertions(+), 153 deletions(-)

diff --git a/common/quota b/common/quota
index d4ae861..c48cc70 100644
--- a/common/quota
+++ b/common/quota
@@ -302,5 +302,15 @@ _check_quota_usage()
 	}
 }
 
+# Report the block usage of root, $qa_user, and nobody
+_report_quota_blocks() {
+	repquota $1 | egrep "^($qa_user|root|nobody)" | awk '{print $1, $3, $4, $5}'
+}
+
+# Report the inode usage of root, $qa_user, and nobody
+_report_quota_inodes() {
+	repquota $1 | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}'
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/generic/305 b/tests/generic/305
index d73d87f..ceef333 100755
--- a/tests/generic/305
+++ b/tests/generic/305
@@ -49,10 +49,8 @@ _require_cp_reflink
 _require_fiemap
 _require_quota
 _require_nobody
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -73,27 +71,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks $SCRATCH_MNT
 
 echo "CoW one of the files"
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/generic/305.out b/tests/generic/305.out
index 0bfd620..fbd4e24 100644
--- a/tests/generic/305.out
+++ b/tests/generic/305.out
@@ -1,22 +1,22 @@
 QA output created by 305
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/generic/326 b/tests/generic/326
index 8afc6a2..3568efe 100755
--- a/tests/generic/326
+++ b/tests/generic/326
@@ -50,10 +50,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -74,27 +72,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks $SCRATCH_MNT
 
 echo "CoW one of the files"
 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/generic/326.out b/tests/generic/326.out
index e771eb7..de7f20b 100644
--- a/tests/generic/326.out
+++ b/tests/generic/326.out
@@ -1,22 +1,22 @@
 QA output created by 326
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/generic/327 b/tests/generic/327
index c165ad5..05cfb4a 100755
--- a/tests/generic/327
+++ b/tests/generic/327
@@ -48,10 +48,8 @@ _require_cp_reflink
 _require_fiemap
 _require_quota
 _require_nobody
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -67,20 +65,21 @@ mkdir $testdir
 sz=1048576
 echo "Create the original files"
 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
-chown fsgqa $testdir/file1
+chown $qa_user $testdir/file1
 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
+quotaon $SCRATCH_MNT 2> /dev/null
 
 echo "Set hard quota to prevent third reflink"
-setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Try to reflink again"
 touch $testdir/file3
-chown fsgqa $testdir/file3
-_cp_reflink $testdir/file1 $testdir/file3 2>&1 | _filter_scratch
-_repquota
+chown $qa_user $testdir/file3
+su $qa_user -c "cp --reflink=always -f $testdir/file1 $testdir/file3" 2>&1 | _filter_scratch
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/generic/327.out b/tests/generic/327.out
index 7160ff2..f4e145a 100644
--- a/tests/generic/327.out
+++ b/tests/generic/327.out
@@ -1,12 +1,12 @@
 QA output created by 327
 Format and mount
 Create the original files
-root      --       0       0       0              4     0     0       
-fsgqa     --    2048       0       0              2     0     0       
+root 0 0 0
+fsgqa 2048 0 0
 Set hard quota to prevent third reflink
-root      --       0       0       0              4     0     0       
-fsgqa     +-    2048       0    1024              2     0     0       
+root 0 0 0
+fsgqa 2048 0 1024
 Try to reflink again
 cp: failed to clone 'SCRATCH_MNT/test-327/file3' from 'SCRATCH_MNT/test-327/file1': Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    2048       0    1024              3     0     0       
+root 0 0 0
+fsgqa 2048 0 1024
diff --git a/tests/generic/328 b/tests/generic/328
index 705368e..21ec9d3 100755
--- a/tests/generic/328
+++ b/tests/generic/328
@@ -49,10 +49,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -68,39 +66,40 @@ mkdir $testdir
 sz=1048576
 echo "Create the original files"
 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
-chown fsgqa $testdir/file1
+chown $qa_user $testdir/file1
 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
+quotaon $SCRATCH_MNT 2> /dev/null
 
 echo "Set hard quota to prevent rewrite"
-setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Try to dio write the whole file"
-_pwrite_byte 0x62 0 $sz $testdir/file1 -d 2>&1 >> $seqres.full | \
+su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
 	_filter_xfs_io_error
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Try to write the whole file"
-_pwrite_byte 0x62 0 $sz $testdir/file1 2>&1 >> $seqres.full | \
+su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
 	_filter_xfs_io_error
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Set hard quota to allow rewrite"
-setquota -u fsgqa 0 8192 0 0 $SCRATCH_MNT
-_repquota
+setquota -u $qa_user 0 8192 0 0 $SCRATCH_MNT
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Try to dio write the whole file"
 _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full
 sync
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Try to write the whole file"
 _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full
 sync
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/generic/328.out b/tests/generic/328.out
index 4630151..b7fe9f8 100644
--- a/tests/generic/328.out
+++ b/tests/generic/328.out
@@ -1,25 +1,25 @@
 QA output created by 328
 Format and mount
 Create the original files
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0       0              3     0     0       
+root 0 0 0
+fsgqa 3072 0 0
 Set hard quota to prevent rewrite
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Try to dio write the whole file
 pwrite: Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Try to write the whole file
 pwrite: Disk quota exceeded
-root      --       0       0       0              4     0     0       
-fsgqa     +-    3072       0    1024              3     0     0       
+root 0 0 0
+fsgqa 3072 0 1024
 Set hard quota to allow rewrite
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
 Try to dio write the whole file
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
 Try to write the whole file
-root      --       0       0       0              4     0     0       
-fsgqa     --    3072       0    8192              3     0     0       
+root 0 0 0
+fsgqa 3072 0 8192
diff --git a/tests/xfs/213 b/tests/xfs/213
index d5cc129..844166c 100755
--- a/tests/xfs/213
+++ b/tests/xfs/213
@@ -52,10 +52,8 @@ _require_fiemap
 _require_quota
 _require_nobody
 _require_xfs_io_command "cowextsize"
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -78,27 +76,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks $SCRATCH_MNT
 
 echo "CoW one of the files"
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/xfs/213.out b/tests/xfs/213.out
index be8d56c..7dd30dd 100644
--- a/tests/xfs/213.out
+++ b/tests/xfs/213.out
@@ -1,22 +1,22 @@
 QA output created by 213
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3520       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3520 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0
diff --git a/tests/xfs/214 b/tests/xfs/214
index 35972c6..01ffbaf 100755
--- a/tests/xfs/214
+++ b/tests/xfs/214
@@ -53,10 +53,8 @@ _require_quota
 _require_nobody
 _require_xfs_io_command "cowextsize"
 _require_odirect
+_require_user
 
-_repquota() {
-	repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
-}
 rm -f $seqres.full
 
 echo "Format and mount"
@@ -79,27 +77,27 @@ _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
 touch $testdir/urk
 chown nobody $testdir/urk
 touch $testdir/erk
-chown fsgqa $testdir/erk
-_repquota
+chown $qa_user $testdir/erk
+_report_quota_blocks $SCRATCH_MNT
 _scratch_cycle_mount
 
 echo "Change file ownership"
-chown fsgqa $testdir/file1
-chown fsgqa $testdir/file2
-chown fsgqa $testdir/file3
-_repquota
+chown $qa_user $testdir/file1
+chown $qa_user $testdir/file2
+chown $qa_user $testdir/file3
+_report_quota_blocks $SCRATCH_MNT
 
 echo "CoW one of the files"
 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Remount the FS to see if accounting changes"
 _scratch_cycle_mount
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 echo "Chown one of the files"
 chown nobody $testdir/file3
-_repquota
+_report_quota_blocks $SCRATCH_MNT
 
 # success, all done
 status=0
diff --git a/tests/xfs/214.out b/tests/xfs/214.out
index 496a503..2c7e358 100644
--- a/tests/xfs/214.out
+++ b/tests/xfs/214.out
@@ -1,22 +1,22 @@
 QA output created by 214
 Format and mount
 Create the original files
-root      --    3072       0       0              7     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --       0       0       0              1     0     0       
+root 3072 0 0
+nobody 0 0 0
+fsgqa 0 0 0
 Change file ownership
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 CoW one of the files
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3520       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3520 0 0
 Remount the FS to see if accounting changes
-root      --       0       0       0              4     0     0       
-nobody    --       0       0       0              1     0     0       
-fsgqa     --    3072       0       0              4     0     0       
+root 0 0 0
+nobody 0 0 0
+fsgqa 3072 0 0
 Chown one of the files
-root      --       0       0       0              4     0     0       
-nobody    --    1024       0       0              2     0     0       
-fsgqa     --    2048       0       0              3     0     0       
+root 0 0 0
+nobody 1024 0 0
+fsgqa 2048 0 0

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

* [PATCH v2 6/7] dedupe: fix consistent error message prefixes for dedupe tests
  2017-01-05  1:05 ` [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests Darrick J. Wong
  2017-01-09  9:26   ` Eryu Guan
@ 2017-01-09 20:54   ` Darrick J. Wong
  1 sibling, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 20:54 UTC (permalink / raw)
  To: eguan; +Cc: linux-xfs, fstests

Since we're fixing the xfs_io dedupe command to consistently
print the dedupe ioctl name on error, fix the tests too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: use _filter_dedupe_error
---
 tests/generic/122     |    2 +-
 tests/generic/122.out |    2 +-
 tests/generic/136     |    2 +-
 tests/generic/136.out |    2 +-
 tests/generic/374     |    2 +-
 tests/generic/374.out |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/generic/122 b/tests/generic/122
index 9dcfa9a..5008190 100755
--- a/tests/generic/122
+++ b/tests/generic/122
@@ -67,7 +67,7 @@ _compare_range $testdir/file1 0 $testdir/file2 0 "$((blksz * 8))" \
 echo "(Fail to) dedupe the middle blocks together"
 free_before=$(stat -f -c '%a' $testdir)
 _dedupe_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
-		$((blksz * 4)) $((blksz * 2)) >> $seqres.full
+		$((blksz * 4)) $((blksz * 2)) 2>&1 | _filter_dedupe_error
 _test_cycle_mount
 free_after=$(stat -f -c '%a' $testdir)
 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
diff --git a/tests/generic/122.out b/tests/generic/122.out
index 7925e90..4459985 100644
--- a/tests/generic/122.out
+++ b/tests/generic/122.out
@@ -4,7 +4,7 @@ Create the original files
 5e3501f97fd2669babfcbd3e1972e833  TEST_DIR/test-122/file2
 Files 1-2 do not match (intentional)
 (Fail to) dedupe the middle blocks together
-dedupe: Extents did not match.
+XFS_IOC_FILE_EXTENT_SAME: Extents did not match.
 Compare sections
 35ac8d7917305c385c30f3d82c30a8f6  TEST_DIR/test-122/file1
 5e3501f97fd2669babfcbd3e1972e833  TEST_DIR/test-122/file2
diff --git a/tests/generic/136 b/tests/generic/136
index c72d11f..665749f 100755
--- a/tests/generic/136
+++ b/tests/generic/136
@@ -85,7 +85,7 @@ echo "Dedupe the last blocks together"
 echo "1->2"
 _dedupe_range $testdir/file1 $blksz $testdir/file2 $blksz 37 >> $seqres.full
 echo "1->3"
-_dedupe_range $testdir/file1 $blksz $testdir/file3 $blksz 37 >> $seqres.full
+_dedupe_range $testdir/file1 $blksz $testdir/file3 $blksz 37 2>&1 | _filter_dedupe_error
 _test_cycle_mount
 
 md5sum $testdir/file1 | _filter_test_dir
diff --git a/tests/generic/136.out b/tests/generic/136.out
index f76f40a..508953f 100644
--- a/tests/generic/136.out
+++ b/tests/generic/136.out
@@ -7,7 +7,7 @@ c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file2
 Dedupe the last blocks together
 1->2
 1->3
-dedupe: Extents did not match.
+XFS_IOC_FILE_EXTENT_SAME: Extents did not match.
 c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file1
 c4fd505be25a0c91bcca9f502b9a8156  TEST_DIR/test-136/file2
 07ac67bf7f271195442509e79cde4cee  TEST_DIR/test-136/file3
diff --git a/tests/generic/374 b/tests/generic/374
index eabaf2e..5a24ec8 100755
--- a/tests/generic/374
+++ b/tests/generic/374
@@ -70,7 +70,7 @@ _pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
 _pwrite_byte 0x61 0 $sz $testdir/otherfile >> $seqres.full
 
 echo "Dedupe one file to another"
-_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz >> $seqres.full
+_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz 2>&1 | _filter_dedupe_error
 
 filter_md5()
 {
diff --git a/tests/generic/374.out b/tests/generic/374.out
index b9a2073..3243ad3 100644
--- a/tests/generic/374.out
+++ b/tests/generic/374.out
@@ -3,7 +3,7 @@ Format and mount
 Mount otherdir
 Create file
 Dedupe one file to another
-dedupe: Invalid cross-device link
+XFS_IOC_FILE_EXTENT_SAME: Invalid cross-device link
 Check output
 2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-374/file
 2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-374/otherfile

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

* [PATCH v2 7/7] xfs/ext4: check negative inode size
  2017-01-05  1:05 ` [PATCH 7/7] xfs/ext4: check negative inode size Darrick J. Wong
  2017-01-09  9:36   ` Eryu Guan
@ 2017-01-09 20:55   ` Darrick J. Wong
  2017-01-10  4:40     ` Eryu Guan
  1 sibling, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 20:55 UTC (permalink / raw)
  To: eguan; +Cc: linux-xfs, fstests

Craft a malicious filesystem image with a negative inode size,
then try to trigger a kernel DoS by appending data to the file.
Ideally this should trigger verifier errors instead of hanging.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: use $DEBUGFS_PROG instead of debugfs; improve documentation
---
 tests/shared/400     |   75 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/400.out |    5 +++
 tests/shared/401     |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/401.out |    5 +++
 tests/shared/group   |    2 +
 tests/xfs/400        |   75 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/400.out    |    5 +++
 tests/xfs/401        |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/401.out    |    5 +++
 tests/xfs/group      |    2 +
 10 files changed, 328 insertions(+)
 create mode 100755 tests/shared/400
 create mode 100644 tests/shared/400.out
 create mode 100755 tests/shared/401
 create mode 100644 tests/shared/401.out
 create mode 100755 tests/xfs/400
 create mode 100644 tests/xfs/400.out
 create mode 100755 tests/xfs/401
 create mode 100644 tests/xfs/401.out

diff --git a/tests/shared/400 b/tests/shared/400
new file mode 100755
index 0000000..2fca911
--- /dev/null
+++ b/tests/shared/400
@@ -0,0 +1,75 @@
+#! /bin/bash
+# FSQA Test No. 400
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+# So, create this malformed inode and try a buffered append to make
+# sure we catch this situation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ext2 ext3 ext4
+_require_scratch_nocheck
+_disable_dmesg_check
+_require_command "$DEBUGFS_PROG"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+
+echo "Corrupt filesystem"
+_scratch_unmount
+$DEBUGFS_PROG -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/shared/400.out b/tests/shared/400.out
new file mode 100644
index 0000000..ddf8a28
--- /dev/null
+++ b/tests/shared/400.out
@@ -0,0 +1,5 @@
+QA output created by 400
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/shared/401 b/tests/shared/401
new file mode 100755
index 0000000..7b61cbb
--- /dev/null
+++ b/tests/shared/401
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FSQA Test No. 401
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+# So, create this malformed inode and try a buffered dio append to make
+# sure we catch this situation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ext2 ext3 ext4
+_require_scratch_nocheck
+_disable_dmesg_check
+_require_command "$DEBUGFS_PROG"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+
+echo "Corrupt filesystem"
+_scratch_unmount
+# Set the file size to the highest multiple of 512 below
+# -1 so that we can perform a dio write.
+$DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/shared/401.out b/tests/shared/401.out
new file mode 100644
index 0000000..0d45add
--- /dev/null
+++ b/tests/shared/401.out
@@ -0,0 +1,5 @@
+QA output created by 401
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/shared/group b/tests/shared/group
index 55bb594..64d2d2f 100644
--- a/tests/shared/group
+++ b/tests/shared/group
@@ -13,3 +13,5 @@
 272 auto enospc rw
 289 auto quick
 298 auto trim
+400 dangerous_fuzzers
+401 dangerous_fuzzers
diff --git a/tests/xfs/400 b/tests/xfs/400
new file mode 100755
index 0000000..fcaaa39
--- /dev/null
+++ b/tests/xfs/400
@@ -0,0 +1,75 @@
+#! /bin/bash
+# FSQA Test No. 400
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+# So, create this malformed inode and try a buffered append to make
+# sure we catch this situation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+inum=$(stat -c "%i" $testdir/a)
+
+echo "Corrupt filesystem"
+_scratch_unmount
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/400.out b/tests/xfs/400.out
new file mode 100644
index 0000000..ddf8a28
--- /dev/null
+++ b/tests/xfs/400.out
@@ -0,0 +1,5 @@
+QA output created by 400
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/xfs/401 b/tests/xfs/401
new file mode 100755
index 0000000..9e1c7ba
--- /dev/null
+++ b/tests/xfs/401
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FSQA Test No. 401
+#
+# Since loff_t is a signed type, it is invalid for a filesystem to load
+# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
+# which means that we can trivially DoS the VFS by creating such a file
+# and appending to it.  This causes an integer overflow in the routines
+# underlying writeback, which results in the kernel locking up.
+#
+# So, create this malformed inode and try a buffered dio append to make
+# sure we catch this situation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle, 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"
+
+PIDS=""
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_nocheck
+_disable_dmesg_check
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs  >> $seqres.full 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT
+echo m > $testdir/a
+inum=$(stat -c "%i" $testdir/a)
+
+echo "Corrupt filesystem"
+_scratch_unmount
+# Set the file size to the highest multiple of 512 below
+# -1 so that we can perform a dio write.
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
+
+echo "Remount, try to append"
+_scratch_mount
+dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
+sync
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/401.out b/tests/xfs/401.out
new file mode 100644
index 0000000..0d45add
--- /dev/null
+++ b/tests/xfs/401.out
@@ -0,0 +1,5 @@
+QA output created by 401
+Format and mount
+Corrupt filesystem
+Remount, try to append
+Write did not succeed (ok).
diff --git a/tests/xfs/group b/tests/xfs/group
index c237b50..10ba27b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -334,3 +334,5 @@
 345 auto quick clone
 346 auto quick clone
 347 auto quick clone
+400 dangerous_fuzzers
+401 dangerous_fuzzers

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

* Re: [PATCH 2/7] common: add leading underscore to get_block_size
  2017-01-09 10:20   ` Eryu Guan
@ 2017-01-09 21:32     ` Darrick J. Wong
  0 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-09 21:32 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-xfs, fstests

On Mon, Jan 09, 2017 at 06:20:44PM +0800, Eryu Guan wrote:
> On Wed, Jan 04, 2017 at 05:04:48PM -0800, Darrick J. Wong wrote:
> > Add a leading underscore to the get_block_size helper since it's a
> > common function.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> There's a new user of get_block_size, after latest fstests update,
> btrfs/012. I can fold the btrfs/012 update to this patch.

Ok.  Assuming you've already done this, I won't repost this patch.

(Though if I end up reposting the whole series then the patch in the new
series will of course have a diff for btrfs/012.)

--D

> 
> Thanks for doing this!
> 
> Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 7/7] xfs/ext4: check negative inode size
  2017-01-09 20:55   ` [PATCH v2 " Darrick J. Wong
@ 2017-01-10  4:40     ` Eryu Guan
  2017-01-10  4:52       ` Darrick J. Wong
  0 siblings, 1 reply; 21+ messages in thread
From: Eryu Guan @ 2017-01-10  4:40 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, fstests

On Mon, Jan 09, 2017 at 12:55:18PM -0800, Darrick J. Wong wrote:
> Craft a malicious filesystem image with a negative inode size,
> then try to trigger a kernel DoS by appending data to the file.
> Ideally this should trigger verifier errors instead of hanging.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: use $DEBUGFS_PROG instead of debugfs; improve documentation

Thanks for all the updated patches! I fixed a minor typo locally and
committed.

> diff --git a/tests/shared/401 b/tests/shared/401
> new file mode 100755
> index 0000000..7b61cbb
> --- /dev/null
> +++ b/tests/shared/401
> @@ -0,0 +1,77 @@
> +#! /bin/bash
> +# FSQA Test No. 401
> +#
> +# Since loff_t is a signed type, it is invalid for a filesystem to load
> +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> +# which means that we can trivially DoS the VFS by creating such a file
> +# and appending to it.  This causes an integer overflow in the routines
> +# underlying writeback, which results in the kernel locking up.
> +#
> +# So, create this malformed inode and try a buffered dio append to make
                                               ^^^^^^^^
I removed the "buffered" here and from xfs/401.

Thanks,
Eryu

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

* Re: [PATCH v2 7/7] xfs/ext4: check negative inode size
  2017-01-10  4:40     ` Eryu Guan
@ 2017-01-10  4:52       ` Darrick J. Wong
  0 siblings, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2017-01-10  4:52 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-xfs, fstests

On Tue, Jan 10, 2017 at 12:40:23PM +0800, Eryu Guan wrote:
> On Mon, Jan 09, 2017 at 12:55:18PM -0800, Darrick J. Wong wrote:
> > Craft a malicious filesystem image with a negative inode size,
> > then try to trigger a kernel DoS by appending data to the file.
> > Ideally this should trigger verifier errors instead of hanging.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > v2: use $DEBUGFS_PROG instead of debugfs; improve documentation
> 
> Thanks for all the updated patches! I fixed a minor typo locally and
> committed.
> 
> > diff --git a/tests/shared/401 b/tests/shared/401
> > new file mode 100755
> > index 0000000..7b61cbb
> > --- /dev/null
> > +++ b/tests/shared/401
> > @@ -0,0 +1,77 @@
> > +#! /bin/bash
> > +# FSQA Test No. 401
> > +#
> > +# Since loff_t is a signed type, it is invalid for a filesystem to load
> > +# an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
> > +# which means that we can trivially DoS the VFS by creating such a file
> > +# and appending to it.  This causes an integer overflow in the routines
> > +# underlying writeback, which results in the kernel locking up.
> > +#
> > +# So, create this malformed inode and try a buffered dio append to make
>                                                ^^^^^^^^
> I removed the "buffered" here and from xfs/401.

D'oh!!!  Thanks for fixing that.

--D

> 
> Thanks,
> Eryu

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

end of thread, other threads:[~2017-01-10  4:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05  1:04 [PATCH 0/7] xfstests: misc reflink test fixes Darrick J. Wong
2017-01-05  1:04 ` [PATCH 1/7] ocfs2: test reflinking to inline data files Darrick J. Wong
2017-01-05  1:04 ` [PATCH 2/7] common: add leading underscore to get_block_size Darrick J. Wong
2017-01-09 10:20   ` Eryu Guan
2017-01-09 21:32     ` Darrick J. Wong
2017-01-05  1:04 ` [PATCH 3/7] ocfs2/reflink: fix file block size reporting Darrick J. Wong
2017-01-05  1:05 ` [PATCH 4/7] reflink: fix quota tests to work properly Darrick J. Wong
2017-01-09  8:55   ` Eryu Guan
2017-01-09 19:30     ` Darrick J. Wong
2017-01-09 20:53   ` [PATCH v2 " Darrick J. Wong
2017-01-05  1:05 ` [PATCH 5/7] reflink: make error reporting consistent when simulating EIO Darrick J. Wong
2017-01-05  1:05 ` [PATCH 6/7] dedupe: fix consistent error message prefixes for dedupe tests Darrick J. Wong
2017-01-09  9:26   ` Eryu Guan
2017-01-09 20:36     ` Darrick J. Wong
2017-01-09 20:54   ` [PATCH v2 " Darrick J. Wong
2017-01-05  1:05 ` [PATCH 7/7] xfs/ext4: check negative inode size Darrick J. Wong
2017-01-09  9:36   ` Eryu Guan
2017-01-09 20:36     ` Darrick J. Wong
2017-01-09 20:55   ` [PATCH v2 " Darrick J. Wong
2017-01-10  4:40     ` Eryu Guan
2017-01-10  4:52       ` 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.