Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next...
[deliverable/linux.git] / mm / swapfile.c
index 560ad380634c19661f5606d0397ac85aa62c8add..031713ab40ce9fdeb289e149605e6d1514f345c0 100644 (file)
@@ -119,7 +119,7 @@ __try_to_reclaim_swap(struct swap_info_struct *si, unsigned long offset)
                ret = try_to_free_swap(page);
                unlock_page(page);
        }
-       page_cache_release(page);
+       put_page(page);
        return ret;
 }
 
@@ -922,18 +922,19 @@ out:
  * to it.  And as a side-effect, free up its swap: because the old content
  * on disk will never be read, and seeking back there to write new content
  * later would only waste time away from clustering.
+ *
+ * NOTE: total_mapcount should not be relied upon by the caller if
+ * reuse_swap_page() returns false, but it may be always overwritten
+ * (see the other implementation for CONFIG_SWAP=n).
  */
-int reuse_swap_page(struct page *page)
+bool reuse_swap_page(struct page *page, int *total_mapcount)
 {
        int count;
 
        VM_BUG_ON_PAGE(!PageLocked(page), page);
        if (unlikely(PageKsm(page)))
-               return 0;
-       /* The page is part of THP and cannot be reused */
-       if (PageTransCompound(page))
-               return 0;
-       count = page_mapcount(page);
+               return false;
+       count = page_trans_huge_mapcount(page, total_mapcount);
        if (count <= 1 && PageSwapCache(page)) {
                count += page_swapcount(page);
                if (count == 1 && !PageWriteback(page)) {
@@ -1000,7 +1001,7 @@ int free_swap_and_cache(swp_entry_t entry)
                        page = find_get_page(swap_address_space(entry),
                                                entry.val);
                        if (page && !trylock_page(page)) {
-                               page_cache_release(page);
+                               put_page(page);
                                page = NULL;
                        }
                }
@@ -1017,7 +1018,7 @@ int free_swap_and_cache(swp_entry_t entry)
                        SetPageDirty(page);
                }
                unlock_page(page);
-               page_cache_release(page);
+               put_page(page);
        }
        return p != NULL;
 }
@@ -1518,7 +1519,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
                }
                if (retval) {
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                        break;
                }
 
@@ -1570,7 +1571,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
                 */
                SetPageDirty(page);
                unlock_page(page);
-               page_cache_release(page);
+               put_page(page);
 
                /*
                 * Make sure that we aren't completely killing
@@ -2574,7 +2575,7 @@ bad_swap:
 out:
        if (page && !IS_ERR(page)) {
                kunmap(page);
-               page_cache_release(page);
+               put_page(page);
        }
        if (name)
                putname(name);
This page took 0.049958 seconds and 5 git commands to generate.