Andrea has noted that page migration code propagates page_mapping(page) through the whole migration stack down to migrate_page() function so it seems stupid to then use page_mapping(page) in expected_page_refs() instead of passed down 'mapping' argument. I agree so let's make expected_page_refs() more in line with the rest of the migration stack.
Unified · Split
| @@ -374,7 +374,7 @@ unlock: · 373 unmodified lines | ||
| 374 | 374 | } |
| 375 | 375 | #endif |
| 376 | 376 | |
| 377 | −static int expected_page_refs(struct page *page) | |
| 377 | +static int expected_page_refs(struct address_space *mapping, struct page *page) | |
| 378 | 378 | { |
| 379 | 379 | int expected_count = 1; |
| 380 | 380 | |
| @@ -384,7 +384,7 @@ static int expected_page_refs(struct page *page) · 3 unmodified lines | ||
| 384 | 384 | */ |
| 385 | 385 | expected_count += is_device_private_page(page); |
| 386 | 386 | expected_count += is_device_public_page(page); |
| 387 | − if (page_mapping(page)) | |
| 387 | + if (mapping) | |
| 388 | 388 | expected_count += hpage_nr_pages(page) + page_has_private(page); |
| 389 | 389 | |
| 390 | 390 | return expected_count; |
| @@ -405,7 +405,7 @@ int migrate_page_move_mapping(struct address_space *mapping, · 14 unmodified lines | ||
| 405 | 405 | XA_STATE(xas, &mapping->i_pages, page_index(page)); |
| 406 | 406 | struct zone *oldzone, *newzone; |
| 407 | 407 | int dirty; |
| 408 | − int expected_count = expected_page_refs(page) + extra_count; | |
| 408 | + int expected_count = expected_page_refs(mapping, page) + extra_count; | |
| 409 | 409 | |
| 410 | 410 | if (!mapping) { |
| 411 | 411 | /* Anonymous page without mapping */ |
| @@ -750,7 +750,7 @@ static int __buffer_migrate_page(struct address_space *mapping, · 338 unmodified lines | ||
| 750 | 750 | return migrate_page(mapping, newpage, page, mode); |
| 751 | 751 | |
| 752 | 752 | /* Check whether page does not have extra refs before we do more work */ |
| 753 | − expected_count = expected_page_refs(page); | |
| 753 | + expected_count = expected_page_refs(mapping, page); | |
| 754 | 754 | if (page_count(page) != expected_count) |
| 755 | 755 | return -EAGAIN; |
| 756 | 756 | |