From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: Re: [PATCH] dio: track and serialise unaligned direct IO Date: Thu, 29 Jul 2010 20:53:24 -0600 Message-ID: <20100730025324.GO25774@parisc-linux.org> References: <1280443516-14448-1-git-send-email-david@fromorbit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com, sandeen@sandeen.net To: Dave Chinner Return-path: Received: from palinux.external.hp.com ([192.25.206.14]:33636 "EHLO mail.parisc-linux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758409Ab0G3Cx0 (ORCPT ); Thu, 29 Jul 2010 22:53:26 -0400 Content-Disposition: inline In-Reply-To: <1280443516-14448-1-git-send-email-david@fromorbit.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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. Urgh. Yuck. > This is easily manifested by qemu using aio+dio with an unaligned > guest filesystem - every IO is unaligned and fileystem corruption is > encountered in the guest filesystem. xfstest 240 (from Eric Sandeen) > is also a simple reproducer. > > To avoid this problem, track unaligned IO that triggers sub-block zeroing and > check new incoming unaligned IO that require sub-block zeroing against that > list. If we get an overlap where the start and end of unaligned IOs hit the > same filesystem block, then we need to block the incoming IOs until the IO that > is zeroing the block completes. The blocked IO can then continue without > needing to do any zeroing and hence won't overwrite valid data with zeros. Urgh. Yuck. Could we perhaps handle this by making an IO instantiate a page cache page for partial writes, and forcing that portion of the IO through the page cache? The second IO would hit the same page and use the existing O_DIRECT vs page cache paths. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."