.. | .. |
---|
22 | 22 | |
---|
23 | 23 | #include <asm/unistd.h> |
---|
24 | 24 | |
---|
| 25 | +#include "internal.h" |
---|
| 26 | + |
---|
25 | 27 | /* |
---|
26 | 28 | * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could |
---|
27 | 29 | * deactivate the pages and clear PG_Referenced. |
---|
28 | 30 | */ |
---|
29 | 31 | |
---|
30 | | -static int generic_fadvise(struct file *file, loff_t offset, loff_t len, |
---|
31 | | - int advice) |
---|
| 32 | +int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) |
---|
32 | 33 | { |
---|
33 | 34 | struct inode *inode; |
---|
34 | 35 | struct address_space *mapping; |
---|
.. | .. |
---|
103 | 104 | if (!nrpages) |
---|
104 | 105 | nrpages = ~0UL; |
---|
105 | 106 | |
---|
106 | | - /* |
---|
107 | | - * Ignore return value because fadvise() shall return |
---|
108 | | - * success even if filesystem can't retrieve a hint, |
---|
109 | | - */ |
---|
110 | 107 | force_page_cache_readahead(mapping, file, start_index, nrpages); |
---|
111 | 108 | break; |
---|
112 | 109 | case POSIX_FADV_NOREUSE: |
---|
.. | .. |
---|
144 | 141 | } |
---|
145 | 142 | |
---|
146 | 143 | if (end_index >= start_index) { |
---|
147 | | - unsigned long count; |
---|
| 144 | + unsigned long nr_pagevec = 0; |
---|
148 | 145 | |
---|
149 | 146 | /* |
---|
150 | 147 | * It's common to FADV_DONTNEED right after |
---|
.. | .. |
---|
157 | 154 | */ |
---|
158 | 155 | lru_add_drain(); |
---|
159 | 156 | |
---|
160 | | - count = invalidate_mapping_pages(mapping, |
---|
161 | | - start_index, end_index); |
---|
| 157 | + invalidate_mapping_pagevec(mapping, |
---|
| 158 | + start_index, end_index, |
---|
| 159 | + &nr_pagevec); |
---|
162 | 160 | |
---|
163 | 161 | /* |
---|
164 | 162 | * If fewer pages were invalidated than expected then |
---|
.. | .. |
---|
166 | 164 | * a per-cpu pagevec for a remote CPU. Drain all |
---|
167 | 165 | * pagevecs and try again. |
---|
168 | 166 | */ |
---|
169 | | - if (count < (end_index - start_index + 1)) { |
---|
| 167 | + if (nr_pagevec) { |
---|
170 | 168 | lru_add_drain_all(); |
---|
171 | 169 | invalidate_mapping_pages(mapping, start_index, |
---|
172 | 170 | end_index); |
---|
.. | .. |
---|
178 | 176 | } |
---|
179 | 177 | return 0; |
---|
180 | 178 | } |
---|
| 179 | +EXPORT_SYMBOL(generic_fadvise); |
---|
181 | 180 | |
---|
182 | 181 | int vfs_fadvise(struct file *file, loff_t offset, loff_t len, int advice) |
---|
183 | 182 | { |
---|