Merge branch 'audit.b10' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[pandora-kernel.git] / mm / migrate.c
index 09f6e4a..1c25040 100644 (file)
@@ -16,8 +16,7 @@
 #include <linux/module.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
-#include <linux/buffer_head.h> /* for try_to_release_page(),
-                                       buffer_heads_over_limit */
+#include <linux/buffer_head.h>
 #include <linux/mm_inline.h>
 #include <linux/pagevec.h>
 #include <linux/rmap.h>
@@ -28,8 +27,6 @@
 
 #include "internal.h"
 
-#include "internal.h"
-
 /* The maximum number of pages to take off the LRU for migration */
 #define MIGRATE_CHUNK_SIZE 256
 
@@ -176,7 +173,6 @@ unlock_retry:
 retry:
        return -EAGAIN;
 }
-EXPORT_SYMBOL(swap_page);
 
 /*
  * Remove references for a page and establish the new page with the correct
@@ -234,7 +230,7 @@ int migrate_page_remove_references(struct page *newpage,
        if (!page_mapping(page) || page_count(page) != nr_refs ||
                        *radix_pointer != page) {
                write_unlock_irq(&mapping->tree_lock);
-               return 1;
+               return -EAGAIN;
        }
 
        /*
@@ -443,6 +439,17 @@ redo:
                        goto unlock_both;
                 }
 
+               /* Make sure the dirty bit is up to date */
+               if (try_to_unmap(page, 1) == SWAP_FAIL) {
+                       rc = -EPERM;
+                       goto unlock_both;
+               }
+
+               if (page_mapcount(page)) {
+                       rc = -EAGAIN;
+                       goto unlock_both;
+               }
+
                /*
                 * Default handling if a filesystem does not provide
                 * a migration function. We can only migrate clean