mm/migrate: Convert expected_page_refs() to folio_expected_refs()

Now that both callers have a folio, convert this function to
take a folio & rename it.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 67235182
...@@ -336,13 +336,18 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd) ...@@ -336,13 +336,18 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd)
} }
#endif #endif
static int expected_page_refs(struct address_space *mapping, struct page *page) static int folio_expected_refs(struct address_space *mapping,
struct folio *folio)
{ {
int expected_count = 1; int refs = 1;
if (!mapping)
return refs;
if (mapping) refs += folio_nr_pages(folio);
expected_count += compound_nr(page) + page_has_private(page); if (folio_test_private(folio))
return expected_count; refs++;
return refs;
} }
/* /*
...@@ -359,7 +364,7 @@ int folio_migrate_mapping(struct address_space *mapping, ...@@ -359,7 +364,7 @@ int folio_migrate_mapping(struct address_space *mapping,
XA_STATE(xas, &mapping->i_pages, folio_index(folio)); XA_STATE(xas, &mapping->i_pages, folio_index(folio));
struct zone *oldzone, *newzone; struct zone *oldzone, *newzone;
int dirty; int dirty;
int expected_count = expected_page_refs(mapping, &folio->page) + extra_count; int expected_count = folio_expected_refs(mapping, folio) + extra_count;
long nr = folio_nr_pages(folio); long nr = folio_nr_pages(folio);
if (!mapping) { if (!mapping) {
...@@ -669,7 +674,7 @@ static int __buffer_migrate_folio(struct address_space *mapping, ...@@ -669,7 +674,7 @@ static int __buffer_migrate_folio(struct address_space *mapping,
return migrate_page(mapping, &dst->page, &src->page, mode); return migrate_page(mapping, &dst->page, &src->page, mode);
/* Check whether page does not have extra refs before we do more work */ /* Check whether page does not have extra refs before we do more work */
expected_count = expected_page_refs(mapping, &src->page); expected_count = folio_expected_refs(mapping, src);
if (folio_ref_count(src) != expected_count) if (folio_ref_count(src) != expected_count)
return -EAGAIN; return -EAGAIN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment