clarify get_user_pages() prototype
[linux-2.6.git] / mm / swap_state.c
index 81c825f..42cd38e 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/migrate.h>
+#include <linux/page_cgroup.h>
 
 #include <asm/pgtable.h>
 
@@ -123,7 +124,6 @@ void __delete_from_swap_cache(struct page *page)
 /**
  * add_to_swap - allocate swap space for a page
  * @page: page we want to move to swap
- * @gfp_mask: memory allocation flags
  *
  * Allocate swap space for the page and add the page to the
  * swap cache.  Caller needs to hold the page lock. 
@@ -161,11 +161,11 @@ int add_to_swap(struct page *page)
                        return 1;
                case -EEXIST:
                        /* Raced with "speculative" read_swap_cache_async */
-                       swap_free(entry);
+                       swapcache_free(entry, NULL);
                        continue;
                default:
                        /* -ENOMEM radix-tree allocation failure */
-                       swap_free(entry);
+                       swapcache_free(entry, NULL);
                        return 0;
                }
        }
@@ -187,7 +187,7 @@ void delete_from_swap_cache(struct page *page)
        __delete_from_swap_cache(page);
        spin_unlock_irq(&swapper_space.tree_lock);
 
-       swap_free(entry);
+       swapcache_free(entry, page);
        page_cache_release(page);
 }
 
@@ -291,7 +291,10 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                /*
                 * Swap entry may have been freed since our caller observed it.
                 */
-               if (!swap_duplicate(entry))
+               err = swapcache_prepare(entry);
+               if (err == -EEXIST) /* seems racy */
+                       continue;
+               if (err)           /* swp entry is obsolete ? */
                        break;
 
                /*
@@ -310,12 +313,12 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                         * Initiate read into locked page and return.
                         */
                        lru_cache_add_anon(new_page);
-                       swap_readpage(NULL, new_page);
+                       swap_readpage(new_page);
                        return new_page;
                }
                ClearPageSwapBacked(new_page);
                __clear_page_locked(new_page);
-               swap_free(entry);
+               swapcache_free(entry, NULL);
        } while (err != -ENOMEM);
 
        if (new_page)