aboutsummaryrefslogtreecommitdiffstats
path: root/mm/readahead.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/readahead.c')
-rw-r--r--mm/readahead.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/mm/readahead.c b/mm/readahead.c
index c5c8981469e7..229788884010 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -58,28 +58,25 @@ int read_cache_pages(struct address_space *mapping, struct list_head *pages,
58 int (*filler)(void *, struct page *), void *data) 58 int (*filler)(void *, struct page *), void *data)
59{ 59{
60 struct page *page; 60 struct page *page;
61 struct pagevec lru_pvec;
62 int ret = 0; 61 int ret = 0;
63 62
64 pagevec_init(&lru_pvec, 0);
65
66 while (!list_empty(pages)) { 63 while (!list_empty(pages)) {
67 page = list_to_page(pages); 64 page = list_to_page(pages);
68 list_del(&page->lru); 65 list_del(&page->lru);
69 if (add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) { 66 if (add_to_page_cache_lru(page, mapping,
67 page->index, GFP_KERNEL)) {
70 page_cache_release(page); 68 page_cache_release(page);
71 continue; 69 continue;
72 } 70 }
71 page_cache_release(page);
72
73 ret = filler(data, page); 73 ret = filler(data, page);
74 if (!pagevec_add(&lru_pvec, page)) 74 if (unlikely(ret)) {
75 __pagevec_lru_add(&lru_pvec);
76 if (ret) {
77 put_pages_list(pages); 75 put_pages_list(pages);
78 break; 76 break;
79 } 77 }
80 task_io_account_read(PAGE_CACHE_SIZE); 78 task_io_account_read(PAGE_CACHE_SIZE);
81 } 79 }
82 pagevec_lru_add(&lru_pvec);
83 return ret; 80 return ret;
84} 81}
85 82
@@ -89,7 +86,6 @@ static int read_pages(struct address_space *mapping, struct file *filp,
89 struct list_head *pages, unsigned nr_pages) 86 struct list_head *pages, unsigned nr_pages)
90{ 87{
91 unsigned page_idx; 88 unsigned page_idx;
92 struct pagevec lru_pvec;
93 int ret; 89 int ret;
94 90
95 if (mapping->a_ops->readpages) { 91 if (mapping->a_ops->readpages) {
@@ -99,19 +95,15 @@ static int read_pages(struct address_space *mapping, struct file *filp,
99 goto out; 95 goto out;
100 } 96 }
101 97
102 pagevec_init(&lru_pvec, 0);
103 for (page_idx = 0; page_idx < nr_pages; page_idx++) { 98 for (page_idx = 0; page_idx < nr_pages; page_idx++) {
104 struct page *page = list_to_page(pages); 99 struct page *page = list_to_page(pages);
105 list_del(&page->lru); 100 list_del(&page->lru);
106 if (!add_to_page_cache(page, mapping, 101 if (!add_to_page_cache_lru(page, mapping,
107 page->index, GFP_KERNEL)) { 102 page->index, GFP_KERNEL)) {
108 mapping->a_ops->readpage(filp, page); 103 mapping->a_ops->readpage(filp, page);
109 if (!pagevec_add(&lru_pvec, page)) 104 }
110 __pagevec_lru_add(&lru_pvec); 105 page_cache_release(page);
111 } else
112 page_cache_release(page);
113 } 106 }
114 pagevec_lru_add(&lru_pvec);
115 ret = 0; 107 ret = 0;
116out: 108out:
117 return ret; 109 return ret;