Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jqt0B-0000G7-Ea for qemu-devel@nongnu.org; Tue, 29 Apr 2008 12:48:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jqt0B-0000FM-21 for qemu-devel@nongnu.org; Tue, 29 Apr 2008 12:48:23 -0400 Received: from [199.232.76.173] (port=33716 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jqt0A-0000FD-KE for qemu-devel@nongnu.org; Tue, 29 Apr 2008 12:48:22 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jqt09-0004Xz-SE for qemu-devel@nongnu.org; Tue, 29 Apr 2008 12:48:22 -0400 Subject: Re: [Qemu-devel] [PATCH] Align file accesses with cache=off (O_DIRECT) From: Laurent Vivier In-Reply-To: <48174B0B.5070904@suse.de> References: <4807514B.9040607@suse.de> <4815EE89.70407@suse.de> <1209459667.4328.7.camel@frecb07144> <48173591.9010609@suse.de> <1209484105.4248.27.camel@frecb07144> <48174B0B.5070904@suse.de> Content-Type: text/plain; charset=UTF-8 Date: Tue, 29 Apr 2008 18:48:39 +0200 Message-Id: <1209487719.4248.43.camel@frecb07144> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org Le mardi 29 avril 2008 =C3=A0 18:21 +0200, Kevin Wolf a =C3=A9crit : > Laurent Vivier schrieb: > >> Disabling O_DIRECT for a single aio request is impossible (after all= ,=20 > >> aio is asynchronous), and disabling it for at least one aio request = is=20 > >=20 > > Perhaps I'm wrong, but I think it is possible: the only consequence i= s > > the asynchronous I/O becomes synchronous... >=20 > Hm, yes. We could call raw_pread in raw_aio_read when O_DIRECT is used=20 > and the request is not properly aligned. Is this what you meant? No, it was just a (stupid) comment. I think we must not convert asynchronous I/O to synchronous I/O. > >> going to be ugly. So maybe we better turn O_DIRECT off for snapsnot=20 > >> saving/loading, even if it's not the generic fix I wanted to have wh= en I=20 > >> started. > >=20 > > I don't think it is a good idea: > >=20 > > In linux world, there are three reasons to use O_DIRECT: > >=20 > > 1- to use linux AIO (not POSIX AIO). > >=20 > > 2- to avoid a buffer copy between user- and kernel- space > > (performance ?) > >=20 > > 3- to increase reliability: by using O_DIRECT you are sure your data = are > > on the disk when the write is over and your system can now crash (if = it > > wants). > >=20 > > And I think reliability is better when the snapshot is being saved... >=20 > I think we agree that it's mostly item 3 why one would use O_DIRECT wit= h=20 > qemu. In terms of reliability, it is important that the data really is=20 > written to the disk when the guest OS thinks so. But when for example=20 > qemu crashes, I don't think it's too important if 40% or 50% of a=20 > snapshot have already been written - it's unusable anyway. A sync=20 > afterwards could be enough there. I don't speak about "qemu crashes" but about "host crashes". >=20 > >> I'm still undecided, though. What do you think? > >=20 > > Is it possible to align the last AIO ? >=20 > I have to admit that I neither know how to recognize the "last AIO" in=20 > the generic code nor do I understand what you want to achieve with it.=20 > The main problem are unaligned buffers and these occur on any request. I'm not in the spirit "my patch is better than yours" (and I don't think so); but could you try to test my patch ? Because if I remember correctly I think It manages all cases and this can help you to find a solution (or perhaps you can add to your patch the part of my patch about block-qcow2.c) > > And see comments below >=20 > Good suggestion, will change the patch accordingly. >=20 > Kevin >=20 Regards, Laurent --=20 ------------- Laurent.Vivier@bull.net --------------- "The best way to predict the future is to invent it." - Alan Kay