From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [Qemu-devel] [PATCH] QEMU: fsync AIO writes on flush request Date: Fri, 28 Mar 2008 13:59:41 -0300 Message-ID: <20080328165941.GA19155@dmt> References: <20080328150517.GA18077@dmt> <20080328150703.GA19624@shareable.org> <20080328163116.GA18853@dmt> <200803281640.55185.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel , Jamie Lokier , qemu-devel@nongnu.org To: Paul Brook Return-path: Content-Disposition: inline In-Reply-To: <200803281640.55185.paul@codesourcery.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Fri, Mar 28, 2008 at 04:40:54PM +0000, Paul Brook wrote: > On Friday 28 March 2008, Marcelo Tosatti wrote: > > On Fri, Mar 28, 2008 at 03:07:03PM +0000, Jamie Lokier wrote: > > > Marcelo Tosatti wrote: > > > > Its necessary to guarantee that pending AIO writes have reached stable > > > > storage when the flush request returns. > > > > > > > > Also change fsync() to fdatasync(), since the modification time is not > > > > critical data. > > > > + if (aio_fsync(O_DSYNC, &acb->aiocb) < 0) { > > > > > > > > BDRVRawState *s = bs->opaque; > > > > - fsync(s->fd); > > > > + raw_aio_flush(bs); > > > > + fdatasync(s->fd); > > > > + > > > > + /* We rely on the fact that no other AIO will be submitted > > > > + * in parallel, but this should be fixed by per-device > > > > + * AIO queues when allowing multiple CPU's to process IO > > > > + * in QEMU. > > > > + */ > > > > + qemu_aio_flush(); > > > > > > I'm a bit confused by this. Why do you need aio_fsync(O_DSYNC) _and_ > > > synchronous fdatasync() calls? Aren't they equivalent? > > > > fdatasync() will write and wait for completion of dirty file data > > present in memory. > > > > aio_write() only queues data for submission: > > > > The "asynchronous" means that this call returns as soon as the > > request has been enqueued; the write may or may not have completed when > > the call returns. One tests for completion using aio_error(3). > > Surely you should be using the normal aio notification to wait for the > aio_fsync to complete before reporting success to the device. qemu_aio_flush() will wait for all pending AIO requests (including aio_fsync) to complete. Or do you mean something else? ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace