On Wed, Apr 03, 2024 at 06:18:35PM +0100, Matthew Wilcox (Oracle) wrote: > @@ -1850,28 +1849,27 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, > } > /* drain lru cache to help isolate_lru_page() */ > lru_add_drain(); > - page = folio_file_page(folio, index); > - } else if (trylock_page(page)) { > - get_page(page); > + } else if (folio_trylock(folio)) { > + folio_get(folio); > xas_unlock_irq(&xas); > } else { > result = SCAN_PAGE_LOCK; > goto xa_locked; > } > } else { /* !is_shmem */ > - if (!page || xa_is_value(page)) { > + if (!folio || xa_is_value(folio)) { > xas_unlock_irq(&xas); > page_cache_sync_readahead(mapping, &file->f_ra, > file, index, > end - index); > /* drain lru cache to help isolate_lru_page() */ > lru_add_drain(); > - page = find_lock_page(mapping, index); > - if (unlikely(page == NULL)) { > + folio = filemap_lock_folio(mapping, index); > + if (unlikely(folio == NULL)) { filemap_lock_folio() can return an ERR_PTR(), find_lock_page() handles it internally.