Skip to contentSkip to conversation

fstests: tons of random fixes

PATCH In review Darrick J. Wong 5 participants 87 messages Sep 15, 2020 – Sep 19, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover fstests: tons of random fixes

Hi all,

So now that I have a cloud account, I suddenly have much more resources to find out if things like external log devices and realtime volumes actually work. This means that I've found a couple dozen minor issues all over fstests; most of the front patches in this series try to address them.

At the end, there is also a new test to try unloading and reloading the filesystem module between tests, to detect problems with resource allocations not being freed.

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

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=random-stuff

---
 README            |    3 +++
 check             |    9 +++++++++
 common/rc         |   20 ++++++++++++++++----
 common/xfs        |   28 +++++++++++++++++++++++++++-
 tests/generic/204 |    9 +++++++--
 tests/generic/600 |    4 +++-
 tests/generic/601 |    4 +++-
 tests/generic/607 |    5 +++++
 tests/overlay/020 |    6 ++++++
 tests/overlay/069 |    2 +-
 tests/overlay/071 |    2 +-
 tests/xfs/003     |   14 +++++++-------
 tests/xfs/016     |    4 ++--
 tests/xfs/019     |    5 +++++
 tests/xfs/031     |    5 +++++
 tests/xfs/032     |    4 +---
 tests/xfs/045     |    2 +-
 tests/xfs/070     |    4 +++-
 tests/xfs/073     |    5 +----
 tests/xfs/077     |    3 +--
 tests/xfs/098     |    8 +++++++-
 tests/xfs/111     |    2 +-
 tests/xfs/135     |    2 +-
 tests/xfs/137     |    4 ++--
 tests/xfs/141     |    4 +++-
 tests/xfs/171     |    1 +
 tests/xfs/172     |    1 +
 tests/xfs/173     |    1 +
 tests/xfs/174     |    1 +
 tests/xfs/194     |    3 +++
 tests/xfs/205     |    1 +
 tests/xfs/284     |    3 +--
 tests/xfs/291     |    6 ++++--
 tests/xfs/306     |    1 +
 tests/xfs/318     |    1 +
 tests/xfs/331     |    1 +
 tests/xfs/424     |    8 +++++++-
 tests/xfs/444     |    1 +
 tests/xfs/449     |    4 +++-
 tests/xfs/503     |    1 +
 40 files changed, 149 insertions(+), 43 deletions(-)
#1 lore raw

PATCH 1/24 xfs/331: don't run this test if fallocate isn't supported

From: Darrick J. Wong <[email protected]>

This test requires fallocate, so make sure that actually works before running it.

---
 tests/xfs/331 |    1 +
 1 file changed, 1 insertion(+)
tests/xfs/331 +1 -0
index b26ea155..501dd1f8 100755
@@ -32,6 +32,7 @@ _supported_fs xfs
 _require_scratch
 _require_xfs_scratch_rmapbt
 _require_scratch_reflink
+_require_xfs_io_command "falloc"
 _require_test_program "punch-alternating"
 
 rm -f "$seqres.full"
Reviewed-by on v1 1/24
#2 lore raw

Re: [PATCH 01/24] xfs/331: don't run this test if fallocate isn't supported

Quoted 16 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test requires fallocate, so make sure that actually works before running it.

---
 tests/xfs/331 |    1 +
 1 file changed, 1 insertion(+)
tests/xfs/331 +0 -0
index b26ea155..501dd1f8 100755

tests/xfs/331 _supported_fs xfs · line 35

Quoted 4 lines
tests/xfs/331 +1 -0
@@ -32,6 +32,7 @@ _supported_fs xfs
 _require_scratch
 _require_xfs_scratch_rmapbt
 _require_scratch_reflink
+_require_xfs_io_command "falloc"

Good to me.

Quoted 4 lines
tests/xfs/331 +0 -0
 _require_test_program "punch-alternating"
 
 rm -f "$seqres.full"
#4 lore raw

PATCH 2/24 generic/60[01]: fix test failure when setting new grace limit

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The setquota command can extend a quota grace period by a certain number of seconds. The extension is provided as a number of seconds relative to right now. However, if the system clock increments the seconds count after this test assigns $now but before setquota gets called, the test will fail because $get and $set will be off by that 1 second. Allow for that.

---
 tests/generic/600 |    4 +++-
 tests/generic/601 |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/generic/600 +3 -1
index 7ea0d6c2..42e4ee55 100755
@@ -60,7 +60,9 @@ let set=now+100
 setquota -T -u $qa_user 0 100 $SCRATCH_MNT 2>&1 | grep -v "^setquota"
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi
 
tests/generic/601 +3 -1
index 1baa6a90..b412ee8a 100755
@@ -71,7 +71,9 @@ $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
 # raw ("since epoch") grace expiry
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi
 
Reviewed-by on v1 2/24
#5 lore raw

Re: [PATCH 02/24] generic/60[01]: fix test failure when setting new grace limit

Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The setquota command can extend a quota grace period by a certain number of seconds. The extension is provided as a number of seconds relative to right now. However, if the system clock increments the seconds count after this test assigns $now but before setquota gets called, the test will fail because $get and $set will be off by that 1 second. Allow for that.

---

Good to me,

Quoted 36 lines
 tests/generic/600 |    4 +++-
 tests/generic/601 |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/generic/600 +3 -1
index 7ea0d6c2..42e4ee55 100755
@@ -60,7 +60,9 @@ let set=now+100
 setquota -T -u $qa_user 0 100 $SCRATCH_MNT 2>&1 | grep -v "^setquota"
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi
 
tests/generic/601 +3 -1
index 1baa6a90..b412ee8a 100755
@@ -71,7 +71,9 @@ $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
 # raw ("since epoch") grace expiry
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi
 
Reviewed-by on v1 2/24
#6 lore raw

Re: [PATCH 02/24] generic/60[01]: fix test failure when setting new grace limit

In reply to Darrick J. Wong
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The setquota command can extend a quota grace period by a certain number of seconds. The extension is provided as a number of seconds relative to right now. However, if the system clock increments the seconds count after this test assigns $now but before setquota gets called, the test will fail because $get and $set will be off by that 1 second. Allow for that.

Looks good,

#7 lore raw

PATCH 3/24 generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---
 common/rc         |   10 ++++++++--
 tests/generic/607 |    5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
 	local testfile=$TEST_DIR/$$.xfs_io
 	local testio
 	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
 	"chattr")
 		if [ -z "$param" ]; then
 			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
 	if [ $exp_s_dax -eq 0 ]; then
 		(( attributes & 0x2000 )) && echo "$target has unexpected S_DAX flag"
 	else
-		(( attributes & 0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag"
 	fi
 }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
 	if [ $exp_xflag -eq 0 ]; then
 		_test_inode_flag dax $target && echo "$target has unexpected FS_XFLAG_DAX flag"
 	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
 	fi
 }
 
tests/generic/607 +5 -0
index b15085ea..14d2c05f 100755
@@ -38,6 +38,11 @@ _require_scratch
 _require_dax_iflag
 _require_xfs_io_command "lsattr" "-v"
 
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device" && \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."
+
 # If a/ is +x, check that a's new children
 # inherit +x from a/.
 test_xflag_inheritance1()
Reviewed-by on v1 3/24
#8 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---

Good to me,

Quoted 57 lines
 common/rc         |   10 ++++++++--
 tests/generic/607 |    5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
 	local testfile=$TEST_DIR/$$.xfs_io
 	local testio
 	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
 	"chattr")
 		if [ -z "$param" ]; then
 			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
 	if [ $exp_s_dax -eq 0 ]; then
 		(( attributes & 0x2000 )) && echo "$target has unexpected S_DAX flag"
 	else
-		(( attributes & 0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag"
 	fi
 }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
 	if [ $exp_xflag -eq 0 ]; then
 		_test_inode_flag dax $target && echo "$target has unexpected FS_XFLAG_DAX flag"
 	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
 	fi
 }
 
tests/generic/607 +5 -0
index b15085ea..14d2c05f 100755
@@ -38,6 +38,11 @@ _require_scratch
 _require_dax_iflag
 _require_xfs_io_command "lsattr" "-v"
 
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device" && \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."
+
 # If a/ is +x, check that a's new children
 # inherit +x from a/.
 test_xflag_inheritance1()
#9 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

In reply to Darrick J. Wong
Quoted 54 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---
  common/rc         |   10 ++++++++--
  tests/generic/607 |    5 +++++
  2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
  	local testfile=$TEST_DIR/$$.xfs_io
  	local testio
  	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
  	"chattr")
  		if [ -z "$param" ]; then
  			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
  	if [ $exp_s_dax -eq 0 ]; then
  		(( attributes&  0x2000 ))&&  echo "$target has unexpected S_DAX flag"
  	else
-		(( attributes&  0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes&  0x2000 )) || echo "$target doesn't have expected S_DAX flag"
  	fi
  }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
  	if [ $exp_xflag -eq 0 ]; then
  		_test_inode_flag dax $target&&  echo "$target has unexpected FS_XFLAG_DAX flag"
  	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
  	fi
  }
 
tests/generic/607 +0 -0
index b15085ea..14d2c05f 100755

tests/generic/607 _require_scratch · line 44

Quoted 7 lines
tests/generic/607 +4 -0
@@ -38,6 +38,11 @@ _require_scratch
  _require_dax_iflag
  _require_xfs_io_command "lsattr" "-v"
 
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device"&&  \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."

Hi Darrick,

Could you tell me which kernel version gets the issue? :-)

Best Regards,
Xiao Yang

Quoted 9 lines
tests/generic/607 +1 -0
+
  # If a/ is +x, check that a's new children
  # inherit +x from a/.
  test_xflag_inheritance1()

.

#10 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 58 lines · Xiao Yang
Quoted 57 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---
  common/rc         |   10 ++++++++--
  tests/generic/607 |    5 +++++
  2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
  	local testfile=$TEST_DIR/$$.xfs_io
  	local testio
  	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
  	"chattr")
  		if [ -z "$param" ]; then
  			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
  	if [ $exp_s_dax -eq 0 ]; then
  		(( attributes&  0x2000 ))&&  echo "$target has unexpected S_DAX flag"
  	else
-		(( attributes&  0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes&  0x2000 )) || echo "$target doesn't have expected S_DAX flag"
  	fi
  }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
  	if [ $exp_xflag -eq 0 ]; then
  		_test_inode_flag dax $target&&  echo "$target has unexpected FS_XFLAG_DAX flag"
  	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
  	fi
  }
 
tests/generic/607 +0 -0
index b15085ea..14d2c05f 100755
@@ -38,6 +38,11 @@ _require_scratch
  _require_dax_iflag
  _require_xfs_io_command "lsattr" "-v"
 
Quoted 7 lines

tests/generic/607 _require_scratch · line 44

Quoted 4 lines
tests/generic/607 +4 -0
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device"&&  \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."

Hi Darrick,

Could you tell me which kernel version gets the issue? :-)

ext4.

--D

Quoted 14 lines

Best Regards,
Xiao Yang

Quoted 9 lines
tests/generic/607 +1 -0
+
  # If a/ is +x, check that a's new children
  # inherit +x from a/.
  test_xflag_inheritance1()

.

#11 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 59 lines · Darrick J. Wong
Quoted 58 lines · Xiao Yang
Quoted 57 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---
   common/rc         |   10 ++++++++--
   tests/generic/607 |    5 +++++
   2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
   	local testfile=$TEST_DIR/$$.xfs_io
   	local testio
   	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
   	"chattr")
   		if [ -z "$param" ]; then
   			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
   	if [ $exp_s_dax -eq 0 ]; then
   		(( attributes&   0x2000 ))&&   echo "$target has unexpected S_DAX flag"
   	else
-		(( attributes&   0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes&   0x2000 )) || echo "$target doesn't have expected S_DAX flag"
   	fi
   }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
   	if [ $exp_xflag -eq 0 ]; then
   		_test_inode_flag dax $target&&   echo "$target has unexpected FS_XFLAG_DAX flag"
   	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
   	fi
   }
 
tests/generic/607 +0 -0
index b15085ea..14d2c05f 100755
@@ -38,6 +38,11 @@ _require_scratch
   _require_dax_iflag
   _require_xfs_io_command "lsattr" "-v"
 
Quoted 8 lines
Quoted 7 lines

tests/generic/607 _require_scratch · line 44

Quoted 4 lines
tests/generic/607 +4 -0
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device"&&   \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."

Hi Darrick,

Could you tell me which kernel version gets the issue? :-)

ext4.

Hi Darrick,

I didn't get the issue by v5.7.0 xfs_io on v5.8.0 kernel:
----------------------------------------------------------------------------------

# blkid /dev/pmem0
/dev/pmem0: UUID="181f4d76-bc21-45b7-a6d2-e486f6cc479b" TYPE="ext4"
# df -h | grep pmem0
/dev/pmem0 2.0G 28K 1.8G 1% /mnt/xfstests/test
# strace -e ioctl xfs_io -c "lsattr -v" /mnt/xfstests/test
ioctl(3, FS_IOC_FSGETXATTR, 0x7ffdc7061d10) = 0
[] /mnt/xfstests/test
----------------------------------------------------------------------------------
Do I miss something?

Thanks,
Xiao Yang

Quoted 18 lines

--D

Quoted 13 lines

Best Regards,
Xiao Yang

Quoted 9 lines
tests/generic/607 +1 -0
+
   # If a/ is +x, check that a's new children
   # inherit +x from a/.
   test_xflag_inheritance1()

.

.

#12 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 72 lines · Xiao Yang
Quoted 59 lines · Darrick J. Wong
Quoted 58 lines · Xiao Yang
Quoted 57 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

This test requires that the filesystem support calling FSGETXATTR on regular files and directories to make sure the FS_XFLAG_DAX flag works. The _require_xfs_io_command tests a regular file but doesn't check directories, so generic/607 should do that itself. Also fix some typos.

---
   common/rc         |   10 ++++++++--
   tests/generic/607 |    5 +++++
   2 files changed, 13 insertions(+), 2 deletions(-)
common/rc +8 -2
index aa5a7409..f78b1cfc 100644
@@ -2162,6 +2162,12 @@ _require_xfs_io_command()
   	local testfile=$TEST_DIR/$$.xfs_io
   	local testio
   	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
   	"chattr")
   		if [ -z "$param" ]; then
   			param=s
@@ -3205,7 +3211,7 @@ _check_s_dax()
   	if [ $exp_s_dax -eq 0 ]; then
   		(( attributes&   0x2000 ))&&   echo "$target has unexpected S_DAX flag"
   	else
-		(( attributes&   0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes&   0x2000 )) || echo "$target doesn't have expected S_DAX flag"
   	fi
   }
 
@@ -3217,7 +3223,7 @@ _check_xflag()
   	if [ $exp_xflag -eq 0 ]; then
   		_test_inode_flag dax $target&&   echo "$target has unexpected FS_XFLAG_DAX flag"
   	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
   	fi
   }
 
tests/generic/607 +0 -0
index b15085ea..14d2c05f 100755
@@ -38,6 +38,11 @@ _require_scratch
   _require_dax_iflag
   _require_xfs_io_command "lsattr" "-v"
 
Quoted 8 lines
Quoted 7 lines

tests/generic/607 _require_scratch · line 44

Quoted 4 lines
tests/generic/607 +4 -0
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device"&&   \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."

Hi Darrick,

Could you tell me which kernel version gets the issue? :-)

ext4.

Hi Darrick,

I didn't get the issue by v5.7.0 xfs_io on v5.8.0 kernel:
----------------------------------------------------------------------------------

Quoted 9 lines
# blkid /dev/pmem0
/dev/pmem0: UUID="181f4d76-bc21-45b7-a6d2-e486f6cc479b" TYPE="ext4"
# df -h | grep pmem0
/dev/pmem0 2.0G 28K 1.8G 1% /mnt/xfstests/test
# strace -e ioctl xfs_io -c "lsattr -v" /mnt/xfstests/test
ioctl(3, FS_IOC_FSGETXATTR, 0x7ffdc7061d10) = 0
[] /mnt/xfstests/test
----------------------------------------------------------------------------------
Do I miss something?

Oops, sorry, I was reading the wrong VM report. It's overlayfs (atop xfs though I don't think that matters) that doesn't support FSGETXATTR on directories.

--D

Quoted 23 lines

Thanks,
Xiao Yang

Quoted 18 lines

--D

Quoted 13 lines

Best Regards,
Xiao Yang

Quoted 9 lines
tests/generic/607 +1 -0
+
   # If a/ is +x, check that a's new children
   # inherit +x from a/.
   test_xflag_inheritance1()

.

.

#13 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 3 lines · Darrick J. Wong

Oops, sorry, I was reading the wrong VM report. It's overlayfs (atop xfs though I don't think that matters) that doesn't support FSGETXATTR on directories.

I think we should overlayfs to support FSGETXATTR on all files that can be opened instead.

#14 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

Oops, sorry, I was reading the wrong VM report. It's overlayfs (atop xfs though I don't think that matters) that doesn't support FSGETXATTR on directories.

I think we should overlayfs to support FSGETXATTR on all files that can be opened instead.

Heh, yes, that would be a better option. :)

Even if they do add it, though, I still think we need to be able to _notrun this test to avoid failures on unpatched kernels?

This also makes me wonder, we lose all the FSGETXATTR state on copy-up, don't we? Since the VFS doesn't have a primitive for cloning all the metadata?

--D

#15 lore raw

Re: [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Quoted 6 lines · Darrick J. Wong
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

Oops, sorry, I was reading the wrong VM report. It's overlayfs (atop xfs though I don't think that matters) that doesn't support FSGETXATTR on directories.

Quoted 7 lines
Quoted 2 lines

I think we should overlayfs to support FSGETXATTR on all files that can be opened instead.

Heh, yes, that would be a better option. :)

Even if they do add it, though, I still think we need to be able to _notrun this test to avoid failures on unpatched kernels?

I think supporting FSGETXATTR only on regular files is a bug and should fail.

Quoted 3 lines

This also makes me wonder, we lose all the FSGETXATTR state on copy-up, don't we? Since the VFS doesn't have a primitive for cloning all the metadata?

Good question.

#16 lore raw

PATCH 4/24 xfs: skip tests that rely on allocation behaviors of the data device

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

A large number of xfs-specific tests rely on specific behaviors of the data device allocator, such as fragmenting free space, carefully curated inode and free space counts, or features like filestreams that only exist on the data device.

These tests fail horribly if the test runner specified rtinherit=1 on the mkfs command line, so skip them all.

---
 tests/xfs/171 |    1 +
 tests/xfs/172 |    1 +
 tests/xfs/173 |    1 +
 tests/xfs/174 |    1 +
 tests/xfs/205 |    1 +
 tests/xfs/306 |    1 +
 tests/xfs/318 |    1 +
 tests/xfs/444 |    1 +
 8 files changed, 8 insertions(+)
tests/xfs/171 +1 -0
index 050d02ab..a0d6e3f9 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/172 +1 -0
index c100481c..13f1f381 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/173 +1 -0
index 1569146f..47e1d029 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/174 +1 -0
index 781a1967..348f38c3 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/205 +1 -0
index 645e509a..6f1c2058 100755
@@ -24,6 +24,7 @@ _supported_os Linux
 
 # single AG will cause xfs_repair to fail checks.
 _require_scratch_nocheck
+_require_no_rtinherit
 
 rm -f $seqres.full
 
tests/xfs/306 +1 -0
index edbb6076..d2a0dd7f 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch_nocheck	# check complains about single AG fs
+_require_no_rtinherit
 _require_xfs_io_command "fpunch"
 _require_command $UUIDGEN_PROG uuidgen
 
tests/xfs/318 +1 -0
index 83b858ea..a45301e2 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _require_scratch
 _require_error_injection
 _require_xfs_io_error_injection "rmap_finish_one"
+_require_no_rtinherit
 
 rm -f $seqres.full
 
tests/xfs/444 +1 -0
index 6ed88715..e84b2cca 100755
@@ -40,6 +40,7 @@ _require_scratch
 _require_test_program "punch-alternating"
 _require_xfs_io_command "falloc"
 _require_xfs_db_write_array
+_require_no_rtinherit
 
 # This is only a v5 filesystem problem
 _require_scratch_xfs_crc
Reviewed-by on v1 4/24
#17 lore raw

Re: [PATCH 04/24] xfs: skip tests that rely on allocation behaviors of the data device

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

A large number of xfs-specific tests rely on specific behaviors of the data device allocator, such as fragmenting free space, carefully curated inode and free space counts, or features like filestreams that only exist on the data device.

Quoted 5 lines

These tests fail horribly if the test runner specified rtinherit=1 on the mkfs command line, so skip them all.

---

Good to me,

Quoted 108 lines
 tests/xfs/171 |    1 +
 tests/xfs/172 |    1 +
 tests/xfs/173 |    1 +
 tests/xfs/174 |    1 +
 tests/xfs/205 |    1 +
 tests/xfs/306 |    1 +
 tests/xfs/318 |    1 +
 tests/xfs/444 |    1 +
 8 files changed, 8 insertions(+)
tests/xfs/171 +1 -0
index 050d02ab..a0d6e3f9 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/172 +1 -0
index c100481c..13f1f381 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/173 +1 -0
index 1569146f..47e1d029 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/174 +1 -0
index 781a1967..348f38c3 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch
+_require_no_rtinherit
 
 _check_filestreams_support || _notrun "filestreams not available"
 
tests/xfs/205 +1 -0
index 645e509a..6f1c2058 100755
@@ -24,6 +24,7 @@ _supported_os Linux
 
 # single AG will cause xfs_repair to fail checks.
 _require_scratch_nocheck
+_require_no_rtinherit
 
 rm -f $seqres.full
 
tests/xfs/306 +1 -0
index edbb6076..d2a0dd7f 100755
@@ -35,6 +35,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_scratch_nocheck	# check complains about single AG fs
+_require_no_rtinherit
 _require_xfs_io_command "fpunch"
 _require_command $UUIDGEN_PROG uuidgen
 
tests/xfs/318 +1 -0
index 83b858ea..a45301e2 100755
@@ -33,6 +33,7 @@ _supported_fs xfs
 _require_scratch
 _require_error_injection
 _require_xfs_io_error_injection "rmap_finish_one"
+_require_no_rtinherit
 
 rm -f $seqres.full
 
tests/xfs/444 +1 -0
index 6ed88715..e84b2cca 100755
@@ -40,6 +40,7 @@ _require_scratch
 _require_test_program "punch-alternating"
 _require_xfs_io_command "falloc"
 _require_xfs_db_write_array
+_require_no_rtinherit
 
 # This is only a v5 filesystem problem
 _require_scratch_xfs_crc
Reviewed-by on v1 4/24
#18 lore raw

Re: [PATCH 04/24] xfs: skip tests that rely on allocation behaviors of the data device

In reply to Darrick J. Wong
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

A large number of xfs-specific tests rely on specific behaviors of the data device allocator, such as fragmenting free space, carefully curated inode and free space counts, or features like filestreams that only exist on the data device.

These tests fail horribly if the test runner specified rtinherit=1 on the mkfs command line, so skip them all.

Looks good,

#19 lore raw

PATCH 5/24 xfs/031: make sure we don't set rtinherit=1 on mkfs

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

mkfs.xfs does not support setting rtinherit on the root directory /and/ pre-populating the filesystem with protofiles, so don't run this test if rtinherit is in the mkfs options.

---
 tests/xfs/019 |    5 +++++
 tests/xfs/031 |    5 +++++
 2 files changed, 10 insertions(+)
tests/xfs/019 +5 -0
index f42b62bb..aa5365e7 100755
@@ -51,6 +51,11 @@ _supported_os Linux
 
 _require_scratch
 
+# mkfs cannot create a filesystem with protofiles if realtime is enabled, so
+# don't run this test if the rtinherit is anywhere in the mkfs options.
+echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
+	_notrun "Cannot mkfs with a protofile and -d rtinherit."
+
 protofile=$tmp.proto
 tempfile=$tmp.file
 
tests/xfs/031 +5 -0
index 6403fd40..671b6727 100755
@@ -81,6 +81,11 @@ _supported_os Linux
 _require_scratch
 _require_no_large_scratch_dev
 
+# mkfs cannot create a filesystem with protofiles if realtime is enabled, so
+# don't run this test if the rtinherit is anywhere in the mkfs options.
+echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
+	_notrun "Cannot mkfs with a protofile and -d rtinherit."
+
 # sanity test - default + one root directory entry
 # Note: must do this proto/mkfs now for later inode size calcs
 _create_proto 0
Reviewed-by on v1 5/24
#20 lore raw

Re: [PATCH 05/24] xfs/031: make sure we don't set rtinherit=1 on mkfs

Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

mkfs.xfs does not support setting rtinherit on the root directory /and/ pre-populating the filesystem with protofiles, so don't run this test if rtinherit is in the mkfs options.

---

Good to me,

Quoted 38 lines
 tests/xfs/019 |    5 +++++
 tests/xfs/031 |    5 +++++
 2 files changed, 10 insertions(+)
tests/xfs/019 +5 -0
index f42b62bb..aa5365e7 100755
@@ -51,6 +51,11 @@ _supported_os Linux
 
 _require_scratch
 
+# mkfs cannot create a filesystem with protofiles if realtime is enabled, so
+# don't run this test if the rtinherit is anywhere in the mkfs options.
+echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
+	_notrun "Cannot mkfs with a protofile and -d rtinherit."
+
 protofile=$tmp.proto
 tempfile=$tmp.file
 
tests/xfs/031 +5 -0
index 6403fd40..671b6727 100755
@@ -81,6 +81,11 @@ _supported_os Linux
 _require_scratch
 _require_no_large_scratch_dev
 
+# mkfs cannot create a filesystem with protofiles if realtime is enabled, so
+# don't run this test if the rtinherit is anywhere in the mkfs options.
+echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
+	_notrun "Cannot mkfs with a protofile and -d rtinherit."
+
 # sanity test - default + one root directory entry
 # Note: must do this proto/mkfs now for later inode size calcs
 _create_proto 0
#21 lore raw

Re: [PATCH 05/24] xfs/031: make sure we don't set rtinherit=1 on mkfs

In reply to Darrick J. Wong
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

mkfs.xfs does not support setting rtinherit on the root directory /and/ pre-populating the filesystem with protofiles, so don't run this test if rtinherit is in the mkfs options.

That is a bit of a weird limitation. Any reason we can't fix this in mkfs instead?

#22 lore raw

Re: [PATCH 05/24] xfs/031: make sure we don't set rtinherit=1 on mkfs

Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

mkfs.xfs does not support setting rtinherit on the root directory /and/ pre-populating the filesystem with protofiles, so don't run this test if rtinherit is in the mkfs options.

That is a bit of a weird limitation. Any reason we can't fix this in mkfs instead?

Userspace doesn't implement the rt allocator at all, and the last few times I've tried to do any serious surgery in the protofile code, Dave grumbled that we should just kill it off instead.

Do people actually /use/ protofile support? Do they like it? Or would they rather have an option like mke2fs -D, where you point it at a directory and it uses ftw to copy-in all the files in that directory tree, attributes and all?

(I guess I could propose deprecating it and see who pops out. :P)

--D

#23 lore raw

Re: [PATCH 05/24] xfs/031: make sure we don't set rtinherit=1 on mkfs

Quoted 8 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

mkfs.xfs does not support setting rtinherit on the root directory /and/ pre-populating the filesystem with protofiles, so don't run this test if rtinherit is in the mkfs options.

Quoted 6 lines
Quoted 2 lines

That is a bit of a weird limitation. Any reason we can't fix this in mkfs instead?

Userspace doesn't implement the rt allocator at all, and the last few times I've tried to do any serious surgery in the protofile code, Dave grumbled that we should just kill it off instead.

Maybe killing it off is indeed the better option. And in that case this patch to disable it for RT devices would be a good start.

Quoted 5 lines

Do people actually /use/ protofile support? Do they like it? Or would they rather have an option like mke2fs -D, where you point it at a directory and it uses ftw to copy-in all the files in that directory tree, attributes and all?

I always found the protofile stuff really weird and not actually useful.

mke2fs -D actually does seem useful if you want to generate an xfs file systems and fill it without having admin privileges. I think that is what the mke2fs feature is used for.

#24 lore raw

PATCH 6/24 xfs: wrap xfs_db calls to the test device

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Create a _test_xfs_db analogue to _scratch_xfs_db so that we can encapsulate whatever strange test fs options were fed to us by the test runner.

---
 common/xfs    |   13 +++++++++++++
 tests/xfs/003 |   14 +++++++-------
 tests/xfs/016 |    4 ++--
 tests/xfs/045 |    2 +-
 4 files changed, 23 insertions(+), 10 deletions(-)
common/xfs +13 -0
index d9a9784f..eab5e292 100644
@@ -218,6 +218,19 @@ _scratch_xfs_db()
 	$XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
 }
 
+_test_xfs_db_options()
+{
+	TEST_OPTIONS=""
+	[ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+		TEST_OPTIONS="-l$TEST_LOGDEV"
+	echo $TEST_OPTIONS $* $TEST_DEV
+}
+
+_test_xfs_db()
+{
+	$XFS_DB_PROG "$@" $(_test_xfs_db_options)
+}
+
 _scratch_xfs_admin()
 {
 	local options=("$SCRATCH_DEV")
tests/xfs/003 +7 -7
index 1ce3e5ce..736bf206 100755
@@ -38,32 +38,32 @@ test_done()
 # real QA test starts here
 
 echo "=== TEST 1 ==="
-xfs_db -r -c 'pop' -c 'type sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'type sb'
 test_done
 
 echo "=== TEST 2 ==="
-xfs_db -r -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'push sb'
 test_done
 
 echo "=== TEST 3 ==="
-xfs_db -r -c 'pop' -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'push sb'
 test_done
 
 echo "=== TEST 4 ==="
-xfs_db -r -c 'type sb' -c 'print' $TEST_DEV
+_test_xfs_db -r -c 'type sb' -c 'print'
 test_done
 
 echo "=== TEST 5 ==="
-xfs_db -r -c 'inode 128' -c 'push' -c 'type' $TEST_DEV >$tmp.out 2>&1
+_test_xfs_db -r -c 'inode 128' -c 'push' -c 'type' >$tmp.out 2>&1
 test_done
 if ! grep -q "current type is \"inode\"" $tmp.out; then
     cat $tmp.out
 fi
 
 echo "=== TEST 6 ==="
-xfs_db -r -c 'sb' -c 'a' $TEST_DEV >$tmp.out 2>&1 # don't care about output
+_test_xfs_db -r -c 'sb' -c 'a' >$tmp.out 2>&1 # don't care about output
 test_done
 
 echo "=== TEST 7 ==="
-xfs_db -r -c 'ring' $TEST_DEV
+_test_xfs_db -r -c 'ring'
 test_done
tests/xfs/016 +2 -2
index 2b41127e..e1b1b6b8 100755
@@ -149,7 +149,7 @@ _log_sunit()
 
 _after_log()
 {
-    xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
+    _scratch_xfs_db -r -c "sb" -c "print" | $AWK_PROG '
         /logstart/  { logstart = $3 }
         /logblocks/ { logblocks = $3 }
         END {
@@ -163,7 +163,7 @@ _check_corrupt()
     f="c6c6c6c6"
     echo "*** check for corruption"
     echo "expect $f..." >>$seqres.full
-    xfs_db -r -c "fsblock $2" -c "print" $1 | head | tee -a $seqres.full | \
+    _scratch_xfs_db -r -c "fsblock $2" -c "print" | head | tee -a $seqres.full | \
         grep -q -v "$f $f $f $f $f $f $f $f" && \
             _fail "!!! block $2 corrupted!"
 }
tests/xfs/045 +1 -1
index 0c9e1b79..6a44da56 100755
@@ -21,7 +21,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 
 _get_existing_uuid()
 {
-    xfs_db -r $TEST_DEV -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
+	_test_xfs_db -r -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
 }
 
 # real QA test starts here
Reviewed-by on v1 6/24
#25 lore raw

Re: [PATCH 06/24] xfs: wrap xfs_db calls to the test device

Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Create a _test_xfs_db analogue to _scratch_xfs_db so that we can encapsulate whatever strange test fs options were fed to us by the test runner.

---

Good to me,

Quoted 111 lines
 common/xfs    |   13 +++++++++++++
 tests/xfs/003 |   14 +++++++-------
 tests/xfs/016 |    4 ++--
 tests/xfs/045 |    2 +-
 4 files changed, 23 insertions(+), 10 deletions(-)
common/xfs +13 -0
index d9a9784f..eab5e292 100644
@@ -218,6 +218,19 @@ _scratch_xfs_db()
 	$XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
 }
 
+_test_xfs_db_options()
+{
+	TEST_OPTIONS=""
+	[ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+		TEST_OPTIONS="-l$TEST_LOGDEV"
+	echo $TEST_OPTIONS $* $TEST_DEV
+}
+
+_test_xfs_db()
+{
+	$XFS_DB_PROG "$@" $(_test_xfs_db_options)
+}
+
 _scratch_xfs_admin()
 {
 	local options=("$SCRATCH_DEV")
tests/xfs/003 +7 -7
index 1ce3e5ce..736bf206 100755
@@ -38,32 +38,32 @@ test_done()
 # real QA test starts here
 
 echo "=== TEST 1 ==="
-xfs_db -r -c 'pop' -c 'type sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'type sb'
 test_done
 
 echo "=== TEST 2 ==="
-xfs_db -r -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'push sb'
 test_done
 
 echo "=== TEST 3 ==="
-xfs_db -r -c 'pop' -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'push sb'
 test_done
 
 echo "=== TEST 4 ==="
-xfs_db -r -c 'type sb' -c 'print' $TEST_DEV
+_test_xfs_db -r -c 'type sb' -c 'print'
 test_done
 
 echo "=== TEST 5 ==="
-xfs_db -r -c 'inode 128' -c 'push' -c 'type' $TEST_DEV >$tmp.out 2>&1
+_test_xfs_db -r -c 'inode 128' -c 'push' -c 'type' >$tmp.out 2>&1
 test_done
 if ! grep -q "current type is \"inode\"" $tmp.out; then
     cat $tmp.out
 fi
 
 echo "=== TEST 6 ==="
-xfs_db -r -c 'sb' -c 'a' $TEST_DEV >$tmp.out 2>&1 # don't care about output
+_test_xfs_db -r -c 'sb' -c 'a' >$tmp.out 2>&1 # don't care about output
 test_done
 
 echo "=== TEST 7 ==="
-xfs_db -r -c 'ring' $TEST_DEV
+_test_xfs_db -r -c 'ring'
 test_done
tests/xfs/016 +2 -2
index 2b41127e..e1b1b6b8 100755
@@ -149,7 +149,7 @@ _log_sunit()
 
 _after_log()
 {
-    xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
+    _scratch_xfs_db -r -c "sb" -c "print" | $AWK_PROG '
         /logstart/  { logstart = $3 }
         /logblocks/ { logblocks = $3 }
         END {
@@ -163,7 +163,7 @@ _check_corrupt()
     f="c6c6c6c6"
     echo "*** check for corruption"
     echo "expect $f..." >>$seqres.full
-    xfs_db -r -c "fsblock $2" -c "print" $1 | head | tee -a $seqres.full | \
+    _scratch_xfs_db -r -c "fsblock $2" -c "print" | head | tee -a $seqres.full | \
         grep -q -v "$f $f $f $f $f $f $f $f" && \
             _fail "!!! block $2 corrupted!"
 }
tests/xfs/045 +1 -1
index 0c9e1b79..6a44da56 100755
@@ -21,7 +21,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 
 _get_existing_uuid()
 {
-    xfs_db -r $TEST_DEV -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
+	_test_xfs_db -r -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
 }
 
 # real QA test starts here
#27 lore raw

PATCH 7/24 xfs/{111,137}: replace open-coded calls to repair with _scratch_xfs_repair

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---
 tests/xfs/111 |    2 +-
 tests/xfs/137 |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tests/xfs/111 +1 -1
index 0db33cb8..1f778966 100755
@@ -62,7 +62,7 @@ $XFS_FSR_PROG -g $SCRATCH_MNT | _filter_scratch
 
 # Fix up intentional corruption so test can pass
 _scratch_unmount
-$XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
 
 status=0
 exit
tests/xfs/137 +2 -2
index 79106c66..c10860bb 100755
@@ -64,11 +64,11 @@ else
 fi
 
 # verify that repair detects invalid LSNs as well
-$XFS_REPAIR_PROG -n $SCRATCH_DEV >> $seqres.full 2>&1 || \
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || \
 	echo repair failure detected
 
 # repair for real so the post-test check can verify repair fixed things up
-$XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
 
 # success, all done
 status=0
Reviewed-by on v1 7/24
#28 lore raw

Re: [PATCH 07/24] xfs/{111,137}: replace open-coded calls to repair with _scratch_xfs_repair

Quoted 4 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---

Good to me,

Quoted 37 lines
 tests/xfs/111 |    2 +-
 tests/xfs/137 |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tests/xfs/111 +1 -1
index 0db33cb8..1f778966 100755
@@ -62,7 +62,7 @@ $XFS_FSR_PROG -g $SCRATCH_MNT | _filter_scratch
 
 # Fix up intentional corruption so test can pass
 _scratch_unmount
-$XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
 
 status=0
 exit
tests/xfs/137 +2 -2
index 79106c66..c10860bb 100755
@@ -64,11 +64,11 @@ else
 fi
 
 # verify that repair detects invalid LSNs as well
-$XFS_REPAIR_PROG -n $SCRATCH_DEV >> $seqres.full 2>&1 || \
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || \
 	echo repair failure detected
 
 # repair for real so the post-test check can verify repair fixed things up
-$XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
 
 # success, all done
 status=0
#30 lore raw

PATCH 8/24 xfs: replace open-coded calls to xfs_logprint with helpers

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use the test/scratch xfs_logprint helpers.

---
 tests/xfs/135 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/135 +1 -1
index cc505980..9783cfc2 100755
@@ -48,7 +48,7 @@ for i in 16 32 64 128 256; do
 	_scratch_xfs_db -x -c "logformat -c 3 -s $lsunit" | \
 		tee -a $seqres.full
 	# don't redirect error output so it causes test failure
-	$XFS_LOGPRINT_PROG $SCRATCH_DEV >> $seqres.full
+	_scratch_xfs_logprint >> $seqres.full
 done
 
 # success, all done
Reviewed-by on v1 8/24
#31 lore raw

Re: [PATCH 08/24] xfs: replace open-coded calls to xfs_logprint with helpers

Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use the test/scratch xfs_logprint helpers.

---

Good to me,

Quoted 18 lines
 tests/xfs/135 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/135 +1 -1
index cc505980..9783cfc2 100755
@@ -48,7 +48,7 @@ for i in 16 32 64 128 256; do
 	_scratch_xfs_db -x -c "logformat -c 3 -s $lsunit" | \
 		tee -a $seqres.full
 	# don't redirect error output so it causes test failure
-	$XFS_LOGPRINT_PROG $SCRATCH_DEV >> $seqres.full
+	_scratch_xfs_logprint >> $seqres.full
 done
 
 # success, all done
#33 lore raw

PATCH 9/24 xfs/070: add scratch log device options to direct repair invocation

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---
 tests/xfs/070 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/070 +3 -1
index 5d52a830..313864b7 100755
@@ -41,9 +41,11 @@ _cleanup()
 _xfs_repair_noscan()
 {
 	# invoke repair directly so we can kill the process if need be
+	[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+		log_repair_opts="-l $SCRATCH_LOGDEV"
 	[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 		rt_repair_opts="-r $SCRATCH_RTDEV"
-	$XFS_REPAIR_PROG $rt_repair_opts $SCRATCH_DEV 2>&1 |
+	$XFS_REPAIR_PROG $log_repair_opts $rt_repair_opts $SCRATCH_DEV 2>&1 |
 		tee -a $seqres.full > $tmp.repair &
 	repair_pid=$!
 
#34 lore raw

Re: [PATCH 09/24] xfs/070: add scratch log device options to direct repair invocation

Quoted 13 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---
 tests/xfs/070 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/070 +0 -0
index 5d52a830..313864b7 100755

tests/xfs/070 _cleanup() · line 49

Quoted 10 lines
tests/xfs/070 +3 -1
@@ -41,9 +41,11 @@ _cleanup()
 _xfs_repair_noscan()
 {
 	# invoke repair directly so we can kill the process if need be
+	[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+		log_repair_opts="-l $SCRATCH_LOGDEV"
 	[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 		rt_repair_opts="-r $SCRATCH_RTDEV"
-	$XFS_REPAIR_PROG $rt_repair_opts $SCRATCH_DEV 2>&1 |
+	$XFS_REPAIR_PROG $log_repair_opts $rt_repair_opts $SCRATCH_DEV 2>&1 |
 		tee -a $seqres.full > $tmp.repair &

Why not use _scratch_xfs_repair at here?

Thanks,
Zorro

Quoted 3 lines
tests/xfs/070 +0 -0
 	repair_pid=$!
 
#35 lore raw

Re: [PATCH 09/24] xfs/070: add scratch log device options to direct repair invocation

Quoted 27 lines · Zorro Lang
Quoted 13 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---
 tests/xfs/070 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/070 +0 -0
index 5d52a830..313864b7 100755

tests/xfs/070 _cleanup() · line 49

Quoted 10 lines
tests/xfs/070 +3 -1
@@ -41,9 +41,11 @@ _cleanup()
 _xfs_repair_noscan()
 {
 	# invoke repair directly so we can kill the process if need be
+	[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+		log_repair_opts="-l $SCRATCH_LOGDEV"
 	[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 		rt_repair_opts="-r $SCRATCH_RTDEV"
-	$XFS_REPAIR_PROG $rt_repair_opts $SCRATCH_DEV 2>&1 |
+	$XFS_REPAIR_PROG $log_repair_opts $rt_repair_opts $SCRATCH_DEV 2>&1 |
 		tee -a $seqres.full > $tmp.repair &

Why not use _scratch_xfs_repair at here?

Quoted 4 lines

Thanks,
Zorro

Quoted 1 line
tests/xfs/070 +0 -0
 	repair_pid=$!
        ^^^^^^^^^^^^^

Because this test needs to hang on to the pid of the repair process in order to kill it, which you can't do if do if you use the wrapper.

--D

Quoted 3 lines
Quoted 2 lines
Reviewed-by
#36 lore raw

Re: [PATCH 09/24] xfs/070: add scratch log device options to direct repair invocation

Quoted 28 lines · Darrick J. Wong
Quoted 27 lines · Zorro Lang
Quoted 13 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

---
 tests/xfs/070 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/070 +0 -0
index 5d52a830..313864b7 100755

tests/xfs/070 _cleanup() · line 49

Quoted 10 lines
tests/xfs/070 +3 -1
@@ -41,9 +41,11 @@ _cleanup()
 _xfs_repair_noscan()
 {
 	# invoke repair directly so we can kill the process if need be
+	[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+		log_repair_opts="-l $SCRATCH_LOGDEV"
 	[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 		rt_repair_opts="-r $SCRATCH_RTDEV"
-	$XFS_REPAIR_PROG $rt_repair_opts $SCRATCH_DEV 2>&1 |
+	$XFS_REPAIR_PROG $log_repair_opts $rt_repair_opts $SCRATCH_DEV 2>&1 |
 		tee -a $seqres.full > $tmp.repair &

Why not use _scratch_xfs_repair at here?

Quoted 6 lines
Quoted 4 lines

Thanks,
Zorro

Quoted 1 line
tests/xfs/070 +0 -0
 	repair_pid=$!
        ^^^^^^^^^^^^^

Oh, right! That's good to me now.

Quoted 9 lines

Because this test needs to hang on to the pid of the repair process in order to kill it, which you can't do if do if you use the wrapper.

--D

Quoted 3 lines
Quoted 2 lines
#38 lore raw

PATCH 10/24 xfs: add a _require_xfs_copy helper

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add a _require helper so that tests can ensure that they're running in the correct environment for xfs_copy to work (no external devices).

---
 common/xfs    |    7 +++++++
 tests/xfs/032 |    4 +---
 tests/xfs/073 |    5 +----
 tests/xfs/077 |    3 +--
 tests/xfs/284 |    3 +--
 tests/xfs/503 |    1 +
 6 files changed, 12 insertions(+), 11 deletions(-)
common/xfs +7 -0
index eab5e292..f4a47dfb 100644
@@ -945,3 +945,10 @@ _try_wipe_scratch_xfs()
 	fi
 	rm -f $tmp.mkfs
 }
+
+_require_xfs_copy()
+{
+	[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
+	[ "$USE_EXTERNAL" = yes ] && \
+		_notrun "Cannot xfs_copy with external devices"
+}
tests/xfs/032 +1 -3
index af18f755..8ece957d 100755
@@ -25,9 +25,7 @@ _supported_os Linux
 
 _require_scratch
 _require_test_program "feature"
-
-[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
-[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
+_require_xfs_copy
 
 rm -f $seqres.full
 
tests/xfs/073 +1 -4
index 6939e102..dc0cde4f 100755
@@ -113,10 +113,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_test
 _require_attrs
-
-[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
-[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
-
+_require_xfs_copy
 _require_scratch
 _require_loop
 
tests/xfs/077 +1 -2
index 02bcc9f7..b11b2c07 100755
@@ -35,8 +35,7 @@ _cleanup()
 
 _supported_fs xfs
 _supported_os Linux
-# xfs_copy does not support realtime devices
-_require_no_realtime
+_require_xfs_copy
 _require_scratch
 _require_no_large_scratch_dev
 _require_xfs_crc
tests/xfs/284 +1 -2
index 7af77634..8f997e17 100755
@@ -34,8 +34,7 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs xfs
 _supported_os Linux
-# xfs_copy does not support realtime devices
-_require_no_realtime
+_require_xfs_copy
 _require_test
 _require_scratch
 _require_no_large_scratch_dev
tests/xfs/503 +1 -0
index 41754353..756bcda3 100755
@@ -33,6 +33,7 @@ testdir=$TEST_DIR/test-$seq
 _supported_os Linux
 _supported_fs xfs
 
+_require_xfs_copy
 _require_scratch_nocheck
 _require_populate_commands
 
Reviewed-by on v1 10/24
#39 lore raw

Re: [PATCH 10/24] xfs: add a _require_xfs_copy helper

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add a _require helper so that tests can ensure that they're running in the correct environment for xfs_copy to work (no external devices).

---

Good to me,

Quoted 96 lines
 common/xfs    |    7 +++++++
 tests/xfs/032 |    4 +---
 tests/xfs/073 |    5 +----
 tests/xfs/077 |    3 +--
 tests/xfs/284 |    3 +--
 tests/xfs/503 |    1 +
 6 files changed, 12 insertions(+), 11 deletions(-)
common/xfs +7 -0
index eab5e292..f4a47dfb 100644
@@ -945,3 +945,10 @@ _try_wipe_scratch_xfs()
 	fi
 	rm -f $tmp.mkfs
 }
+
+_require_xfs_copy()
+{
+	[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
+	[ "$USE_EXTERNAL" = yes ] && \
+		_notrun "Cannot xfs_copy with external devices"
+}
tests/xfs/032 +1 -3
index af18f755..8ece957d 100755
@@ -25,9 +25,7 @@ _supported_os Linux
 
 _require_scratch
 _require_test_program "feature"
-
-[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
-[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
+_require_xfs_copy
 
 rm -f $seqres.full
 
tests/xfs/073 +1 -4
index 6939e102..dc0cde4f 100755
@@ -113,10 +113,7 @@ _supported_fs xfs
 _supported_os Linux
 _require_test
 _require_attrs
-
-[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
-[ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
-
+_require_xfs_copy
 _require_scratch
 _require_loop
 
tests/xfs/077 +1 -2
index 02bcc9f7..b11b2c07 100755
@@ -35,8 +35,7 @@ _cleanup()
 
 _supported_fs xfs
 _supported_os Linux
-# xfs_copy does not support realtime devices
-_require_no_realtime
+_require_xfs_copy
 _require_scratch
 _require_no_large_scratch_dev
 _require_xfs_crc
tests/xfs/284 +1 -2
index 7af77634..8f997e17 100755
@@ -34,8 +34,7 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs xfs
 _supported_os Linux
-# xfs_copy does not support realtime devices
-_require_no_realtime
+_require_xfs_copy
 _require_test
 _require_scratch
 _require_no_large_scratch_dev
tests/xfs/503 +1 -0
index 41754353..756bcda3 100755
@@ -33,6 +33,7 @@ testdir=$TEST_DIR/test-$seq
 _supported_os Linux
 _supported_fs xfs
 
+_require_xfs_copy
 _require_scratch_nocheck
 _require_populate_commands
 
#41 lore raw

PATCH 11/24 overlay/{069,071}: fix undefined variables

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Change OVL_BASE_TEST_MNT -> OVL_BASE_TEST_DIR, since the former is not actually defined anywhere.

---
 tests/overlay/069 |    2 +-
 tests/overlay/071 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/overlay/069 +1 -1
index 77dfce63..f7eaec2d 100755
@@ -53,7 +53,7 @@ _require_test_program "open_by_handle"
 _require_scratch_overlay_features index nfs_export redirect_dir
 
 # Lower overlay lower layer is on test fs, upper is on scratch fs
-lower=$OVL_BASE_TEST_MNT/$OVL_LOWER-$seq
+lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
 
tests/overlay/071 +1 -1
index e083c29d..043fc4d3 100755
@@ -56,7 +56,7 @@ _require_scratch_overlay_features index nfs_export redirect_dir
 _require_loop
 
 # Lower overlay lower layer is on test fs, upper is on scratch fs
-lower=$OVL_BASE_TEST_MNT/$OVL_LOWER-$seq
+lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
 # Lower dir of nested overlay is the scratch overlay mount at SCRATCH_MNT
#43 lore raw

PATCH 12/24 overlay/020: make sure the system supports the required namespaces

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Don't run this test if the kernel doesn't support namespaces.

---
 tests/overlay/020 |    6 ++++++
 1 file changed, 6 insertions(+)
tests/overlay/020 +6 -0
index 85488b83..9029f042 100755
@@ -32,10 +32,16 @@ rm -f $seqres.full
 
 # real QA test starts here
 
+require_unshare() {
+	unshare -f -r "$@" true &>/dev/null || \
+		_notrun "unshare $@: not supported"
+}
+
 # Modify as appropriate.
 _supported_fs overlay
 _supported_os Linux
 _require_scratch
+require_unshare -m -p -U
 
 # Remove all files from previous tests
 _scratch_mkfs
Reviewed-by on v1 12/24
#44 lore raw

Re: [PATCH 12/24] overlay/020: make sure the system supports the required namespaces

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Don't run this test if the kernel doesn't support namespaces.

---

Quoted 9 lines
 tests/overlay/020 |    6 ++++++
 1 file changed, 6 insertions(+)
tests/overlay/020 +0 -0
index 85488b83..9029f042 100755

tests/overlay/020 rm -f $seqres.full · line 39

Quoted 8 lines
tests/overlay/020 +5 -0
@@ -32,10 +32,16 @@ rm -f $seqres.full
 
 # real QA test starts here
 
+require_unshare() {
+       unshare -f -r "$@" true &>/dev/null || \
+               _notrun "unshare $@: not supported"
+}
+

I guess we can defer making this common until xfstests catches up on testing FS_USERNS_MOUNT...

Thanks,
Amir.

#45 lore raw

PATCH 13/24 generic/204: don't flood stdout with ENOSPC messages on an ENOSPC test

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has been on and off my bad list for many years due to the fact that it will spew potentially millions of "No space left on device" errors if the file count calculations are wrong. The calculations should be correct for the XFS data device, but they don't apply to other filesystems.

Therefore, filter out the ENOSPC messages when the files are not going to be created on the xfs data device (e.g. ext4, xfs realtime, etc.)

---
 tests/generic/204 |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/generic/204 +6 -2
index 349f5eff..7250c00a 100755
@@ -76,9 +76,13 @@ files=$((space / (direntlen + isize + dbsize)))
 echo files $files, resvblks $resv_blks >> $seqres.full
 _scratch_resvblks $resv_blks >> $seqres.full 2>&1
 
+filter() {
+	test $FSTYP != xfs && sed -e '/No space left on device/d'
+}
+
 for i in `seq -w 1 $files`; do
-    echo -n > $SCRATCH_MNT/$i
-    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
+	(echo -n > $SCRATCH_MNT/$i;
+	 echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i) 2>&1 | filter
 done
 
 # success, all done
Reviewed-by on v1 13/24
#46 lore raw

Re: [PATCH 13/24] generic/204: don't flood stdout with ENOSPC messages on an ENOSPC test

Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has been on and off my bad list for many years due to the fact that it will spew potentially millions of "No space left on device" errors if the file count calculations are wrong. The calculations should be correct for the XFS data device, but they don't apply to other filesystems.

Quoted 5 lines

Therefore, filter out the ENOSPC messages when the files are not going to be created on the xfs data device (e.g. ext4, xfs realtime, etc.)

---

Good to me,

Quoted 25 lines
 tests/generic/204 |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/generic/204 +6 -2
index 349f5eff..7250c00a 100755
@@ -76,9 +76,13 @@ files=$((space / (direntlen + isize + dbsize)))
 echo files $files, resvblks $resv_blks >> $seqres.full
 _scratch_resvblks $resv_blks >> $seqres.full 2>&1
 
+filter() {
+	test $FSTYP != xfs && sed -e '/No space left on device/d'
+}
+
 for i in `seq -w 1 $files`; do
-    echo -n > $SCRATCH_MNT/$i
-    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
+	(echo -n > $SCRATCH_MNT/$i;
+	 echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i) 2>&1 | filter
 done
 
 # success, all done
#47 lore raw

Re: [PATCH 13/24] generic/204: don't flood stdout with ENOSPC messages on an ENOSPC test

In reply to Darrick J. Wong
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has been on and off my bad list for many years due to the fact that it will spew potentially millions of "No space left on device" errors if the file count calculations are wrong. The calculations should be correct for the XFS data device, but they don't apply to other filesystems.

Therefore, filter out the ENOSPC messages when the files are not going to be created on the xfs data device (e.g. ext4, xfs realtime, etc.)

Should this move to an xfs specific test instead?

#48 lore raw

Re: [PATCH 13/24] generic/204: don't flood stdout with ENOSPC messages on an ENOSPC test

Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has been on and off my bad list for many years due to the fact that it will spew potentially millions of "No space left on device" errors if the file count calculations are wrong. The calculations should be correct for the XFS data device, but they don't apply to other filesystems.

Quoted 4 lines
Quoted 2 lines

Therefore, filter out the ENOSPC messages when the files are not going to be created on the xfs data device (e.g. ext4, xfs realtime, etc.)

Should this move to an xfs specific test instead?

I'm on the fence about that, but probably. I've though that generic/ can have a test that formats a small fs and fills it with files until it hits ENOSPC, and this test (with its weird calculations) can move to xfs/.

But I haven't been around long enough to know if there's a specific reason why we calculate the number of files to create? Is this test really a regression test for some long-ago bug? Or that weird noalloc dir update mode thing that we ripped out last year?

--D

#49 lore raw

PATCH 14/24 common/xfs: extract minimum log size message from mkfs correctly

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Modify the command that searches for the minimum log size message from mkfs to handle external log devices correctly.

---
 common/xfs |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
common/xfs +7 -1
index f4a47dfb..6520ad29 100644
@@ -103,7 +103,7 @@ _scratch_find_xfs_min_logblocks()
 	# try again without MKFS_OPTIONS because that's what _scratch_do_mkfs
 	# will do if we pass in the log size option.
 	if [ $mkfs_status -ne 0 ] &&
-	   ! grep -q 'log size.*too small, minimum' $tmp.mkfserr; then
+	   ! egrep -q '(log size.*too small, minimum|external log device.*too small, must be)' $tmp.mkfserr; then
 		eval "$mkfs_cmd $extra_mkfs_options $SCRATCH_DEV" \
 			2>$tmp.mkfserr 1>$tmp.mkfsstd
 		mkfs_status=$?
@@ -126,6 +126,12 @@ _scratch_find_xfs_min_logblocks()
 		rm -f $tmp.mkfsstd $tmp.mkfserr
 		return
 	fi
+	if grep -q 'external log device.*too small, must be' $tmp.mkfserr; then
+		grep 'external log device.*too small, must be' $tmp.mkfserr | \
+			sed -e 's/^.*must be at least \([0-9]*\) blocks/\1/g'
+		rm -f $tmp.mkfsstd $tmp.mkfserr
+		return
+	fi
 
 	# Don't know what to do, so fail
 	echo "Cannot determine minimum log size" >&2
Reviewed-by on v1 14/24
#50 lore raw

Re: [PATCH 14/24] common/xfs: extract minimum log size message from mkfs correctly

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Modify the command that searches for the minimum log size message from mkfs to handle external log devices correctly.

---

Good to me,

Quoted 31 lines
 common/xfs |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
common/xfs +7 -1
index f4a47dfb..6520ad29 100644
@@ -103,7 +103,7 @@ _scratch_find_xfs_min_logblocks()
 	# try again without MKFS_OPTIONS because that's what _scratch_do_mkfs
 	# will do if we pass in the log size option.
 	if [ $mkfs_status -ne 0 ] &&
-	   ! grep -q 'log size.*too small, minimum' $tmp.mkfserr; then
+	   ! egrep -q '(log size.*too small, minimum|external log device.*too small, must be)' $tmp.mkfserr; then
 		eval "$mkfs_cmd $extra_mkfs_options $SCRATCH_DEV" \
 			2>$tmp.mkfserr 1>$tmp.mkfsstd
 		mkfs_status=$?
@@ -126,6 +126,12 @@ _scratch_find_xfs_min_logblocks()
 		rm -f $tmp.mkfsstd $tmp.mkfserr
 		return
 	fi
+	if grep -q 'external log device.*too small, must be' $tmp.mkfserr; then
+		grep 'external log device.*too small, must be' $tmp.mkfserr | \
+			sed -e 's/^.*must be at least \([0-9]*\) blocks/\1/g'
+		rm -f $tmp.mkfsstd $tmp.mkfserr
+		return
+	fi
 
 	# Don't know what to do, so fail
 	echo "Cannot determine minimum log size" >&2
#52 lore raw

PATCH 15/24 xfs/194: actually check if we got 512-byte blocks before proceeding

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has specific fs block size requirements, so make sure that's what we got before we proceed with the test.

---
 tests/xfs/194 |    3 +++
 1 file changed, 3 insertions(+)
tests/xfs/194 +3 -0
index 9001a146..90b74c8f 100755
@@ -84,6 +84,9 @@ unset XFS_MKFS_OPTIONS
 # we need 512 byte block size, so crc's are turned off
 _scratch_mkfs_xfs -m crc=0 -b size=$blksize >/dev/null 2>&1
 _scratch_mount
+test "$(_get_block_size $SCRATCH_MNT)" = 512 || \
+	_notrun "Could not get 512-byte blocks"
+
 
 # 512b block / 4k page example:
 #
#53 lore raw

Re: [PATCH 15/24] xfs/194: actually check if we got 512-byte blocks before proceeding

Quoted 16 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has specific fs block size requirements, so make sure that's what we got before we proceed with the test.

---
 tests/xfs/194 |    3 +++
 1 file changed, 3 insertions(+)
tests/xfs/194 +0 -0
index 9001a146..90b74c8f 100755

tests/xfs/194 unset XFS_MKFS_OPTIONS · line 89

Quoted 6 lines
tests/xfs/194 +3 -0
@@ -84,6 +84,9 @@ unset XFS_MKFS_OPTIONS
 # we need 512 byte block size, so crc's are turned off
 _scratch_mkfs_xfs -m crc=0 -b size=$blksize >/dev/null 2>&1
 _scratch_mount
+test "$(_get_block_size $SCRATCH_MNT)" = 512 || \
+	_notrun "Could not get 512-byte blocks"
+

If this case is only for 512 byte blocksize, the "blksize=expr $pgsize / 8" and all things with the "$blksize" looks redundant, right?

Thanks,
Zorro

Quoted 4 lines
tests/xfs/194 +0 -0
 # 512b block / 4k page example:
 #
 
#54 lore raw

Re: [PATCH 15/24] xfs/194: actually check if we got 512-byte blocks before proceeding

Quoted 12 lines · Zorro Lang
Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test has specific fs block size requirements, so make sure that's what we got before we proceed with the test.

---
 tests/xfs/194 |    3 +++
 1 file changed, 3 insertions(+)
Quoted 14 lines

tests/xfs/194 unset XFS_MKFS_OPTIONS · line 89

Quoted 11 lines
tests/xfs/194 +3 -0
index 9001a146..90b74c8f 100755
@@ -84,6 +84,9 @@ unset XFS_MKFS_OPTIONS
 # we need 512 byte block size, so crc's are turned off
 _scratch_mkfs_xfs -m crc=0 -b size=$blksize >/dev/null 2>&1
 _scratch_mount
+test "$(_get_block_size $SCRATCH_MNT)" = 512 || \
+	_notrun "Could not get 512-byte blocks"
+

If this case is only for 512 byte blocksize, the "blksize=expr $pgsize / 8" and all things with the "$blksize" looks redundant, right?

Hmm... in hindsight I shouldn't have hardwired the right hand argument. This needs only to be a simple equivalence test:

test "$(_get_block_size $SCRATCH_MNT)" = $blksize || \
_notrun "Could not get $blksize-byte blocks"

Will fix and resend.

--D

Quoted 8 lines

Thanks,
Zorro

Quoted 4 lines
tests/xfs/194 +0 -0
 # 512b block / 4k page example:
 #
 
#55 lore raw

PATCH 16/24 xfs/098: adapt to external log devices

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach this test to deal with external log devices correctly.

---
 tests/xfs/098 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/xfs/098 +7 -1
index c63b9d60..b7d3253e 100755
@@ -76,7 +76,13 @@ echo "+ corrupt image"
 logstart="$(_scratch_xfs_get_sb_field logstart)"
 logstart="$(_scratch_xfs_db -c "convert fsblock ${logstart} byte" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
 logblocks="$(_scratch_xfs_get_sb_field logblocks)"
-$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" "${SCRATCH_DEV}" >> $seqres.full
+
+if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_LOGDEV" ]; then
+	logdev=$SCRATCH_LOGDEV
+else
+	logdev=$SCRATCH_DEV
+fi
+$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" $logdev >> $seqres.full
 
 echo "+ mount image"
 _try_scratch_mount 2>/dev/null && _fail "mount should not succeed"
Reviewed-by on v1 16/24
#56 lore raw

Re: [PATCH 16/24] xfs/098: adapt to external log devices

Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Teach this test to deal with external log devices correctly.

---

Looks good to me,

Quoted 24 lines
 tests/xfs/098 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/xfs/098 +7 -1
index c63b9d60..b7d3253e 100755
@@ -76,7 +76,13 @@ echo "+ corrupt image"
 logstart="$(_scratch_xfs_get_sb_field logstart)"
 logstart="$(_scratch_xfs_db -c "convert fsblock ${logstart} byte" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
 logblocks="$(_scratch_xfs_get_sb_field logblocks)"
-$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" "${SCRATCH_DEV}" >> $seqres.full
+
+if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_LOGDEV" ]; then
+	logdev=$SCRATCH_LOGDEV
+else
+	logdev=$SCRATCH_DEV
+fi
+$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" $logdev >> $seqres.full
 
 echo "+ mount image"
 _try_scratch_mount 2>/dev/null && _fail "mount should not succeed"
#58 lore raw

PATCH 17/24 xfs: refactor _xfs_check calls to the scratch device

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use _scratch_xfs_check, not _xfs_check $SCRATCH_DEV.

---
 tests/xfs/291 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/291 +1 -1
index 8a4b1354..adef2536 100755
@@ -102,7 +102,7 @@ done
 _scratch_unmount
 # Can xfs_repair and xfs_check cope with this monster?
 _scratch_xfs_repair >> $seqres.full 2>&1 || _fail "xfs_repair failed"
-_xfs_check $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_check failed"
+_scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed"
 
 # Yes they can!  Now...
 # Can xfs_metadump cope with this monster?
Reviewed-by on v1 17/24
#59 lore raw

Re: [PATCH 17/24] xfs: refactor _xfs_check calls to the scratch device

Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use _scratch_xfs_check, not _xfs_check $SCRATCH_DEV.

---

Good to me,

Quoted 18 lines
 tests/xfs/291 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/291 +1 -1
index 8a4b1354..adef2536 100755
@@ -102,7 +102,7 @@ done
 _scratch_unmount
 # Can xfs_repair and xfs_check cope with this monster?
 _scratch_xfs_repair >> $seqres.full 2>&1 || _fail "xfs_repair failed"
-_xfs_check $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_check failed"
+_scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed"
 
 # Yes they can!  Now...
 # Can xfs_metadump cope with this monster?
#61 lore raw

Re: [PATCH 17/24] xfs: refactor _xfs_check calls to the scratch device

Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use _scratch_xfs_check, not _xfs_check $SCRATCH_DEV.

This looks ok:

But shouldn't we finally kill off all xfs_check alls instead? :)

I will some day, but I keep finding more bugs and missed stuff in xfs_repair. :(

--D

#62 lore raw

PATCH 18/24 xfs/291: fix open-coded repair call to mdrestore'd fs image

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Attach any external log devices to the open-coded repair call.

---
 tests/xfs/291 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/291 +3 -1
index adef2536..5d4f1ac4 100755
@@ -110,7 +110,9 @@ _scratch_metadump $tmp.metadump || _fail "xfs_metadump failed"
 xfs_mdrestore $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed"
 [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 	rt_repair_opts="-r $SCRATCH_RTDEV"
-$XFS_REPAIR_PROG $rt_repair_opts -f $tmp.img >> $seqres.full 2>&1 || \
+[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_LOGDEV" ] && \
+	log_repair_opts="-l $SCRATCH_LOGDEV"
+$XFS_REPAIR_PROG $rt_repair_opts $log_repair_opts -f $tmp.img >> $seqres.full 2>&1 || \
 	_fail "xfs_repair of metadump failed"
 
 # Yes it can; success, all done
Reviewed-by on v1 18/24
#63 lore raw

Re: [PATCH 18/24] xfs/291: fix open-coded repair call to mdrestore'd fs image

Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Attach any external log devices to the open-coded repair call.

---

Good to me,

Quoted 20 lines
 tests/xfs/291 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/291 +3 -1
index adef2536..5d4f1ac4 100755
@@ -110,7 +110,9 @@ _scratch_metadump $tmp.metadump || _fail "xfs_metadump failed"
 xfs_mdrestore $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed"
 [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
 	rt_repair_opts="-r $SCRATCH_RTDEV"
-$XFS_REPAIR_PROG $rt_repair_opts -f $tmp.img >> $seqres.full 2>&1 || \
+[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_LOGDEV" ] && \
+	log_repair_opts="-l $SCRATCH_LOGDEV"
+$XFS_REPAIR_PROG $rt_repair_opts $log_repair_opts -f $tmp.img >> $seqres.full 2>&1 || \
 	_fail "xfs_repair of metadump failed"
 
 # Yes it can; success, all done
#64 lore raw

PATCH 19/24 xfs/424: disable external devices

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test uses an open-coded call to mkfs, so we need to disable the external devices so that _scratch_xfs_db doesn't get confused. We also disable the post-check fsck because it's run by the parent ./check program, which won't know that we didn't use the external devices.

---
 tests/xfs/424 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/xfs/424 +7 -1
index 66d79458..4907cf0f 100755
@@ -47,7 +47,13 @@ rm -f $seqres.full
 # Modify as appropriate
 _supported_os Linux
 _supported_fs xfs
-_require_scratch
+
+# Since we have an open-coded mkfs call, disable the external devices and
+# don't let the post-check fsck actually run since it'll trip over us not
+# using the external devices.
+_require_scratch_nocheck
+export SCRATCH_LOGDEV=
+export SCRATCH_RTDEV=
 
 echo "Silence is golden."
 
Reviewed-by on v1 19/24
#65 lore raw

Re: [PATCH 19/24] xfs/424: disable external devices

Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test uses an open-coded call to mkfs, so we need to disable the external devices so that _scratch_xfs_db doesn't get confused. We also disable the post-check fsck because it's run by the parent ./check program, which won't know that we didn't use the external devices.

---

Good to me,

Quoted 24 lines
 tests/xfs/424 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/xfs/424 +7 -1
index 66d79458..4907cf0f 100755
@@ -47,7 +47,13 @@ rm -f $seqres.full
 # Modify as appropriate
 _supported_os Linux
 _supported_fs xfs
-_require_scratch
+
+# Since we have an open-coded mkfs call, disable the external devices and
+# don't let the post-check fsck actually run since it'll trip over us not
+# using the external devices.
+_require_scratch_nocheck
+export SCRATCH_LOGDEV=
+export SCRATCH_RTDEV=
 
 echo "Silence is golden."
 
Reviewed-by on v1 19/24
#66 lore raw

Re: [PATCH 19/24] xfs/424: disable external devices

In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This test uses an open-coded call to mkfs, so we need to disable the external devices so that _scratch_xfs_db doesn't get confused. We also disable the post-check fsck because it's run by the parent ./check program, which won't know that we didn't use the external devices.

Looks good,

#67 lore raw

PATCH 20/24 xfs/449: fix xfs info report output if realtime device specified

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Modify the mkfs.xfs output so that "realtime =/dev/XXX" becomes "realtime =external" so that the output will match xfs_db, which doesn't take a rt device argument and thus does not know.

---
 tests/xfs/449 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/449 +3 -1
index 83c3c493..938dbe28 100755
@@ -46,7 +46,9 @@ cat $tmp.mkfs >> $seqres.full
 _scratch_xfs_db -c "info" > $tmp.dbinfo
 echo DB >> $seqres.full
 cat $tmp.dbinfo >> $seqres.full
-diff -u $tmp.mkfs $tmp.dbinfo
+# xfs_db doesn't take a rtdev argument, so it reports "realtime=external".
+# mkfs does, so make a quick substitution
+diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external               extsz=/g') $tmp.dbinfo
 
 _scratch_mount
 
Reviewed-by on v1 20/24
#68 lore raw

Re: [PATCH 20/24] xfs/449: fix xfs info report output if realtime device specified

Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Modify the mkfs.xfs output so that "realtime =/dev/XXX" becomes "realtime =external" so that the output will match xfs_db, which doesn't take a rt device argument and thus does not know.

---

Good to me,

Quoted 20 lines
 tests/xfs/449 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/449 +3 -1
index 83c3c493..938dbe28 100755
@@ -46,7 +46,9 @@ cat $tmp.mkfs >> $seqres.full
 _scratch_xfs_db -c "info" > $tmp.dbinfo
 echo DB >> $seqres.full
 cat $tmp.dbinfo >> $seqres.full
-diff -u $tmp.mkfs $tmp.dbinfo
+# xfs_db doesn't take a rtdev argument, so it reports "realtime=external".
+# mkfs does, so make a quick substitution
+diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external               extsz=/g') $tmp.dbinfo
 
 _scratch_mount
 
Reviewed-by on v1 20/24
#69 lore raw

Re: [PATCH 20/24] xfs/449: fix xfs info report output if realtime device specified

In reply to Darrick J. Wong
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Modify the mkfs.xfs output so that "realtime =/dev/XXX" becomes "realtime =external" so that the output will match xfs_db, which doesn't take a rt device argument and thus does not know.

Looks good,

#70 lore raw

PATCH 21/24 common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generally speaking, tests that call _scratch_mkfs_sized are trying to constrain a test's run time by formatting a filesystem that's smaller than the device. The current helper does this for the scratch device, but it doesn't do this for the xfs realtime volume.

If fstests has been configured to create files on the realtime device by default ("-d rtinherit=1) then those tests that want to run with a small volume size will instead be running with a huge realtime device. This makes certain tests take forever to run, so apply the same sizing to the rt volume if one exists.

---
 common/rc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
common/rc +8 -2
index f78b1cfc..b2d45fa2 100644
@@ -976,14 +976,20 @@ _scratch_mkfs_sized()
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
 
+    if [ "$HOSTOS" == "Linux" ] && [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+	rt_ops="-r size=$fssize"
+    fi
+
     case $FSTYP in
     xfs)
 	# don't override MKFS_OPTIONS that set a block size.
 	echo $MKFS_OPTIONS |egrep -q "b?size="
 	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs -d size=$fssize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops
 	else
-		_scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
 	fi
 	;;
     ext2|ext3|ext4|ext4dev)
Reviewed-by on v1 21/24
#71 lore raw

Re: [PATCH 21/24] common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generally speaking, tests that call _scratch_mkfs_sized are trying to constrain a test's run time by formatting a filesystem that's smaller than the device. The current helper does this for the scratch device, but it doesn't do this for the xfs realtime volume.

Quoted 8 lines

If fstests has been configured to create files on the realtime device by default ("-d rtinherit=1) then those tests that want to run with a small volume size will instead be running with a huge realtime device. This makes certain tests take forever to run, so apply the same sizing to the rt volume if one exists.

---

Good to me,

Quoted 32 lines
 common/rc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
common/rc +8 -2
index f78b1cfc..b2d45fa2 100644
@@ -976,14 +976,20 @@ _scratch_mkfs_sized()
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
 
+    if [ "$HOSTOS" == "Linux" ] && [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+	rt_ops="-r size=$fssize"
+    fi
+
     case $FSTYP in
     xfs)
 	# don't override MKFS_OPTIONS that set a block size.
 	echo $MKFS_OPTIONS |egrep -q "b?size="
 	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs -d size=$fssize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops
 	else
-		_scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
 	fi
 	;;
     ext2|ext3|ext4|ext4dev)
Reviewed-by on v1 21/24
#72 lore raw

Re: [PATCH 21/24] common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume

In reply to Darrick J. Wong
Quoted 24 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generally speaking, tests that call _scratch_mkfs_sized are trying to constrain a test's run time by formatting a filesystem that's smaller than the device. The current helper does this for the scratch device, but it doesn't do this for the xfs realtime volume.

If fstests has been configured to create files on the realtime device by default ("-d rtinherit=1) then those tests that want to run with a small volume size will instead be running with a huge realtime device. This makes certain tests take forever to run, so apply the same sizing to the rt volume if one exists.

---
 common/rc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
common/rc +0 -0
index f78b1cfc..b2d45fa2 100644

common/rc _scratch_mkfs_sized() · line 983

Quoted 8 lines
common/rc +5 -0
@@ -976,14 +976,20 @@ _scratch_mkfs_sized()
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
 
+    if [ "$HOSTOS" == "Linux" ] && [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+	rt_ops="-r size=$fssize"
+    fi

The indentation here looks rather weird. I also don't think we need the HOSTOS check.

Otherwise looks good:

#73 lore raw

Re: [PATCH 21/24] common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume

Quoted 28 lines · Christoph Hellwig
Quoted 27 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generally speaking, tests that call _scratch_mkfs_sized are trying to constrain a test's run time by formatting a filesystem that's smaller than the device. The current helper does this for the scratch device, but it doesn't do this for the xfs realtime volume.

If fstests has been configured to create files on the realtime device by default ("-d rtinherit=1) then those tests that want to run with a small volume size will instead be running with a huge realtime device. This makes certain tests take forever to run, so apply the same sizing to the rt volume if one exists.

---
 common/rc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
common/rc +0 -0
index f78b1cfc..b2d45fa2 100644
@@ -976,14 +976,20 @@ _scratch_mkfs_sized()
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
 
Quoted 8 lines

common/rc _scratch_mkfs_sized() · line 983

Quoted 5 lines
common/rc +5 -0
+    if [ "$HOSTOS" == "Linux" ] && [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+	rt_ops="-r size=$fssize"
+    fi

The indentation here looks rather weird. I also don't think we need the HOSTOS check.

<nod> it's copy-pastaing the clause above it. I guess I could just send an indentation cleanup for that, since it's a bit fugly.

--D

Quoted 4 lines

Otherwise looks good:

#74 lore raw

PATCH v2 21/24 common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Generally speaking, tests that call _scratch_mkfs_sized are trying to constrain a test's run time by formatting a filesystem that's smaller than the device. The current helper does this for the scratch device, but it doesn't do this for the xfs realtime volume.

If fstests has been configured to create files on the realtime device by default ("-d rtinherit=1) then those tests that want to run with a small volume size will instead be running with a huge realtime device. This makes certain tests take forever to run, so apply the same sizing to the rt volume if one exists.

---
v2: don't bother with HOSTOS

---
 common/rc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
common/rc +8 -2
index 6366a7b2..b707db76 100644
@@ -997,14 +997,20 @@ _scratch_mkfs_sized()
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
 
+    if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+	rt_ops="-r size=$fssize"
+    fi
+
     case $FSTYP in
     xfs)
 	# don't override MKFS_OPTIONS that set a block size.
 	echo $MKFS_OPTIONS |egrep -q "b?size="
 	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs -d size=$fssize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops
 	else
-		_scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
+		_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
 	fi
 	;;
     ext2|ext3|ext4|ext4dev)
#75 lore raw

PATCH 22/24 xfs/141: run for longer with TIME_FACTOR

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Allow the test runner to run the crash loop in this test for longer by setting TIME_FACTOR. This has been useful for finding bugs in log recovery.

---
 tests/xfs/141 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/141 +3 -1
index 754ca37a..ef7210ff 100755
@@ -50,7 +50,8 @@ _scratch_mount
 
 sdev=$(_short_dev $SCRATCH_DEV)
 
-for i in $(seq 1 5); do
+nr_times=$((TIME_FACTOR * 5))
+while [ $nr_times -gt 0 ]; do
 	# Enable error injection. Use a random bad crc factor up to 100
 	# (increase this value to run fsstress longer).
 	factor=$((RANDOM % 100 + 1))
@@ -65,6 +66,7 @@ for i in $(seq 1 5); do
 	# write.
 	_scratch_unmount
 	_scratch_mount
+	nr_times=$((nr_times - 1))
 done
 
 # success, all done
Reviewed-by on v1 22/24
#76 lore raw

Re: [PATCH 22/24] xfs/141: run for longer with TIME_FACTOR

Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Allow the test runner to run the crash loop in this test for longer by setting TIME_FACTOR. This has been useful for finding bugs in log recovery.

---

Good to me,

Quoted 27 lines
 tests/xfs/141 |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/xfs/141 +3 -1
index 754ca37a..ef7210ff 100755
@@ -50,7 +50,8 @@ _scratch_mount
 
 sdev=$(_short_dev $SCRATCH_DEV)
 
-for i in $(seq 1 5); do
+nr_times=$((TIME_FACTOR * 5))
+while [ $nr_times -gt 0 ]; do
 	# Enable error injection. Use a random bad crc factor up to 100
 	# (increase this value to run fsstress longer).
 	factor=$((RANDOM % 100 + 1))
@@ -65,6 +66,7 @@ for i in $(seq 1 5); do
 	# write.
 	_scratch_unmount
 	_scratch_mount
+	nr_times=$((nr_times - 1))
 done
 
 # success, all done
#78 lore raw

PATCH 23/24 generic/204: sync before scrub hits EIO

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Let's see if we can prevent fs corruption warnings by flushing dirty data to disk before the test ends.

---
 tests/generic/204 |    1 +
 1 file changed, 1 insertion(+)
tests/generic/204 +1 -0
index 7250c00a..22d6fed5 100755
@@ -18,6 +18,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	rm -f $tmp.*
+	sync
 }
 
 # get standard environment, filters and checks
Reviewed-by on v1 23/24
#79 lore raw

Re: [PATCH 23/24] generic/204: sync before scrub hits EIO

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Let's see if we can prevent fs corruption warnings by flushing dirty data to disk before the test ends.

---

At least it won't break more things:)

Quoted 17 lines
 tests/generic/204 |    1 +
 1 file changed, 1 insertion(+)
tests/generic/204 +1 -0
index 7250c00a..22d6fed5 100755
@@ -18,6 +18,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	rm -f $tmp.*
+	sync
 }
 
 # get standard environment, filters and checks
#81 lore raw

PATCH 24/24 check: try reloading modules

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Optionally reload the module between each test to try to pinpoint slab cache errors and whatnot.

---
 README |    3 +++
 check  |    9 +++++++++
 2 files changed, 12 insertions(+)
README +3 -0
index d0e23fcd..4af331b4 100644
@@ -106,6 +106,9 @@ Preparing system for tests:
              - set USE_KMEMLEAK=yes to scan for memory leaks in the kernel
                after every test, if the kernel supports kmemleak.
              - set KEEP_DMESG=yes to keep dmesg log after test
+             - Set TEST_FS_MODULE_RELOAD=1 to unload the module and reload
+               it between test invocations.  This assumes that the name of
+               the module is the same as FSTYP.
 
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
check +9 -0
index 5ffa8777..29306262 100755
@@ -810,6 +810,15 @@ function run_section()
 			_check_dmesg || err=true
 		fi
 
+		# Reload the module after each test to check for leaks or
+		# other problems.
+		if [ -n "${TEST_FS_MODULE_RELOAD}" ]; then
+			_test_unmount 2> /dev/null
+			_scratch_unmount 2> /dev/null
+			modprobe -r $FSTYP
+			modprobe $FSTYP
+		fi
+
 		# Scan for memory leaks after every test so that associating
 		# a leak to a particular test will be as accurate as possible.
 		_check_kmemleak || err=true
#82 lore raw

Re: [PATCH 24/24] check: try reloading modules

Quoted 32 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Optionally reload the module between each test to try to pinpoint slab cache errors and whatnot.

---
 README |    3 +++
 check  |    9 +++++++++
 2 files changed, 12 insertions(+)
README +3 -0
index d0e23fcd..4af331b4 100644
@@ -106,6 +106,9 @@ Preparing system for tests:
              - set USE_KMEMLEAK=yes to scan for memory leaks in the kernel
                after every test, if the kernel supports kmemleak.
              - set KEEP_DMESG=yes to keep dmesg log after test
+             - Set TEST_FS_MODULE_RELOAD=1 to unload the module and reload
+               it between test invocations.  This assumes that the name of
+               the module is the same as FSTYP.
 
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
check +0 -0
index 5ffa8777..29306262 100755

check function run_section() · line 819

Quoted 10 lines
check +7 -0
@@ -810,6 +810,15 @@ function run_section()
                        _check_dmesg || err=true
                fi
 
+               # Reload the module after each test to check for leaks or
+               # other problems.
+               if [ -n "${TEST_FS_MODULE_RELOAD}" ]; then
+                       _test_unmount 2> /dev/null
+                       _scratch_unmount 2> /dev/null
+                       modprobe -r $FSTYP
+                       modprobe $FSTYP

It is safer to use fs-$FSTYP namespaced module alias.

Thanks,
Amir.

#83 lore raw

[PATCH 27/24] common/rc: fix indentation in _scratch_mkfs_sized

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Fix the weird indentation in _scratch_mkfs_sized.

---
 common/rc |  205 ++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 102 insertions(+), 103 deletions(-)
common/rc +102 -103
index 3adeeefe..94936a8e 100644
@@ -956,116 +956,115 @@ _available_memory_bytes()
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
 {
-    local fssize=$1
-    local blocksize=$2
-    local def_blksz
+	local fssize=$1
+	local blocksize=$2
+	local def_blksz
 
-    case $FSTYP in
-    xfs)
-	def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
-	;;
-    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|reiserfs)
-	def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
-	;;
-    jfs)
-	def_blksz=4096
-	;;
-    esac
+	case $FSTYP in
+	xfs)
+		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
+		;;
+	ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|reiserfs)
+		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
+		;;
+	jfs)
+		def_blksz=4096
+		;;
+	esac
 
-    [ -n "$def_blksz" ] && blocksize=$def_blksz
-    [ -z "$blocksize" ] && blocksize=4096
+	[ -n "$def_blksz" ] && blocksize=$def_blksz
+	[ -z "$blocksize" ] && blocksize=4096
 
+	local re='^[0-9]+$'
+	if ! [[ $fssize =~ $re ]] ; then
+		_notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
+	fi
+	if ! [[ $blocksize =~ $re ]] ; then
+		_notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+	fi
 
-    local re='^[0-9]+$'
-    if ! [[ $fssize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
-    fi
-    if ! [[ $blocksize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
-    fi
-
-    local blocks=`expr $fssize / $blocksize`
-
-    if [ -b "$SCRATCH_DEV" ]; then
-	local devsize=`blockdev --getsize64 $SCRATCH_DEV`
-	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
-    fi
-
-    if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
-	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
-	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
-	rt_ops="-r size=$fssize"
-    fi
+	local blocks=`expr $fssize / $blocksize`
 
-    case $FSTYP in
-    xfs)
-	# don't override MKFS_OPTIONS that set a block size.
-	echo $MKFS_OPTIONS |egrep -q "b?size="
-	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs -d size=$fssize $rt_ops
-	else
-		_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
-	fi
-	;;
-    ext2|ext3|ext4|ext4dev)
-	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    gfs2)
-	# mkfs.gfs2 doesn't automatically shrink journal files on small
-	# filesystems, so the journal files may end up being bigger than the
-	# filesystem, which will cause mkfs.gfs2 to fail.  Until that's fixed,
-	# shrink the journal size to at most one eigth of the filesystem and at
-	# least 8 MiB, the minimum size allowed.
-	local min_journal_size=8
-	local default_journal_size=128
-	if (( fssize/8 / (1024*1024) < default_journal_size )); then
-	    local journal_size=$(( fssize/8 / (1024*1024) ))
-	    (( journal_size >= min_journal_size )) || journal_size=$min_journal_size
-	    MKFS_OPTIONS="-J $journal_size $MKFS_OPTIONS"
+	if [ -b "$SCRATCH_DEV" ]; then
+		local devsize=`blockdev --getsize64 $SCRATCH_DEV`
+		[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
 	fi
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    ocfs2)
-	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    udf)
-	$MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    btrfs)
-	local mixed_opt=
-	# minimum size that's needed without the mixed option.
-	# Ref: btrfs-prog: btrfs_min_dev_size()
-	# Non mixed mode is also the default option.
-	(( fssize < $((256 * 1024 *1024)) )) && mixed_opt='--mixed'
-	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
-	;;
-    jfs)
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
-	;;
-    reiserfs)
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    reiser4)
-	# mkfs.resier4 requires size in KB as input for creating filesystem
-	$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
-			   `expr $fssize / 1024`
-	;;
-    f2fs)
-	# mkfs.f2fs requires # of sectors as an input for the size
-	local sector_size=`blockdev --getss $SCRATCH_DEV`
-	$MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size`
-	;;
-    tmpfs)
-	local free_mem=`_free_memory_bytes`
-	if [ "$free_mem" -lt "$fssize" ] ; then
-	   _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes"
+
+	if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+		local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+		[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+		rt_ops="-r size=$fssize"
 	fi
-	export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
-	;;
-    *)
-	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
-	;;
-    esac
+
+	case $FSTYP in
+	xfs)
+		# don't override MKFS_OPTIONS that set a block size.
+		echo $MKFS_OPTIONS |egrep -q "b?size="
+		if [ $? -eq 0 ]; then
+			_scratch_mkfs_xfs -d size=$fssize $rt_ops
+		else
+			_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
+		fi
+		;;
+	ext2|ext3|ext4|ext4dev)
+		${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	gfs2)
+		# mkfs.gfs2 doesn't automatically shrink journal files on small
+		# filesystems, so the journal files may end up being bigger than the
+		# filesystem, which will cause mkfs.gfs2 to fail.  Until that's fixed,
+		# shrink the journal size to at most one eigth of the filesystem and at
+		# least 8 MiB, the minimum size allowed.
+		local min_journal_size=8
+		local default_journal_size=128
+		if (( fssize/8 / (1024*1024) < default_journal_size )); then
+			local journal_size=$(( fssize/8 / (1024*1024) ))
+			(( journal_size >= min_journal_size )) || journal_size=$min_journal_size
+			MKFS_OPTIONS="-J $journal_size $MKFS_OPTIONS"
+		fi
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	ocfs2)
+		yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	udf)
+		$MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	btrfs)
+		local mixed_opt=
+		# minimum size that's needed without the mixed option.
+		# Ref: btrfs-prog: btrfs_min_dev_size()
+		# Non mixed mode is also the default option.
+		(( fssize < $((256 * 1024 *1024)) )) && mixed_opt='--mixed'
+		$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
+		;;
+	jfs)
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
+		;;
+	reiserfs)
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	reiser4)
+		# mkfs.resier4 requires size in KB as input for creating filesystem
+		$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
+				   `expr $fssize / 1024`
+		;;
+	f2fs)
+		# mkfs.f2fs requires # of sectors as an input for the size
+		local sector_size=`blockdev --getss $SCRATCH_DEV`
+		$MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size`
+		;;
+	tmpfs)
+		local free_mem=`_free_memory_bytes`
+		if [ "$free_mem" -lt "$fssize" ] ; then
+		   _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes"
+		fi
+		export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
+		;;
+	*)
+		_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
+		;;
+	esac
 }
 
 # Emulate an N-data-disk stripe w/ various stripe units
#85 lore raw

[PATCH 26/24] common: drop HOSTOS

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

We effectively support only Linux these days, so drop most of the special casing of HOSTOS. We'll retain the simple check just in case someone tries to run this on a different operating system.

---
 common/config |   50 ++++++++++++++++++++++----------------------------
 common/rc     |   20 ++------------------
 common/xfs    |    2 +-
 3 files changed, 25 insertions(+), 47 deletions(-)
common/config +22 -28
index 1fe1e0e1..3de87ea7 100644
@@ -46,7 +46,7 @@ export LC_ALL=C
 PATH=".:$PATH"
 
 export HOST=`hostname -s`
-export HOSTOS=`uname -s`
+test `uname -s` = "Linux" || _fatal "fstests only supports Linux"
 
 export MODULAR=0               # using XFS as a module or not
 export BOOT="/boot"            # install target for kernels
@@ -143,7 +143,7 @@ export PS_ALL_FLAGS="-ef"
 
 export DF_PROG="$(type -P df)"
 [ "$DF_PROG" = "" ] && _fatal "df not found"
-[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T -P"
+export DF_PROG="$DF_PROG -T -P"	# Linux
 
 export XFS_IO_PROG="$(type -P xfs_io)"
 [ "$XFS_IO_PROG" = "" ] && _fatal "xfs_io not found"
@@ -242,29 +242,25 @@ if [ "$UDEV_SETTLE_PROG" == "" ]; then
 fi
 export UDEV_SETTLE_PROG
 
-case "$HOSTOS" in
-    Linux)
-	export MKFS_XFS_PROG=$(type -P mkfs.xfs)
-	export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
-	export MKFS_UDF_PROG=$(type -P mkudffs)
-	export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
-	export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
-	export DUMP_F2FS_PROG=$(type -P dump.f2fs)
-	export F2FS_IO_PROG=$(type -P f2fs_io)
-	export BTRFS_UTIL_PROG=$(type -P btrfs)
-	export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
-	export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
-	export BTRFS_TUNE_PROG=$(type -P btrfstune)
-	export XFS_FSR_PROG=$(type -P xfs_fsr)
-	export MKFS_NFS_PROG="false"
-	export MKFS_CIFS_PROG="false"
-	export MKFS_OVERLAY_PROG="false"
-	export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
-	export E2FSCK_PROG=$(type -P e2fsck)
-	export TUNE2FS_PROG=$(type -P tune2fs)
-	export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
-        ;;
-esac
+export MKFS_XFS_PROG=$(type -P mkfs.xfs)
+export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
+export MKFS_UDF_PROG=$(type -P mkudffs)
+export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
+export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
+export DUMP_F2FS_PROG=$(type -P dump.f2fs)
+export F2FS_IO_PROG=$(type -P f2fs_io)
+export BTRFS_UTIL_PROG=$(type -P btrfs)
+export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
+export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
+export BTRFS_TUNE_PROG=$(type -P btrfstune)
+export XFS_FSR_PROG=$(type -P xfs_fsr)
+export MKFS_NFS_PROG="false"
+export MKFS_CIFS_PROG="false"
+export MKFS_OVERLAY_PROG="false"
+export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
+export E2FSCK_PROG=$(type -P e2fsck)
+export TUNE2FS_PROG=$(type -P tune2fs)
+export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
 
 # SELinux adds extra xattrs which can mess up our expected output.
 # So, mount with a context, and they won't be created.
@@ -753,9 +749,7 @@ if [ -z "$CONFIG_INCLUDED" ]; then
 
 	# Autodetect fs type based on what's on $TEST_DEV unless it's been set
 	# externally
-	if [ -z "$FSTYP" ] && \
-	   [ "$HOSTOS" == "Linux" -o "$OSTYPE" == "linux-gnu" ] && \
-	   [ ! -z "$TEST_DEV" ]; then
+	if [ -z "$FSTYP" ] && [ ! -z "$TEST_DEV" ]; then
 		FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
 	fi
 	FSTYP=${FSTYP:=xfs}
common/rc +2 -18
index bbafc73d..3adeeefe 100644
@@ -49,19 +49,13 @@ _math()
 
 dd()
 {
-   if [ "$HOSTOS" == "Linux" ]
-   then	
 	command dd --help 2>&1 | grep noxfer >/dev/null
-	
 	if [ "$?" -eq 0 ]
 	    then
 		command dd status=noxfer $@
 	    else
 		command dd $@
-    	fi
-   else
-	command dd $@
-   fi
+	fi
 }
 
 # Prints the md5 checksum of a given file
@@ -992,7 +986,7 @@ _scratch_mkfs_sized()
 
     local blocks=`expr $fssize / $blocksize`
 
-    if [ "$HOSTOS" == "Linux" -a -b "$SCRATCH_DEV" ]; then
+    if [ -b "$SCRATCH_DEV" ]; then
 	local devsize=`blockdev --getsize64 $SCRATCH_DEV`
 	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
     fi
@@ -1764,11 +1758,6 @@ _require_logdev()
 #
 _require_loop()
 {
-    if [ "$HOSTOS" != "Linux" ]
-    then
-	_notrun "This test requires linux for loopback device support"
-    fi
-
     modprobe loop >/dev/null 2>&1
     if grep loop /proc/devices >/dev/null 2>&1
     then
@@ -1782,11 +1771,6 @@ _require_loop()
 #
 _require_ext2()
 {
-    if [ "$HOSTOS" != "Linux" ]
-    then
-	_notrun "This test requires linux for ext2 filesystem support"
-    fi
-
     modprobe ext2 >/dev/null 2>&1
     if grep ext2 /proc/filesystems >/dev/null 2>&1
     then
common/xfs +1 -1
index 8a3fd30c..0f4b8521 100644
@@ -481,7 +481,7 @@ _check_xfs_filesystem()
 
 	$XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
 		| tee $tmp.logprint | grep -q "<CLEAN>"
-	if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]; then
+	if [ $? -ne 0 ]; then
 		_log_err "_check_xfs_filesystem: filesystem on $device has dirty log"
 		echo "*** xfs_logprint -t output ***"	>>$seqres.full
 		cat $tmp.logprint			>>$seqres.full

A message that is not in the archive (sent off-list or not yet received): 20200918020936.GJ7954@magnolia