Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: Add aops->migrate_folio

Provide a folio-based replacement for aops->migratepage. Update the
documentation to document migrate_folio instead of migratepage.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>

+23 -15
+3 -2
Documentation/filesystems/locking.rst
··· 252 252 bool (*release_folio)(struct folio *, gfp_t); 253 253 void (*free_folio)(struct folio *); 254 254 int (*direct_IO)(struct kiocb *, struct iov_iter *iter); 255 - int (*migratepage)(struct address_space *, struct page *, struct page *); 255 + int (*migrate_folio)(struct address_space *, struct folio *dst, 256 + struct folio *src, enum migrate_mode); 256 257 int (*launder_folio)(struct folio *); 257 258 bool (*is_partially_uptodate)(struct folio *, size_t from, size_t count); 258 259 int (*error_remove_page)(struct address_space *, struct page *); ··· 279 278 release_folio: yes 280 279 free_folio: yes 281 280 direct_IO: 282 - migratepage: yes (both) 281 + migrate_folio: yes (both) 283 282 launder_folio: yes 284 283 is_partially_uptodate: yes 285 284 error_remove_page: yes
+7 -7
Documentation/filesystems/vfs.rst
··· 737 737 bool (*release_folio)(struct folio *, gfp_t); 738 738 void (*free_folio)(struct folio *); 739 739 ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter); 740 - /* migrate the contents of a page to the specified target */ 741 - int (*migratepage) (struct page *, struct page *); 740 + int (*migrate_folio)(struct mapping *, struct folio *dst, 741 + struct folio *src, enum migrate_mode); 742 742 int (*launder_folio) (struct folio *); 743 743 744 744 bool (*is_partially_uptodate) (struct folio *, size_t from, ··· 926 926 data directly between the storage and the application's address 927 927 space. 928 928 929 - ``migrate_page`` 929 + ``migrate_folio`` 930 930 This is used to compact the physical memory usage. If the VM 931 - wants to relocate a page (maybe off a memory card that is 932 - signalling imminent failure) it will pass a new page and an old 933 - page to this function. migrate_page should transfer any private 934 - data across and update any references that it has to the page. 931 + wants to relocate a folio (maybe from a memory device that is 932 + signalling imminent failure) it will pass a new folio and an old 933 + folio to this function. migrate_folio should transfer any private 934 + data across and update any references that it has to the folio. 935 935 936 936 ``launder_folio`` 937 937 Called before freeing a folio - it writes back the dirty folio.
+3 -1
include/linux/fs.h
··· 362 362 void (*free_folio)(struct folio *folio); 363 363 ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter); 364 364 /* 365 - * migrate the contents of a page to the specified target. If 365 + * migrate the contents of a folio to the specified target. If 366 366 * migrate_mode is MIGRATE_ASYNC, it must not block. 367 367 */ 368 + int (*migrate_folio)(struct address_space *, struct folio *dst, 369 + struct folio *src, enum migrate_mode); 368 370 int (*migratepage) (struct address_space *, 369 371 struct page *, struct page *, enum migrate_mode); 370 372 int (*launder_folio)(struct folio *);
+3 -1
mm/compaction.c
··· 1042 1042 goto isolate_fail_put; 1043 1043 1044 1044 mapping = page_mapping(page); 1045 - migrate_dirty = !mapping || mapping->a_ops->migratepage; 1045 + migrate_dirty = !mapping || 1046 + mapping->a_ops->migrate_folio || 1047 + mapping->a_ops->migratepage; 1046 1048 unlock_page(page); 1047 1049 if (!migrate_dirty) 1048 1050 goto isolate_fail_put;
+7 -4
mm/migrate.c
··· 856 856 857 857 if (!mapping) 858 858 rc = migrate_page(mapping, &dst->page, &src->page, mode); 859 - else if (mapping->a_ops->migratepage) 859 + else if (mapping->a_ops->migrate_folio) 860 860 /* 861 - * Most pages have a mapping and most filesystems 862 - * provide a migratepage callback. Anonymous pages 861 + * Most folios have a mapping and most filesystems 862 + * provide a migrate_folio callback. Anonymous folios 863 863 * are part of swap space which also has its own 864 - * migratepage callback. This is the most common path 864 + * migrate_folio callback. This is the most common path 865 865 * for page migration. 866 866 */ 867 + rc = mapping->a_ops->migrate_folio(mapping, dst, src, 868 + mode); 869 + else if (mapping->a_ops->migratepage) 867 870 rc = mapping->a_ops->migratepage(mapping, &dst->page, 868 871 &src->page, mode); 869 872 else