diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2012-05-29 18:06:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:23 -0400 |
commit | 782182e53a6cdb3e3d04cc40516e173046942a32 (patch) | |
tree | 9e6f74d90b65ca12d4992c034ffa9b2415f37068 /mm/readahead.c | |
parent | 4fb5ef089b288942c6fc3f85c4ecb4016c1aa4c3 (diff) |
mm: move readahead syscall to mm/readahead.c
It is better to define readahead(2) in mm/readahead.c than in
mm/filemap.c.
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/readahead.c')
-rw-r--r-- | mm/readahead.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mm/readahead.c b/mm/readahead.c index cbcbb02f3e28..ea8f8fa21649 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/task_io_accounting_ops.h> | 17 | #include <linux/task_io_accounting_ops.h> |
18 | #include <linux/pagevec.h> | 18 | #include <linux/pagevec.h> |
19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
20 | #include <linux/syscalls.h> | ||
21 | #include <linux/file.h> | ||
20 | 22 | ||
21 | /* | 23 | /* |
22 | * Initialise a struct file's readahead state. Assumes that the caller has | 24 | * Initialise a struct file's readahead state. Assumes that the caller has |
@@ -562,3 +564,41 @@ page_cache_async_readahead(struct address_space *mapping, | |||
562 | ondemand_readahead(mapping, ra, filp, true, offset, req_size); | 564 | ondemand_readahead(mapping, ra, filp, true, offset, req_size); |
563 | } | 565 | } |
564 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); | 566 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); |
567 | |||
568 | static ssize_t | ||
569 | do_readahead(struct address_space *mapping, struct file *filp, | ||
570 | pgoff_t index, unsigned long nr) | ||
571 | { | ||
572 | if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage) | ||
573 | return -EINVAL; | ||
574 | |||
575 | force_page_cache_readahead(mapping, filp, index, nr); | ||
576 | return 0; | ||
577 | } | ||
578 | |||
579 | SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count) | ||
580 | { | ||
581 | ssize_t ret; | ||
582 | struct file *file; | ||
583 | |||
584 | ret = -EBADF; | ||
585 | file = fget(fd); | ||
586 | if (file) { | ||
587 | if (file->f_mode & FMODE_READ) { | ||
588 | struct address_space *mapping = file->f_mapping; | ||
589 | pgoff_t start = offset >> PAGE_CACHE_SHIFT; | ||
590 | pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT; | ||
591 | unsigned long len = end - start + 1; | ||
592 | ret = do_readahead(mapping, file, start, len); | ||
593 | } | ||
594 | fput(file); | ||
595 | } | ||
596 | return ret; | ||
597 | } | ||
598 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
599 | asmlinkage long SyS_readahead(long fd, loff_t offset, long count) | ||
600 | { | ||
601 | return SYSC_readahead((int) fd, offset, (size_t) count); | ||
602 | } | ||
603 | SYSCALL_ALIAS(sys_readahead, SyS_readahead); | ||
604 | #endif | ||