From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mingming Cao Subject: Re: [PATCH] dio: track and serialise unaligned direct IO Date: Tue, 03 Aug 2010 16:41:14 -0700 Message-ID: <1280878874.2334.6.camel@mingming-laptop> References: <1280443516-14448-1-git-send-email-david@fromorbit.com> <20100730025324.GO25774@parisc-linux.org> <20100730045331.GA2126@dastard> <1280856865.2436.31.camel@mingming-laptop> <20100803225658.GB26402@dastard> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Matthew Wilcox , linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com, sandeen@sandeen.net To: Dave Chinner Return-path: Received: from e34.co.us.ibm.com ([32.97.110.152]:45524 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756741Ab0HCXlf (ORCPT ); Tue, 3 Aug 2010 19:41:35 -0400 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o73NWt5B005168 for ; Tue, 3 Aug 2010 17:32:55 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o73NfKA3111042 for ; Tue, 3 Aug 2010 17:41:21 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o73NfGN2012678 for ; Tue, 3 Aug 2010 17:41:17 -0600 In-Reply-To: <20100803225658.GB26402@dastard> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 2010-08-04 at 08:56 +1000, Dave Chinner wrote: > On Tue, Aug 03, 2010 at 10:34:25AM -0700, Mingming Cao wrote: > > On Fri, 2010-07-30 at 14:53 +1000, Dave Chinner wrote: > > > On Thu, Jul 29, 2010 at 08:53:24PM -0600, Matthew Wilcox wrote: > > > > On Fri, Jul 30, 2010 at 08:45:16AM +1000, Dave Chinner wrote: > > > > > If we get two unaligned direct IO's to the same filesystem block > > > > > that is marked as a new allocation (i.e. buffer_new), then both IOs will > > > > > zero the portion of the block they are not writing data to. As a > > > > > result, when the IOs complete there will be a portion of the block > > > > > that contains zeros from the last IO to complete rather than the > > > > > data that should be there. > .... > > > I don't want any direct IO for XFS to go through the page cache - > > > unaligned or not. using the page cache for the unaligned blocks > > > would also be much worse for performance that this method because it > > > turns unaligned direct IO into 3 IOs - the unaligned head block, the > > > aligned body and the unaligned tail block. It would also be a > > > performance hit you take on every single dio, whereas this way the > > > hit is only taken when an overlap is detected. > > > > Does this problem also possible for DIO and non AIO case? (Ext4 case > > this only happy with AIO+DIO+unaligned). If not, could we simply force > > unaligned AIO+DIO to be synchronous? Still direct IO... > > There is nothing specific to AIO about this bug. XFS (at least) > allows concurrent DIO writes to the same inode regardless of whether > they are dispatched via AIO or multiple separate threads and so the > race condition exists outside just the AIO context... > Okay..yeah ext4 prevent direct IO write to the same inode from multiple threads, so this is not a issue for non-aio case. How does XFS serialize direct IO (aligned) to the same file offset(or overlap) from multiple threads? Mingming