@@ -2200,7 +2200,7 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
22002200int memory_failure (unsigned long pfn , int flags )
22012201{
22022202 struct page * p ;
2203- struct page * hpage ;
2203+ struct folio * folio ;
22042204 struct dev_pagemap * pgmap ;
22052205 int res = 0 ;
22062206 unsigned long page_flags ;
@@ -2288,8 +2288,8 @@ int memory_failure(unsigned long pfn, int flags)
22882288 }
22892289 }
22902290
2291- hpage = compound_head (p );
2292- if (PageTransHuge ( hpage )) {
2291+ folio = page_folio (p );
2292+ if (folio_test_large ( folio )) {
22932293 /*
22942294 * The flag must be set after the refcount is bumped
22952295 * otherwise it may race with THP split.
@@ -2303,12 +2303,13 @@ int memory_failure(unsigned long pfn, int flags)
23032303 * or unhandlable page. The refcount is bumped iff the
23042304 * page is a valid handlable page.
23052305 */
2306- SetPageHasHWPoisoned ( hpage );
2306+ folio_set_has_hwpoisoned ( folio );
23072307 if (try_to_split_thp_page (p ) < 0 ) {
23082308 res = action_result (pfn , MF_MSG_UNSPLIT_THP , MF_IGNORED );
23092309 goto unlock_mutex ;
23102310 }
23112311 VM_BUG_ON_PAGE (!page_count (p ), p );
2312+ folio = page_folio (p );
23122313 }
23132314
23142315 /*
@@ -2319,21 +2320,21 @@ int memory_failure(unsigned long pfn, int flags)
23192320 * The check (unnecessarily) ignores LRU pages being isolated and
23202321 * walked by the page reclaim code, however that's not a big loss.
23212322 */
2322- shake_page ( p );
2323+ shake_folio ( folio );
23232324
2324- lock_page ( p );
2325+ folio_lock ( folio );
23252326
23262327 /*
23272328 * We're only intended to deal with the non-Compound page here.
23282329 * However, the page could have changed compound pages due to
23292330 * race window. If this happens, we could try again to hopefully
23302331 * handle the page next round.
23312332 */
2332- if (PageCompound ( p )) {
2333+ if (folio_test_large ( folio )) {
23332334 if (retry ) {
23342335 ClearPageHWPoison (p );
2335- unlock_page ( p );
2336- put_page ( p );
2336+ folio_unlock ( folio );
2337+ folio_put ( folio );
23372338 flags &= ~MF_COUNT_INCREASED ;
23382339 retry = false;
23392340 goto try_again ;
@@ -2349,29 +2350,29 @@ int memory_failure(unsigned long pfn, int flags)
23492350 * page_remove_rmap() in try_to_unmap_one(). So to determine page status
23502351 * correctly, we save a copy of the page flags at this time.
23512352 */
2352- page_flags = p -> flags ;
2353+ page_flags = folio -> flags ;
23532354
23542355 if (hwpoison_filter (p )) {
23552356 ClearPageHWPoison (p );
2356- unlock_page ( p );
2357- put_page ( p );
2357+ folio_unlock ( folio );
2358+ folio_put ( folio );
23582359 res = - EOPNOTSUPP ;
23592360 goto unlock_mutex ;
23602361 }
23612362
23622363 /*
2363- * __munlock_folio() may clear a writeback page 's LRU flag without
2364- * page_lock . We need wait writeback completion for this page or it
2365- * may trigger vfs BUG while evict inode.
2364+ * __munlock_folio() may clear a writeback folio 's LRU flag without
2365+ * the folio lock . We need to wait for writeback completion for this
2366+ * folio or it may trigger a vfs BUG while evicting inode.
23662367 */
2367- if (!PageLRU ( p ) && !PageWriteback ( p ))
2368+ if (!folio_test_lru ( folio ) && !folio_test_writeback ( folio ))
23682369 goto identify_page_state ;
23692370
23702371 /*
23712372 * It's very difficult to mess with pages currently under IO
23722373 * and in many cases impossible, so we just avoid it here.
23732374 */
2374- wait_on_page_writeback ( p );
2375+ folio_wait_writeback ( folio );
23752376
23762377 /*
23772378 * Now take care of user space mappings.
@@ -2385,7 +2386,8 @@ int memory_failure(unsigned long pfn, int flags)
23852386 /*
23862387 * Torn down by someone else?
23872388 */
2388- if (PageLRU (p ) && !PageSwapCache (p ) && p -> mapping == NULL ) {
2389+ if (folio_test_lru (folio ) && !folio_test_swapcache (folio ) &&
2390+ folio -> mapping == NULL ) {
23892391 res = action_result (pfn , MF_MSG_TRUNCATED_LRU , MF_IGNORED );
23902392 goto unlock_page ;
23912393 }
@@ -2395,7 +2397,7 @@ int memory_failure(unsigned long pfn, int flags)
23952397 mutex_unlock (& mf_mutex );
23962398 return res ;
23972399unlock_page :
2398- unlock_page ( p );
2400+ folio_unlock ( folio );
23992401unlock_mutex :
24002402 mutex_unlock (& mf_mutex );
24012403 return res ;
0 commit comments