aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ramfs/file-nommu.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 995ef1d6686c..ebb2c417912c 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -59,7 +59,6 @@ const struct inode_operations ramfs_file_inode_operations = {
59 */ 59 */
60int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) 60int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
61{ 61{
62 struct pagevec lru_pvec;
63 unsigned long npages, xpages, loop, limit; 62 unsigned long npages, xpages, loop, limit;
64 struct page *pages; 63 struct page *pages;
65 unsigned order; 64 unsigned order;
@@ -102,24 +101,20 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
102 memset(data, 0, newsize); 101 memset(data, 0, newsize);
103 102
104 /* attach all the pages to the inode's address space */ 103 /* attach all the pages to the inode's address space */
105 pagevec_init(&lru_pvec, 0);
106 for (loop = 0; loop < npages; loop++) { 104 for (loop = 0; loop < npages; loop++) {
107 struct page *page = pages + loop; 105 struct page *page = pages + loop;
108 106
109 ret = add_to_page_cache(page, inode->i_mapping, loop, GFP_KERNEL); 107 ret = add_to_page_cache_lru(page, inode->i_mapping, loop,
108 GFP_KERNEL);
110 if (ret < 0) 109 if (ret < 0)
111 goto add_error; 110 goto add_error;
112 111
113 if (!pagevec_add(&lru_pvec, page))
114 __pagevec_lru_add_file(&lru_pvec);
115
116 /* prevent the page from being discarded on memory pressure */ 112 /* prevent the page from being discarded on memory pressure */
117 SetPageDirty(page); 113 SetPageDirty(page);
118 114
119 unlock_page(page); 115 unlock_page(page);
120 } 116 }
121 117
122 pagevec_lru_add_file(&lru_pvec);
123 return 0; 118 return 0;
124 119
125 fsize_exceeded: 120 fsize_exceeded:
@@ -128,10 +123,8 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
128 return -EFBIG; 123 return -EFBIG;
129 124
130 add_error: 125 add_error:
131 pagevec_lru_add_file(&lru_pvec); 126 while (loop < npages)
132 page_cache_release(pages + loop); 127 __free_page(pages + loop++);
133 for (loop++; loop < npages; loop++)
134 __free_page(pages + loop);
135 return ret; 128 return ret;
136} 129}
137 130