Skip to contentSkip to conversation

tiny fixes for xfstests

PATCH Superseded Hou Tao 3 participants 12 messages Dec 29, 2018 – Jan 4, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Hou Tao

author
#0 lore raw

cover tiny fixes for xfstests

Hou Tao (5):
check: use _try_scratch_mount instead of _scratch_mount to mount
SCRATCH_DEV
generic/019: check scratch device is a block device or not generic/131: wait until the server is ready generic/466: explicitly request $SCRATCH_DEV to be a block device
fsx: check ENOSYS in test_copy_range()

 check             |  2 +-
 ltp/fsx.c         |  2 +-
 tests/generic/019 |  1 +
 tests/generic/131 | 19 +++++++++++++------
 tests/generic/466 |  1 +
 5 files changed, 17 insertions(+), 8 deletions(-)
Signature · 1 line
2.16.2.dirty
author
#1 lore raw

PATCH 1/5 check: use _try_scratch_mount instead of _scratch_mount to mount SCRATCH_DEV

Else there won't be any error messages when mounting SCRATCH_DEV failed, because _scratch_mount exits early by invoking _fail.

---
 check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check +1 -1
index e85f40ac..e4d76737 100755
@@ -607,7 +607,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
 
 	  # call the overridden mount - make sure the FS mounts with
 	  # the same options that we'll mount with later.
-	  if ! _scratch_mount >$tmp.err 2>&1
+	  if ! _try_scratch_mount >$tmp.err 2>&1
 	  then
 	      echo "our local mount routine ..."
 	      cat $tmp.err
Signature · 1 line
2.16.2.dirty
author
#2 lore raw

PATCH 2/5 generic/019: check scratch device is a block device or not

In reply to Hou Tao

To ensure "blockdev --getsz $SCRATCH_DEV" will succeed.

---
 tests/generic/019 | 1 +
 1 file changed, 1 insertion(+)
tests/generic/019 +1 -0
index 32db36fc..8e1c9331 100755
@@ -22,6 +22,7 @@ status=1	# failure is the default!
 _supported_fs generic
 _supported_os Linux
 _require_scratch
+_require_block_device $SCRATCH_DEV
 _require_fail_make_request
 
 SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
Signature · 1 line
2.16.2.dirty
author
#3 lore raw

PATCH 3/5 generic/131: wait until the server is ready

In reply to Hou Tao

When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early.

Fix it by repeatedly checking the readiness signal until it's found, or the server exits.

---
 tests/generic/131 | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
tests/generic/131 +13 -6
index d7c146ae..1af86e77 100755
@@ -37,13 +37,20 @@ TESTFILE=$TEST_DIR/lock_file
 src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out &
 locktest_pid1=$!
 
-sleep 1
+while true; do
+	sleep 1
 
-PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
-if [ -z $PORT ]; then
-	echo "Could not get server port"
-	exit 1
-fi
+	PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
+	if [ -n "$PORT" ]; then
+		break
+	fi
+
+	# check the existence of server process
+	if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then
+		echo "Could not get server port"
+		exit 1
+	fi
+done
 
 # Start the client
 src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out
Signature · 1 line
2.16.2.dirty
#4 lore raw

Re: [PATCH 3/5] generic/131: wait until the server is ready

Quoted 17 lines · Hou Tao

When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early.

Fix it by repeatedly checking the readiness signal until it's found, or the server exits.

---
 tests/generic/131 | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
tests/generic/131 +0 -0
index d7c146ae..1af86e77 100755

tests/generic/131 TESTFILE=$TEST_DIR/lock_file · line 41

Quoted 6 lines
tests/generic/131 +2 -1
@@ -37,13 +37,20 @@ TESTFILE=$TEST_DIR/lock_file
 src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out &
 locktest_pid1=$!
 
-sleep 1
+while true; do
+	sleep 1

Looks like we'll loop forever if the locktest process is there but fails to print out the server port due to random reasons.

I think it's better to retry N times and give up if the server is still not ready.

Thanks,
Eryu

Quoted 23 lines
tests/generic/131 +11 -5
-PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
-if [ -z $PORT ]; then
-	echo "Could not get server port"
-	exit 1
-fi
+	PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
+	if [ -n "$PORT" ]; then
+		break
+	fi
+
+	# check the existence of server process
+	if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then
+		echo "Could not get server port"
+		exit 1
+	fi
+done
 
 # Start the client
 src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out
Signature · 1 line
2.16.2.dirty
author
#5 lore raw

Re: [PATCH 3/5] generic/131: wait until the server is ready

Hi,

Quoted 28 lines · Eryu Guan
Quoted 17 lines · Hou Tao

When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early.

Fix it by repeatedly checking the readiness signal until it's found, or the server exits.

---
 tests/generic/131 | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
tests/generic/131 +0 -0
index d7c146ae..1af86e77 100755

tests/generic/131 TESTFILE=$TEST_DIR/lock_file · line 41

Quoted 6 lines
tests/generic/131 +2 -1
@@ -37,13 +37,20 @@ TESTFILE=$TEST_DIR/lock_file
 src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out &
 locktest_pid1=$!
 
-sleep 1
+while true; do
+	sleep 1

Looks like we'll loop forever if the locktest process is there but fails to print out the server port due to random reasons.

Quoted 3 lines

I think it's better to retry N times and give up if the server is still not ready.

Thanks for your suggestion, will send v2 soon.

Quoted 28 lines

Thanks,
Eryu

Quoted 23 lines
tests/generic/131 +11 -5
-PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
-if [ -z $PORT ]; then
-	echo "Could not get server port"
-	exit 1
-fi
+	PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
+	if [ -n "$PORT" ]; then
+		break
+	fi
+
+	# check the existence of server process
+	if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then
+		echo "Could not get server port"
+		exit 1
+	fi
+done
 
 # Start the client
 src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out
Signature · 1 line
2.16.2.dirty
author
#6 lore raw

PATCH 4/5 generic/466: explicitly request $SCRATCH_DEV to be a block device

In reply to Hou Tao

so "blockdev --getsize64 $SCRATCH_DEV" will succeed.

---
 tests/generic/466 | 1 +
 1 file changed, 1 insertion(+)
tests/generic/466 +1 -0
index bc577df7..8168b5be 100755
@@ -29,6 +29,7 @@ _cleanup()
 _supported_os Linux
 _supported_fs generic
 _require_scratch_nocheck
+_require_block_device $SCRATCH_DEV
 
 rm -f $seqres.full
 
Signature · 1 line
2.16.2.dirty
author
#7 lore raw

PATCH 5/5 fsx: check ENOSYS in test_copy_range()

In reply to Hou Tao

In configure script, we only check whether or not the build of copy-range test program is successful, but that doesn't mean the kernel has implemented the syscall, so checking for this case.

---
 ltp/fsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ltp/fsx.c +1 -1
index 316f08eb..b84180f7 100644
@@ -1583,7 +1583,7 @@ test_copy_range(void)
 	loff_t o1 = 0, o2 = 0;
 
 	if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 0, 0) == -1 &&
-	    (errno == EOPNOTSUPP || errno == ENOTTY)) {
+	    (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {
 		if (!quiet)
 			fprintf(stderr,
 				"main: filesystem does not support "
Signature · 1 line
2.16.2.dirty
#8 lore raw

Re: [PATCH 5/5] fsx: check ENOSYS in test_copy_range()

Quoted 15 lines · Hou Tao

In configure script, we only check whether or not the build of copy-range test program is successful, but that doesn't mean the kernel has implemented the syscall, so checking for this case.

---
 ltp/fsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ltp/fsx.c +0 -0
index 316f08eb..b84180f7 100644

ltp/fsx.c test_copy_range(void) · line 1586

Quoted 5 lines
ltp/fsx.c +1 -1
@@ -1583,7 +1583,7 @@ test_copy_range(void)
 	loff_t o1 = 0, o2 = 0;
 
 	if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 0, 0) == -1 &&
-	    (errno == EOPNOTSUPP || errno == ENOTTY)) {
+	    (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {

Should we also check for ENOSYS in other operations like {clone,dedupe}_range and fallocate?

Other fixes look good to me, thanks a lot for the fixes!

Thanks,
Eryu

Quoted 6 lines
ltp/fsx.c +0 -0
 		if (!quiet)
 			fprintf(stderr,
 				"main: filesystem does not support "
Signature · 1 line
2.16.2.dirty
#9 lore raw

Re: [PATCH 5/5] fsx: check ENOSYS in test_copy_range()

Quoted 18 lines · Eryu Guan
Quoted 17 lines · Hou Tao

In configure script, we only check whether or not the build of copy-range test program is successful, but that doesn't mean the kernel has implemented the syscall, so checking for this case.

---
 ltp/fsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ltp/fsx.c +0 -0
index 316f08eb..b84180f7 100644
@@ -1583,7 +1583,7 @@ test_copy_range(void)
 	loff_t o1 = 0, o2 = 0;
 
Quoted 6 lines

ltp/fsx.c test_copy_range(void) · line 1586

Quoted 3 lines
ltp/fsx.c +1 -1
 	if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 0, 0) == -1 &&
-	    (errno == EOPNOTSUPP || errno == ENOTTY)) {
+	    (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {

Should we also check for ENOSYS in other operations like {clone,dedupe}_range

Unimplemented ioctls usually return EOPNOTSUPP or ENOTTY, not ENOSYS, so I don't think that's necessary.... unless there are kernels that don't implement the ioctl syscall?

In any case, the manpage for clone and dedupe don't say anything about returning ENOSYS.

Quoted 1 line

and fallocate?

Yes.

--D

Quoted 11 lines

Other fixes look good to me, thanks a lot for the fixes!

Thanks,
Eryu

Quoted 6 lines
ltp/fsx.c +0 -0
 		if (!quiet)
 			fprintf(stderr,
 				"main: filesystem does not support "
Signature · 1 line
2.16.2.dirty
author
#10 lore raw

Re: [PATCH 5/5] fsx: check ENOSYS in test_copy_range()

Hi,

Quoted 26 lines · Darrick J. Wong
Quoted 18 lines · Eryu Guan
Quoted 17 lines · Hou Tao

In configure script, we only check whether or not the build of copy-range test program is successful, but that doesn't mean the kernel has implemented the syscall, so checking for this case.

---
 ltp/fsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ltp/fsx.c +0 -0
index 316f08eb..b84180f7 100644
@@ -1583,7 +1583,7 @@ test_copy_range(void)
 	loff_t o1 = 0, o2 = 0;
 
Quoted 6 lines

ltp/fsx.c test_copy_range(void) · line 1586

Quoted 3 lines
ltp/fsx.c +1 -1
 	if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 0, 0) == -1 &&
-	    (errno == EOPNOTSUPP || errno == ENOTTY)) {
+	    (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {

Should we also check for ENOSYS in other operations like {clone,dedupe}_range

Quoted 9 lines

Unimplemented ioctls usually return EOPNOTSUPP or ENOTTY, not ENOSYS, so I don't think that's necessary.... unless there are kernels that don't implement the ioctl syscall?

In any case, the manpage for clone and dedupe don't say anything about returning ENOSYS.

Quoted 2 lines

and fallocate?
Yes.

I will send a v2 to also check test_fallocate(), and thanks for your review.

Quoted 16 lines

--D

Quoted 11 lines

Other fixes look good to me, thanks a lot for the fixes!

Thanks,
Eryu

Quoted 6 lines
ltp/fsx.c +0 -0
 		if (!quiet)
 			fprintf(stderr,
 				"main: filesystem does not support "
Signature · 1 line
2.16.2.dirty
Reviewed-by on v1 5/5
#11 lore raw

Re: [PATCH 5/5] fsx: check ENOSYS in test_copy_range()

In reply to Hou Tao
Quoted 6 lines · Hou Tao

In configure script, we only check whether or not the build of copy-range test program is successful, but that doesn't mean the kernel has implemented the syscall, so checking for this case.

Err, oops. Thanks for catching that!

--D

Quoted 20 lines
---
 ltp/fsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ltp/fsx.c +1 -1
index 316f08eb..b84180f7 100644
@@ -1583,7 +1583,7 @@ test_copy_range(void)
 	loff_t o1 = 0, o2 = 0;
 
 	if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 0, 0) == -1 &&
-	    (errno == EOPNOTSUPP || errno == ENOTTY)) {
+	    (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {
 		if (!quiet)
 			fprintf(stderr,
 				"main: filesystem does not support "
Signature · 1 line
2.16.2.dirty