From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jqljn-0001B3-Sl for qemu-devel@nongnu.org; Tue, 29 Apr 2008 05:02:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jqljl-0001AR-SA for qemu-devel@nongnu.org; Tue, 29 Apr 2008 05:02:58 -0400 Received: from [199.232.76.173] (port=48731 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jqljl-0001AG-Lu for qemu-devel@nongnu.org; Tue, 29 Apr 2008 05:02:57 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jqljk-0006Kr-Uf for qemu-devel@nongnu.org; Tue, 29 Apr 2008 05:02:57 -0400 Subject: Re: [Qemu-devel] [PATCH] Align file accesses with cache=off (O_DIRECT) From: Laurent Vivier In-Reply-To: <4815EE89.70407@suse.de> References: <4807514B.9040607@suse.de> <4815EE89.70407@suse.de> Content-Type: text/plain; charset=utf-8 Date: Tue, 29 Apr 2008 11:01:07 +0200 Message-Id: <1209459667.4328.7.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: qemu-devel@nongnu.org Cc: Kevin Wolf Le lundi 28 avril 2008 =C3=A0 17:34 +0200, Kevin Wolf a =C3=A9crit : > Kevin Wolf schrieb: > > In December a patch was applied which introduced the cache=3Doff opti= on to > > -drive. When using this option files are opened with the O_DIRECT fla= g. > > This means that all accesses have to be aligned. The patch made a cou= ple > > of changes in this respect, still in other places they are missing (e= .g. > > you can't use cache=3Doff with qcow(2) files). > >=20 > > This patch implements wrappers for raw_pread and raw_pwrite which ali= gn > > all file accesses and make qcow(2) work with cache=3Doff. This method > > might not be the most performant one (compared to fixing qcow, qcow2 = and > > everything else that might be using unaligned accesses), but unaligne= d > > accesses don't happen that frequently and with this patch really all > > image accesses should be covered. > >=20 > > Signed-off-by: Kevin Wolf >=20 > Anything wrong with this one? Hi Kevin, I did a patch to manage this problem too: http://thread.gmane.org/gmane.comp.emulators.qemu/22881 What I like in your patch: - simplicity What I don't like in your patch: - memcpy() and memalign() What I like in my patch: - no memcpy() What I don't like in my patch: - complexity But if we want too keep simplicity without memcpy(), we could only de-activate O_DIRECT on pread() or pwrite() : fd_arg =3D fcntl(fd, F_GETFL); if ((fd_arg & O_DIRECT) =3D=3D 0) return 0; fcntl(fd, F_SETFL, fd_arg & ~O_DIRECT); And restore it after. Regards, Laurent --=20 ------------- Laurent.Vivier@bull.net --------------- "The best way to predict the future is to invent it." - Alan Kay