tcp: enforce tcp_min_snd_mss in tcp_mtu_probing()
[pandora-kernel.git] / mm / fadvise.c
index 8d723c9..35b2bb0 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fadvise.h>
 #include <linux/writeback.h>
 #include <linux/syscalls.h>
+#include <linux/swap.h>
 
 #include <asm/unistd.h>
 
@@ -123,9 +124,22 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
                start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT;
                end_index = (endbyte >> PAGE_CACHE_SHIFT);
 
-               if (end_index >= start_index)
-                       invalidate_mapping_pages(mapping, start_index,
+               if (end_index >= start_index) {
+                       unsigned long count = invalidate_mapping_pages(mapping,
+                                               start_index, end_index);
+
+                       /*
+                        * If fewer pages were invalidated than expected then
+                        * it is possible that some of the pages were on
+                        * a per-cpu pagevec for a remote CPU. Drain all
+                        * pagevecs and try again.
+                        */
+                       if (count < (end_index - start_index + 1)) {
+                               lru_add_drain_all();
+                               invalidate_mapping_pages(mapping, start_index,
                                                end_index);
+                       }
+               }
                break;
        default:
                ret = -EINVAL;