From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JfHdW-0006NJ-0z for qemu-devel@nongnu.org; Fri, 28 Mar 2008 12:41:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JfHdU-0006Mc-Bf for qemu-devel@nongnu.org; Fri, 28 Mar 2008 12:41:01 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JfHdU-0006MW-6k for qemu-devel@nongnu.org; Fri, 28 Mar 2008 12:41:00 -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 1JfHdT-0007mX-Qu for qemu-devel@nongnu.org; Fri, 28 Mar 2008 12:41:00 -0400 From: Paul Brook Subject: Re: [kvm-devel] [Qemu-devel] [PATCH] QEMU: fsync AIO writes on flush request Date: Fri, 28 Mar 2008 16:40:54 +0000 References: <20080328150517.GA18077@dmt> <20080328150703.GA19624@shareable.org> <20080328163116.GA18853@dmt> In-Reply-To: <20080328163116.GA18853@dmt> MIME-Version: 1.0 Content-Type: text/plain; charset="ansi_x3.4-1968" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803281640.55185.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: Marcelo Tosatti , kvm-devel 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. Paul