diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-05-07 15:05:06 -0400 |
---|---|---|
committer | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-10-18 07:49:39 -0400 |
commit | 715cbfd6c5c595bc8b7a6f9ad1fe9fec0122bb20 (patch) | |
tree | 029dfa5ed425a0a06fc6c00885c68f3eeaaf2b5e /mm/util.c | |
parent | 19138349ed59b90ce58aca319b873eca2e04ad43 (diff) | |
download | linux-715cbfd6c5c595bc8b7a6f9ad1fe9fec0122bb20.tar.gz linux-715cbfd6c5c595bc8b7a6f9ad1fe9fec0122bb20.tar.bz2 linux-715cbfd6c5c595bc8b7a6f9ad1fe9fec0122bb20.zip |
mm/migrate: Add folio_migrate_copy()
This is the folio equivalent of migrate_page_copy(), which is retained
as a wrapper for filesystems which are not yet converted to folios.
Also convert copy_huge_page() to folio_copy().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/mm/util.c b/mm/util.c index bf860838282c..e58151a61255 100644 --- a/mm/util.c +++ b/mm/util.c @@ -747,13 +747,26 @@ int __page_mapcount(struct page *page) } EXPORT_SYMBOL_GPL(__page_mapcount); -void copy_huge_page(struct page *dst, struct page *src) +/** + * folio_copy - Copy the contents of one folio to another. + * @dst: Folio to copy to. + * @src: Folio to copy from. + * + * The bytes in the folio represented by @src are copied to @dst. + * Assumes the caller has validated that @dst is at least as large as @src. + * Can be called in atomic context for order-0 folios, but if the folio is + * larger, it may sleep. + */ +void folio_copy(struct folio *dst, struct folio *src) { - unsigned i, nr = compound_nr(src); + long i = 0; + long nr = folio_nr_pages(src); - for (i = 0; i < nr; i++) { + for (;;) { + copy_highpage(folio_page(dst, i), folio_page(src, i)); + if (++i == nr) + break; cond_resched(); - copy_highpage(nth_page(dst, i), nth_page(src, i)); } } |