diff options
-rw-r--r-- | mm/filemap.c | 39 | ||||
-rw-r--r-- | mm/readahead.c | 40 |
2 files changed, 40 insertions, 39 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 79c4b2b0b14e..64b48f934b89 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/pagevec.h> | 29 | #include <linux/pagevec.h> |
30 | #include <linux/blkdev.h> | 30 | #include <linux/blkdev.h> |
31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
32 | #include <linux/syscalls.h> | ||
33 | #include <linux/cpuset.h> | 32 | #include <linux/cpuset.h> |
34 | #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ | 33 | #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ |
35 | #include <linux/memcontrol.h> | 34 | #include <linux/memcontrol.h> |
@@ -1478,44 +1477,6 @@ out: | |||
1478 | } | 1477 | } |
1479 | EXPORT_SYMBOL(generic_file_aio_read); | 1478 | EXPORT_SYMBOL(generic_file_aio_read); |
1480 | 1479 | ||
1481 | static ssize_t | ||
1482 | do_readahead(struct address_space *mapping, struct file *filp, | ||
1483 | pgoff_t index, unsigned long nr) | ||
1484 | { | ||
1485 | if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage) | ||
1486 | return -EINVAL; | ||
1487 | |||
1488 | force_page_cache_readahead(mapping, filp, index, nr); | ||
1489 | return 0; | ||
1490 | } | ||
1491 | |||
1492 | SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count) | ||
1493 | { | ||
1494 | ssize_t ret; | ||
1495 | struct file *file; | ||
1496 | |||
1497 | ret = -EBADF; | ||
1498 | file = fget(fd); | ||
1499 | if (file) { | ||
1500 | if (file->f_mode & FMODE_READ) { | ||
1501 | struct address_space *mapping = file->f_mapping; | ||
1502 | pgoff_t start = offset >> PAGE_CACHE_SHIFT; | ||
1503 | pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT; | ||
1504 | unsigned long len = end - start + 1; | ||
1505 | ret = do_readahead(mapping, file, start, len); | ||
1506 | } | ||
1507 | fput(file); | ||
1508 | } | ||
1509 | return ret; | ||
1510 | } | ||
1511 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
1512 | asmlinkage long SyS_readahead(long fd, loff_t offset, long count) | ||
1513 | { | ||
1514 | return SYSC_readahead((int) fd, offset, (size_t) count); | ||
1515 | } | ||
1516 | SYSCALL_ALIAS(sys_readahead, SyS_readahead); | ||
1517 | #endif | ||
1518 | |||
1519 | #ifdef CONFIG_MMU | 1480 | #ifdef CONFIG_MMU |
1520 | /** | 1481 | /** |
1521 | * page_cache_read - adds requested page to the page cache if not already there | 1482 | * page_cache_read - adds requested page to the page cache if not already there |
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 | ||