@@ -228,8 +228,7 @@ void __filemap_remove_folio(struct folio *folio, void *shadow)
page_cache_delete(mapping, folio, shadow);
}
-static void filemap_free_folio(struct address_space *mapping,
- struct folio *folio)
+void filemap_free_folio(struct address_space *mapping, struct folio *folio)
{
void (*freepage)(struct page *);
@@ -73,6 +73,7 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
pgoff_t end, struct pagevec *pvec, pgoff_t *indices);
bool truncate_inode_partial_page(struct page *page, loff_t start, loff_t end);
+void filemap_free_folio(struct address_space *mapping, struct folio *folio);
/**
* folio_evictable - Test whether a folio is evictable.
@@ -619,10 +619,7 @@ static int invalidate_complete_folio2(struct address_space *mapping,
__filemap_remove_folio(folio, NULL);
xa_unlock_irqrestore(&mapping->i_pages, flags);
- if (mapping->a_ops->freepage)
- mapping->a_ops->freepage(&folio->page);
-
- folio_ref_sub(folio, folio_nr_pages(folio)); /* pagecache ref */
+ filemap_free_folio(mapping, folio);
return 1;
failed:
xa_unlock_irqrestore(&mapping->i_pages, flags);
invalidate_complete_page2() currently open-codes filemap_free_folio(), except for the part where it handles THP. Rather than adding that, call page_cache_free_page() from invalidate_complete_page2(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- mm/filemap.c | 3 +-- mm/internal.h | 1 + mm/truncate.c | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-)