Skip to content

Commit f00b295

Browse files
Kefeng Wangakpm00
authored andcommitted
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/[email protected] Signed-off-by: Kefeng Wang <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Benjamin LaHaise <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Jane Chu <[email protected]> Cc: Jérôme Glisse <[email protected]> Cc: Jiaqi Yan <[email protected]> Cc: Lance Yang <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Muchun Song <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vishal Moola (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0609139 commit f00b295

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

fs/hugetlbfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
11281128
hugetlb_set_folio_subpool(src, NULL);
11291129
}
11301130

1131-
folio_migrate_copy(dst, src);
1131+
folio_migrate_flags(dst, src);
11321132

11331133
return MIGRATEPAGE_SUCCESS;
11341134
}

mm/migrate.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,16 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
550550
struct folio *dst, struct folio *src)
551551
{
552552
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;
554561

555562
xas_lock_irq(&xas);
556-
expected_count = folio_expected_refs(mapping, src);
557563
if (!folio_ref_freeze(src, expected_count)) {
558564
xas_unlock_irq(&xas);
559565
return -EAGAIN;

0 commit comments

Comments
 (0)