]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: Convert btrfs_migratepage to migrate_folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 6 Jun 2022 14:47:21 +0000 (10:47 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 2 Aug 2022 16:34:04 +0000 (12:34 -0400)
Use filemap_migrate_folio() to do the bulk of the work, and then copy
the ordered flag across if needed.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 81737eff92f3d8129b384b8bcdd3d67ebc1820d5..5f41d869c6484d7d3bed7c732aa06287de428880 100644 (file)
@@ -8255,30 +8255,24 @@ static bool btrfs_release_folio(struct folio *folio, gfp_t gfp_flags)
 }
 
 #ifdef CONFIG_MIGRATION
-static int btrfs_migratepage(struct address_space *mapping,
-                            struct page *newpage, struct page *page,
+static int btrfs_migrate_folio(struct address_space *mapping,
+                            struct folio *dst, struct folio *src,
                             enum migrate_mode mode)
 {
-       int ret;
+       int ret = filemap_migrate_folio(mapping, dst, src, mode);
 
-       ret = migrate_page_move_mapping(mapping, newpage, page, 0);
        if (ret != MIGRATEPAGE_SUCCESS)
                return ret;
 
-       if (page_has_private(page))
-               attach_page_private(newpage, detach_page_private(page));
-
-       if (PageOrdered(page)) {
-               ClearPageOrdered(page);
-               SetPageOrdered(newpage);
+       if (folio_test_ordered(src)) {
+               folio_clear_ordered(src);
+               folio_set_ordered(dst);
        }
 
-       if (mode != MIGRATE_SYNC_NO_COPY)
-               migrate_page_copy(newpage, page);
-       else
-               migrate_page_states(newpage, page);
        return MIGRATEPAGE_SUCCESS;
 }
+#else
+#define btrfs_migrate_folio NULL
 #endif
 
 static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
@@ -11422,9 +11416,7 @@ static const struct address_space_operations btrfs_aops = {
        .direct_IO      = noop_direct_IO,
        .invalidate_folio = btrfs_invalidate_folio,
        .release_folio  = btrfs_release_folio,
-#ifdef CONFIG_MIGRATION
-       .migratepage    = btrfs_migratepage,
-#endif
+       .migrate_folio  = btrfs_migrate_folio,
        .dirty_folio    = filemap_dirty_folio,
        .error_remove_page = generic_error_remove_page,
        .swap_activate  = btrfs_swap_activate,