mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Stancek <jstancek@redhat.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Wanlong Gao <gaowanlong@cn.fujitsu.com>
Subject: [BUG] LTP test case readahead01 fails after commit 63d0f0a3c7
Date: Fri, 20 Dec 2013 11:45:29 +0800	[thread overview]
Message-ID: <52B3BD59.5010207@cn.fujitsu.com> (raw)

Hi AKPM and folks,

LTP test readahead syscall return value like this:

=====================
static void test_invalid_fd(void)
{
	int fd[2];

	tst_resm(TINFO, "test_invalid_fd pipe");
	if (pipe(fd) < 0)
		tst_resm(TBROK | TERRNO, "Failed to create pipe");
	TEST(ltp_syscall(__NR_readahead, fd[0], 0, getpagesize()));
	check_ret(-1);
	check_errno(EINVAL);
	close(fd[0]);
	close(fd[1]);

	tst_resm(TINFO, "test_invalid_fd socket");
	fd[0] = socket(AF_INET, SOCK_STREAM, 0);
	if (fd[0] < 0)
		tst_resm(TBROK | TERRNO, "Failed to create socket");
	TEST(ltp_syscall(__NR_readahead, fd[0], 0, getpagesize()));
	check_ret(-1);
	check_errno(EINVAL);
	close(fd[0]);
}
====================================
FULL case code: https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/readahead/readahead01.c


This case passed before the following kernel commit[1],
it means kernel will return -1 with errno=EINVAL. But after
this commit[1], kernel will return 0 here.

The different between before and after this commit[1] is that:
BEFORE:
=============
do_readahead():
if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage)
	return EINVAL;
============

AFTER:
======================
do_readahead():
if (!mapping || !mapping->a_ops)
	return EINVAL;

And followed with:

force_page_cache_readahead():
if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))
		return -EINVAL;
=====================

I think you must know which is right?




Thanks,
Wanlong Gao



[1]:
commit 63d0f0a3c7e1281fd79268a8d988167eff607fb6
Author: Andrew Morton <akpm@linux-foundation.org>
Date:   Tue Nov 12 15:07:09 2013 -0800

    mm/readahead.c:do_readhead(): don't check for ->readpage
    
    The callee force_page_cache_readahead() already does this and unlike
    do_readahead(), force_page_cache_readahead() remembers to check for
    ->readpages() as well.
    
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

diff --git a/mm/readahead.c b/mm/readahead.c
index e4ed041..5024183 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -569,7 +569,7 @@ static ssize_t
 do_readahead(struct address_space *mapping, struct file *filp,
             pgoff_t index, unsigned long nr)
 {
-       if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage)
+       if (!mapping || !mapping->a_ops)
                return -EINVAL;
 
        force_page_cache_readahead(mapping, filp, index, nr);


                 reply	other threads:[~2013-12-20  3:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=52B3BD59.5010207@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=jstancek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.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