diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 5dfc093ceb3d..070e7547d5b5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1726,7 +1726,7 @@ int generic_file_readonly_mmap(struct file * file, struct vm_area_struct * vma) | |||
1726 | EXPORT_SYMBOL(generic_file_mmap); | 1726 | EXPORT_SYMBOL(generic_file_mmap); |
1727 | EXPORT_SYMBOL(generic_file_readonly_mmap); | 1727 | EXPORT_SYMBOL(generic_file_readonly_mmap); |
1728 | 1728 | ||
1729 | static inline struct page *__read_cache_page(struct address_space *mapping, | 1729 | static struct page *__read_cache_page(struct address_space *mapping, |
1730 | unsigned long index, | 1730 | unsigned long index, |
1731 | int (*filler)(void *,struct page*), | 1731 | int (*filler)(void *,struct page*), |
1732 | void *data) | 1732 | void *data) |
@@ -1763,17 +1763,11 @@ repeat: | |||
1763 | return page; | 1763 | return page; |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | /** | 1766 | /* |
1767 | * read_cache_page - read into page cache, fill it if needed | 1767 | * Same as read_cache_page, but don't wait for page to become unlocked |
1768 | * @mapping: the page's address_space | 1768 | * after submitting it to the filler. |
1769 | * @index: the page index | ||
1770 | * @filler: function to perform the read | ||
1771 | * @data: destination for read data | ||
1772 | * | ||
1773 | * Read into the page cache. If a page already exists, | ||
1774 | * and PageUptodate() is not set, try to fill the page. | ||
1775 | */ | 1769 | */ |
1776 | struct page *read_cache_page(struct address_space *mapping, | 1770 | struct page *read_cache_page_async(struct address_space *mapping, |
1777 | unsigned long index, | 1771 | unsigned long index, |
1778 | int (*filler)(void *,struct page*), | 1772 | int (*filler)(void *,struct page*), |
1779 | void *data) | 1773 | void *data) |
@@ -1805,6 +1799,39 @@ retry: | |||
1805 | page = ERR_PTR(err); | 1799 | page = ERR_PTR(err); |
1806 | } | 1800 | } |
1807 | out: | 1801 | out: |
1802 | mark_page_accessed(page); | ||
1803 | return page; | ||
1804 | } | ||
1805 | EXPORT_SYMBOL(read_cache_page_async); | ||
1806 | |||
1807 | /** | ||
1808 | * read_cache_page - read into page cache, fill it if needed | ||
1809 | * @mapping: the page's address_space | ||
1810 | * @index: the page index | ||
1811 | * @filler: function to perform the read | ||
1812 | * @data: destination for read data | ||
1813 | * | ||
1814 | * Read into the page cache. If a page already exists, and PageUptodate() is | ||
1815 | * not set, try to fill the page then wait for it to become unlocked. | ||
1816 | * | ||
1817 | * If the page does not get brought uptodate, return -EIO. | ||
1818 | */ | ||
1819 | struct page *read_cache_page(struct address_space *mapping, | ||
1820 | unsigned long index, | ||
1821 | int (*filler)(void *,struct page*), | ||
1822 | void *data) | ||
1823 | { | ||
1824 | struct page *page; | ||
1825 | |||
1826 | page = read_cache_page_async(mapping, index, filler, data); | ||
1827 | if (IS_ERR(page)) | ||
1828 | goto out; | ||
1829 | wait_on_page_locked(page); | ||
1830 | if (!PageUptodate(page)) { | ||
1831 | page_cache_release(page); | ||
1832 | page = ERR_PTR(-EIO); | ||
1833 | } | ||
1834 | out: | ||
1808 | return page; | 1835 | return page; |
1809 | } | 1836 | } |
1810 | EXPORT_SYMBOL(read_cache_page); | 1837 | EXPORT_SYMBOL(read_cache_page); |