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

fs: hugetlbfs: support poisoned recover from hugetlbfs_migrate_folio()

This is similar to __migrate_folio(), use folio_mc_copy() in HugeTLB folio
migration to avoid panic when copy from poisoned folio.

Link: https://lkml.kernel.org/r/20240626085328.608006-6-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Jiaqi Yan <jiaqiyan@google.com>
Cc: Lance Yang <ioworker0@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
f00b295b 06091399

+9 -3
+1 -1
fs/hugetlbfs/inode.c
··· 1128 1128 hugetlb_set_folio_subpool(src, NULL); 1129 1129 } 1130 1130 1131 - folio_migrate_copy(dst, src); 1131 + folio_migrate_flags(dst, src); 1132 1132 1133 1133 return MIGRATEPAGE_SUCCESS; 1134 1134 }
+8 -2
mm/migrate.c
··· 550 550 struct folio *dst, struct folio *src) 551 551 { 552 552 XA_STATE(xas, &mapping->i_pages, folio_index(src)); 553 - int expected_count; 553 + int rc, expected_count = folio_expected_refs(mapping, src); 554 + 555 + if (folio_ref_count(src) != expected_count) 556 + return -EAGAIN; 557 + 558 + rc = folio_mc_copy(dst, src); 559 + if (unlikely(rc)) 560 + return rc; 554 561 555 562 xas_lock_irq(&xas); 556 - expected_count = folio_expected_refs(mapping, src); 557 563 if (!folio_ref_freeze(src, expected_count)) { 558 564 xas_unlock_irq(&xas); 559 565 return -EAGAIN;