]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/migrate: Add filemap_migrate_folio()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 6 Jun 2022 16:55:08 +0000 (12:55 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 2 Aug 2022 16:34:04 +0000 (12:34 -0400)
There is nothing iomap-specific about iomap_migratepage(), and it fits
a pattern used by several other filesystems, so move it to mm/migrate.c,
convert it to be filemap_migrate_folio() and convert the iomap filesystems
to use it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fs/gfs2/aops.c
fs/iomap/buffered-io.c
fs/xfs/xfs_aops.c
fs/zonefs/super.c
include/linux/iomap.h
include/linux/pagemap.h
mm/migrate.c

index 106e90a365838efee54e8e3a6f8bfa77d52a536c..57ff883d432c75dde34adb3372569c75041667b1 100644 (file)
@@ -774,7 +774,7 @@ static const struct address_space_operations gfs2_aops = {
        .invalidate_folio = iomap_invalidate_folio,
        .bmap = gfs2_bmap,
        .direct_IO = noop_direct_IO,
-       .migratepage = iomap_migrate_page,
+       .migrate_folio = filemap_migrate_folio,
        .is_partially_uptodate = iomap_is_partially_uptodate,
        .error_remove_page = generic_error_remove_page,
 };
index 66278a14bfa7c98044aee7ad835dc4ab24ee16aa..5a91aa1db945bcb040026024f2e90d2684453aca 100644 (file)
@@ -489,31 +489,6 @@ void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len)
 }
 EXPORT_SYMBOL_GPL(iomap_invalidate_folio);
 
-#ifdef CONFIG_MIGRATION
-int
-iomap_migrate_page(struct address_space *mapping, struct page *newpage,
-               struct page *page, enum migrate_mode mode)
-{
-       struct folio *folio = page_folio(page);
-       struct folio *newfolio = page_folio(newpage);
-       int ret;
-
-       ret = folio_migrate_mapping(mapping, newfolio, folio, 0);
-       if (ret != MIGRATEPAGE_SUCCESS)
-               return ret;
-
-       if (folio_test_private(folio))
-               folio_attach_private(newfolio, folio_detach_private(folio));
-
-       if (mode != MIGRATE_SYNC_NO_COPY)
-               folio_migrate_copy(newfolio, folio);
-       else
-               folio_migrate_flags(newfolio, folio);
-       return MIGRATEPAGE_SUCCESS;
-}
-EXPORT_SYMBOL_GPL(iomap_migrate_page);
-#endif /* CONFIG_MIGRATION */
-
 static void
 iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
 {
index 8ec38b25187bdb850ed9ec4024c6868d3afb9a9a..5d1a995b15f8331bb55f748fe2e42e2e9ebb652c 100644 (file)
@@ -570,7 +570,7 @@ const struct address_space_operations xfs_address_space_operations = {
        .invalidate_folio       = iomap_invalidate_folio,
        .bmap                   = xfs_vm_bmap,
        .direct_IO              = noop_direct_IO,
-       .migratepage            = iomap_migrate_page,
+       .migrate_folio          = filemap_migrate_folio,
        .is_partially_uptodate  = iomap_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
        .swap_activate          = xfs_iomap_swapfile_activate,
index 053299758deb98abfe8a2154dd14fb6e32646a07..cc6d4cf580ac6f612599a9255173ec11b6db4748 100644 (file)
@@ -271,7 +271,7 @@ static const struct address_space_operations zonefs_file_aops = {
        .dirty_folio            = filemap_dirty_folio,
        .release_folio          = iomap_release_folio,
        .invalidate_folio       = iomap_invalidate_folio,
-       .migratepage            = iomap_migrate_page,
+       .migrate_folio          = filemap_migrate_folio,
        .is_partially_uptodate  = iomap_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
        .direct_IO              = noop_direct_IO,
index e552097c67e0bb3bd659e7ebf9683046131e01ae..758a1125e72fb2cd63ddcc76b02be5b558b08fbc 100644 (file)
@@ -231,12 +231,6 @@ void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops);
 bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count);
 bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags);
 void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len);
-#ifdef CONFIG_MIGRATION
-int iomap_migrate_page(struct address_space *mapping, struct page *newpage,
-               struct page *page, enum migrate_mode mode);
-#else
-#define iomap_migrate_page NULL
-#endif
 int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
                const struct iomap_ops *ops);
 int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
index 87d4ea571240e93149bd7e5ad91357044dadc086..cc9adbaddb591bf69854943cdc16c40ebae17956 100644 (file)
@@ -1078,6 +1078,12 @@ static inline int __must_check write_one_page(struct page *page)
 int __set_page_dirty_nobuffers(struct page *page);
 bool noop_dirty_folio(struct address_space *mapping, struct folio *folio);
 
+#ifdef CONFIG_MIGRATION
+int filemap_migrate_folio(struct address_space *mapping, struct folio *dst,
+               struct folio *src, enum migrate_mode mode);
+#else
+#define filemap_migrate_folio NULL
+#endif
 void page_endio(struct page *page, bool is_write, int err);
 
 void folio_end_private_2(struct folio *folio);
index 77aeb7e12f62986a4c525e476356bb28cf754cd4..4ed8f0d53c77c2bcd77fc253ac3d6c79172c030d 100644 (file)
@@ -784,6 +784,26 @@ int buffer_migrate_folio_norefs(struct address_space *mapping,
 }
 #endif
 
+int filemap_migrate_folio(struct address_space *mapping,
+               struct folio *dst, struct folio *src, enum migrate_mode mode)
+{
+       int ret;
+
+       ret = folio_migrate_mapping(mapping, dst, src, 0);
+       if (ret != MIGRATEPAGE_SUCCESS)
+               return ret;
+
+       if (folio_get_private(src))
+               folio_attach_private(dst, folio_detach_private(src));
+
+       if (mode != MIGRATE_SYNC_NO_COPY)
+               folio_migrate_copy(dst, src);
+       else
+               folio_migrate_flags(dst, src);
+       return MIGRATEPAGE_SUCCESS;
+}
+EXPORT_SYMBOL_GPL(filemap_migrate_folio);
+
 /*
  * Writeback a folio to clean the dirty state
  */