From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JteNw-0002dc-7C for qemu-devel@nongnu.org; Wed, 07 May 2008 03:48:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JteNt-0002c7-JH for qemu-devel@nongnu.org; Wed, 07 May 2008 03:48:18 -0400 Received: from [199.232.76.173] (port=57197 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JteNt-0002c3-DV for qemu-devel@nongnu.org; Wed, 07 May 2008 03:48:17 -0400 Received: from mail2.shareable.org ([80.68.89.115]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JteNs-0002Ws-RC for qemu-devel@nongnu.org; Wed, 07 May 2008 03:48:17 -0400 Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from ) id 1JteNn-0007Xg-28 for qemu-devel@nongnu.org; Wed, 07 May 2008 08:48:11 +0100 Date: Wed, 7 May 2008 08:48:10 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [4367] Align file accesses with cache=off (Kevin Wolf, Laurent Vivier) Message-ID: <20080507074810.GA28519@shareable.org> References: <4820D905.4020407@bellard.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4820D905.4020407@bellard.org> 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 Fabrice Bellard wrote: > A note: in order to avoid uncontrolled recursions, it is better to call > the read/write AIO callback outside the aio_read/write (see > bdrv_aio_read_em). Definitely, I've been bitten by equivalent recursions and deadlocks in my own code recently. > Personally I would not trust the OS to correctly handle the mix of > O_DIRECT and buffered operations, especially if the corresponding file > regions intersect ! I agree. Several OSes document that _any_ open buffered descriptors suppress O_DIRECT, causing all descriptors to do buffered I/O, and (explicitly or implied) opening a descriptor with O_DIRECT, and no buffered descriptors at the time, flushes any buffers for that file so that switching between them is coherent. (Though I picked up hints that some OSes don't even manage that coherence.) Because it's not merely a flag change, it requires some cache flushing for coherence, I would not trust fcntl(fd, F_SETFL, x) where x changes between O_DIRECT and non-O_DIRECT to do the right thing on some OSes - even for _synchronous_ I/O on separate regions. -- Jamie