CGroup API files: make CGROUP_DEBUG default to off
[safe/jmp/linux-2.6] / mm / swap_state.c
index c75eda2..50757ee 100644 (file)
@@ -67,8 +67,7 @@ void show_swap_cache_info(void)
  * add_to_swap_cache resembles add_to_page_cache on swapper_space,
  * but sets SwapCache flag and private instead of mapping and index.
  */
-static int add_to_swap_cache(struct page *page, swp_entry_t entry,
-                              gfp_t gfp_mask)
+int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask)
 {
        int error;
 
@@ -116,6 +115,7 @@ 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. 
@@ -126,6 +126,7 @@ int add_to_swap(struct page * page, gfp_t gfp_mask)
        int err;
 
        BUG_ON(!PageLocked(page));
+       BUG_ON(!PageUptodate(page));
 
        for (;;) {
                entry = get_swap_page();
@@ -148,7 +149,6 @@ int add_to_swap(struct page * page, gfp_t gfp_mask)
 
                switch (err) {
                case 0:                         /* Success */
-                       SetPageUptodate(page);
                        SetPageDirty(page);
                        return 1;
                case -EEXIST:
@@ -183,38 +183,6 @@ void delete_from_swap_cache(struct page *page)
        page_cache_release(page);
 }
 
-/*
- * Strange swizzling function only for use by shmem_writepage
- */
-int move_to_swap_cache(struct page *page, swp_entry_t entry)
-{
-       int err = add_to_swap_cache(page, entry, GFP_ATOMIC);
-       if (!err) {
-               remove_from_page_cache(page);
-               page_cache_release(page);       /* pagecache ref */
-               if (!swap_duplicate(entry))
-                       BUG();
-               SetPageDirty(page);
-       }
-       return err;
-}
-
-/*
- * Strange swizzling function for shmem_getpage (and shmem_unuse)
- */
-int move_from_swap_cache(struct page *page, unsigned long index,
-               struct address_space *mapping)
-{
-       int err = add_to_page_cache(page, mapping, index, GFP_ATOMIC);
-       if (!err) {
-               delete_from_swap_cache(page);
-               /* shift page from clean_pages to dirty_pages list */
-               ClearPageDirty(page);
-               set_page_dirty(page);
-       }
-       return err;
-}
-
 /* 
  * If we are the only user, then try to free up the swap cache. 
  * 
@@ -348,6 +316,7 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
 /**
  * swapin_readahead - swap in pages in hope we need them soon
  * @entry: swap entry of this memory
+ * @gfp_mask: memory allocation flags
  * @vma: user vma this address belongs to
  * @addr: target address for mempolicy
  *