From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jh23J-00009D-83 for qemu-devel@nongnu.org; Wed, 02 Apr 2008 08:26:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jh23H-00008W-Ep for qemu-devel@nongnu.org; Wed, 02 Apr 2008 08:26:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jh23H-00008T-6x for qemu-devel@nongnu.org; Wed, 02 Apr 2008 08:26:51 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jh23H-0003RN-1S for qemu-devel@nongnu.org; Wed, 02 Apr 2008 08:26:51 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] Asynchronous reliable and configurable cache flush Date: Wed, 2 Apr 2008 13:26:21 +0100 References: <18418.28291.689482.198484@mariner.uk.xensource.com> <200804011846.25975.paul@codesourcery.com> <20080401184501.GA26813@shareable.org> In-Reply-To: <20080401184501.GA26813@shareable.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200804021326.22707.paul@codesourcery.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 Cc: Ian Jackson On Tuesday 01 April 2008, Jamie Lokier wrote: > Paul Brook wrote: > > > @@ -1021,6 +1031,13 @@ static void ide_write_dma_cb(void *opaque, int > > > ret)=20 > > > =A0 =A0 =A0/* end of transfer ? */ > > > =A0 =A0 =A0if (s->nsector =3D=3D 0) { > > > +=A0=A0=A0=A0=A0=A0=A0if (!s->write_cache) { > > > +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0ret =3D bdrv_flush(s->bs); > > > +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0if (ret !=3D 0) { > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ide_dma_error(s); > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return; > > > +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0} > > > +=A0=A0=A0=A0=A0=A0=A0} > > > > By my reading this is adding a synchronous flush to the end of an > > async write operation, which in practice makes the whole operation > > synchronous. > > Looks that way to me too. It might be simplest to open the device > with O_DSYNC when !s->write_cache and user actually wants fdatasync, > so that async write can be used. I suspect every platform with useful > Posix AIO has O_DSYNC. The cache is dynamically enabled/disabled by the target. This means you've = got=20 to close and repopen the file every time it changes, which is likely to get= =20 really hairy. > Otherwise, chaining where the completion of aio_write triggers > aio_fsync instead of reporting completion to the guest? Yes, that should do it. Paul