From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G6lZb-0002ww-PS for qemu-devel@nongnu.org; Sat, 29 Jul 2006 05:57:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G6lZa-0002wT-OZ for qemu-devel@nongnu.org; Sat, 29 Jul 2006 05:57:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6lZa-0002wQ-GH for qemu-devel@nongnu.org; Sat, 29 Jul 2006 05:57:30 -0400 Received: from [84.96.92.60] (helo=Smtp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G6lbl-0005IQ-Ti for qemu-devel@nongnu.org; Sat, 29 Jul 2006 05:59:46 -0400 Received: from [84.102.211.120] by sp604001mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0J35007HWSZQBD11@sp604001mt.gpm.neuf.ld> for qemu-devel@nongnu.org; Sat, 29 Jul 2006 11:57:26 +0200 (CEST) Date: Sat, 29 Jul 2006 11:57:31 +0200 From: Fabrice Bellard Subject: Re: [Qemu-devel] [RFC][PATCH] make sure disk writes actually hit disk In-reply-to: <44CA6B76.7000004@redhat.com> Message-id: <44CB310B.9060308@bellard.org> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <44CA6B76.7000004@redhat.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, Using O_SYNC for disk image access is not acceptable: QEMU relies on the host OS to ensure that the data is written correctly. Even the current 'fsync' support is questionnable to say the least ! Please don't mix issues regarding QEMU disk handling and the underlying hypervisor/host OS block device handling. Regards, Fabrice. Rik van Riel wrote: > 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. > > > ------------------------------------------------------------------------ > > 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 > > --- 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) > > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel