public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: akpm@linux-foundation.org, zach.brown@oracle.com,
	linux-aio@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch] aio: invalidate async directio writes
Date: Thu, 19 Jun 2008 09:51:25 +0200	[thread overview]
Message-ID: <1213861885.16944.255.camel@twins> (raw)
In-Reply-To: <x49ej6uy5qo.fsf@segfault.boston.devel.redhat.com>

On Wed, 2008-06-18 at 14:09 -0400, Jeff Moyer wrote:
> Hi, Andrew,
> 
> This is a follow-up to:
> 
> commit bdb76ef5a4bc8676a81034a443f1eda450b4babb
> Author: Zach Brown <zach.brown@oracle.com>
> Date:   Tue Oct 30 11:45:46 2007 -0700
> 
>     dio: fix cache invalidation after sync writes
>     
>     Commit commit 65b8291c4000e5f38fc94fb2ca0cb7e8683c8a1b ("dio: invalidate
>     clean pages before dio write") introduced a bug which stopped dio from
>     ever invalidating the page cache after writes.  It still invalidated it
>     before writes so most users were fine.
>     
>     Karl Schendel reported ( http://lkml.org/lkml/2007/10/26/481 ) hitting
>     this bug when he had a buffered reader immediately reading file data
>     after an O_DIRECT [writer] had written the data.  The kernel issued
>     read-ahead beyond the position of the reader which overlapped with the
>     O_DIRECT writer.  The failure to invalidate after writes caused the
>     reader to see stale data from the read-ahead.
>     
>     The following patch is originally from Karl.  The following commentary
>     is his:
>     
>         The below 3rd try takes on your suggestion of just invalidating
>         no matter what the retval from the direct_IO call.  I ran it
>         thru the test-case several times and it has worked every time.
>         The post-invalidate is probably still too early for async-directio,
>         but I don't have a testcase for that;  just sync.  And, this
>         won't be any worse in the async case.
>     
>     I added a test to the aio-dio-regress repository which mimics Karl's IO
>     pattern.  It verifed the bad behaviour and that the patch fixed it.  I
>     agree with Karl, this still doesn't help the case where a buffered
>     reader follows an AIO O_DIRECT writer.  That will require a bit more
>     work.
>     
>     This gives up on the idea of returning EIO to indicate to userspace that
>     stale data remains if the invalidation failed.
> 
> Note the second-to-last paragraph, where it mentions that this does not fix
> the AIO case.  I updated the regression test to also perform asynchronous
> I/O and verified that the problem does exist.
> 
> To fix the problem, we need to invalidate the pages that were under write
> I/O after the I/O completes.  Because the I/O completion handler can be called
> in interrupt context (and invalidate_inode_pages2 cannot be called in interrupt
> context), this patch opts to defer the completion to a workqueue.  That
> workqueue is responsible for invalidating the page cache pages and completing
> the I/O.
> 
> I verified that the test case passes with the following patch applied.

I'm utterly ignorant of all thing [AD]IO, but doesn't deferring the
invalidate open up/widen a race window?


  parent reply	other threads:[~2008-06-19  7:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18 18:09 [patch] aio: invalidate async directio writes Jeff Moyer
2008-06-18 18:22 ` Christoph Hellwig
2008-06-18 19:45   ` Jeff Moyer
2008-06-18 19:48     ` Christoph Hellwig
2008-06-19  7:51 ` Peter Zijlstra [this message]
2008-06-19 13:50   ` Jeff Moyer
2008-06-19 13:58     ` Peter Zijlstra
2008-06-19 14:05       ` Jeff Moyer
2008-06-19 17:50   ` Zach Brown
2008-06-19 17:23 ` Zach Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1213861885.16944.255.camel@twins \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=jmoyer@redhat.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zach.brown@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox