qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC][PATCH] make sure disk writes actually hit disk
@ 2006-07-28 19:54 Rik van Riel
  2006-07-28 19:58 ` [Qemu-devel] " Rik van Riel
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Rik van Riel @ 2006-07-28 19:54 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

This is the simple approach to making sure that disk writes actually
hit disk before we tell the guest OS that IO has completed.  Thanks
to DMA_MULTI_THREAD the performance still seems to be adequate.

A fancier solution would be to make the sync/non-sync behaviour of
the qemu disk backing store tunable from the guest OS, by tuning
the IDE disk write cache on/off with hdparm, and having hw/ide.c
call ->fsync functions in the block backends.

I'm willing to code up the fancy solution if people prefer that.

-- 
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

[-- Attachment #2: xen-hvm-osync.patch --]
[-- Type: text/x-patch, Size: 3160 bytes --]

Make sure disk writes really made it to disk before we report I/O
completion to the guest domain.  The DMA_MULTI_THREAD functionality
from the qemu-dm IDE emulation should make the performance overhead
of synchronous writes bearable, or at least comparable to native
hardware.

Signed-off-by: Rik van Riel <riel@redhat.com>

--- xen-unstable-10712/tools/ioemu/block-bochs.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block-bochs.c	2006-07-28 02:21:08.000000000 -0400
@@ -91,7 +91,7 @@
     int fd, i;
     struct bochs_header bochs;
 
-    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
+    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
         if (fd < 0)
--- xen-unstable-10712/tools/ioemu/block.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block.c	2006-07-28 02:19:27.000000000 -0400
@@ -677,7 +677,7 @@
     int rv;
 #endif
 
-    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
+    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
         if (fd < 0)
--- xen-unstable-10712/tools/ioemu/block-cloop.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block-cloop.c	2006-07-28 02:17:13.000000000 -0400
@@ -55,7 +55,7 @@
     BDRVCloopState *s = bs->opaque;
     uint32_t offsets_size,max_compressed_block_size=1,i;
 
-    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
+    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE | O_SYNC);
     if (s->fd < 0)
         return -1;
     bs->read_only = 1;
--- xen-unstable-10712/tools/ioemu/block-cow.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block-cow.c	2006-07-28 02:21:34.000000000 -0400
@@ -69,7 +69,7 @@
     struct cow_header_v2 cow_header;
     int64_t size;
 
-    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
+    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
         if (fd < 0)
--- xen-unstable-10712/tools/ioemu/block-qcow.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block-qcow.c	2006-07-28 02:20:05.000000000 -0400
@@ -95,7 +95,7 @@
     int fd, len, i, shift;
     QCowHeader header;
     
-    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
+    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
         if (fd < 0)
--- xen-unstable-10712/tools/ioemu/block-vmdk.c.osync	2006-07-28 02:15:56.000000000 -0400
+++ xen-unstable-10712/tools/ioemu/block-vmdk.c	2006-07-28 02:20:20.000000000 -0400
@@ -96,7 +96,7 @@
     uint32_t magic;
     int l1_size;
 
-    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
+    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     if (fd < 0) {
         fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
         if (fd < 0)

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-07-31 17:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-28 19:54 [Qemu-devel] [RFC][PATCH] make sure disk writes actually hit disk Rik van Riel
2006-07-28 19:58 ` [Qemu-devel] " Rik van Riel
2006-07-28 20:12 ` Anthony Liguori
2006-07-28 20:18   ` Rik van Riel
2006-07-28 20:30     ` Paul Brook
2006-07-28 20:43       ` Rik van Riel
2006-07-28 21:01         ` Paul Brook
2006-07-31  7:08     ` Jens Axboe
2006-07-29  9:57 ` [Qemu-devel] " Fabrice Bellard
2006-07-29 14:59   ` Rik van Riel
2006-07-29 16:04     ` Paul Brook
2006-07-29 16:22       ` Rik van Riel
2006-07-29 16:31         ` Paul Brook
2006-07-31  7:08           ` Jens Axboe
2006-07-29 17:33     ` Bill C. Riemers
2006-07-30 21:47       ` Jamie Lokier
2006-07-30 21:41     ` Jamie Lokier
2006-07-31  9:52       ` andrzej zaborowski
2006-07-31 10:17         ` Jens Axboe
2006-07-31 17:50           ` andrzej zaborowski
2006-07-31  7:08     ` Jens Axboe
2006-07-31  7:56       ` Jonas Maebe
2006-07-31  8:18         ` Jens Axboe

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).