From: Chen Gang <gang.chen@asianux.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>, Mel Gorman <mgorman@suse.de>,
rientjes@google.com, sasha.levin@oracle.com,
linux@rasmusvillemoes.dk, kosaki.motohiro@jp.fujitsu.com,
Wu Fengguang <fengguang.wu@intel.com>,
lczerner@redhat.com, linux-mm@kvack.org
Subject: [PATCH] mm/readahead.c: need always return 0 when system call readahead() succeeds
Date: Tue, 15 Oct 2013 16:06:31 +0800 [thread overview]
Message-ID: <525CF787.6050107@asianux.com> (raw)
In-Reply-To: <52390907.7050101@asianux.com>
For system call readahead(), need always return 0 instead of bytes read
when succeed. The related commit "fee53ce mm/readahead.c: return the
value which force_page_cache_readahead() returns" causes this issue.
This bug is found by LTP readahead02 test, the related output:
[root@gchenlinux readahead]# ./readahead02
readahead02 0 TINFO : creating test file of size: 67108864
readahead02 0 TINFO : read_testfile(0)
readahead02 0 TINFO : read_testfile(1)
readahead02 1 TFAIL : unexpected failure - returned value = 16384, expected: 0
readahead02 2 TPASS : offset is still at 0 as expected
readahead02 0 TINFO : read_testfile(0) took: 2292819 usec
readahead02 0 TINFO : read_testfile(1) took: 3524116 usec
readahead02 0 TINFO : read_testfile(0) read: 67108864 bytes
readahead02 0 TINFO : read_testfile(1) read: 0 bytes
readahead02 3 TPASS : readahead saved some I/O
readahead02 0 TINFO : cache can hold at least: 624316 kB
readahead02 0 TINFO : read_testfile(0) used cache: 65476 kB
readahead02 0 TINFO : read_testfile(1) used cache: 65632 kB
readahead02 4 TPASS : using cache as expected
After this fix, it can pass LTP common test by readahead01 and readahead02.
[root@gchenlinux readahead]# ./readahead01
readahead01 0 TINFO : test_bad_fd -1
readahead01 1 TPASS : expected ret success - returned value = -1
readahead01 2 TPASS : expected failure: TEST_ERRNO=EBADF(9): Bad file descriptor
readahead01 0 TINFO : test_bad_fd O_WRONLY
readahead01 3 TPASS : expected ret success - returned value = -1
readahead01 4 TPASS : expected failure: TEST_ERRNO=EBADF(9): Bad file descriptor
readahead01 0 TINFO : test_invalid_fd pipe
readahead01 5 TPASS : expected ret success - returned value = -1
readahead01 6 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument
readahead01 0 TINFO : test_invalid_fd socket
readahead01 7 TPASS : expected ret success - returned value = -1
readahead01 8 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument
[root@gchenlinux readahead]# ./readahead02
readahead02 0 TINFO : creating test file of size: 67108864
readahead02 0 TINFO : read_testfile(0)
readahead02 0 TINFO : read_testfile(1)
readahead02 1 TPASS : expected ret success - returned value = 0
readahead02 2 TPASS : offset is still at 0 as expected
readahead02 0 TINFO : read_testfile(0) took: 3327468 usec
readahead02 0 TINFO : read_testfile(1) took: 2802184 usec
readahead02 0 TINFO : read_testfile(0) read: 67108864 bytes
readahead02 0 TINFO : read_testfile(1) read: 0 bytes
readahead02 3 TPASS : readahead saved some I/O
readahead02 0 TINFO : cache can hold at least: 794800 kB
readahead02 0 TINFO : read_testfile(0) used cache: 66704 kB
readahead02 0 TINFO : read_testfile(1) used cache: 65528 kB
readahead02 4 TPASS : using cache as expected
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
mm/readahead.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mm/readahead.c b/mm/readahead.c
index 1eee42b..83a202e 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -592,5 +592,5 @@ SYSCALL_DEFINE3(readahead, int, fd, loff_t, offset, size_t, count)
}
fdput(f);
}
- return ret;
+ return ret < 0 ? ret : 0;
}
--
1.7.7.6
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-10-15 8:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 3:31 [PATCH] mm: readahead: return the value which force_page_cache_readahead() returns Chen Gang
2013-08-20 23:16 ` Andrew Morton
2013-08-21 2:29 ` Chen Gang
2013-08-21 2:41 ` [PATCH v2] m: " Chen Gang
2013-09-03 5:27 ` Chen Gang
2013-09-17 22:56 ` Andrew Morton
2013-09-18 1:59 ` Chen Gang
2013-10-15 8:06 ` Chen Gang [this message]
2013-10-15 12:12 ` [PATCH] mm/madvise.c: return 0 instead of read bytes after force_page_cache_readahead() succeeds Chen Gang
2013-10-16 23:06 ` [PATCH] mm/readahead.c: need always return 0 when system call readahead() succeeds David Rientjes
2013-10-17 0:57 ` Chen Gang
2013-10-17 1:17 ` David Rientjes
2013-10-17 1:32 ` Chen Gang
2013-10-17 2:21 ` David Rientjes
2013-10-17 2:37 ` Chen Gang
2013-10-17 2:40 ` Chen Gang
2013-10-15 8:20 ` [PATCH v2] m: readahead: return the value which force_page_cache_readahead() returns Chen Gang
2013-10-17 9:56 ` Chen Gang
2013-11-04 5:31 ` [PATCH v3] mm: readahead: check return " Chen Gang
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=525CF787.6050107@asianux.com \
--to=gang.chen@asianux.com \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=lczerner@redhat.com \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mgorman@suse.de \
--cc=rientjes@google.com \
--cc=sasha.levin@oracle.com \
--cc=viro@zeniv.linux.org.uk \
/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