From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: barriers vs. reads Date: Tue, 22 Jun 2004 22:53:10 +0200 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20040622205309.GC3200@suse.de> References: <20040622113245.GA1104@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jamie Lokier , linux-fsdevel@vger.kernel.org, Werner Almesberger Return-path: Received: from ns.virtualhost.dk ([195.184.98.160]:40150 "EHLO virtualhost.dk") by vger.kernel.org with ESMTP id S266031AbUFVUxn (ORCPT ); Tue, 22 Jun 2004 16:53:43 -0400 To: Bryan Henderson Content-Disposition: inline In-Reply-To: List-Id: linux-fsdevel.vger.kernel.org On Tue, Jun 22 2004, Bryan Henderson wrote: > >> 2. Other than O_DIRECT, can the I/O subsystem issue reads that > >> overlap writes in flight? Surely that never occurs? > > > >No, it can only happen for reads that don't go through the page cache. > > > >> If it never occurs, then reads can be safely moved before write > >> barriers without looking at block numbers. > > > >It can happen with direct io of any sort, the solution has to take this > >into account. That's why we currently have handling for rbtree aliases > >as well. > > Are you saying that if Sector A contains "foo", and I do a > __make_request(Write, Sector A, "bar") and then a __make_request(Read, > Sector A), the read might read "foo"? Assuming no barriers. Well no, even for direct io we maintain ordering if you hit an alias. See cfq_add_crq_rb() in cfq-iosched.c for example. AS handles it differently, but result is the same. At least the io is issued in that order, so if the underlying storage hardware doesn't mess it up, there is no problem. If you have overlapping requests, then you could get into serious trouble. You should not do that. > As I understand it, the topic of discussion is completely outside the > realm of the page cache and open() flags -- it's all down below that. The page cache will make sure don't see "foo", since you'll wait for the page to unlocked at the end of io. The above description is only valid for direct io, this is where the alias handling works. -- Jens Axboe