hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IASFAM
--------------------------------
During page migration, if MIGRATE_SYNC_NO_COPY mode is used, the page content should not be migrated.
This patch fix it.
Fixes: 374fe8ea8082 ("fs: hugetlbfs: support poisoned recover from hugetlbfs_migrate_folio()") Fixes: 1d263184ba06 ("mm: migrate: support poisoned recover from migrate folio") Signed-off-by: Tong Tiangen tongtiangen@huawei.com --- fs/hugetlbfs/inode.c | 2 +- include/linux/migrate.h | 4 ++-- mm/migrate.c | 26 ++++++++++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 8386d78eabe5..fb0d3db162c2 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1146,7 +1146,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, { int rc;
- rc = migrate_huge_page_move_mapping(mapping, dst, src); + rc = migrate_huge_page_move_mapping(mapping, dst, src, mode); if (rc != MIGRATEPAGE_SUCCESS) return rc;
diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 517f70b70620..910a6718ad33 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -72,7 +72,7 @@ struct folio *alloc_migration_target(struct folio *src, unsigned long private); bool isolate_movable_page(struct page *page, isolate_mode_t mode);
int migrate_huge_page_move_mapping(struct address_space *mapping, - struct folio *dst, struct folio *src); + struct folio *dst, struct folio *src, enum migrate_mode mode); void migration_entry_wait_on_locked(swp_entry_t entry, spinlock_t *ptl) __releases(ptl); void folio_migrate_flags(struct folio *newfolio, struct folio *folio); @@ -94,7 +94,7 @@ static inline bool isolate_movable_page(struct page *page, isolate_mode_t mode) { return false; }
static inline int migrate_huge_page_move_mapping(struct address_space *mapping, - struct folio *dst, struct folio *src) + struct folio *dst, struct folio *src, enum migrate_mode mode) { return -ENOSYS; } diff --git a/mm/migrate.c b/mm/migrate.c index efcca5330568..2a4c4a4d15e9 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -544,20 +544,30 @@ int folio_migrate_mapping(struct address_space *mapping, } EXPORT_SYMBOL(folio_migrate_mapping);
+static int folio_migrate_mc_copy(struct folio *dst, struct folio *src, + enum migrate_mode mode, int expected_count) +{ + /* Check whether src does not have extra refs before we do more work */ + if (folio_ref_count(src) != expected_count) + return -EAGAIN; + + if (mode == MIGRATE_SYNC_NO_COPY) + return 0; + + return folio_mc_copy(dst, src); +} + /* * The expected number of remaining references is the same as that * of folio_migrate_mapping(). */ int migrate_huge_page_move_mapping(struct address_space *mapping, - struct folio *dst, struct folio *src) + struct folio *dst, struct folio *src, enum migrate_mode mode) { XA_STATE(xas, &mapping->i_pages, folio_index(src)); int rc, expected_count = folio_expected_refs(mapping, src);
- if (folio_ref_count(src) != expected_count) - return -EAGAIN; - - rc = folio_mc_copy(dst, src); + rc = folio_migrate_mc_copy(dst, src, mode, expected_count); if (unlikely(rc)) return rc;
@@ -691,11 +701,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, { int rc, expected_count = folio_expected_refs(mapping, src);
- /* Check whether src does not have extra refs before we do more work */ - if (folio_ref_count(src) != expected_count) - return -EAGAIN; - - rc = folio_mc_copy(dst, src); + rc = folio_migrate_mc_copy(dst, src, mode, expected_count); if (unlikely(rc)) return rc;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/11721 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/11721 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...