mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Mark Rutland <mark.rutland@arm.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: readahead: fix do_readahead for no readpage(s)
Date: Tue, 28 Jan 2014 13:09:10 -0800	[thread overview]
Message-ID: <20140128130910.925240fae4cd8b44238178e2@linux-foundation.org> (raw)
In-Reply-To: <20140128210126.GA27556@node.dhcp.inet.fi>

On Tue, 28 Jan 2014 23:01:26 +0200 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:

> On Tue, Jan 28, 2014 at 12:03:01PM -0800, Andrew Morton wrote:
> > On Tue, 28 Jan 2014 11:14:19 +0000 Mark Rutland <mark.rutland@arm.com> wrote:
> > 
> > > Commit 63d0f0a3c7e1 (mm/readahead.c:do_readhead(): don't check for
> > > ->readpage) unintentionally made do_readahead return 0 for all valid
> > > files regardless of whether readahead was supported, rather than the
> > > expected -EINVAL. This gets forwarded on to userspace, and results in
> > > sys_readahead appearing to succeed in cases that don't make sense (e.g.
> > > when called on pipes or sockets). This issue is detected by the LTP
> > > readahead01 testcase.
> > 
> > How can this be?
> > 
> > : static ssize_t
> > : do_readahead(struct address_space *mapping, struct file *filp,
> > : 	     pgoff_t index, unsigned long nr)
> > : {
> > : 	if (!mapping || !mapping->a_ops)
> > : 		return -EINVAL;
> > : 
> > : 	return force_page_cache_readahead(mapping, filp, index, nr);
> 
> It's not what we have in Linus' tree. force_page_cache_readahead() return
> code is unused:
> 
> 	force_page_cache_readahead(mapping, filp, index, nr);
> 	return 0;
> 

ah, oops, I was looking at the code with Mark's patch applied.

Yes, the force_page_cache_readahead() return value should be propagated.

And I guess the lobotomising of the force_page_cache_readahead() return
value is OK.  force_page_cache_readahead() presently returns an errno
even if it has performed some reads.  A read()-style function shouldn't
do that - it should return a short read in that case.


      reply	other threads:[~2014-01-28 21:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 11:14 Mark Rutland
2014-01-28 11:53 ` Kirill A. Shutemov
2014-01-28 20:03 ` Andrew Morton
2014-01-28 21:01   ` Kirill A. Shutemov
2014-01-28 21:09     ` Andrew Morton [this message]

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=20140128130910.925240fae4cd8b44238178e2@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.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

Powered by JetHome