Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JhOE3-0001jr-Ii for qemu-devel@nongnu.org; Thu, 03 Apr 2008 08:07:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JhOE2-0001ib-Dg for qemu-devel@nongnu.org; Thu, 03 Apr 2008 08:07:27 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JhOE2-0001iV-Aj for qemu-devel@nongnu.org; Thu, 03 Apr 2008 08:07:26 -0400 Received: from smtp02.citrix.com ([66.165.176.63]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JhOE1-0007h2-FC for qemu-devel@nongnu.org; Thu, 03 Apr 2008 08:07:25 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18420.51290.573494.991916@mariner.uk.xensource.com> Date: Thu, 3 Apr 2008 13:06:50 +0100 Subject: Re: [Qemu-devel] [PATCH] Asynchronous reliable and configurable cache flush In-Reply-To: <20080403113833.GB17900@shareable.org> References: <18418.28291.689482.198484@mariner.uk.xensource.com> <200804011846.25975.paul@codesourcery.com> <20080401184501.GA26813@shareable.org> <200804021326.22707.paul@codesourcery.com> <20080402152339.GA15460@shareable.org> <18419.45671.159207.564940@mariner.uk.xensource.com> <20080403113833.GB17900@shareable.org> From: Ian Jackson Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: Marcelo Tosatti , Paul Brook , qemu-devel@nongnu.org Jamie Lokier writes ("Re: [Qemu-devel] [PATCH] Asynchronous reliable and configurable cache flush"): > Ian Jackson wrote: > > Doing it with bdrv_aio_flush wasn't too hard, so that's what'll be in > > my revised patch shortly. > > For "uncached" writes, do you wait until _after_ the aio_write has > completed before calling aio_fsync, or do you assume the aio_fsync > will wait for all aio_writes queued (but not completed) prior to it, > as Marcelo Tosatti believes the documentation implies? I do the former. In general, I assume that in the following case: aio_write returns 0, operation is in progress . . aio_fsync . returns 0, operation is in progress . . aio_return on the aio_write . says completed OK . . aio_return on the aio_fsync says completed OK the aio_f(data)sync completion does not tell us that the write (which had not been completed at the time aio_fsync was called) has been synchronised. I don't agree with Marcelo's analysis. I think SuSv3 unhelpfully uses the word `queued' in two different ways: firstly, to refer to data for which a write(2) or equivalent has completed but where the data has not yet reached stable storage, and secondly to refer to asynchronous IO operations (including aio_write and aio_fsync) which have been submitted but not yet completed. The former usage is demonstrated clearly in the SuSv3 page for write(2) which describes the data as having been `queued' when write(2) completes - ie when it is in the buffer cache. This interpretation for write(2) is supported by the page for read(2) not mentioning queues (except for STREAMS queues which are irrelevant). The latter usage is demonstrated by the spec for aio_read, which talks about a read having been queued, and even for aio_fsync which is specified to return when `the synchronisation request has been ... queued'. Clearly it is the former meaning of `queue' which is referred to by the specification of fsync and fdatasync since those calls apply to data from write(2) as well. In the spec for aio_write, `queued' is used in the first paragraph with an identical wording to that for aio_read, so has the latter of the two meanings above. Sadly in aio_fsync these two meanings of `queued' appear in different parts of the page. Firstly, we have the statement that aio_fsync shall return when the synchronisation request has been queued (identical wording to that used for aio_read and aio_write). Then in the second paragraph we refer to queued IO operations but this can only refer to the former, fsync, sense (since the text explicitly says `as if by a call to fsync and since otherwise the reference would be semi-recursive as the aio_fsync would itself be a queued IO operation). If one thinks that both of these meanings of `queue' are the same: what is the difference between aio_write and write(2) ? Why can't write(2) return immediately just like aio_write ? Ian.