From: Junho Ryu Date: Tue, 16 Dec 2014 03:01:06 +0000 (+1100) Subject: Check O_DIRECT support before testing direct I/O X-Git-Tag: v2022.05.01~2983 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=46a08542e342adff05e0ccfeed69eeec823205e8;p=xfstests-dev.git Check O_DIRECT support before testing direct I/O Some filesystems do not support O_DIRECT. Check whether TEST_DIR supports it by running xfs_io with -d flag. Signed-off-by: Junho Ryu Signed-off-by: Dushan Tcholich Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/common/rc b/common/rc index cddc8487..82a91c21 100644 --- a/common/rc +++ b/common/rc @@ -1402,6 +1402,7 @@ _require_aiodio() AIO_TEST=src/aio-dio-regress/$1 [ -x $AIO_TEST ] || _notrun "$AIO_TEST not built" fi + _require_odirect } # run an aio-dio program @@ -1530,6 +1531,17 @@ _require_xfs_io_command() _notrun "xfs_io $command failed (old kernel/wrong fs?)" } +# check that kernel and filesystem support direct I/O +_require_odirect() +{ + testfile=$TEST_DIR/$$.direct + $XFS_IO_PROG -F -f -d -c "pwrite 0 20k" $testfile > /dev/null 2>&1 + if [ $? -ne 0 ]; then + _notrun "O_DIRECT is not supported" + fi + rm -f $testfile 2>&1 > /dev/null +} + # Check that a fs has enough free space (in 1024b blocks) # _require_fs_space() diff --git a/tests/generic/091 b/tests/generic/091 index 3775016b..30491bfc 100755 --- a/tests/generic/091 +++ b/tests/generic/091 @@ -39,6 +39,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 _supported_fs generic _supported_os Linux _require_test +_require_odirect rm -f $seqres.full diff --git a/tests/generic/130 b/tests/generic/130 index 8367dc7d..1e96630e 100755 --- a/tests/generic/130 +++ b/tests/generic/130 @@ -50,6 +50,7 @@ _supported_os Linux IRIX _require_scratch _require_sparse_files +_require_odirect _scratch_mkfs >/dev/null 2>&1 _scratch_mount diff --git a/tests/generic/133 b/tests/generic/133 index f1d67aa6..f1a221e0 100755 --- a/tests/generic/133 +++ b/tests/generic/133 @@ -39,6 +39,7 @@ trap "exit \$status" 0 1 2 3 15 _supported_fs generic _supported_os Linux IRIX _require_test +_require_odirect echo "Buffered writer, buffered reader" $XFS_IO_PROG -f -d -c 'pwrite -b 64k 0 512m' $TEST_DIR/io_test > /dev/null diff --git a/tests/generic/135 b/tests/generic/135 index e3b827a8..79558f5e 100755 --- a/tests/generic/135 +++ b/tests/generic/135 @@ -39,6 +39,7 @@ trap "exit \$status" 0 1 2 3 15 _supported_fs generic _supported_os Linux IRIX +_require_odirect _require_scratch _scratch_mkfs >/dev/null 2>&1 diff --git a/tests/generic/226 b/tests/generic/226 index b98e8898..4ad56a50 100755 --- a/tests/generic/226 +++ b/tests/generic/226 @@ -37,6 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 _supported_fs generic _supported_os Linux IRIX _require_scratch +_require_odirect # real QA test starts here rm -f $seqres.full diff --git a/tests/generic/263 b/tests/generic/263 index 6ee21654..7584bc7c 100755 --- a/tests/generic/263 +++ b/tests/generic/263 @@ -39,6 +39,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 _supported_fs generic _supported_os Linux _require_test +_require_odirect rm -f $seqres.full diff --git a/tests/generic/299 b/tests/generic/299 index 953f1bd8..0459f42b 100755 --- a/tests/generic/299 +++ b/tests/generic/299 @@ -43,6 +43,7 @@ _supported_fs generic _supported_os Linux _need_to_be_root _require_scratch +_require_odirect NUM_JOBS=$((4*LOAD_FACTOR)) BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` diff --git a/tests/generic/300 b/tests/generic/300 index 5234d05a..d7523aae 100755 --- a/tests/generic/300 +++ b/tests/generic/300 @@ -43,6 +43,7 @@ _supported_fs generic _supported_os Linux _need_to_be_root _require_scratch +_require_odirect # xfs_io is not required for this test, but it's the best way to verify # the test system supports fallocate() for allocation and hole punching