On Tue, Jan 28, 2014 at 12:03:01PM -0800, Andrew Morton wrote:
> On Tue, 28 Jan 2014 11:14:19 +0000 Mark Rutland <[email protected]> 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;

> : }
> 
> and
> 
> : int force_page_cache_readahead(struct address_space *mapping, struct file 
> *filp,
> :             pgoff_t offset, unsigned long nr_to_read)
> : {
> :     if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))
> :             return -EINVAL;
> 
> Clearly, do_readahead() will return -EINVAL if neither ->readpage or
> ->readpages are implemented.
> 
> I can see that the behaviour would change if the address_space
> implements only one of ->readpage and ->readpages, but that doesn't
> appear to match your description and the new behaviour is correct - we
> can now perform readahead for address_spaces which implement
> ->readpages and not ->readpage (which would be odd and might not work
> for other reasons..).
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to