Skip to contentSkip to conversation

common: implement _require_xfs_io_command "open"

PATCH New Amir Goldstein 1 participant 2 messages Dec 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 common: implement _require_xfs_io_command "open"

-c "open $f" is broken in xfs_io <= 4.8. Using it results in an endless loop and xfs_io exists with error EMFILE.

A fix for that bug makes "open" a 'one shot' command. Along with this fix, a new -C flag was introduced to explicitly request to execute a one shot command.

Check for -C flag support as an indication that -c "open $f" is not broken.

---
 common/rc | 8 ++++++++
 1 file changed, 8 insertions(+)
common/rc +8 -0
index 2719b23..cd2e8eb 100644
@@ -1757,6 +1757,14 @@ _require_xfs_io_command()
 		echo $testio | egrep -q "Inappropriate ioctl" && \
 			_notrun "xfs_io $command support is missing"
 		;;
+	"open")
+		# -c "open $f" is broken in xfs_io <= 4.8. Along with the fix,
+		# a new -C flag was introduced to execute one shot commands.
+		# Check for -C flag support as an indication for the bug fix.
+		testio=`$XFS_IO_PROG -F -f -C "open $testfile" $testfile 2>&1`
+		echo $testio | egrep -q "invalid option" && \
+			_notrun "xfs_io $command support is missing"
+		;;
 	*)
 		testio=`$XFS_IO_PROG -c "$command help" 2>&1`
 	esac
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 overlay/016: use xfs_io -C for executing commands

This test requires a fix to xfs_io to support
-C one shot commands and -c "open foo" command.

---
 tests/overlay/016     | 27 +++++++++++++--------------
 tests/overlay/016.out | 11 +++++------
 2 files changed, 18 insertions(+), 20 deletions(-)
tests/overlay/016 +13 -14
index 6d3e339..041ab3d 100755
@@ -50,6 +50,7 @@ _cleanup()
 _supported_fs overlay
 _supported_os Linux
 _require_scratch
+_require_xfs_io_command "open"
 
 rm -f $seqres.full
 
@@ -72,13 +73,12 @@ cd $SCRATCH_MNT
 # write to rwfd
 # read from rofd
 #
-$XFS_IO_PROG << EOF | _filter_xfs_io
-open -r foo
-open foo
-pwrite -S 0x61 0 16
-file 0
-pread -v 0 16
-EOF
+$XFS_IO_PROG -r foo \
+	-C "open foo" \
+	-C "pwrite -S 0x61 0 16" \
+	-C "file 0" \
+	-C "pread -v 0 16" \
+| _filter_xfs_io
 
 #
 # case #2:
@@ -86,13 +86,12 @@ EOF
 # write to rwfd
 # read from mapped memory
 #
-$XFS_IO_PROG << EOF | _filter_xfs_io
-open -r bar
-mmap -r 0 16
-open bar
-pwrite -S 0x61 0 16
-mread -v 0 16
-EOF
+$XFS_IO_PROG -r bar \
+	-C "mmap -r 0 16" \
+	-C "open bar" \
+	-C "pwrite -S 0x61 0 16" \
+	-C "mread -v 0 16" \
+| _filter_xfs_io
 
 status=0
 exit
tests/overlay/016.out +5 -6
index 52b8cd7..c49f8dc 100644
@@ -1,12 +1,11 @@
 QA output created by 016
-xfs_io> xfs_io> xfs_io> wrote 16/16 bytes at offset 0
+wrote 16/16 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-xfs_io> [000] foo            (foreign,non-sync,non-direct,read-only)
+[000] foo            (foreign,non-sync,non-direct,read-only)
  001  foo            (foreign,non-sync,non-direct,read-write)
-xfs_io> 00000000:  61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61  aaaaaaaaaaaaaaaa
+00000000:  61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61  aaaaaaaaaaaaaaaa
 read 16/16 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-xfs_io> xfs_io> xfs_io> xfs_io> xfs_io> wrote 16/16 bytes at offset 0
+wrote 16/16 bytes at offset 0
 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-xfs_io> 00000000:  61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61  aaaaaaaaaaaaaaaa
-xfs_io> 
\ No newline at end of file
+00000000:  61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61  aaaaaaaaaaaaaaaa
Signature · 1 line
2.7.4