hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/mm/fadvise.c
....@@ -22,13 +22,14 @@
2222
2323 #include <asm/unistd.h>
2424
25
+#include "internal.h"
26
+
2527 /*
2628 * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
2729 * deactivate the pages and clear PG_Referenced.
2830 */
2931
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)
3233 {
3334 struct inode *inode;
3435 struct address_space *mapping;
....@@ -103,10 +104,6 @@
103104 if (!nrpages)
104105 nrpages = ~0UL;
105106
106
- /*
107
- * Ignore return value because fadvise() shall return
108
- * success even if filesystem can't retrieve a hint,
109
- */
110107 force_page_cache_readahead(mapping, file, start_index, nrpages);
111108 break;
112109 case POSIX_FADV_NOREUSE:
....@@ -144,7 +141,7 @@
144141 }
145142
146143 if (end_index >= start_index) {
147
- unsigned long count;
144
+ unsigned long nr_pagevec = 0;
148145
149146 /*
150147 * It's common to FADV_DONTNEED right after
....@@ -157,8 +154,9 @@
157154 */
158155 lru_add_drain();
159156
160
- count = invalidate_mapping_pages(mapping,
161
- start_index, end_index);
157
+ invalidate_mapping_pagevec(mapping,
158
+ start_index, end_index,
159
+ &nr_pagevec);
162160
163161 /*
164162 * If fewer pages were invalidated than expected then
....@@ -166,7 +164,7 @@
166164 * a per-cpu pagevec for a remote CPU. Drain all
167165 * pagevecs and try again.
168166 */
169
- if (count < (end_index - start_index + 1)) {
167
+ if (nr_pagevec) {
170168 lru_add_drain_all();
171169 invalidate_mapping_pages(mapping, start_index,
172170 end_index);
....@@ -178,6 +176,7 @@
178176 }
179177 return 0;
180178 }
179
+EXPORT_SYMBOL(generic_fadvise);
181180
182181 int vfs_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
183182 {