tools headers UAPI: Sync openat2.h with the kernel sources
[linux-2.6-microblaze.git] / mm / swapfile.c
index 9fffc5a..084a5b9 100644 (file)
@@ -47,7 +47,6 @@
 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
                                 unsigned char);
 static void free_swap_count_continuations(struct swap_info_struct *);
-static sector_t map_swap_entry(swp_entry_t, struct block_device**);
 
 DEFINE_SPINLOCK(swap_lock);
 static unsigned int nr_swapfiles;
@@ -220,6 +219,19 @@ offset_to_swap_extent(struct swap_info_struct *sis, unsigned long offset)
        BUG();
 }
 
+sector_t swap_page_sector(struct page *page)
+{
+       struct swap_info_struct *sis = page_swap_info(page);
+       struct swap_extent *se;
+       sector_t sector;
+       pgoff_t offset;
+
+       offset = __page_file_index(page);
+       se = offset_to_swap_extent(sis, offset);
+       sector = se->start_block + (offset - se->start_page);
+       return sector << (PAGE_SHIFT - 9);
+}
+
 /*
  * swap allocation tell device that a cluster of swap can now be discarded,
  * to allow the swap device to optimize its wear-levelling.
@@ -1158,13 +1170,13 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry)
        return p;
 
 bad_offset:
-       pr_err("swap_info_get: %s%08lx\n", Bad_offset, entry.val);
+       pr_err("%s: %s%08lx\n", __func__, Bad_offset, entry.val);
        goto out;
 bad_device:
-       pr_err("swap_info_get: %s%08lx\n", Unused_file, entry.val);
+       pr_err("%s: %s%08lx\n", __func__, Unused_file, entry.val);
        goto out;
 bad_nofile:
-       pr_err("swap_info_get: %s%08lx\n", Bad_file, entry.val);
+       pr_err("%s: %s%08lx\n", __func__, Bad_file, entry.val);
 out:
        return NULL;
 }
@@ -1181,7 +1193,7 @@ static struct swap_info_struct *_swap_info_get(swp_entry_t entry)
        return p;
 
 bad_free:
-       pr_err("swap_info_get: %s%08lx\n", Unused_offset, entry.val);
+       pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val);
 out:
        return NULL;
 }
@@ -1850,12 +1862,13 @@ int find_first_swap(dev_t *device)
  */
 sector_t swapdev_block(int type, pgoff_t offset)
 {
-       struct block_device *bdev;
        struct swap_info_struct *si = swap_type_to_swap_info(type);
+       struct swap_extent *se;
 
        if (!si || !(si->flags & SWP_WRITEOK))
                return 0;
-       return map_swap_entry(swp_entry(type, offset), &bdev);
+       se = offset_to_swap_extent(si, offset);
+       return se->start_block + (offset - se->start_page);
 }
 
 /*
@@ -1951,8 +1964,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
        si = swap_info[type];
        pte = pte_offset_map(pmd, addr);
        do {
-               struct vm_fault vmf;
-
                if (!is_swap_pte(*pte))
                        continue;
 
@@ -1968,9 +1979,12 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
                swap_map = &si->swap_map[offset];
                page = lookup_swap_cache(entry, vma, addr);
                if (!page) {
-                       vmf.vma = vma;
-                       vmf.address = addr;
-                       vmf.pmd = pmd;
+                       struct vm_fault vmf = {
+                               .vma = vma,
+                               .address = addr,
+                               .pmd = pmd,
+                       };
+
                        page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
                                                &vmf);
                }
@@ -2281,36 +2295,6 @@ static void drain_mmlist(void)
        spin_unlock(&mmlist_lock);
 }
 
-/*
- * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
- * corresponds to page offset for the specified swap entry.
- * Note that the type of this function is sector_t, but it returns page offset
- * into the bdev, not sector offset.
- */
-static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
-{
-       struct swap_info_struct *sis;
-       struct swap_extent *se;
-       pgoff_t offset;
-
-       sis = swp_swap_info(entry);
-       *bdev = sis->bdev;
-
-       offset = swp_offset(entry);
-       se = offset_to_swap_extent(sis, offset);
-       return se->start_block + (offset - se->start_page);
-}
-
-/*
- * Returns the page offset into bdev for the specified page's swap entry.
- */
-sector_t map_swap_page(struct page *page, struct block_device **bdev)
-{
-       swp_entry_t entry;
-       entry.val = page_private(page);
-       return map_swap_entry(entry, bdev);
-}
-
 /*
  * Free all of a swapdev's extent information
  */