mm/swap: convert find_get_incore_page to use folios
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 19 Oct 2022 18:33:30 +0000 (19:33 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 9 Nov 2022 01:37:18 +0000 (17:37 -0800)
Eliminates a use of FGP_HEAD and saves 35 bytes of text.

Link: https://lkml.kernel.org/r/20221019183332.2802139-3-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swap_state.c

index 438d0676c5be2d3463f08890531a7038b0c89c17..44e3530520e8642015615a2efd399eddbc4b9947 100644 (file)
@@ -386,17 +386,14 @@ struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
 {
        swp_entry_t swp;
        struct swap_info_struct *si;
-       struct page *page = pagecache_get_page(mapping, index,
-                                               FGP_ENTRY | FGP_HEAD, 0);
+       struct folio *folio = __filemap_get_folio(mapping, index, FGP_ENTRY, 0);
 
-       if (!page)
-               return page;
-       if (!xa_is_value(page))
-               return find_subpage(page, index);
+       if (!xa_is_value(folio))
+               goto out;
        if (!shmem_mapping(mapping))
                return NULL;
 
-       swp = radix_to_swp_entry(page);
+       swp = radix_to_swp_entry(folio);
        /* There might be swapin error entries in shmem mapping. */
        if (non_swap_entry(swp))
                return NULL;
@@ -404,9 +401,13 @@ struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
        si = get_swap_device(swp);
        if (!si)
                return NULL;
-       page = find_get_page(swap_address_space(swp), swp_offset(swp));
+       index = swp_offset(swp);
+       folio = filemap_get_folio(swap_address_space(swp), index);
        put_swap_device(si);
-       return page;
+out:
+       if (!folio)
+               return NULL;
+       return folio_file_page(folio, index);
 }
 
 struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,