diff mbox

[v4,1/3] Check pwrite parameters

Message ID 20171207160044.8913-1-rgoldwyn@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Goldwyn Rodrigues Dec. 7, 2017, 4 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

There are some parameters added with xfs_io. Check if the pwrite
parameters are available. For some cases, xfs_io now returns "command
-%c not supported", so added "not supported" to count as error.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Changes since v3:
 - pwrite -N check to add -V parameters to check on pwritev2()

---
 common/rc | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/common/rc b/common/rc
index 4c053a53..4f4b9e10 100644
--- a/common/rc
+++ b/common/rc
@@ -2035,6 +2035,7 @@  _require_xfs_io_command()
 	shift
 	local param="$*"
 	local param_checked=0
+	local opts=""
 
 	testfile=$TEST_DIR/$$.xfs_io
 	case $command in
@@ -2079,6 +2080,17 @@  _require_xfs_io_command()
 		echo $testio | grep -q "invalid option" && \
 			_notrun "xfs_io $command support is missing"
 		;;
+	"pwrite")
+		# -N (RWF_NOWAIT) only works with direct I/O writes
+		local pwrite_opts=" "
+		if [ "$param" == "-N" ]; then
+			opts+=" -d"
+			pwrite_opts+="-V 1 -b 4k"
+		fi
+		testio=`$XFS_IO_PROG -f $opts -c \
+		        "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`
+		param_checked=1
+		;;
 	"scrub"|"repair")
 		testio=`$XFS_IO_PROG -x -c "$command probe 0" $TEST_DIR 2>&1`
 		echo $testio | grep -q "Inappropriate ioctl" && \
@@ -2109,7 +2121,9 @@  _require_xfs_io_command()
 		$XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
 			_notrun "xfs_io $command doesn't support $param"
 	else
-		echo $testio | grep -q "invalid option" && \
+		# xfs_io could result in "command %c not supported" if it was
+		# built on kernels not supporting pwritev2() calls
+		echo $testio | grep -q "\(invalid option\|not supported\)" && \
 			_notrun "xfs_io $command doesn't support $param"
 	fi
 }