linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ryan Finnie" <ryan@finnie.org>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Erez Zadok" <ezk@cs.sunysb.edu>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	cjwatson@ubuntu.com, linux-mm@kvack.org
Subject: Re: msync(2) bug(?), returns AOP_WRITEPAGE_ACTIVATE to userland
Date: Thu, 11 Oct 2007 15:12:05 -0700	[thread overview]
Message-ID: <cfa94dc20710111512j9b6c038qf89c516ecd605411@mail.gmail.com> (raw)
In-Reply-To: <20071011144740.136b31a8.akpm@linux-foundation.org>

On 10/11/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> shit.  That's a nasty bug.  Really userspace should be testing for -1, but
> the msync() library function should only ever return 0 or -1.
>
> Does this fix it?
>
> --- a/mm/page-writeback.c~a
> +++ a/mm/page-writeback.c
> @@ -850,8 +850,10 @@ retry:
>
>                         ret = (*writepage)(page, wbc, data);
>
> -                       if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE))
> +                       if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE)) {
>                                 unlock_page(page);
> +                               ret = 0;
> +                       }
>                         if (ret || (--(wbc->nr_to_write) <= 0))
>                                 done = 1;
>                         if (wbc->nonblocking && bdi_write_congested(bdi)) {
> _
>

Pekka Enberg replied with an identical patch a few days ago, but for
some reason the same condition flows up to msync as -1 EIO instead of
AOP_WRITEPAGE_ACTIVATE with that patch applied.  The last part of the
thread is below.  Thanks.

Ryan

On 10/7/07, Ryan Finnie <ryan@finnie.org> wrote:
> On 10/7/07, Pekka J Enberg <penberg@cs.helsinki.fi> wrote:
> > On 10/7/07, Erez Zadok <ezk@cs.sunysb.edu> wrote:
> > > Anyway, some Ubuntu users of Unionfs reported that msync(2) sometimes
> > > returns AOP_WRITEPAGE_ACTIVATE (decimal 524288) back to userland.
> > > Therefore, some user programs fail, esp. if they're written such as
> > > this:
> >
> ...
> > It's a kernel bug. AOP_WRITEPAGE_ACTIVATE is a hint to the VM to avoid
> > writeback of the page in the near future. I wonder if it's enough that we
> > change the return value to zero from
> > mm/page-writeback.c:write_cache_pages() in case we hit AOP_WRITEPAGE_ACTIVE...
>
> Doesn't appear to be enough.  I can't figure out why (since it appears
> write_cache_pages bubbles up directly to sys_msync), but with that
> patch applied, in my test case[1], msync returns -1 EIO.  However,
> with the exact same kernel without that patch applied, msync returns
> 524288 (AOP_WRITEPAGE_ACTIVATE).  But as your patch specifically flips
> 524288 to 0, I can't figure out how it eventually returns  -1 EIO.
>
> Ryan
>
> [1] "apt-get check" on a unionfs2 mount backed by tmpfs over cdrom,
> standard livecd setup
>

  reply	other threads:[~2007-10-11 22:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-07 19:20 msync(2) bug(?), returns AOP_WRITEPAGE_ACTIVATE to userland Erez Zadok
2007-10-11 21:47 ` Andrew Morton
2007-10-11 22:12   ` Ryan Finnie [this message]
2007-10-12  0:38     ` Hugh Dickins
2007-10-12 21:45       ` Pekka Enberg
2007-10-14  8:44         ` Hugh Dickins
2007-10-14 17:09           ` Pekka Enberg
2007-10-14 17:23             ` Erez Zadok
2007-10-14 17:50               ` Pekka J Enberg
2007-10-14 22:32                 ` Erez Zadok
2007-10-15 11:47                   ` Pekka Enberg
2007-10-16 18:02                     ` Erez Zadok
2007-10-22 20:16                     ` Hugh Dickins
2007-10-22 20:48                       ` Pekka Enberg
2007-10-25 15:36                         ` Hugh Dickins
2007-10-25 16:44                           ` Erez Zadok
2007-10-25 18:23                             ` Hugh Dickins
2007-10-26  2:00                           ` Neil Brown
2007-10-26  8:09                             ` Pekka Enberg
2007-10-26 11:26                             ` Hugh Dickins
2007-10-26  8:05                           ` Pekka Enberg
2007-10-22 21:04                       ` Erez Zadok
2007-10-25 16:40                         ` Hugh Dickins
2007-10-24 21:02                       ` [PATCH] fix tmpfs BUG and AOP_WRITEPAGE_ACTIVATE Hugh Dickins
2007-10-24 21:08                         ` Andrew Morton
2007-10-24 21:37                           ` [PATCH+comment] " Hugh Dickins
2007-10-25  5:37                             ` Pekka Enberg
2007-10-25  6:30                               ` Hugh Dickins
2007-10-25  7:24                                 ` Pekka Enberg
2007-10-25 16:01                                 ` Erez Zadok
2007-10-25 20:51                                   ` H. Peter Anvin
2007-10-22 20:01                   ` msync(2) bug(?), returns AOP_WRITEPAGE_ACTIVATE to userland Hugh Dickins
2007-10-22 20:40                     ` Pekka Enberg
2007-10-22 19:42               ` Hugh Dickins
2007-10-22 21:38                 ` Erez Zadok
2007-10-25 18:03                   ` Hugh Dickins
2007-10-27 20:47                     ` Erez Zadok
2007-10-28 20:23                     ` Erez Zadok
2007-10-29 20:33                       ` Hugh Dickins
2007-10-31 23:53                         ` Erez Zadok
2007-11-05 15:40                           ` Hugh Dickins
2007-11-05 16:38                             ` Dave Hansen
2007-11-05 18:57                               ` Hugh Dickins
2007-11-09  2:47                               ` Erez Zadok
2007-11-09  6:05                             ` Erez Zadok
2007-11-12  5:41                               ` Hugh Dickins
2007-11-12 17:01                               ` Hugh Dickins
2007-11-13 10:18                                 ` Erez Zadok
2007-11-17 21:24                                   ` Hugh Dickins
2007-11-20  1:30                                     ` Erez Zadok
  -- strict thread matches above, loose matches on Subject: below --
2007-10-07 19:58 Pekka J Enberg
2007-10-08  1:58 ` Ryan Finnie
2007-10-08 11:18   ` Pekka Enberg

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=cfa94dc20710111512j9b6c038qf89c516ecd605411@mail.gmail.com \
    --to=ryan@finnie.org \
    --cc=akpm@linux-foundation.org \
    --cc=cjwatson@ubuntu.com \
    --cc=ezk@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for NNTP newsgroup(s).