From: Artemy Kapitula <dalt74@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v0] Implement new cache mode "target"
Date: Wed, 7 Aug 2019 16:09:54 +0300 [thread overview]
Message-ID: <2c685097-1647-e2d3-8b8a-21f76551ce3c@gmail.com> (raw)
There is an issue with databases in VM that perform too slow
on generic SAN storages. The key point is fdatasync that flushes
disk on SCSI target.
The QEMU blockdev "target" cache mode intended to be used with
SAN storages and is a mix of "none" by using direct I/O and
"unsafe" that omit device flush.
Such storages has its own data integrity protection and can
be operated with direct I/O without additional fdatasyc().
With generic SCSI targets like LIO or SCST it boost performance
up to 100% on some profiles like database with transaction journal
(postrgesql/mssql/oracle etc) or virtualized SDS (ceph/rook inside
VMs) which performs block device cache flush on journal record.
Signed-off-by: Artemy Kapitula <dalt74@gmail.com>
---
block.c | 4 ++++
qemu-options.hx | 3 ++-
tests/qemu-iotests/026 | 2 +-
tests/qemu-iotests/091 | 2 +-
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index cbd8da5f3b..60919d82ff 100644
--- a/block.c
+++ b/block.c
@@ -884,6 +884,10 @@ int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough)
} else if (!strcmp(mode, "unsafe")) {
*writethrough = false;
*flags |= BDRV_O_NO_FLUSH;
+ } else if (!strcmp(mode, "target")) {
+ *writethrough = false;
+ *flags |= BDRV_O_NOCACHE;
+ *flags |= BDRV_O_NO_FLUSH;
} else if (!strcmp(mode, "writethrough")) {
*writethrough = true;
} else {
diff --git a/qemu-options.hx b/qemu-options.hx
index 9621e934c0..01f1f4ad34 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1065,7 +1065,7 @@ This option defines the type of the media: disk or cdrom.
@var{snapshot} is "on" or "off" and controls snapshot mode for the given drive
(see @option{-snapshot}).
@item cache=@var{cache}
-@var{cache} is "none", "writeback", "unsafe", "directsync" or "writethrough"
+@var{cache} is "none", "writeback", "unsafe", "target", "directsync" or "writethrough"
and controls how the host cache is used to access block data. This is a
shortcut that sets the @option{cache.direct} and @option{cache.no-flush}
options (as in @option{-blockdev}), and additionally @option{cache.writeback},
@@ -1084,6 +1084,7 @@ none │ on on off
writethrough │ off off off
directsync │ off on off
unsafe │ on off on
+target │ on on on
@end example
The default mode is @option{cache=writeback}.
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index e30243608b..e7179b0de4 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto file
_default_cache_mode "writethrough"
-_supported_cache_modes "writethrough" "none"
+_supported_cache_modes "writethrough" "none" "target"
# The refcount table tests expect a certain minimum width for refcount entries
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
# being the default refcount entry width.
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
index d62ef18a02..2eaf258c8a 100755
--- a/tests/qemu-iotests/091
+++ b/tests/qemu-iotests/091
@@ -47,7 +47,7 @@ _supported_fmt qcow2
_supported_proto file
_supported_os Linux
_default_cache_mode "none"
-_supported_cache_modes "writethrough" "none" "writeback"
+_supported_cache_modes "writethrough" "none" "writeback" "target"
size=1G
--
2.21.0
next reply other threads:[~2019-08-07 13:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 13:09 Artemy Kapitula [this message]
2019-08-15 13:53 ` [Qemu-devel] [PATCH v0] Implement new cache mode "target" Stefan Hajnoczi
2019-08-15 14:27 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c685097-1647-e2d3-8b8a-21f76551ce3c@gmail.com \
--to=dalt74@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).