[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/30] iotests: handle tmpfs
From: |
Kevin Wolf |
Subject: |
[PULL 01/30] iotests: handle tmpfs |
Date: |
Fri, 8 May 2020 14:41:06 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Some tests requires O_DIRECT, or want it by default. Introduce smarter
O_DIRECT handling:
- Check O_DIRECT in common.rc, if it is requested by selected
cache-mode.
- Support second fall-through argument in _default_cache_mode
Inspired-by: Max's 23e1d054112cec1e
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/091 | 2 +-
tests/qemu-iotests/common.rc | 37 ++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
index d2a2aca347..68fbfd777b 100755
--- a/tests/qemu-iotests/091
+++ b/tests/qemu-iotests/091
@@ -46,8 +46,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto file
_supported_os Linux
-_default_cache_mode none
_supported_cache_modes writethrough none writeback
+_default_cache_mode none writeback
size=1G
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index bf3b9fdea0..ba912555ca 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -673,11 +673,44 @@ _supported_cache_modes()
_notrun "not suitable for cache mode: $CACHEMODE"
}
+# Check whether the filesystem supports O_DIRECT
+_check_o_direct()
+{
+ $QEMU_IMG create -f raw "$TEST_IMG".test_o_direct 1M > /dev/null
+ out=$($QEMU_IO -f raw -t none -c quit "$TEST_IMG".test_o_direct 2>&1)
+ rm -f "$TEST_IMG".test_o_direct
+
+ [[ "$out" != *"O_DIRECT"* ]]
+}
+
+_require_o_direct()
+{
+ if ! _check_o_direct; then
+ _notrun "file system on $TEST_DIR does not support O_DIRECT"
+ fi
+}
+
+_check_cache_mode()
+{
+ if [ $CACHEMODE == "none" ] || [ $CACHEMODE == "directsync" ]; then
+ _require_o_direct
+ fi
+}
+
+_check_cache_mode
+
+# $1 - cache mode to use by default
+# $2 - (optional) cache mode to use by default if O_DIRECT is not supported
_default_cache_mode()
{
if $CACHEMODE_IS_DEFAULT; then
- CACHEMODE="$1"
- QEMU_IO="$QEMU_IO --cache $1"
+ if [ -z "$2" ] || _check_o_direct; then
+ CACHEMODE="$1"
+ else
+ CACHEMODE="$2"
+ fi
+ QEMU_IO="$QEMU_IO --cache $CACHEMODE"
+ _check_cache_mode
return
fi
}
--
2.25.3
- [PULL 00/30] Block layer patches, Kevin Wolf, 2020/05/08
- [PULL 02/30] iotests/082: require bochs, Kevin Wolf, 2020/05/08
- [PULL 01/30] iotests: handle tmpfs,
Kevin Wolf <=
- [PULL 04/30] iotests/041: drop self.assert_no_active_block_jobs(), Kevin Wolf, 2020/05/08
- [PULL 03/30] iotests/148: use skip_if_unsupported, Kevin Wolf, 2020/05/08
- [PULL 06/30] iotests/055: skip vmdk target tests if vmdk is not whitelisted, Kevin Wolf, 2020/05/08
- [PULL 07/30] iotests/109: mark required formats as required to support whitelisting, Kevin Wolf, 2020/05/08
- [PULL 05/30] iotests/055: refactor compressed backup to vmdk, Kevin Wolf, 2020/05/08
- [PULL 08/30] iotests/113: mark bochs as required to support whitelisting, Kevin Wolf, 2020/05/08
- [PULL 10/30] vmdk: Rename VmdkMetaData.valid to new_allocation, Kevin Wolf, 2020/05/08
- [PULL 12/30] vmdk: Fix partial overwrite of zero cluster, Kevin Wolf, 2020/05/08
- [PULL 14/30] vmdk: Flush only once in vmdk_L2update(), Kevin Wolf, 2020/05/08
- [PULL 11/30] vmdk: Fix zero cluster allocation, Kevin Wolf, 2020/05/08