All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 0/8] fstests: miscellaneous fixes
@ 2021-05-12  2:01 Darrick J. Wong
  2021-05-12  2:01 ` [PATCH 1/8] xfs/122: add entries for structures added to 5.13 Darrick J. Wong
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:01 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

Hi all,

Various small fixes to the fstests suite, and some refactoring of common
idioms needed for testing realtime devices.

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

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

--D

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

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

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=random-fixes
---
 common/populate   |    2 +-
 common/rc         |    2 +-
 common/xfs        |   27 ++++++++++++++++++++++++++-
 ltp/fsstress.c    |   24 ++++++++++++------------
 ltp/fsx.c         |   24 ++++++++++++------------
 src/global.h      |   13 +++++++++++++
 tests/generic/223 |    3 ++-
 tests/generic/449 |    2 +-
 tests/xfs/004     |    2 +-
 tests/xfs/083     |    8 ++++----
 tests/xfs/085     |    2 +-
 tests/xfs/086     |    4 ++--
 tests/xfs/087     |    2 +-
 tests/xfs/088     |    5 +++--
 tests/xfs/089     |    5 +++--
 tests/xfs/091     |    5 +++--
 tests/xfs/093     |    2 +-
 tests/xfs/097     |    2 +-
 tests/xfs/099     |    4 ++--
 tests/xfs/100     |    4 ++--
 tests/xfs/101     |    4 ++--
 tests/xfs/102     |    4 ++--
 tests/xfs/105     |    4 ++--
 tests/xfs/112     |    4 ++--
 tests/xfs/113     |    4 ++--
 tests/xfs/117     |   49 ++++++++++++++++++++++++++++++-------------------
 tests/xfs/120     |    3 ++-
 tests/xfs/122.out |    1 +
 tests/xfs/123     |    2 +-
 tests/xfs/124     |    4 ++--
 tests/xfs/125     |    4 ++--
 tests/xfs/126     |    4 ++--
 tests/xfs/130     |    3 ++-
 tests/xfs/146     |    2 +-
 tests/xfs/147     |    2 +-
 tests/xfs/178     |    4 ++--
 tests/xfs/235     |    3 ++-
 tests/xfs/272     |    2 +-
 tests/xfs/318     |    2 +-
 tests/xfs/431     |    4 ++--
 tests/xfs/521     |    2 +-
 tests/xfs/528     |    2 +-
 tests/xfs/532     |    2 +-
 tests/xfs/533     |    2 +-
 tests/xfs/538     |    2 +-
 45 files changed, 159 insertions(+), 102 deletions(-)


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

* [PATCH 1/8] xfs/122: add entries for structures added to 5.13
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
@ 2021-05-12  2:01 ` Darrick J. Wong
  2021-05-12  2:01 ` [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device Darrick J. Wong
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:01 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

Add a new entry for a structure that was changed in 5.13.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/122.out |    1 +
 1 file changed, 1 insertion(+)


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index f229465a..7607f0a5 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -99,6 +99,7 @@ sizeof(struct xfs_inumbers) = 24
 sizeof(struct xfs_inumbers_req) = 64
 sizeof(struct xfs_legacy_timestamp) = 8
 sizeof(struct xfs_log_dinode) = 176
+sizeof(struct xfs_log_legacy_timestamp) = 8
 sizeof(struct xfs_map_extent) = 32
 sizeof(struct xfs_phys_extent) = 16
 sizeof(struct xfs_refcount_key) = 4


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

* [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
  2021-05-12  2:01 ` [PATCH 1/8] xfs/122: add entries for structures added to 5.13 Darrick J. Wong
@ 2021-05-12  2:01 ` Darrick J. Wong
  2021-05-16 15:49   ` Eryu Guan
  2021-05-12  2:01 ` [PATCH 3/8] xfs: fix old fuzz test invocations of xfs_repair Darrick J. Wong
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:01 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

Refactor all the places where we try to force new file data allocations
to a specific xfs backing device so that we don't end up open-coding the
same xfs_io command lines over and over.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/populate   |    2 +-
 common/xfs        |   25 +++++++++++++++++++++++++
 tests/generic/223 |    3 ++-
 tests/generic/449 |    2 +-
 tests/xfs/004     |    2 +-
 tests/xfs/088     |    1 +
 tests/xfs/089     |    1 +
 tests/xfs/091     |    1 +
 tests/xfs/120     |    1 +
 tests/xfs/130     |    1 +
 tests/xfs/146     |    2 +-
 tests/xfs/147     |    2 +-
 tests/xfs/235     |    1 +
 tests/xfs/272     |    2 +-
 tests/xfs/318     |    2 +-
 tests/xfs/431     |    4 ++--
 tests/xfs/521     |    2 +-
 tests/xfs/528     |    2 +-
 tests/xfs/532     |    2 +-
 tests/xfs/533     |    2 +-
 tests/xfs/538     |    2 +-
 21 files changed, 47 insertions(+), 15 deletions(-)


diff --git a/common/populate b/common/populate
index d484866a..e1704b10 100644
--- a/common/populate
+++ b/common/populate
@@ -162,7 +162,7 @@ _scratch_xfs_populate() {
 	# Clear the rtinherit flag on the root directory so that files are
 	# always created on the data volume regardless of MKFS_OPTIONS.  We can
 	# set the realtime flag when needed.
-	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+	_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 	blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
 	dblksz="$($XFS_INFO_PROG "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
diff --git a/common/xfs b/common/xfs
index 5cd7b35c..49bd6c31 100644
--- a/common/xfs
+++ b/common/xfs
@@ -194,6 +194,31 @@ _xfs_get_file_block_size()
 	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
 }
 
+# Set or clear the realtime status of every supplied path.  The first argument
+# is either 'data' or 'realtime'.  All other arguments should be paths to
+# existing directories or empty regular files.
+#
+# For each directory, each file subsequently created will target the given
+# device for file data allocations.  For each empty regular file, each
+# subsequent file data allocation will be on the given device.
+_scratch_xfs_force_bdev()
+{
+	local device="$1"
+	shift
+	local chattr_arg=""
+
+	case "$device" in
+	"data")		chattr_arg="-t";;
+	"realtime")	chattr_arg="+t";;
+	*)
+		echo "${device}: Don't know what device this is?"
+		return 1
+		;;
+	esac
+
+	$XFS_IO_PROG -c "chattr $chattr_arg" "$@"
+}
+
 _xfs_get_fsxattr()
 {
 	local field="$1"
diff --git a/tests/generic/223 b/tests/generic/223
index f6393293..0df84c2b 100755
--- a/tests/generic/223
+++ b/tests/generic/223
@@ -46,7 +46,8 @@ for SUNIT_K in 8 16 32 64 128; do
 	# This test checks for stripe alignments of space allocations on the
 	# filesystem.  Make sure all files get created on the main device,
 	# which for XFS means no rt files.
-	test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+	test "$FSTYP" = "xfs" && \
+		_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 	for SIZE_MULT in 1 2 8 64 256; do
 		let SIZE=$SIZE_MULT*$SUNIT_BYTES
diff --git a/tests/generic/449 b/tests/generic/449
index 5fd15367..9035b705 100755
--- a/tests/generic/449
+++ b/tests/generic/449
@@ -46,7 +46,7 @@ _scratch_mount || _fail "mount failed"
 # This is a test of xattr behavior when we run out of disk space for xattrs,
 # so make sure the pwrite goes to the data device and not the rt volume.
 test "$FSTYP" = "xfs" && \
-	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+	_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 TFILE=$SCRATCH_MNT/testfile.$seq
 
diff --git a/tests/xfs/004 b/tests/xfs/004
index 7633071c..b3a00fb6 100755
--- a/tests/xfs/004
+++ b/tests/xfs/004
@@ -31,7 +31,7 @@ _populate_scratch()
 	# This test looks at specific behaviors of the xfs_db freesp command,
 	# which reports on the contents of the free space btrees for the data
 	# device.  Don't let anything get created on the realtime volume.
-	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+	_scratch_xfs_force_bdev data $SCRATCH_MNT
 	dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
 	dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
 	dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
diff --git a/tests/xfs/088 b/tests/xfs/088
index fe621d0a..62360ca8 100755
--- a/tests/xfs/088
+++ b/tests/xfs/088
@@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
 echo "+ mount fs image"
 _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 mkdir -p "${TESTDIR}"
diff --git a/tests/xfs/089 b/tests/xfs/089
index 3339ff63..79167a57 100755
--- a/tests/xfs/089
+++ b/tests/xfs/089
@@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
 echo "+ mount fs image"
 _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 mkdir -p "${TESTDIR}"
diff --git a/tests/xfs/091 b/tests/xfs/091
index 9304849d..db6bb0b2 100755
--- a/tests/xfs/091
+++ b/tests/xfs/091
@@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
 echo "+ mount fs image"
 _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 mkdir -p "${TESTDIR}"
diff --git a/tests/xfs/120 b/tests/xfs/120
index 59ac0433..9fcce9ee 100755
--- a/tests/xfs/120
+++ b/tests/xfs/120
@@ -47,6 +47,7 @@ echo "+ mount fs image"
 _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
 nr="$((blksz * 2 / 16))"
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full
diff --git a/tests/xfs/130 b/tests/xfs/130
index 9fec009f..b4404c5d 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -43,6 +43,7 @@ echo "+ mount fs image"
 _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
 agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 _pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
diff --git a/tests/xfs/146 b/tests/xfs/146
index 8f85024d..a62b8429 100755
--- a/tests/xfs/146
+++ b/tests/xfs/146
@@ -78,7 +78,7 @@ _scratch_mkfs -r size=$rtsize >> $seqres.full
 _scratch_mount >> $seqres.full
 
 # Make sure the root directory has rtinherit set so our test file will too
-$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
+_scratch_xfs_force_bdev realtime $SCRATCH_MNT
 
 # Allocate some stuff at the start, to force the first falloc of the ouch file
 # to happen somewhere in the middle of the rt volume
diff --git a/tests/xfs/147 b/tests/xfs/147
index da962f96..0071f5c3 100755
--- a/tests/xfs/147
+++ b/tests/xfs/147
@@ -50,7 +50,7 @@ rextblks=$((rextsize / blksz))
 echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
 
 # Make sure the root directory has rtinherit set so our test file will too
-$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
+_scratch_xfs_force_bdev realtime $SCRATCH_MNT
 
 sz=$((rextsize * 100))
 range="$((blksz * 3)) $blksz"
diff --git a/tests/xfs/235 b/tests/xfs/235
index 1ed19424..553a3bc8 100755
--- a/tests/xfs/235
+++ b/tests/xfs/235
@@ -41,6 +41,7 @@ echo "+ mount fs image"
 _scratch_mount
 blksz=$(stat -f -c '%s' ${SCRATCH_MNT})
 agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "+ make some files"
 _pwrite_byte 0x62 0 $((blksz * 64)) ${SCRATCH_MNT}/file0 >> $seqres.full
diff --git a/tests/xfs/272 b/tests/xfs/272
index 6c0fede5..2848848d 100755
--- a/tests/xfs/272
+++ b/tests/xfs/272
@@ -38,7 +38,7 @@ _scratch_mkfs > "$seqres.full" 2>&1
 _scratch_mount
 
 # Make sure everything is on the data device
-$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
 sync
diff --git a/tests/xfs/318 b/tests/xfs/318
index 07375b1f..823f3e6c 100755
--- a/tests/xfs/318
+++ b/tests/xfs/318
@@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
 
 # This test depends on specific behaviors of the data device, so create all
 # files on it.
-$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "Create files"
 touch $SCRATCH_MNT/file1
diff --git a/tests/xfs/431 b/tests/xfs/431
index e67906dc..dd634ed6 100755
--- a/tests/xfs/431
+++ b/tests/xfs/431
@@ -47,7 +47,7 @@ _scratch_mount
 
 # Set realtime inherit flag on scratch mount, suppress output
 # as this may simply error out on future kernels
-$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
+_scratch_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
 
 # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
 # an attribute. And erroring out here is fine, this would be desired behavior
@@ -60,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
 	# Remove the testfile and rt inherit flag after we are done or
 	# xfs_repair will fail.
 	rm -f $SCRATCH_MNT/testfile
-	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1
+	_scratch_xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
 fi
 
 # success, all done
diff --git a/tests/xfs/521 b/tests/xfs/521
index b8026d45..64155662 100755
--- a/tests/xfs/521
+++ b/tests/xfs/521
@@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Check rt volume stats"
-$XFS_IO_PROG -c 'chattr +t' $testdir
+_scratch_xfs_force_bdev realtime $testdir
 $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
 before=$(stat -f -c '%b' $testdir)
 
diff --git a/tests/xfs/528 b/tests/xfs/528
index 7f98c5b8..4db4f513 100755
--- a/tests/xfs/528
+++ b/tests/xfs/528
@@ -77,7 +77,7 @@ test_ops() {
 		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
 
 	# Force all files to be realtime files
-	$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
+	_scratch_xfs_force_bdev realtime $SCRATCH_MNT
 
 	log "Test regular write, rextsize=$rextsize"
 	mk_file $SCRATCH_MNT/write $rextsize
diff --git a/tests/xfs/532 b/tests/xfs/532
index 560af586..1749d6ac 100755
--- a/tests/xfs/532
+++ b/tests/xfs/532
@@ -47,7 +47,7 @@ _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
 # device gets fragmented rather than realtime device.
-$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 bsize=$(_get_block_size $SCRATCH_MNT)
 
diff --git a/tests/xfs/533 b/tests/xfs/533
index dd4cb4c4..b73097e1 100755
--- a/tests/xfs/533
+++ b/tests/xfs/533
@@ -58,7 +58,7 @@ _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
 # device gets fragmented rather than realtime device.
-$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 echo "Consume free space"
 fillerdir=$SCRATCH_MNT/fillerdir
diff --git a/tests/xfs/538 b/tests/xfs/538
index 97273b88..deb43d7c 100755
--- a/tests/xfs/538
+++ b/tests/xfs/538
@@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
 # device gets fragmented rather than realtime device.
-$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
+_scratch_xfs_force_bdev data $SCRATCH_MNT
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
 


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

* [PATCH 3/8] xfs: fix old fuzz test invocations of xfs_repair
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
  2021-05-12  2:01 ` [PATCH 1/8] xfs/122: add entries for structures added to 5.13 Darrick J. Wong
  2021-05-12  2:01 ` [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device Darrick J. Wong
@ 2021-05-12  2:01 ` Darrick J. Wong
  2021-05-12  2:02 ` [PATCH 4/8] xfs/117: fix fragility in this fuzz test Darrick J. Wong
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:01 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

Some of the older blocktrash-based fuzz tests cause the fs to go down
due to the corrupted image and fail to remount.  Offline repair fails
because _repair_scratch_fs is the helper that is smart enough to call
xfs_repair -L, not _scratch_xfs_repair.  Fix these instances.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/083 |    8 ++++----
 tests/xfs/085 |    2 +-
 tests/xfs/086 |    4 ++--
 tests/xfs/087 |    2 +-
 tests/xfs/088 |    4 ++--
 tests/xfs/089 |    4 ++--
 tests/xfs/091 |    4 ++--
 tests/xfs/093 |    2 +-
 tests/xfs/097 |    2 +-
 tests/xfs/099 |    4 ++--
 tests/xfs/100 |    4 ++--
 tests/xfs/101 |    4 ++--
 tests/xfs/102 |    4 ++--
 tests/xfs/105 |    4 ++--
 tests/xfs/112 |    4 ++--
 tests/xfs/113 |    4 ++--
 tests/xfs/117 |    2 +-
 tests/xfs/120 |    2 +-
 tests/xfs/123 |    2 +-
 tests/xfs/124 |    4 ++--
 tests/xfs/125 |    4 ++--
 tests/xfs/126 |    4 ++--
 tests/xfs/130 |    2 +-
 tests/xfs/235 |    2 +-
 24 files changed, 41 insertions(+), 41 deletions(-)


diff --git a/tests/xfs/083 b/tests/xfs/083
index a3f32cb7..14a36416 100755
--- a/tests/xfs/083
+++ b/tests/xfs/083
@@ -44,7 +44,7 @@ scratch_repair() {
 
 	FSCK_LOG="${tmp}-fuzz-${fsck_pass}.log"
 	echo "++ fsck pass ${fsck_pass}" > "${FSCK_LOG}"
-	_scratch_xfs_repair >> "${FSCK_LOG}" 2>&1
+	_repair_scratch_fs >> "${FSCK_LOG}" 2>&1
 	res=$?
 	if [ "${res}" -eq 0 ]; then
 		echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
@@ -105,7 +105,7 @@ echo "+ populate fs image" >> $seqres.full
 _scratch_populate >> $seqres.full
 
 echo "+ check fs" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1 || _fail "should pass initial fsck"
+_repair_scratch_fs >> $seqres.full 2>&1 || _fail "should pass initial fsck"
 
 echo "++ corrupt image" >> $seqres.full
 _scratch_xfs_db -x -c blockget -c "blocktrash ${FUZZ_ARGS}" >> $seqres.full 2>&1
@@ -129,7 +129,7 @@ done
 echo "+ fsck loop returns ${fsck_loop_ret}" >> $seqres.full
 
 echo "++ check fs for round 2" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 ROUND2_LOG="${tmp}-round2-${fsck_pass}.log"
 echo "++ mount image (2)" >> $ROUND2_LOG
@@ -150,7 +150,7 @@ umount "${SCRATCH_MNT}" >> $ROUND2_LOG 2>&1
 cat "$ROUND2_LOG" >> $seqres.full
 
 echo "++ check fs (2)" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 egrep -q '(did not fix|makes no progress)' $seqres.full && echo "xfs_repair failed" | tee -a $seqres.full
 if [ "$(wc -l < "$ROUND2_LOG")" -ne 8 ]; then
diff --git a/tests/xfs/085 b/tests/xfs/085
index 560b5a24..5d898088 100755
--- a/tests/xfs/085
+++ b/tests/xfs/085
@@ -75,7 +75,7 @@ echo "+ mount image"
 _try_scratch_mount 2>/dev/null && _fail "mount should not succeed"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/086 b/tests/xfs/086
index f94c26b4..f4cf950d 100755
--- a/tests/xfs/086
+++ b/tests/xfs/086
@@ -86,7 +86,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
@@ -109,7 +109,7 @@ done
 umount "${SCRATCH_MNT}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/087 b/tests/xfs/087
index 967791dd..e7b06e09 100755
--- a/tests/xfs/087
+++ b/tests/xfs/087
@@ -86,7 +86,7 @@ fi
 echo "broken: ${broken}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/088 b/tests/xfs/088
index 62360ca8..42a186be 100755
--- a/tests/xfs/088
+++ b/tests/xfs/088
@@ -86,7 +86,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
@@ -109,7 +109,7 @@ done
 umount "${SCRATCH_MNT}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/089 b/tests/xfs/089
index 79167a57..7d8af7ce 100755
--- a/tests/xfs/089
+++ b/tests/xfs/089
@@ -86,7 +86,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
@@ -110,7 +110,7 @@ done
 umount "${SCRATCH_MNT}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/091 b/tests/xfs/091
index db6bb0b2..5fa98328 100755
--- a/tests/xfs/091
+++ b/tests/xfs/091
@@ -86,7 +86,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
@@ -110,7 +110,7 @@ done
 umount "${SCRATCH_MNT}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/093 b/tests/xfs/093
index 3bdbff4d..9a61cc3e 100755
--- a/tests/xfs/093
+++ b/tests/xfs/093
@@ -86,7 +86,7 @@ fi
 echo "broken: ${broken}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/097 b/tests/xfs/097
index f8ea4676..98648c9e 100755
--- a/tests/xfs/097
+++ b/tests/xfs/097
@@ -88,7 +88,7 @@ fi
 echo "broken: ${broken}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/099 b/tests/xfs/099
index 0cf19682..9a1408b8 100755
--- a/tests/xfs/099
+++ b/tests/xfs/099
@@ -74,8 +74,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/100 b/tests/xfs/100
index 44d175cc..277f26ec 100755
--- a/tests/xfs/100
+++ b/tests/xfs/100
@@ -79,8 +79,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/101 b/tests/xfs/101
index 023cc349..6eb303ad 100755
--- a/tests/xfs/101
+++ b/tests/xfs/101
@@ -74,8 +74,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/102 b/tests/xfs/102
index 907b8592..23326ecf 100755
--- a/tests/xfs/102
+++ b/tests/xfs/102
@@ -79,8 +79,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/105 b/tests/xfs/105
index bb7e93e1..7aeee7f0 100755
--- a/tests/xfs/105
+++ b/tests/xfs/105
@@ -79,8 +79,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/112 b/tests/xfs/112
index cf0a36d0..085f21ee 100755
--- a/tests/xfs/112
+++ b/tests/xfs/112
@@ -79,11 +79,11 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 if [ $? -eq 2 ]; then
 	_scratch_mount
 	umount "${SCRATCH_MNT}"
-	_scratch_xfs_repair >> $seqres.full 2>&1
+	_repair_scratch_fs >> $seqres.full 2>&1
 fi
 
 echo "+ mount image (2)"
diff --git a/tests/xfs/113 b/tests/xfs/113
index 3ab3cf5e..3dc51381 100755
--- a/tests/xfs/113
+++ b/tests/xfs/113
@@ -79,8 +79,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/117 b/tests/xfs/117
index 15765a56..d3f4675f 100755
--- a/tests/xfs/117
+++ b/tests/xfs/117
@@ -88,7 +88,7 @@ fi
 echo "broken: ${broken}"
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/120 b/tests/xfs/120
index 9fcce9ee..1f594ebc 100755
--- a/tests/xfs/120
+++ b/tests/xfs/120
@@ -74,7 +74,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/123 b/tests/xfs/123
index a7fae5f6..ced453bd 100755
--- a/tests/xfs/123
+++ b/tests/xfs/123
@@ -69,7 +69,7 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/124 b/tests/xfs/124
index f4b24dd6..50faa66b 100755
--- a/tests/xfs/124
+++ b/tests/xfs/124
@@ -78,8 +78,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/125 b/tests/xfs/125
index 3bdf73c4..c9ee2cf3 100755
--- a/tests/xfs/125
+++ b/tests/xfs/125
@@ -78,8 +78,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/126 b/tests/xfs/126
index 3f069c16..0ca0670c 100755
--- a/tests/xfs/126
+++ b/tests/xfs/126
@@ -83,8 +83,8 @@ if _try_scratch_mount >> $seqres.full 2>&1; then
 fi
 
 echo "+ repair fs"
-_scratch_xfs_repair >> $seqres.full 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/130 b/tests/xfs/130
index b4404c5d..7ff565c6 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -71,7 +71,7 @@ _scratch_unmount >> $seqres.full 2>&1
 echo "+ repair fs"
 _disable_dmesg_check
 _repair_scratch_fs >> "$seqres.full" 2>&1
-_scratch_xfs_repair >> "$seqres.full" 2>&1
+_repair_scratch_fs >> "$seqres.full" 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount
diff --git a/tests/xfs/235 b/tests/xfs/235
index 553a3bc8..fe3a2cd0 100755
--- a/tests/xfs/235
+++ b/tests/xfs/235
@@ -72,7 +72,7 @@ fi
 echo "+ repair fs"
 _disable_dmesg_check
 _repair_scratch_fs >> "$seqres.full" 2>&1
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 echo "+ mount image (2)"
 _scratch_mount


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

* [PATCH 4/8] xfs/117: fix fragility in this fuzz test
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (2 preceding siblings ...)
  2021-05-12  2:01 ` [PATCH 3/8] xfs: fix old fuzz test invocations of xfs_repair Darrick J. Wong
@ 2021-05-12  2:02 ` Darrick J. Wong
  2021-05-12  2:02 ` [PATCH 5/8] common: always pass -f to $DUMP_COMPRESSOR Darrick J. Wong
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:02 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

This fuzz test has some fragility problems -- it doesn't do anything to
guarantee that the inodes that it checks for EFSCORRUPTED are the same
ones that it fuzzed, and it doesn't explicitly try to avoid victimizing
inodes in the same chunk as the root directory.  As a result, this test
fails annoyingly frequently.

Fix both of these problems and get rid of the confusingly named TESTDIR
variable.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/117 |   47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)


diff --git a/tests/xfs/117 b/tests/xfs/117
index d3f4675f..32be525f 100755
--- a/tests/xfs/117
+++ b/tests/xfs/117
@@ -39,8 +39,7 @@ _require_xfs_db_blocktrash_z_command
 test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
 
 rm -f $seqres.full
-TESTDIR="${SCRATCH_MNT}/scratchdir"
-TESTFILE="${TESTDIR}/testfile"
+victimdir="${SCRATCH_MNT}/scratchdir"
 
 echo "+ create scratch fs"
 _scratch_mkfs_xfs > /dev/null
@@ -50,37 +49,49 @@ _scratch_mount
 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
 
 echo "+ make some files"
-mkdir -p "${TESTDIR}"
-for x in `seq 1 1024`; do
-	touch "${SCRATCH_MNT}/junk.${x}"
-	inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
-	if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
-		mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
-		break
-	fi
+mkdir -p "$victimdir"
+
+rootdir="$(stat -c '%i' "$SCRATCH_MNT")"
+rootchunk=$(( rootdir / 64 ))
+
+# First we create some dummy file so that the victim files don't get created
+# in the same inode chunk as the root directory, because a corrupt inode in
+# the root chunk causes mount to fail.
+for ((i = 0; i < 256; i++)); do
+	fname="$SCRATCH_MNT/dummy.$i"
+	touch "$fname"
+	ino="$(stat -c '%i' "$fname")"
+	ichunk=$(( ino / 64 ))
+	test "$ichunk" -gt "$rootchunk" && break
 done
-for x in `seq 2 64`; do
-	touch "${TESTFILE}.${x}"
+
+# Now create some victim files
+inos=()
+for ((i = 0; i < 64; i++)); do
+	fname="$victimdir/test.$i"
+	touch "$fname"
+	inos+=("$(stat -c '%i' "$fname")")
 done
-inode="$(stat -c '%i' "${TESTFILE}.1")"
+echo "First victim inode is: " >> $seqres.full
+stat -c '%i' "$fname" >> $seqres.full
 umount "${SCRATCH_MNT}"
 
 echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-seq "${inode}" "$((inode + 63))" | while read ino; do
+for ino in "${inos[@]}"; do
 	_scratch_xfs_db -x -c "inode ${ino}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 echo "+ mount image && modify files"
 broken=1
 if _try_scratch_mount >> $seqres.full 2>&1; then
-
-	for x in `seq 1 64`; do
-		stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+	for ((i = 0; i < 64; i++)); do
+		fname="$victimdir/test.$i"
+		stat "$fname" &>> $seqres.full
 		test $? -eq 0 && broken=0
-		touch "${TESTFILE}.${x}" >> $seqres.full 2>&1
+		touch "$fname" &>> $seqres.full
 		test $? -eq 0 && broken=0
 	done
 	umount "${SCRATCH_MNT}"


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

* [PATCH 5/8] common: always pass -f to $DUMP_COMPRESSOR
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (3 preceding siblings ...)
  2021-05-12  2:02 ` [PATCH 4/8] xfs/117: fix fragility in this fuzz test Darrick J. Wong
@ 2021-05-12  2:02 ` Darrick J. Wong
  2021-05-12  2:02 ` [PATCH 6/8] fsx/fsstress: round blocksize properly Darrick J. Wong
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:02 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

If the test runner gave us the name of a program to use to compress
dumps, always pass -f to overwrite older compressed images, like the
documentation says we do. This prevents the test suite from stalling on
"foo.md.gz exists, overwrite?" prompts.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/rc  |    2 +-
 common/xfs |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/common/rc b/common/rc
index 919028ef..b18cf61e 100644
--- a/common/rc
+++ b/common/rc
@@ -628,7 +628,7 @@ _ext4_metadump()
 	test -n "$E2IMAGE_PROG" || _fail "e2image not installed"
 	$E2IMAGE_PROG -Q "$device" "$dumpfile"
 	[ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] &&
-		$DUMP_COMPRESSOR "$dumpfile" &>> "$seqres.full"
+		$DUMP_COMPRESSOR -f "$dumpfile" &>> "$seqres.full"
 }
 
 _test_mkfs()
diff --git a/common/xfs b/common/xfs
index 49bd6c31..add33008 100644
--- a/common/xfs
+++ b/common/xfs
@@ -503,7 +503,7 @@ _xfs_metadump() {
 	$XFS_METADUMP_PROG $options "$device" "$metadump"
 	res=$?
 	[ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] &&
-		$DUMP_COMPRESSOR "$metadump" &> /dev/null
+		$DUMP_COMPRESSOR -f "$metadump" &> /dev/null
 	return $res
 }
 


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

* [PATCH 6/8] fsx/fsstress: round blocksize properly
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (4 preceding siblings ...)
  2021-05-12  2:02 ` [PATCH 5/8] common: always pass -f to $DUMP_COMPRESSOR Darrick J. Wong
@ 2021-05-12  2:02 ` Darrick J. Wong
  2021-05-12  2:02 ` [PATCH 7/8] fsx: fix backwards parameters in complaint about overly long copy Darrick J. Wong
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:02 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

The block sizes reported by stat and DIOINFO aren't required to be
powers of two.  This can happen on an XFS filesystem with a realtime
extent size that isn't a power of two; on such filesystems, certain IO
calls will fail due to alignment issues.  Fix that by providing rounding
helpers that work for all sizes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 ltp/fsstress.c |   24 ++++++++++++------------
 ltp/fsx.c      |   22 +++++++++++-----------
 src/global.h   |   13 +++++++++++++
 3 files changed, 36 insertions(+), 23 deletions(-)


diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index e7cd0eae..b4ddf5e2 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -2140,7 +2140,7 @@ do_aio_rw(int opno, long r, int flags)
 			" fallback to stat()\n",
 				procid, opno, f.path, st, errno);
 		diob.d_mem = diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+		diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
 	}
 	dio_env = getenv("XFS_DIO_MIN");
 	if (dio_env)
@@ -2608,7 +2608,7 @@ clonerange_f(
 
 	/* Calculate offsets */
 	len = (random() % FILELEN_MAX) + 1;
-	len &= ~(stat1.st_blksize - 1);
+	len = rounddown_64(len, stat1.st_blksize);
 	if (len == 0)
 		len = stat1.st_blksize;
 	if (len > stat1.st_size)
@@ -2620,7 +2620,7 @@ clonerange_f(
 	else
 		off1 = (off64_t)(lr % MIN(stat1.st_size - len, MAXFSIZE));
 	off1 %= maxfsize;
-	off1 &= ~(stat1.st_blksize - 1);
+	off1 = rounddown_64(off1, stat1.st_blksize);
 
 	/*
 	 * If srcfile == destfile, randomly generate destination ranges
@@ -2631,7 +2631,7 @@ clonerange_f(
 		lr = ((int64_t)random() << 32) + random();
 		off2 = (off64_t)(lr % max_off2);
 		off2 %= maxfsize;
-		off2 &= ~(stat2.st_blksize - 1);
+		off2 = rounddown_64(off2, stat2.st_blksize);
 	} while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len);
 
 	/* Clone data blocks */
@@ -2968,7 +2968,7 @@ deduperange_f(
 
 	/* Never try to dedupe more than half of the src file. */
 	len = (random() % FILELEN_MAX) + 1;
-	len &= ~(stat[0].st_blksize - 1);
+	len = rounddown_64(len, stat[0].st_blksize);
 	if (len == 0)
 		len = stat[0].st_blksize / 2;
 	if (len > stat[0].st_size / 2)
@@ -2981,7 +2981,7 @@ deduperange_f(
 	else
 		off[0] = (off64_t)(lr % MIN(stat[0].st_size - len, MAXFSIZE));
 	off[0] %= maxfsize;
-	off[0] &= ~(stat[0].st_blksize - 1);
+	off[0] = rounddown_64(off[0], stat[0].st_blksize);
 
 	/*
 	 * If srcfile == destfile[i], randomly generate destination ranges
@@ -2997,7 +2997,7 @@ deduperange_f(
 			else
 				off[i] = (off64_t)(lr % MIN(stat[i].st_size - len, MAXFSIZE));
 			off[i] %= maxfsize;
-			off[i] &= ~(stat[i].st_blksize - 1);
+			off[i] = rounddown_64(off[i], stat[i].st_blksize);
 		} while (stat[0].st_ino == stat[i].st_ino &&
 			 llabs(off[i] - off[0]) < len &&
 			 tries++ < 10);
@@ -3406,7 +3406,7 @@ dread_f(int opno, long r)
 			" fallback to stat()\n",
 				procid, opno, f.path, st, errno);
 		diob.d_mem = diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+		diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
 	}
 
 	dio_env = getenv("XFS_DIO_MIN");
@@ -3483,7 +3483,7 @@ dwrite_f(int opno, long r)
 				" %s%s return %d, fallback to stat()\n",
 			       procid, opno, f.path, st, errno);
 		diob.d_mem = diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+		diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
 	}
 
 	dio_env = getenv("XFS_DIO_MIN");
@@ -3579,8 +3579,8 @@ do_fallocate(int opno, long r, int mode)
 	 */
 	if ((mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)) &&
 		(opno % 2)) {
-		off = ((off + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
-		len = ((len + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
+		off = roundup_64(off, stb.st_blksize);
+		len = roundup_64(len, stb.st_blksize);
 	}
 	mode |= FALLOC_FL_KEEP_SIZE & random();
 	e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
@@ -4186,7 +4186,7 @@ do_mmap(int opno, long r, int prot)
 
 	lr = ((int64_t)random() << 32) + random();
 	off = (off64_t)(lr % stb.st_size);
-	off &= (off64_t)(~(sysconf(_SC_PAGE_SIZE) - 1));
+	off = rounddown_64(off, sysconf(_SC_PAGE_SIZE));
 	len = (size_t)(random() % MIN(stb.st_size - off, FILELEN_MAX)) + 1;
 
 	flags = (random() % 2) ? MAP_SHARED : MAP_PRIVATE;
diff --git a/ltp/fsx.c b/ltp/fsx.c
index cd0bae55..16e75c40 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -203,7 +203,7 @@ static void *round_ptr_up(void *ptr, unsigned long align, unsigned long offset)
 {
 	unsigned long ret = (unsigned long)ptr;
 
-	ret = ((ret + align - 1) & ~(align - 1));
+	ret = roundup_64(ret, align);
 	ret += offset;
 	return (void *)ret;
 }
@@ -1948,12 +1948,12 @@ static void generate_dest_range(bool bdy_align,
 
 	TRIM_OFF_LEN(*src_offset, *size, file_size);
 	if (bdy_align) {
-		*src_offset -= *src_offset % readbdy;
+		*src_offset = rounddown_64(*src_offset, readbdy);
 		if (o_direct)
-			*size -= *size % readbdy;
+			*size = rounddown_64(*size, readbdy);
 	} else {
-		*src_offset = *src_offset & ~(block_size - 1);
-		*size = *size & ~(block_size - 1);
+		*src_offset = rounddown_64(*src_offset, block_size);
+		*size = rounddown_64(*size, block_size);
 	}
 
 	do {
@@ -1964,9 +1964,9 @@ static void generate_dest_range(bool bdy_align,
 		*dst_offset = random();
 		TRIM_OFF(*dst_offset, max_range_end);
 		if (bdy_align)
-			*dst_offset -= *dst_offset % writebdy;
+			*dst_offset = rounddown_64(*dst_offset, writebdy);
 		else
-			*dst_offset = *dst_offset & ~(block_size - 1);
+			*dst_offset = rounddown_64(*dst_offset, block_size);
 	} while (range_overlaps(*src_offset, *dst_offset, *size) ||
 		 *dst_offset + *size > max_range_end);
 }
@@ -2156,8 +2156,8 @@ test(void)
 		break;
 	case OP_COLLAPSE_RANGE:
 		TRIM_OFF_LEN(offset, size, file_size - 1);
-		offset = offset & ~(block_size - 1);
-		size = size & ~(block_size - 1);
+		offset = rounddown_64(offset, block_size);
+		size = rounddown_64(size, block_size);
 		if (size == 0) {
 			log4(OP_COLLAPSE_RANGE, offset, size, FL_SKIPPED);
 			goto out;
@@ -2167,8 +2167,8 @@ test(void)
 	case OP_INSERT_RANGE:
 		TRIM_OFF(offset, file_size);
 		TRIM_LEN(file_size, size, maxfilelen);
-		offset = offset & ~(block_size - 1);
-		size = size & ~(block_size - 1);
+		offset = rounddown_64(offset, block_size);
+		size = rounddown_64(size, block_size);
 		if (size == 0) {
 			log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED);
 			goto out;
diff --git a/src/global.h b/src/global.h
index e5e46234..b4407099 100644
--- a/src/global.h
+++ b/src/global.h
@@ -171,4 +171,17 @@
 #include <sys/mman.h>
 #endif
 
+static inline unsigned long long
+rounddown_64(unsigned long long x, unsigned int y)
+{
+	x /= y;
+	return x * y;
+}
+
+static inline unsigned long long
+roundup_64(unsigned long long x, unsigned int y)
+{
+	return rounddown_64(x + y - 1, y);
+}
+
 #endif /* GLOBAL_H */


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

* [PATCH 7/8] fsx: fix backwards parameters in complaint about overly long copy
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (5 preceding siblings ...)
  2021-05-12  2:02 ` [PATCH 6/8] fsx/fsstress: round blocksize properly Darrick J. Wong
@ 2021-05-12  2:02 ` Darrick J. Wong
  2021-05-12  2:02 ` [PATCH 8/8] xfs/178: fix mkfs success test Darrick J. Wong
  2021-05-16 15:58 ` [PATCHSET 0/8] fstests: miscellaneous fixes Eryu Guan
  8 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:02 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

If fsx encounters a situation where copy_file_range reports that it
copied more than it was asked to, we report this as a failure.
Unfortunately, the parameters to the print function are backwards,
leading to this bogus complaint about a short copy:

do_copy_range: asked 28672, copied 24576??

When we really asked to copy 24k but 28k was copied instead.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 ltp/fsx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/ltp/fsx.c b/ltp/fsx.c
index 16e75c40..12c2cc33 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -1662,7 +1662,7 @@ do_copy_range(unsigned offset, unsigned length, unsigned dest)
 			prt("copy range: 0x%x to 0x%x at 0x%x\n", offset,
 					offset + length, dest);
 			prt("do_copy_range: asked %u, copied %u??\n",
-					nr, olen);
+					olen, nr);
 			report_failure(161);
 		} else if (nr > 0)
 			olen -= nr;


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

* [PATCH 8/8] xfs/178: fix mkfs success test
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (6 preceding siblings ...)
  2021-05-12  2:02 ` [PATCH 7/8] fsx: fix backwards parameters in complaint about overly long copy Darrick J. Wong
@ 2021-05-12  2:02 ` Darrick J. Wong
  2021-05-16 15:54   ` Eryu Guan
  2021-05-16 15:58 ` [PATCHSET 0/8] fstests: miscellaneous fixes Eryu Guan
  8 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-12  2:02 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

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

Fix the obviously incorrect code here that wants to fail the test if
mkfs doesn't succeed.  The return value ("$?") is always the status of
the /last/ command in the pipe.  Change the checker to _notrun so that
we don't leave the scratch check files around.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/178 |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/tests/xfs/178 b/tests/xfs/178
index a24ef50c..bf72e640 100755
--- a/tests/xfs/178
+++ b/tests/xfs/178
@@ -57,8 +57,8 @@ _supported_fs xfs
 #             fix filesystem, new mkfs.xfs will be fine.
 
 _require_scratch
-_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
-        || _fail "mkfs failed!"
+_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
+test "${PIPESTATUS[0]}" -eq 0 || _notrun "mkfs failed!"
 
 # By executing the followint tmp file, will get on the mkfs options stored in
 # variables


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

* Re: [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device
  2021-05-12  2:01 ` [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device Darrick J. Wong
@ 2021-05-16 15:49   ` Eryu Guan
  2021-05-16 20:34     ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Eryu Guan @ 2021-05-16 15:49 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests

On Tue, May 11, 2021 at 07:01:51PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Refactor all the places where we try to force new file data allocations
> to a specific xfs backing device so that we don't end up open-coding the
> same xfs_io command lines over and over.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  common/populate   |    2 +-
>  common/xfs        |   25 +++++++++++++++++++++++++
>  tests/generic/223 |    3 ++-
>  tests/generic/449 |    2 +-
>  tests/xfs/004     |    2 +-

>  tests/xfs/088     |    1 +
>  tests/xfs/089     |    1 +
>  tests/xfs/091     |    1 +
>  tests/xfs/120     |    1 +
>  tests/xfs/130     |    1 +

I think above updates should be in a separate patch.

Thanks,
Eryu

>  tests/xfs/146     |    2 +-
>  tests/xfs/147     |    2 +-
>  tests/xfs/235     |    1 +
>  tests/xfs/272     |    2 +-
>  tests/xfs/318     |    2 +-
>  tests/xfs/431     |    4 ++--
>  tests/xfs/521     |    2 +-
>  tests/xfs/528     |    2 +-
>  tests/xfs/532     |    2 +-
>  tests/xfs/533     |    2 +-
>  tests/xfs/538     |    2 +-
>  21 files changed, 47 insertions(+), 15 deletions(-)
> 
> 
> diff --git a/common/populate b/common/populate
> index d484866a..e1704b10 100644
> --- a/common/populate
> +++ b/common/populate
> @@ -162,7 +162,7 @@ _scratch_xfs_populate() {
>  	# Clear the rtinherit flag on the root directory so that files are
>  	# always created on the data volume regardless of MKFS_OPTIONS.  We can
>  	# set the realtime flag when needed.
> -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +	_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  	blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
>  	dblksz="$($XFS_INFO_PROG "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
> diff --git a/common/xfs b/common/xfs
> index 5cd7b35c..49bd6c31 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -194,6 +194,31 @@ _xfs_get_file_block_size()
>  	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
>  }
>  
> +# Set or clear the realtime status of every supplied path.  The first argument
> +# is either 'data' or 'realtime'.  All other arguments should be paths to
> +# existing directories or empty regular files.
> +#
> +# For each directory, each file subsequently created will target the given
> +# device for file data allocations.  For each empty regular file, each
> +# subsequent file data allocation will be on the given device.
> +_scratch_xfs_force_bdev()
> +{
> +	local device="$1"
> +	shift
> +	local chattr_arg=""
> +
> +	case "$device" in
> +	"data")		chattr_arg="-t";;
> +	"realtime")	chattr_arg="+t";;
> +	*)
> +		echo "${device}: Don't know what device this is?"
> +		return 1
> +		;;
> +	esac
> +
> +	$XFS_IO_PROG -c "chattr $chattr_arg" "$@"
> +}
> +
>  _xfs_get_fsxattr()
>  {
>  	local field="$1"
> diff --git a/tests/generic/223 b/tests/generic/223
> index f6393293..0df84c2b 100755
> --- a/tests/generic/223
> +++ b/tests/generic/223
> @@ -46,7 +46,8 @@ for SUNIT_K in 8 16 32 64 128; do
>  	# This test checks for stripe alignments of space allocations on the
>  	# filesystem.  Make sure all files get created on the main device,
>  	# which for XFS means no rt files.
> -	test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +	test "$FSTYP" = "xfs" && \
> +		_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  	for SIZE_MULT in 1 2 8 64 256; do
>  		let SIZE=$SIZE_MULT*$SUNIT_BYTES
> diff --git a/tests/generic/449 b/tests/generic/449
> index 5fd15367..9035b705 100755
> --- a/tests/generic/449
> +++ b/tests/generic/449
> @@ -46,7 +46,7 @@ _scratch_mount || _fail "mount failed"
>  # This is a test of xattr behavior when we run out of disk space for xattrs,
>  # so make sure the pwrite goes to the data device and not the rt volume.
>  test "$FSTYP" = "xfs" && \
> -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +	_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  TFILE=$SCRATCH_MNT/testfile.$seq
>  
> diff --git a/tests/xfs/004 b/tests/xfs/004
> index 7633071c..b3a00fb6 100755
> --- a/tests/xfs/004
> +++ b/tests/xfs/004
> @@ -31,7 +31,7 @@ _populate_scratch()
>  	# This test looks at specific behaviors of the xfs_db freesp command,
>  	# which reports on the contents of the free space btrees for the data
>  	# device.  Don't let anything get created on the realtime volume.
> -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +	_scratch_xfs_force_bdev data $SCRATCH_MNT
>  	dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
>  	dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
>  	dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
> diff --git a/tests/xfs/088 b/tests/xfs/088
> index fe621d0a..62360ca8 100755
> --- a/tests/xfs/088
> +++ b/tests/xfs/088
> @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
>  echo "+ mount fs image"
>  _scratch_mount
>  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  mkdir -p "${TESTDIR}"
> diff --git a/tests/xfs/089 b/tests/xfs/089
> index 3339ff63..79167a57 100755
> --- a/tests/xfs/089
> +++ b/tests/xfs/089
> @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
>  echo "+ mount fs image"
>  _scratch_mount
>  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  mkdir -p "${TESTDIR}"
> diff --git a/tests/xfs/091 b/tests/xfs/091
> index 9304849d..db6bb0b2 100755
> --- a/tests/xfs/091
> +++ b/tests/xfs/091
> @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
>  echo "+ mount fs image"
>  _scratch_mount
>  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  mkdir -p "${TESTDIR}"
> diff --git a/tests/xfs/120 b/tests/xfs/120
> index 59ac0433..9fcce9ee 100755
> --- a/tests/xfs/120
> +++ b/tests/xfs/120
> @@ -47,6 +47,7 @@ echo "+ mount fs image"
>  _scratch_mount
>  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
>  nr="$((blksz * 2 / 16))"
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full
> diff --git a/tests/xfs/130 b/tests/xfs/130
> index 9fec009f..b4404c5d 100755
> --- a/tests/xfs/130
> +++ b/tests/xfs/130
> @@ -43,6 +43,7 @@ echo "+ mount fs image"
>  _scratch_mount
>  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
>  agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  _pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
> diff --git a/tests/xfs/146 b/tests/xfs/146
> index 8f85024d..a62b8429 100755
> --- a/tests/xfs/146
> +++ b/tests/xfs/146
> @@ -78,7 +78,7 @@ _scratch_mkfs -r size=$rtsize >> $seqres.full
>  _scratch_mount >> $seqres.full
>  
>  # Make sure the root directory has rtinherit set so our test file will too
> -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev realtime $SCRATCH_MNT
>  
>  # Allocate some stuff at the start, to force the first falloc of the ouch file
>  # to happen somewhere in the middle of the rt volume
> diff --git a/tests/xfs/147 b/tests/xfs/147
> index da962f96..0071f5c3 100755
> --- a/tests/xfs/147
> +++ b/tests/xfs/147
> @@ -50,7 +50,7 @@ rextblks=$((rextsize / blksz))
>  echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
>  
>  # Make sure the root directory has rtinherit set so our test file will too
> -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev realtime $SCRATCH_MNT
>  
>  sz=$((rextsize * 100))
>  range="$((blksz * 3)) $blksz"
> diff --git a/tests/xfs/235 b/tests/xfs/235
> index 1ed19424..553a3bc8 100755
> --- a/tests/xfs/235
> +++ b/tests/xfs/235
> @@ -41,6 +41,7 @@ echo "+ mount fs image"
>  _scratch_mount
>  blksz=$(stat -f -c '%s' ${SCRATCH_MNT})
>  agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "+ make some files"
>  _pwrite_byte 0x62 0 $((blksz * 64)) ${SCRATCH_MNT}/file0 >> $seqres.full
> diff --git a/tests/xfs/272 b/tests/xfs/272
> index 6c0fede5..2848848d 100755
> --- a/tests/xfs/272
> +++ b/tests/xfs/272
> @@ -38,7 +38,7 @@ _scratch_mkfs > "$seqres.full" 2>&1
>  _scratch_mount
>  
>  # Make sure everything is on the data device
> -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
>  sync
> diff --git a/tests/xfs/318 b/tests/xfs/318
> index 07375b1f..823f3e6c 100755
> --- a/tests/xfs/318
> +++ b/tests/xfs/318
> @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
>  
>  # This test depends on specific behaviors of the data device, so create all
>  # files on it.
> -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "Create files"
>  touch $SCRATCH_MNT/file1
> diff --git a/tests/xfs/431 b/tests/xfs/431
> index e67906dc..dd634ed6 100755
> --- a/tests/xfs/431
> +++ b/tests/xfs/431
> @@ -47,7 +47,7 @@ _scratch_mount
>  
>  # Set realtime inherit flag on scratch mount, suppress output
>  # as this may simply error out on future kernels
> -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
> +_scratch_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
>  
>  # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
>  # an attribute. And erroring out here is fine, this would be desired behavior
> @@ -60,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
>  	# Remove the testfile and rt inherit flag after we are done or
>  	# xfs_repair will fail.
>  	rm -f $SCRATCH_MNT/testfile
> -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1
> +	_scratch_xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
>  fi
>  
>  # success, all done
> diff --git a/tests/xfs/521 b/tests/xfs/521
> index b8026d45..64155662 100755
> --- a/tests/xfs/521
> +++ b/tests/xfs/521
> @@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
>  mkdir $testdir
>  
>  echo "Check rt volume stats"
> -$XFS_IO_PROG -c 'chattr +t' $testdir
> +_scratch_xfs_force_bdev realtime $testdir
>  $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
>  before=$(stat -f -c '%b' $testdir)
>  
> diff --git a/tests/xfs/528 b/tests/xfs/528
> index 7f98c5b8..4db4f513 100755
> --- a/tests/xfs/528
> +++ b/tests/xfs/528
> @@ -77,7 +77,7 @@ test_ops() {
>  		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
>  
>  	# Force all files to be realtime files
> -	$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> +	_scratch_xfs_force_bdev realtime $SCRATCH_MNT
>  
>  	log "Test regular write, rextsize=$rextsize"
>  	mk_file $SCRATCH_MNT/write $rextsize
> diff --git a/tests/xfs/532 b/tests/xfs/532
> index 560af586..1749d6ac 100755
> --- a/tests/xfs/532
> +++ b/tests/xfs/532
> @@ -47,7 +47,7 @@ _scratch_mount >> $seqres.full
>  
>  # Disable realtime inherit flag (if any) on root directory so that space on data
>  # device gets fragmented rather than realtime device.
> -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  bsize=$(_get_block_size $SCRATCH_MNT)
>  
> diff --git a/tests/xfs/533 b/tests/xfs/533
> index dd4cb4c4..b73097e1 100755
> --- a/tests/xfs/533
> +++ b/tests/xfs/533
> @@ -58,7 +58,7 @@ _scratch_mount >> $seqres.full
>  
>  # Disable realtime inherit flag (if any) on root directory so that space on data
>  # device gets fragmented rather than realtime device.
> -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  echo "Consume free space"
>  fillerdir=$SCRATCH_MNT/fillerdir
> diff --git a/tests/xfs/538 b/tests/xfs/538
> index 97273b88..deb43d7c 100755
> --- a/tests/xfs/538
> +++ b/tests/xfs/538
> @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
>  
>  # Disable realtime inherit flag (if any) on root directory so that space on data
>  # device gets fragmented rather than realtime device.
> -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> +_scratch_xfs_force_bdev data $SCRATCH_MNT
>  
>  bsize=$(_get_file_block_size $SCRATCH_MNT)
>  
> 

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

* Re: [PATCH 8/8] xfs/178: fix mkfs success test
  2021-05-12  2:02 ` [PATCH 8/8] xfs/178: fix mkfs success test Darrick J. Wong
@ 2021-05-16 15:54   ` Eryu Guan
  2021-05-19 23:20     ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Eryu Guan @ 2021-05-16 15:54 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests

On Tue, May 11, 2021 at 07:02:24PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Fix the obviously incorrect code here that wants to fail the test if
> mkfs doesn't succeed.  The return value ("$?") is always the status of
> the /last/ command in the pipe.  Change the checker to _notrun so that
> we don't leave the scratch check files around.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  tests/xfs/178 |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/tests/xfs/178 b/tests/xfs/178
> index a24ef50c..bf72e640 100755
> --- a/tests/xfs/178
> +++ b/tests/xfs/178
> @@ -57,8 +57,8 @@ _supported_fs xfs
>  #             fix filesystem, new mkfs.xfs will be fine.
>  
>  _require_scratch
> -_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
> -        || _fail "mkfs failed!"
> +_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
> +test "${PIPESTATUS[0]}" -eq 0 || _notrun "mkfs failed!"

I still don't understand why changing this to _notrun, shouldn't creating a
default filesystem should always pass? and fail the test if mkfs failed?

Thanks,
Eryu

>  
>  # By executing the followint tmp file, will get on the mkfs options stored in
>  # variables
> 

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

* Re: [PATCHSET 0/8] fstests: miscellaneous fixes
  2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
                   ` (7 preceding siblings ...)
  2021-05-12  2:02 ` [PATCH 8/8] xfs/178: fix mkfs success test Darrick J. Wong
@ 2021-05-16 15:58 ` Eryu Guan
  8 siblings, 0 replies; 16+ messages in thread
From: Eryu Guan @ 2021-05-16 15:58 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests

On Tue, May 11, 2021 at 07:01:39PM -0700, Darrick J. Wong wrote:
> Hi all,
> 
> Various small fixes to the fstests suite, and some refactoring of common
> idioms needed for testing realtime devices.

I applied patch 1 3 5 and 7. I have some comments in patch 2 and 8, and
need more eyes to look at patch 4 and 6.

Thanks,
Eryu

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

* Re: [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device
  2021-05-16 15:49   ` Eryu Guan
@ 2021-05-16 20:34     ` Darrick J. Wong
  2021-05-19  3:03       ` Eryu Guan
  0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-16 20:34 UTC (permalink / raw)
  To: Eryu Guan; +Cc: guaneryu, linux-xfs, fstests

On Sun, May 16, 2021 at 11:49:55PM +0800, Eryu Guan wrote:
> On Tue, May 11, 2021 at 07:01:51PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Refactor all the places where we try to force new file data allocations
> > to a specific xfs backing device so that we don't end up open-coding the
> > same xfs_io command lines over and over.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  common/populate   |    2 +-
> >  common/xfs        |   25 +++++++++++++++++++++++++
> >  tests/generic/223 |    3 ++-
> >  tests/generic/449 |    2 +-
> >  tests/xfs/004     |    2 +-
> 
> >  tests/xfs/088     |    1 +
> >  tests/xfs/089     |    1 +
> >  tests/xfs/091     |    1 +
> >  tests/xfs/120     |    1 +
> >  tests/xfs/130     |    1 +
> 
> I think above updates should be in a separate patch.

Why?

--D

> Thanks,
> Eryu
> 
> >  tests/xfs/146     |    2 +-
> >  tests/xfs/147     |    2 +-
> >  tests/xfs/235     |    1 +
> >  tests/xfs/272     |    2 +-
> >  tests/xfs/318     |    2 +-
> >  tests/xfs/431     |    4 ++--
> >  tests/xfs/521     |    2 +-
> >  tests/xfs/528     |    2 +-
> >  tests/xfs/532     |    2 +-
> >  tests/xfs/533     |    2 +-
> >  tests/xfs/538     |    2 +-
> >  21 files changed, 47 insertions(+), 15 deletions(-)
> > 
> > 
> > diff --git a/common/populate b/common/populate
> > index d484866a..e1704b10 100644
> > --- a/common/populate
> > +++ b/common/populate
> > @@ -162,7 +162,7 @@ _scratch_xfs_populate() {
> >  	# Clear the rtinherit flag on the root directory so that files are
> >  	# always created on the data volume regardless of MKFS_OPTIONS.  We can
> >  	# set the realtime flag when needed.
> > -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +	_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  	blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> >  	dblksz="$($XFS_INFO_PROG "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
> > diff --git a/common/xfs b/common/xfs
> > index 5cd7b35c..49bd6c31 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -194,6 +194,31 @@ _xfs_get_file_block_size()
> >  	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
> >  }
> >  
> > +# Set or clear the realtime status of every supplied path.  The first argument
> > +# is either 'data' or 'realtime'.  All other arguments should be paths to
> > +# existing directories or empty regular files.
> > +#
> > +# For each directory, each file subsequently created will target the given
> > +# device for file data allocations.  For each empty regular file, each
> > +# subsequent file data allocation will be on the given device.
> > +_scratch_xfs_force_bdev()
> > +{
> > +	local device="$1"
> > +	shift
> > +	local chattr_arg=""
> > +
> > +	case "$device" in
> > +	"data")		chattr_arg="-t";;
> > +	"realtime")	chattr_arg="+t";;
> > +	*)
> > +		echo "${device}: Don't know what device this is?"
> > +		return 1
> > +		;;
> > +	esac
> > +
> > +	$XFS_IO_PROG -c "chattr $chattr_arg" "$@"
> > +}
> > +
> >  _xfs_get_fsxattr()
> >  {
> >  	local field="$1"
> > diff --git a/tests/generic/223 b/tests/generic/223
> > index f6393293..0df84c2b 100755
> > --- a/tests/generic/223
> > +++ b/tests/generic/223
> > @@ -46,7 +46,8 @@ for SUNIT_K in 8 16 32 64 128; do
> >  	# This test checks for stripe alignments of space allocations on the
> >  	# filesystem.  Make sure all files get created on the main device,
> >  	# which for XFS means no rt files.
> > -	test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +	test "$FSTYP" = "xfs" && \
> > +		_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  	for SIZE_MULT in 1 2 8 64 256; do
> >  		let SIZE=$SIZE_MULT*$SUNIT_BYTES
> > diff --git a/tests/generic/449 b/tests/generic/449
> > index 5fd15367..9035b705 100755
> > --- a/tests/generic/449
> > +++ b/tests/generic/449
> > @@ -46,7 +46,7 @@ _scratch_mount || _fail "mount failed"
> >  # This is a test of xattr behavior when we run out of disk space for xattrs,
> >  # so make sure the pwrite goes to the data device and not the rt volume.
> >  test "$FSTYP" = "xfs" && \
> > -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +	_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  TFILE=$SCRATCH_MNT/testfile.$seq
> >  
> > diff --git a/tests/xfs/004 b/tests/xfs/004
> > index 7633071c..b3a00fb6 100755
> > --- a/tests/xfs/004
> > +++ b/tests/xfs/004
> > @@ -31,7 +31,7 @@ _populate_scratch()
> >  	# This test looks at specific behaviors of the xfs_db freesp command,
> >  	# which reports on the contents of the free space btrees for the data
> >  	# device.  Don't let anything get created on the realtime volume.
> > -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +	_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  	dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
> >  	dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
> >  	dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
> > diff --git a/tests/xfs/088 b/tests/xfs/088
> > index fe621d0a..62360ca8 100755
> > --- a/tests/xfs/088
> > +++ b/tests/xfs/088
> > @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
> >  echo "+ mount fs image"
> >  _scratch_mount
> >  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  mkdir -p "${TESTDIR}"
> > diff --git a/tests/xfs/089 b/tests/xfs/089
> > index 3339ff63..79167a57 100755
> > --- a/tests/xfs/089
> > +++ b/tests/xfs/089
> > @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
> >  echo "+ mount fs image"
> >  _scratch_mount
> >  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  mkdir -p "${TESTDIR}"
> > diff --git a/tests/xfs/091 b/tests/xfs/091
> > index 9304849d..db6bb0b2 100755
> > --- a/tests/xfs/091
> > +++ b/tests/xfs/091
> > @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null
> >  echo "+ mount fs image"
> >  _scratch_mount
> >  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  mkdir -p "${TESTDIR}"
> > diff --git a/tests/xfs/120 b/tests/xfs/120
> > index 59ac0433..9fcce9ee 100755
> > --- a/tests/xfs/120
> > +++ b/tests/xfs/120
> > @@ -47,6 +47,7 @@ echo "+ mount fs image"
> >  _scratch_mount
> >  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> >  nr="$((blksz * 2 / 16))"
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full
> > diff --git a/tests/xfs/130 b/tests/xfs/130
> > index 9fec009f..b4404c5d 100755
> > --- a/tests/xfs/130
> > +++ b/tests/xfs/130
> > @@ -43,6 +43,7 @@ echo "+ mount fs image"
> >  _scratch_mount
> >  blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
> >  agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  _pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
> > diff --git a/tests/xfs/146 b/tests/xfs/146
> > index 8f85024d..a62b8429 100755
> > --- a/tests/xfs/146
> > +++ b/tests/xfs/146
> > @@ -78,7 +78,7 @@ _scratch_mkfs -r size=$rtsize >> $seqres.full
> >  _scratch_mount >> $seqres.full
> >  
> >  # Make sure the root directory has rtinherit set so our test file will too
> > -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev realtime $SCRATCH_MNT
> >  
> >  # Allocate some stuff at the start, to force the first falloc of the ouch file
> >  # to happen somewhere in the middle of the rt volume
> > diff --git a/tests/xfs/147 b/tests/xfs/147
> > index da962f96..0071f5c3 100755
> > --- a/tests/xfs/147
> > +++ b/tests/xfs/147
> > @@ -50,7 +50,7 @@ rextblks=$((rextsize / blksz))
> >  echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
> >  
> >  # Make sure the root directory has rtinherit set so our test file will too
> > -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev realtime $SCRATCH_MNT
> >  
> >  sz=$((rextsize * 100))
> >  range="$((blksz * 3)) $blksz"
> > diff --git a/tests/xfs/235 b/tests/xfs/235
> > index 1ed19424..553a3bc8 100755
> > --- a/tests/xfs/235
> > +++ b/tests/xfs/235
> > @@ -41,6 +41,7 @@ echo "+ mount fs image"
> >  _scratch_mount
> >  blksz=$(stat -f -c '%s' ${SCRATCH_MNT})
> >  agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "+ make some files"
> >  _pwrite_byte 0x62 0 $((blksz * 64)) ${SCRATCH_MNT}/file0 >> $seqres.full
> > diff --git a/tests/xfs/272 b/tests/xfs/272
> > index 6c0fede5..2848848d 100755
> > --- a/tests/xfs/272
> > +++ b/tests/xfs/272
> > @@ -38,7 +38,7 @@ _scratch_mkfs > "$seqres.full" 2>&1
> >  _scratch_mount
> >  
> >  # Make sure everything is on the data device
> > -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
> >  sync
> > diff --git a/tests/xfs/318 b/tests/xfs/318
> > index 07375b1f..823f3e6c 100755
> > --- a/tests/xfs/318
> > +++ b/tests/xfs/318
> > @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
> >  
> >  # This test depends on specific behaviors of the data device, so create all
> >  # files on it.
> > -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "Create files"
> >  touch $SCRATCH_MNT/file1
> > diff --git a/tests/xfs/431 b/tests/xfs/431
> > index e67906dc..dd634ed6 100755
> > --- a/tests/xfs/431
> > +++ b/tests/xfs/431
> > @@ -47,7 +47,7 @@ _scratch_mount
> >  
> >  # Set realtime inherit flag on scratch mount, suppress output
> >  # as this may simply error out on future kernels
> > -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null
> > +_scratch_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null
> >  
> >  # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set
> >  # an attribute. And erroring out here is fine, this would be desired behavior
> > @@ -60,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then
> >  	# Remove the testfile and rt inherit flag after we are done or
> >  	# xfs_repair will fail.
> >  	rm -f $SCRATCH_MNT/testfile
> > -	$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1
> > +	_scratch_xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1
> >  fi
> >  
> >  # success, all done
> > diff --git a/tests/xfs/521 b/tests/xfs/521
> > index b8026d45..64155662 100755
> > --- a/tests/xfs/521
> > +++ b/tests/xfs/521
> > @@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
> >  mkdir $testdir
> >  
> >  echo "Check rt volume stats"
> > -$XFS_IO_PROG -c 'chattr +t' $testdir
> > +_scratch_xfs_force_bdev realtime $testdir
> >  $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
> >  before=$(stat -f -c '%b' $testdir)
> >  
> > diff --git a/tests/xfs/528 b/tests/xfs/528
> > index 7f98c5b8..4db4f513 100755
> > --- a/tests/xfs/528
> > +++ b/tests/xfs/528
> > @@ -77,7 +77,7 @@ test_ops() {
> >  		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
> >  
> >  	# Force all files to be realtime files
> > -	$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
> > +	_scratch_xfs_force_bdev realtime $SCRATCH_MNT
> >  
> >  	log "Test regular write, rextsize=$rextsize"
> >  	mk_file $SCRATCH_MNT/write $rextsize
> > diff --git a/tests/xfs/532 b/tests/xfs/532
> > index 560af586..1749d6ac 100755
> > --- a/tests/xfs/532
> > +++ b/tests/xfs/532
> > @@ -47,7 +47,7 @@ _scratch_mount >> $seqres.full
> >  
> >  # Disable realtime inherit flag (if any) on root directory so that space on data
> >  # device gets fragmented rather than realtime device.
> > -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  bsize=$(_get_block_size $SCRATCH_MNT)
> >  
> > diff --git a/tests/xfs/533 b/tests/xfs/533
> > index dd4cb4c4..b73097e1 100755
> > --- a/tests/xfs/533
> > +++ b/tests/xfs/533
> > @@ -58,7 +58,7 @@ _scratch_mount >> $seqres.full
> >  
> >  # Disable realtime inherit flag (if any) on root directory so that space on data
> >  # device gets fragmented rather than realtime device.
> > -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  echo "Consume free space"
> >  fillerdir=$SCRATCH_MNT/fillerdir
> > diff --git a/tests/xfs/538 b/tests/xfs/538
> > index 97273b88..deb43d7c 100755
> > --- a/tests/xfs/538
> > +++ b/tests/xfs/538
> > @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full
> >  
> >  # Disable realtime inherit flag (if any) on root directory so that space on data
> >  # device gets fragmented rather than realtime device.
> > -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
> > +_scratch_xfs_force_bdev data $SCRATCH_MNT
> >  
> >  bsize=$(_get_file_block_size $SCRATCH_MNT)
> >  
> > 

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

* Re: [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device
  2021-05-16 20:34     ` Darrick J. Wong
@ 2021-05-19  3:03       ` Eryu Guan
  2021-05-19 20:46         ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Eryu Guan @ 2021-05-19  3:03 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eryu Guan, guaneryu, linux-xfs, fstests

On Sun, May 16, 2021 at 01:34:37PM -0700, Darrick J. Wong wrote:
> On Sun, May 16, 2021 at 11:49:55PM +0800, Eryu Guan wrote:
> > On Tue, May 11, 2021 at 07:01:51PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <djwong@kernel.org>
> > > 
> > > Refactor all the places where we try to force new file data allocations
> > > to a specific xfs backing device so that we don't end up open-coding the
> > > same xfs_io command lines over and over.
> > > 
> > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > ---
> > >  common/populate   |    2 +-
> > >  common/xfs        |   25 +++++++++++++++++++++++++
> > >  tests/generic/223 |    3 ++-
> > >  tests/generic/449 |    2 +-
> > >  tests/xfs/004     |    2 +-
> > 
> > >  tests/xfs/088     |    1 +
> > >  tests/xfs/089     |    1 +
> > >  tests/xfs/091     |    1 +
> > >  tests/xfs/120     |    1 +
> > >  tests/xfs/130     |    1 +
> > 
> > I think above updates should be in a separate patch.
> 
> Why?

This patch is refactoring open-coded command into a helper, which should
not change the logic. But above changes are adding new users of this
helper and change test behavior. So I think they should be in a separate
patch for review.

Thanks,
Eryu

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

* Re: [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device
  2021-05-19  3:03       ` Eryu Guan
@ 2021-05-19 20:46         ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-19 20:46 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Eryu Guan, guaneryu, linux-xfs, fstests

On Wed, May 19, 2021 at 11:03:24AM +0800, Eryu Guan wrote:
> On Sun, May 16, 2021 at 01:34:37PM -0700, Darrick J. Wong wrote:
> > On Sun, May 16, 2021 at 11:49:55PM +0800, Eryu Guan wrote:
> > > On Tue, May 11, 2021 at 07:01:51PM -0700, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong <djwong@kernel.org>
> > > > 
> > > > Refactor all the places where we try to force new file data allocations
> > > > to a specific xfs backing device so that we don't end up open-coding the
> > > > same xfs_io command lines over and over.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > > ---
> > > >  common/populate   |    2 +-
> > > >  common/xfs        |   25 +++++++++++++++++++++++++
> > > >  tests/generic/223 |    3 ++-
> > > >  tests/generic/449 |    2 +-
> > > >  tests/xfs/004     |    2 +-
> > > 
> > > >  tests/xfs/088     |    1 +
> > > >  tests/xfs/089     |    1 +
> > > >  tests/xfs/091     |    1 +
> > > >  tests/xfs/120     |    1 +
> > > >  tests/xfs/130     |    1 +
> > > 
> > > I think above updates should be in a separate patch.
> > 
> > Why?
> 
> This patch is refactoring open-coded command into a helper, which should
> not change the logic. But above changes are adding new users of this
> helper and change test behavior. So I think they should be in a separate
> patch for review.

Oh, ok.  Will do then.

--D

> Thanks,
> Eryu

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

* Re: [PATCH 8/8] xfs/178: fix mkfs success test
  2021-05-16 15:54   ` Eryu Guan
@ 2021-05-19 23:20     ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-05-19 23:20 UTC (permalink / raw)
  To: Eryu Guan; +Cc: guaneryu, linux-xfs, fstests

On Sun, May 16, 2021 at 11:54:30PM +0800, Eryu Guan wrote:
> On Tue, May 11, 2021 at 07:02:24PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Fix the obviously incorrect code here that wants to fail the test if
> > mkfs doesn't succeed.  The return value ("$?") is always the status of
> > the /last/ command in the pipe.  Change the checker to _notrun so that
> > we don't leave the scratch check files around.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  tests/xfs/178 |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/tests/xfs/178 b/tests/xfs/178
> > index a24ef50c..bf72e640 100755
> > --- a/tests/xfs/178
> > +++ b/tests/xfs/178
> > @@ -57,8 +57,8 @@ _supported_fs xfs
> >  #             fix filesystem, new mkfs.xfs will be fine.
> >  
> >  _require_scratch
> > -_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
> > -        || _fail "mkfs failed!"
> > +_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
> > +test "${PIPESTATUS[0]}" -eq 0 || _notrun "mkfs failed!"
> 
> I still don't understand why changing this to _notrun, shouldn't creating a
> default filesystem should always pass?

It will, unless you've injected a malicious mkfs.xfs to make sure
constructions like these actually work.

> and fail the test if mkfs failed?

Yeah, you're right, it /should/ fail.  I'll leave it alone then.

--D

> 
> Thanks,
> Eryu
> 
> >  
> >  # By executing the followint tmp file, will get on the mkfs options stored in
> >  # variables
> > 

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

end of thread, other threads:[~2021-05-19 23:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12  2:01 [PATCHSET 0/8] fstests: miscellaneous fixes Darrick J. Wong
2021-05-12  2:01 ` [PATCH 1/8] xfs/122: add entries for structures added to 5.13 Darrick J. Wong
2021-05-12  2:01 ` [PATCH 2/8] common/xfs: refactor commands to select a particular xfs backing device Darrick J. Wong
2021-05-16 15:49   ` Eryu Guan
2021-05-16 20:34     ` Darrick J. Wong
2021-05-19  3:03       ` Eryu Guan
2021-05-19 20:46         ` Darrick J. Wong
2021-05-12  2:01 ` [PATCH 3/8] xfs: fix old fuzz test invocations of xfs_repair Darrick J. Wong
2021-05-12  2:02 ` [PATCH 4/8] xfs/117: fix fragility in this fuzz test Darrick J. Wong
2021-05-12  2:02 ` [PATCH 5/8] common: always pass -f to $DUMP_COMPRESSOR Darrick J. Wong
2021-05-12  2:02 ` [PATCH 6/8] fsx/fsstress: round blocksize properly Darrick J. Wong
2021-05-12  2:02 ` [PATCH 7/8] fsx: fix backwards parameters in complaint about overly long copy Darrick J. Wong
2021-05-12  2:02 ` [PATCH 8/8] xfs/178: fix mkfs success test Darrick J. Wong
2021-05-16 15:54   ` Eryu Guan
2021-05-19 23:20     ` Darrick J. Wong
2021-05-16 15:58 ` [PATCHSET 0/8] fstests: miscellaneous fixes Eryu Guan

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.