]> git.baikalelectronics.ru Git - kernel.git/commit
mm/readahead.c: fix do_readahead() for no readpage(s)
authorMark Rutland <mark.rutland@arm.com>
Wed, 29 Jan 2014 22:05:51 +0000 (14:05 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 30 Jan 2014 00:22:40 +0000 (16:22 -0800)
commit7836eff1c070090a757325c4a442f0aa901d1c85
tree9f4c83901b87b3c7d90d93c4b054c04ef4ef9700
parente485d307c7c7593dc246f0e58b032676555140e5
mm/readahead.c: fix do_readahead() for no readpage(s)

Commit 2341e52e63f5 ("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.

As the exact return value of force_page_cache_readahead is currently
never used, we can simplify it to return only 0 or -EINVAL (when
readpage or readpages is missing).  With that in place we can simply
forward on the return value of force_page_cache_readahead in
do_readahead.

This patch performs said change, restoring the expected semantics.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/readahead.c