common/rc: Check pwrite parameters in _require_xfs_io_command
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Thu, 7 Dec 2017 16:00:42 +0000 (10:00 -0600)
committerEryu Guan <eguan@redhat.com>
Thu, 14 Dec 2017 04:39:57 +0000 (12:39 +0800)
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>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc

index cbd37e795c7f6a665ccb2915f181e6a109919b1a..c7278cac76ff3c132ed1f74f0cf63c61eaba8969 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2023,6 +2023,7 @@ _require_xfs_io_command()
        shift
        local param="$*"
        local param_checked=0
+       local opts=""
 
        testfile=$TEST_DIR/$$.xfs_io
        case $command in
@@ -2067,6 +2068,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 vectored 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" && \
@@ -2097,7 +2109,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
 }